~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to src/reboot.c

  • Committer: Michael Vogt
  • Date: 2011-10-05 10:09:25 UTC
  • mfrom: (639.1.6 app-indicator-port)
  • Revision ID: michael.vogt@ubuntu.com-20111005100925-c0j7d7k3706145uk
port to libappindicator (LP: #779382) to ensure its visible
under unity{,-2d}

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
        NotifyNotification *n;
21
21
 
22
22
        // only show once the icon is realy availabe
23
 
        if(!gtk_status_icon_get_visible(ta->tray_icon))
 
23
        if(!tray_applet_ui_get_visible(ta))
24
24
           return TRUE;
25
25
 
26
26
        /* Create and show the notification */
111
111
   }
112
112
}
113
113
 
114
 
 
115
114
static void
116
115
ask_reboot_required(TrayApplet *ta, gboolean focus_on_map)
117
116
{
125
124
}
126
125
 
127
126
static gboolean
 
127
button_release_cb (GtkWidget *widget,
 
128
                   TrayApplet *ta)
 
129
{
 
130
   ask_reboot_required(ta, TRUE);
 
131
 
 
132
   return TRUE;
 
133
}
 
134
 
 
135
static gboolean
128
136
aptdaemon_pending_transactions ()
129
137
{
130
138
  GError *error;
209
217
        if (stat (REBOOT_FILE, &statbuf)) {
210
218
                NotifyNotification *n;
211
219
 
212
 
                gtk_status_icon_set_visible (ta->tray_icon, FALSE);
 
220
                tray_applet_ui_set_visible (ta, FALSE);
213
221
                /* Hide any notification popup */
214
 
                n = g_object_get_data (G_OBJECT(ta->tray_icon), "notification");
 
222
                n = tray_applet_ui_get_data (ta, "notification");
215
223
                if (n)
216
224
                        notify_notification_close (n, NULL);
217
 
                g_object_set_data (G_OBJECT(ta->tray_icon), "notification", NULL);
 
225
                tray_applet_ui_set_data (ta, "notification", NULL);
218
226
 
219
227
                return;
220
228
        }
221
229
 
222
230
        /* Skip the rest if the icon is already visible */
223
 
        if (gtk_status_icon_get_visible (ta->tray_icon))
 
231
        if (tray_applet_ui_get_visible (ta))
224
232
           return;
225
 
        gtk_status_icon_set_tooltip_text (ta->tray_icon,  
226
 
                                     _("System restart required"));
227
 
        gtk_status_icon_set_visible (ta->tray_icon, TRUE);
 
233
        tray_applet_ui_set_visible (ta, TRUE);
 
234
 
228
235
 
229
236
        /* Check whether the user doesn't like notifications */
230
237
        if (g_settings_get_boolean ((GSettings*) ta->user_data,
247
254
   return FALSE;
248
255
}
249
256
 
250
 
static gboolean
251
 
button_release_cb (GtkWidget *widget,
252
 
                   TrayApplet *ta)
253
 
{
254
 
   ask_reboot_required(ta, TRUE);
255
 
 
256
 
   return TRUE;
257
 
}
258
 
 
259
257
 
260
258
void
261
259
reboot_tray_icon_init (TrayApplet *ta)
268
266
                g_warning ("Couldn't load builder file: %s", error->message);
269
267
                g_error_free (error);
270
268
        }
 
269
        ta->user_data = g_settings_new(SETTINGS_SCHEMA);
271
270
 
272
271
        widget = GTK_WIDGET (gtk_builder_get_object (builder, "image"));
273
 
        GtkIconTheme* icon_theme = gtk_icon_theme_get_default();
274
 
        GdkPixbuf *pixbuf = gtk_icon_theme_load_icon (icon_theme, "un-reboot",
275
 
                                                      48, 0,NULL);
276
 
        gtk_status_icon_set_from_pixbuf (ta->tray_icon, pixbuf);
277
 
        ta->user_data = g_settings_new(SETTINGS_SCHEMA);
278
 
 
279
 
        g_signal_connect (G_OBJECT(ta->tray_icon),
280
 
                          "activate",
281
 
                          G_CALLBACK (button_release_cb),
282
 
                          ta);
283
 
 
284
 
        gtk_image_set_from_pixbuf(GTK_IMAGE(widget), pixbuf);
 
272
        gtk_image_set_from_icon_name(GTK_IMAGE(widget), "un-reboot", GTK_ICON_SIZE_DIALOG);
 
273
 
 
274
        tray_applet_ui_set_icon(ta, "un-reboot");
 
275
        tray_applet_ui_set_single_action(ta, 
 
276
                                         _("System restart required"),
 
277
                                         G_CALLBACK (button_release_cb),
 
278
                                         ta);
285
279
 
286
280
        /* Check for updates for the first time */
287
281
        reboot_check (ta);