Mercurial > projects > pk-update-icon
annotate pkui-icon.c @ 24:3493e7b90e81
Added tag pk-update-icon-0.2 for changeset b2bc4af4a36d
author | Guido Berhoerster <guido@berhoerster.name> |
---|---|
date | Sat, 22 Oct 2011 10:20:14 +0200 |
parents | 38b37e4a4d63 |
children | bae8a7e20382 |
rev | line source |
---|---|
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
1 /* |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
2 * (C) 2011 Guido Berhoerster <gber@opensuse.org> |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
3 * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
4 * Licensed under the GNU General Public License Version 2 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
5 * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
9 * (at your option) any later version. |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
10 * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
15 * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
19 */ |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
20 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
21 #include <glib/gi18n.h> |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
22 #include <libnotify/notify.h> |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
23 #include "pkui-backend.h" |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
24 #include "pkui-icon.h" |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
25 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
26 G_DEFINE_TYPE(PkuiIcon, pkui_icon, G_TYPE_OBJECT) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
27 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
28 #define UPDATE_VIEWER_COMMAND "/usr/bin/gpk-update-viewer" |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
29 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
30 #define PKUI_ICON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
31 PKUI_TYPE_ICON, PkuiIconPrivate)) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
32 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
33 struct _PkuiIconPrivate |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
34 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
35 PkuiBackend *backend; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
36 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
37 GtkStatusIcon *status_icon; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
38 GtkWidget *status_icon_popup_menu; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
39 NotifyNotification *notification; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
40 }; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
41 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
42 static GtkWidget* icon_popup_menu_create(PkuiIcon *self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
43 static void icon_popup_menu_popup(GtkStatusIcon *status_icon, guint button, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
44 guint activate_time, gpointer user_data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
45 static void icon_activated(GtkStatusIcon *status_icon, gpointer user_data); |
19
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
46 static void hide_notification(PkuiIcon *self); |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
47 static void backend_state_changed(PkuiBackend *backend, gpointer user_data); |
19
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
48 static void update_viewer_exited(GPid pid, gint status, gpointer user_data); |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
49 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
50 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
51 pkui_icon_finalize(GObject *gobject) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
52 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
53 PkuiIcon *self = PKUI_ICON(gobject); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
54 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
55 gtk_widget_destroy(self->priv->status_icon_popup_menu); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
56 g_object_unref(self->priv->status_icon_popup_menu); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
57 g_object_unref(self->priv->status_icon); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
58 if (self->priv->notification != NULL) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
59 notify_notification_close(self->priv->notification, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
60 g_object_unref(self->priv->notification); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
61 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
62 g_object_unref(self->priv->backend); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
63 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
64 G_OBJECT_CLASS(pkui_icon_parent_class)->finalize(gobject); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
65 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
66 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
67 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
68 pkui_icon_class_init(PkuiIconClass *klass) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
69 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
70 GObjectClass *gobject_class = G_OBJECT_CLASS(klass); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
71 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
72 gobject_class->finalize = pkui_icon_finalize; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
73 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
74 g_type_class_add_private(klass, sizeof (PkuiIconPrivate)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
75 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
76 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
77 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
78 pkui_icon_init(PkuiIcon *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
79 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
80 self->priv = PKUI_ICON_GET_PRIVATE(self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
81 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
82 gtk_window_set_default_icon_name("system-software-update"); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
83 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
84 self->priv->status_icon_popup_menu = icon_popup_menu_create(self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
85 g_object_ref(self->priv->status_icon_popup_menu); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
86 g_object_ref_sink(GTK_OBJECT(self->priv->status_icon_popup_menu)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
87 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
88 self->priv->status_icon = gtk_status_icon_new(); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
89 gtk_status_icon_set_title(self->priv->status_icon, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
90 _("Software Updates")); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
91 gtk_status_icon_set_visible(self->priv->status_icon, FALSE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
92 g_signal_connect(G_OBJECT(self->priv->status_icon), "activate", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
93 G_CALLBACK(icon_activated), self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
94 g_signal_connect(G_OBJECT(self->priv->status_icon), "popup-menu", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
95 G_CALLBACK(icon_popup_menu_popup), self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
96 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
97 self->priv->notification = NULL; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
98 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
99 self->priv->backend = NULL; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
100 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
101 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
102 static void |
19
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
103 exec_update_viewer(PkuiIcon *self) |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
104 { |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
105 static const gchar *argv[] = { UPDATE_VIEWER_COMMAND, NULL }; |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
106 GPid pid; |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
107 gboolean retval; |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
108 |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
109 g_return_if_fail(PKUI_IS_BACKEND(self->priv->backend)); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
110 |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
111 g_debug("executing " UPDATE_VIEWER_COMMAND); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
112 |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
113 retval = g_spawn_async(NULL, (gchar **)argv, NULL, |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
114 G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
115 if (!retval) { |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
116 g_warning("Could not execute" UPDATE_VIEWER_COMMAND); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
117 return; |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
118 } |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
119 g_child_watch_add(pid, (GChildWatchFunc)update_viewer_exited, self); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
120 |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
121 pkui_backend_set_inhibit_check(self->priv->backend, TRUE); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
122 hide_notification(self); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
123 } |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
124 |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
125 static void |
18
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
126 about_dialog_show(GtkMenuItem *item, gpointer user_data) |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
127 { |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
128 static const gchar *copyright = "Copyright \xc2\xa9 2011 Guido " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
129 "Berhoerster\nCopyright \xc2\xa9 2011 Pavol Rusnak\n"; |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
130 static const gchar *authors[3] = { |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
131 "Guido Berhoerster <gber@opensuse.org>", |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
132 "Pavol Rusnak <stick@gk2.sk>", |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
133 NULL |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
134 }; |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
135 static const gchar *documenters[2] = { |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
136 "Guido Berhoerster <gber@opensuse.org>", |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
137 NULL |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
138 }; |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
139 static const gchar *license = |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
140 "Licensed under the GNU General Public License Version 2\n\nThis " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
141 "program is free software; you can redistribute it and/or modify it" |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
142 " under the terms of the GNU General Public License as published by" |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
143 " the Free Software Foundation; either version 2 of the License, or" |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
144 " (at your option) any later version.\n\nThis program is " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
145 "distributed in the hope that it will be useful, but WITHOUT ANY " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
146 "WARRANTY; without even the implied warranty of MERCHANTABILITY or " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
147 "FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
148 "License for more details.\n\nYou should have received a copy of " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
149 "the GNU General Public License along with this program; if not, " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
150 "write to the Free Software Foundation, Inc., 51 Franklin Street, " |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
151 "Fifth Floor, Boston, MA 02110-1301 USA."; |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
152 const gchar *translators = _("translators"); |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
153 |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
154 if (strcmp(translators, "translators") == 0) |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
155 translators = NULL; |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
156 |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
157 gtk_show_about_dialog (NULL, "version", "0.1", "copyright", copyright, |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
158 "authors", authors, "documenters", documenters, |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
159 "translator-credits", translators, "license", license, |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
160 "wrap-license", TRUE, NULL); |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
161 } |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
162 |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
163 static void |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
164 backend_check_now(GtkMenuItem *menu_item, gpointer user_data) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
165 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
166 PkuiIcon *self = PKUI_ICON(user_data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
167 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
168 g_return_if_fail(PKUI_IS_BACKEND(self->priv->backend)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
169 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
170 pkui_backend_check_now(self->priv->backend); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
171 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
172 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
173 static GtkWidget* |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
174 icon_popup_menu_create(PkuiIcon *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
175 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
176 GtkWidget *popup_menu = gtk_menu_new(); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
177 GtkWidget *item; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
178 GtkWidget *image; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
179 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
180 item = gtk_image_menu_item_new_with_mnemonic(_("_Check for Updates")); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
181 image = gtk_image_new_from_icon_name(GTK_STOCK_REFRESH, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
182 GTK_ICON_SIZE_MENU); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
183 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
184 gtk_menu_shell_append(GTK_MENU_SHELL(popup_menu), item); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
185 g_signal_connect(G_OBJECT(item), "activate", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
186 G_CALLBACK(backend_check_now), self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
187 |
18
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
188 item = gtk_image_menu_item_new_with_mnemonic(_("_About")); |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
189 image = gtk_image_new_from_icon_name(GTK_STOCK_ABOUT, |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
190 GTK_ICON_SIZE_MENU); |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
191 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
192 gtk_menu_shell_append(GTK_MENU_SHELL(popup_menu), item); |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
193 g_signal_connect(G_OBJECT(item), "activate", |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
194 G_CALLBACK(about_dialog_show), self); |
9537882d759f
add an about dialog
Guido Berhoerster <guido@berhoerster.name>
parents:
14
diff
changeset
|
195 |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
196 gtk_widget_show_all(GTK_WIDGET(popup_menu)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
197 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
198 return (popup_menu); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
199 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
200 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
201 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
202 icon_popup_menu_popup(GtkStatusIcon *status_icon, guint button, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
203 guint activate_time, gpointer user_data) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
204 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
205 PkuiIcon *self = PKUI_ICON(user_data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
206 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
207 gtk_menu_popup(GTK_MENU(self->priv->status_icon_popup_menu), NULL, NULL, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
208 NULL, NULL, button, activate_time); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
209 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
210 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
211 static void |
19
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
212 notification_handle_action(NotifyNotification *notification, gchar *action, |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
213 gpointer user_data) |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
214 { |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
215 PkuiIcon *self = PKUI_ICON(user_data); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
216 |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
217 if (strcmp(action, "install-updates") == 0) |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
218 exec_update_viewer(self); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
219 } |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
220 |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
221 static void |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
222 update_notification(PkuiIcon *self, guint updates_normal, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
223 guint updates_important) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
224 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
225 gchar *message; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
226 gchar *title = updates_important ? |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
227 ngettext("Important Software Update", "Important Software Updates", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
228 updates_important + updates_normal) : |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
229 ngettext("Software Update", "Software Updates", updates_important + |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
230 updates_normal); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
231 gchar *icon = updates_important ? "software-update-urgent" : |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
232 "software-update-available"; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
233 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
234 if (updates_important > 0) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
235 if (updates_normal > 0) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
236 message = g_strdup_printf(ngettext("There are %d " |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
237 "software updates available, %d of them is " |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
238 "important.", "There are %d software updates " |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
239 "available, %d of them are important.", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
240 updates_important), |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
241 updates_normal + updates_important, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
242 updates_important); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
243 else |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
244 message = g_strdup_printf(ngettext("There is an " |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
245 "important software update available.", "There are " |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
246 "%d important software updates available.", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
247 updates_important), updates_important); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
248 else |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
249 message = g_strdup_printf(ngettext("There is a software update " |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
250 "available.", "There are %d software updates available.", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
251 updates_normal), updates_normal); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
252 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
253 gtk_status_icon_set_tooltip(self->priv->status_icon, message); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
254 gtk_status_icon_set_from_icon_name(self->priv->status_icon, icon); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
255 gtk_status_icon_set_visible(self->priv->status_icon, TRUE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
256 |
19
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
257 if (self->priv->notification == NULL) { |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
258 self->priv->notification = notify_notification_new(title, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
259 message, icon |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
260 #if (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
261 , NULL |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
262 #endif |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
263 ); |
19
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
264 notify_notification_add_action(self->priv->notification, |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
265 "install-updates", ngettext("Install Update", |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
266 "Install Updates", updates_normal + updates_important), |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
267 notification_handle_action, self, NULL); |
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
268 } else |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
269 notify_notification_update(self->priv->notification, title, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
270 message, icon); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
271 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
272 notify_notification_set_timeout(self->priv->notification, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
273 NOTIFY_EXPIRES_NEVER); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
274 notify_notification_set_urgency(self->priv->notification, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
275 updates_important ? NOTIFY_URGENCY_CRITICAL : |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
276 NOTIFY_URGENCY_NORMAL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
277 notify_notification_show(self->priv->notification, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
278 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
279 g_free(message); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
280 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
281 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
282 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
283 hide_notification(PkuiIcon *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
284 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
285 gtk_status_icon_set_visible(self->priv->status_icon, FALSE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
286 notify_notification_close(self->priv->notification, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
287 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
288 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
289 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
290 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
291 backend_state_changed(PkuiBackend *backend, gpointer user_data) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
292 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
293 PkuiIcon *self = PKUI_ICON(user_data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
294 guint updates_normal; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
295 guint updates_important; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
296 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
297 g_return_if_fail(PKUI_IS_BACKEND(backend)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
298 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
299 updates_normal = pkui_backend_get_updates_normal(backend); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
300 updates_important = pkui_backend_get_updates_important(backend); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
301 if (updates_normal > 0 || updates_important > 0) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
302 update_notification(self, updates_normal, updates_important); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
303 else if (updates_normal + updates_important == 0) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
304 hide_notification(self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
305 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
306 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
307 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
308 update_viewer_exited(GPid pid, gint status, gpointer user_data) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
309 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
310 PkuiIcon *self = PKUI_ICON(user_data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
311 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
312 g_return_if_fail(PKUI_IS_BACKEND(self->priv->backend)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
313 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
314 g_spawn_close_pid(pid); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
315 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
316 pkui_backend_check_now(self->priv->backend); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
317 pkui_backend_set_inhibit_check(self->priv->backend, FALSE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
318 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
319 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
320 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
321 icon_activated(GtkStatusIcon *status_icon, gpointer user_data) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
322 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
323 PkuiIcon *self = PKUI_ICON(user_data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
324 |
19
38b37e4a4d63
added a button for installing updates to the notification
Guido Berhoerster <guido@berhoerster.name>
parents:
18
diff
changeset
|
325 exec_update_viewer(self); |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
326 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
327 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
328 PkuiIcon * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
329 pkui_icon_new(guint startup_delay, guint check_interval) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
330 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
331 PkuiIcon *icon = g_object_new(PKUI_TYPE_ICON, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
332 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
333 icon->priv->backend = pkui_backend_new(startup_delay, check_interval); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
334 g_signal_connect(icon->priv->backend, "state-changed", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
335 G_CALLBACK(backend_state_changed), icon); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
336 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
337 return (icon); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
338 } |