aboutsummaryrefslogtreecommitdiff
path: root/src/gtk-logout-helper.c
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2012-07-11 19:53:59 +0200
committerSebastien Bacher <seb128@ubuntu.com>2012-07-11 19:53:59 +0200
commit7a6621d316ea0825de80548f6d8db81e98f56099 (patch)
treef0348b62daae64b69ce9ae1390c2088267d1f9f4 /src/gtk-logout-helper.c
parent58b72505bad696704ad01e749830196400339ad5 (diff)
parente1ec25c1ccc63162bcfefc0661fc61fac9f376d1 (diff)
downloadayatana-indicator-session-7a6621d316ea0825de80548f6d8db81e98f56099.tar.gz
ayatana-indicator-session-7a6621d316ea0825de80548f6d8db81e98f56099.tar.bz2
ayatana-indicator-session-7a6621d316ea0825de80548f6d8db81e98f56099.zip
releasing version 12.10.0-0ubuntu1
Diffstat (limited to 'src/gtk-logout-helper.c')
-rw-r--r--src/gtk-logout-helper.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/gtk-logout-helper.c b/src/gtk-logout-helper.c
index f5c11ba..7868978 100644
--- a/src/gtk-logout-helper.c
+++ b/src/gtk-logout-helper.c
@@ -8,26 +8,28 @@ Authors:
Ted Gould <ted@canonical.com>
Christoph Korn <c_korn@gmx.de>
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
-You should have received a copy of the GNU General Public License along
+You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <config.h>
+#include "config.h"
+
#include <locale.h>
#include <glib.h>
-#include <gtk/gtk.h>
+#include <glib/gi18n.h> /* textdomain(), bindtextdomain() */
#include <dbus/dbus-glib.h>
+#include <gtk/gtk.h>
#include "dialog.h"
-#include "settings-helper.h"
+#include "shared-names.h"
static void
consolekit_fallback (LogoutDialogType action)
@@ -90,7 +92,7 @@ session_action (LogoutDialogType action)
GError * error = NULL;
gboolean res = FALSE;
- sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+ sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
if (sbus == NULL) {
g_warning("Unable to get DBus session bus.");
return;
@@ -112,15 +114,15 @@ session_action (LogoutDialogType action)
if (action == LOGOUT_DIALOG_TYPE_LOG_OUT) {
g_debug("Asking Session manager to 'Logout'");
- res = dbus_g_proxy_call_with_timeout (sm_proxy, "Logout", INT_MAX, &error,
+ res = dbus_g_proxy_call_with_timeout (sm_proxy, "Logout", INT_MAX, &error,
G_TYPE_UINT, 1, G_TYPE_INVALID, G_TYPE_INVALID);
} else if (action == LOGOUT_DIALOG_TYPE_SHUTDOWN) {
g_debug("Asking Session manager to 'RequestShutdown'");
- res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestShutdown", INT_MAX, &error,
+ res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestShutdown", INT_MAX, &error,
G_TYPE_INVALID, G_TYPE_INVALID);
} else if (action == LOGOUT_DIALOG_TYPE_RESTART) {
g_debug("Asking Session manager to 'RequestReboot'");
- res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestReboot", INT_MAX, &error,
+ res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestReboot", INT_MAX, &error,
G_TYPE_INVALID, G_TYPE_INVALID);
} else {
g_warning ("Unknown session action");
@@ -137,10 +139,7 @@ session_action (LogoutDialogType action)
}
g_object_unref(sm_proxy);
-
- if (error != NULL) {
- g_error_free(error);
- }
+ g_clear_error (&error);
return;
}
@@ -179,6 +178,17 @@ static GOptionEntry options[] = {
{NULL}
};
+static gboolean
+suppress_confirmations (void)
+{
+ GSettings * s = g_settings_new (SESSION_SCHEMA);
+ const gboolean suppress = g_settings_get_boolean (s, SUPPRESS_KEY);
+ g_clear_object (&s);
+ return suppress;
+}
+
+
+
int
main (int argc, char * argv[])
{
@@ -207,7 +217,7 @@ main (int argc, char * argv[])
INDICATOR_ICONS_DIR);
GtkWidget * dialog = NULL;
- if (!supress_confirmations()) {
+ if (!suppress_confirmations()) {
g_debug("Showing dialog to ask for user confirmation");
dialog = GTK_WIDGET(logout_dialog_new(type));
}