summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorWilliam Jon McCann <jmccann@redhat.com>2011-02-24 17:38:13 -0500
committerWilliam Jon McCann <jmccann@redhat.com>2011-02-24 17:56:03 -0500
commit8663860ff44b9a5e441e4909a49eee4cfa08378d (patch)
tree21e5e58a0d6ef70bd82a1c3fc08b39b29789c1ef /tools
parentcba6e372e3f9130b22d7d614d376c3c9ae898ce7 (diff)
downloadgnome-session-8663860ff44b9a5e441e4909a49eee4cfa08378d.tar.gz
rename gnome-session-save to gnome-session-quit
Is much less misleading since it doesn't save anything.
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am10
-rw-r--r--tools/gnome-session-quit.c (renamed from tools/gnome-session-save.c)116
2 files changed, 24 insertions, 102 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index fbc41b58..f53a0124 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,14 +1,14 @@
-bin_PROGRAMS = gnome-session-save
+bin_PROGRAMS = gnome-session-quit
libexec_PROGRAMS = gnome-session-is-accelerated
AM_CPPFLAGS =
AM_CFLAGS = $(WARN_CFLAGS)
-gnome_session_save_SOURCES = \
- gnome-session-save.c
+gnome_session_quit_SOURCES = \
+ gnome-session-quit.c
-gnome_session_save_CPPFLAGS = \
+gnome_session_quit_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(GNOME_SESSION_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
@@ -16,7 +16,7 @@ gnome_session_save_CPPFLAGS = \
-DLOCALE_DIR=\""$(datadir)/locale"\" \
$(DISABLE_DEPRECATED_CFLAGS)
-gnome_session_save_LDADD = \
+gnome_session_quit_LDADD = \
$(SM_LIBS) \
$(ICE_LIBS) \
$(GNOME_SESSION_LIBS) \
diff --git a/tools/gnome-session-save.c b/tools/gnome-session-quit.c
index 28f6443d..f5d18382 100644
--- a/tools/gnome-session-save.c
+++ b/tools/gnome-session-quit.c
@@ -43,54 +43,23 @@ enum {
GSM_LOGOUT_MODE_FORCE
};
-/* True if killing. This is deprecated, but we keep it for compatibility
- * reasons. */
-static gboolean kill_session = FALSE;
-
-/* The real options that should be used now. They are not ambiguous. */
static gboolean logout = FALSE;
-static gboolean force_logout = FALSE;
-static gboolean logout_dialog = FALSE;
-static gboolean shutdown_dialog = FALSE;
-
-/* True if we should use dialog boxes */
-static gboolean show_error_dialogs = FALSE;
-
-/* True if we should do the requested action without confirmation */
-static gboolean no_interaction = FALSE;
-
-static char *session_name = NULL;
+static gboolean power_off = FALSE;
+static gboolean no_prompt = FALSE;
+static gboolean force = FALSE;
static GOptionEntry options[] = {
{"logout", '\0', 0, G_OPTION_ARG_NONE, &logout, N_("Log out"), NULL},
- {"force-logout", '\0', 0, G_OPTION_ARG_NONE, &force_logout, N_("Log out, ignoring any existing inhibitors"), NULL},
- {"logout-dialog", '\0', 0, G_OPTION_ARG_NONE, &logout_dialog, N_("Show logout dialog"), NULL},
- {"shutdown-dialog", '\0', 0, G_OPTION_ARG_NONE, &shutdown_dialog, N_("Show shutdown dialog"), NULL},
- {"gui", '\0', 0, G_OPTION_ARG_NONE, &show_error_dialogs, N_("Use dialog boxes for errors"), NULL},
- /* deprecated options */
- {"session-name", 's', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &session_name, N_("Set the current session name"), N_("NAME")},
- {"kill", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &kill_session, N_("Kill session"), NULL},
- {"silent", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &no_interaction, N_("Do not require confirmation"), NULL},
+ {"power-off", '\0', 0, G_OPTION_ARG_NONE, &power_off, N_("Power off"), NULL},
+ {"force", '\0', 0, G_OPTION_ARG_NONE, &force, N_("Ignoring any existing inhibitors"), NULL},
+ {"no-prompt", '\0', 0, G_OPTION_ARG_NONE, &no_prompt, N_("Don't prompt for user confirmation"), NULL},
{NULL}
};
static void
display_error (const char *message)
{
- if (show_error_dialogs && !no_interaction) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", message);
-
- /*gtk_window_set_default_icon_name (GTK_STOCK_SAVE);*/
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- } else {
- g_printerr ("%s\n", message);
- }
+ g_printerr ("%s\n", message);
}
static DBusGConnection *
@@ -134,43 +103,6 @@ get_sm_proxy (void)
return sm_proxy;
}
-#if 0
-static void
-set_session_name (const char *session_name)
-{
- DBusGProxy *sm_proxy;
- GError *error;
- gboolean res;
-
- sm_proxy = get_sm_proxy ();
- if (sm_proxy == NULL) {
- return;
- }
-
- error = NULL;
- res = dbus_g_proxy_call (sm_proxy,
- "SetName",
- &error,
- G_TYPE_STRING, session_name,
- G_TYPE_INVALID, G_TYPE_INVALID);
-
- if (!res) {
- if (error != NULL) {
- g_warning ("Failed to set session name '%s': %s",
- session_name, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to set session name '%s'",
- session_name);
- }
- }
-
- if (sm_proxy != NULL) {
- g_object_unref (sm_proxy);
- }
-}
-#endif
-
static void
do_logout (unsigned int mode)
{
@@ -207,7 +139,7 @@ do_logout (unsigned int mode)
}
static void
-do_shutdown_dialog (void)
+do_power_off (void)
{
DBusGProxy *sm_proxy;
GError *error;
@@ -259,34 +191,24 @@ main (int argc, char *argv[])
}
conflicting_options = 0;
- if (kill_session)
- conflicting_options++;
if (logout)
conflicting_options++;
- if (force_logout)
- conflicting_options++;
- if (logout_dialog)
- conflicting_options++;
- if (shutdown_dialog)
+ if (power_off)
conflicting_options++;
if (conflicting_options > 1)
display_error (_("Program called with conflicting options"));
- if (kill_session) {
- if (no_interaction)
- force_logout = TRUE;
- else
- logout_dialog = TRUE;
- }
+ if (power_off) {
+ do_power_off ();
+ } else {
+ /* default to logout */
- if (logout) {
- do_logout (GSM_LOGOUT_MODE_NO_CONFIRMATION);
- } else if (force_logout) {
- do_logout (GSM_LOGOUT_MODE_FORCE);
- } else if (logout_dialog) {
- do_logout (GSM_LOGOUT_MODE_NORMAL);
- } else if (shutdown_dialog) {
- do_shutdown_dialog ();
+ if (force)
+ do_logout (GSM_LOGOUT_MODE_FORCE);
+ else if (no_prompt)
+ do_logout (GSM_LOGOUT_MODE_NO_CONFIRMATION);
+ else
+ do_logout (GSM_LOGOUT_MODE_NORMAL);
}
return 0;