annotate main.c @ 14:64f05992d8ec

GObject-based rewrite use asynchronous packagekit-glib API use persistent menu widget and notification object update existing notification when new updates become available, close it when no updates are available show status icon when updates are available, hide it when no updates are available hide icon when gpk-update-viewer is executed, check for updates when gpk-update-viewer exits introduce a startup delay before the first check for updates is made add context menu item to manually trigger a check for updates remove context menu item for quitting pk-update-icon
author Guido Berhoerster <guido@berhoerster.name>
date Thu, 20 Oct 2011 08:19:22 +0200
parents 0e50d3652326
children 7af115023d5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
1 /*
8
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
2 * Copyright (C) 2011 Guido Berhoerster <gber@opensuse.org>
2
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
3 *
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
4 * Licensed under the GNU General Public License Version 2
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
5 *
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
6 * This program is free software; you can redistribute it and/or modify
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
7 * it under the terms of the GNU General Public License as published by
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
9 * (at your option) any later version.
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
10 *
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
11 * This program is distributed in the hope that it will be useful,
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
14 * GNU General Public License for more details.
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
15 *
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
16 * You should have received a copy of the GNU General Public License
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
17 * along with this program; if not, write to the Free Software
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
19 */
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 1
diff changeset
20
8
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
21 #include <locale.h>
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
22 #include <glib/gi18n.h>
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
23 #include <gtk/gtk.h>
9
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
24 #include <unique/unique.h>
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
25 #include <libnotify/notify.h>
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
26 #include "pkui-icon.h"
1
483f5fe9d2b2 change icon and tooltip of the tray icon
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
27
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
28 int
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
29 main(int argc, char **argv)
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
30 {
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
31 PkuiIcon *icon;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
32 UniqueApp *app;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
33 int exitval = 0;
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
34
8
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
35 setlocale(LC_ALL, "");
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
36
8
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
37 bindtextdomain(PACKAGE, LOCALEDIR);
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
38 bind_textdomain_codeset(PACKAGE, "UTF-8");
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
39 textdomain(PACKAGE);
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
40
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
41 gtk_init(&argc, &argv);
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
42
9
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
43 app = unique_app_new(APP_NAME, NULL);
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
44 if (unique_app_is_running(app)) {
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
45 g_printerr("Another instance of pk-update-icon is already "
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
46 "running. Exiting.\n");
9
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
47 exitval = 1;
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
48 goto out;
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
49 }
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
50
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
51 notify_init(PACKAGE);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
52
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
53 icon = pkui_icon_new(10, 2 * 3600);
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
54
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
55 gtk_main();
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
56
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
57 g_object_unref(icon);
9
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
58 out:
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
59 g_object_unref(app);
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
60 if (notify_is_initted())
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
61 notify_uninit ();
9
0e50d3652326 use libunique to ensure that only a single instance of pk-update-icon can be run
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
62
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents: 9
diff changeset
63 return (exitval);
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
64 }