53
DBusGConnection *connection;
58
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
59
if (connection == NULL) {
64
proxy = dbus_g_proxy_new_for_name (connection,
65
"org.gnome.SessionManager",
66
"/org/gnome/SessionManager",
67
"org.gnome.SessionManager");
72
if (!dbus_g_proxy_call (proxy, "RequestReboot", &error,
73
G_TYPE_INVALID, G_TYPE_INVALID)) {
83
DBusGConnection *connection;
88
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
89
if (connection == NULL) {
94
proxy = dbus_g_proxy_new_for_name (connection,
95
"org.freedesktop.ConsoleKit",
96
"/org/freedesktop/ConsoleKit/Manager",
97
"org.freedesktop.ConsoleKit.Manager");
102
if (!dbus_g_proxy_call (proxy, "Restart", &error,
103
G_TYPE_INVALID, G_TYPE_INVALID)) {
104
g_error_free (error);
112
50
request_reboot (void)
114
if(!gdm_action_reboot() && !ck_action_reboot()) {
115
const char *fmt, *msg, *details;
116
fmt = "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s\n";
117
msg = _("Reboot failed");
118
details = _("Failed to request reboot, please shutdown manually");
119
GtkWidget *dlg = gtk_message_dialog_new_with_markup(NULL, 0,
123
gtk_dialog_run(GTK_DIALOG(dlg));
124
gtk_widget_destroy(dlg);
54
client = gnome_master_client ();
55
g_return_if_fail (client != NULL);
57
/* set gdm logout action */
58
gdm_set_logout_action(GDM_LOGOUT_ACTION_REBOOT);
60
/* Tell gnome-session to save and exit the session without asking
62
gnome_client_request_save (client,
138
80
gtk_widget_hide (dia);
142
is_aptdaemon_on_the_system_bus ()
144
DBusConnection *connection;
145
DBusError *dbus_error = NULL;
146
DBusMessage *message, *reply;
147
const char *aptdaemon_bus_name = "org.debian.apt";
150
connection = dbus_bus_get(DBUS_BUS_SYSTEM, dbus_error);
151
if (dbus_error != NULL) {
152
g_warning("failed to connect to the system bus");
155
message = dbus_message_new_method_call(DBUS_SERVICE_DBUS,
159
if (message == NULL) {
160
g_warning ("failed to create dbus message");
164
dbus_message_append_args(message,
165
DBUS_TYPE_STRING, &aptdaemon_bus_name,
168
reply = dbus_connection_send_with_reply_and_block(connection,
172
dbus_message_unref(message);
175
dbus_message_unref(reply);
181
g_debug("aptdaemon on bus: %i", res);
186
aptdaemon_pending_transactions ()
188
DBusGConnection *connection;
191
char *current = NULL;
192
char **pending = NULL;
194
if (!is_aptdaemon_on_the_system_bus())
198
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
199
if (connection == NULL) {
200
g_debug ("Failed to open connection to bus: %s\n", error->message);
201
g_error_free (error);
205
proxy = dbus_g_proxy_new_for_name (connection,
210
if (!dbus_g_proxy_call (proxy, "GetActiveTransactions", &error,
212
G_TYPE_STRING, ¤t,
213
G_TYPE_STRV, &pending,
215
g_debug ("error during dbus call: %s\n", error->message);
216
g_error_free (error);
217
g_object_unref (proxy);
221
gboolean has_pending = FALSE;
222
if ((current && strcmp(current,"") != 0) || g_strv_length(pending) > 0)
225
g_object_unref (proxy);
227
g_strfreev (pending);
233
do_reboot_check (TrayApplet *ta)
84
reboot_check (TrayApplet *ta)
86
static gboolean already_asked_for_reboot = FALSE;
235
87
struct stat statbuf;
237
// if we are not supposed to show the reboot notification
239
if(gconf_client_get_bool((GConfClient*) ta->user_data,
240
GCONF_KEY_HIDE_REBOOT, NULL))
242
// no auto-open of this dialog
243
if(gconf_client_get_bool((GConfClient*) ta->user_data,
244
GCONF_KEY_AUTO_LAUNCH, NULL)) {
245
g_debug ("Skipping reboot required");
249
89
/* If the file doesn't exist, we don't need to reboot */
250
90
if (stat (REBOOT_FILE, &statbuf)) {
251
91
NotifyNotification *n;
257
97
notify_notification_close (n, NULL);
258
98
g_object_set_data (G_OBJECT(ta->tray_icon), "notification", NULL);
103
// check if we are in auto-launch dialog/apps mode
104
if(gconf_client_get_bool((GConfClient*) ta->user_data,
105
GCONF_KEY_AUTO_LAUNCH, NULL)) {
106
if (!already_asked_for_reboot)
107
ask_reboot_required(ta, FALSE);
108
already_asked_for_reboot = TRUE;
263
112
/* Skip the rest if the icon is already visible */
264
113
if (gtk_status_icon_get_visible (ta->tray_icon))
266
116
gtk_status_icon_set_tooltip (ta->tray_icon,
267
117
_("System restart required"));
268
118
gtk_status_icon_set_visible (ta->tray_icon, TRUE);
270
120
/* Check whether the user doesn't like notifications */
271
121
if (gconf_client_get_bool ((GConfClient*) ta->user_data,
272
122
GCONF_KEY_NO_UPDATE_NOTIFICATIONS, NULL))
275
125
/* Show the notification, after a delay so it doesn't look ugly
276
126
* if we've just logged in */
277
127
g_timeout_add(5000, (GSourceFunc)(show_notification), ta);
282
reboot_check (TrayApplet *ta)
284
if (aptdaemon_pending_transactions())
285
g_timeout_add_seconds (5, (GSourceFunc)reboot_check, ta);