gnome-session r4767 - in branches/dbus_based: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4767 - in branches/dbus_based: . gnome-session
- Date: Tue, 24 Jun 2008 17:09:28 +0000 (UTC)
Author: mccann
Date: Tue Jun 24 17:09:28 2008
New Revision: 4767
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4767&view=rev
Log:
2008-06-24 William Jon McCann <jmccann redhat com>
* configure.in:
* gnome-session/Makefile.am:
* gnome-session/gsm-client-store.h:
* gnome-session/gsm-inhibitor-store.c
(gsm_inhibitor_store_error_quark), (gsm_inhibitor_store_size),
(gsm_inhibitor_store_clear), (remove_inhibitor),
(gsm_inhibitor_store_remove), (gsm_inhibitor_store_foreach),
(gsm_inhibitor_store_find), (gsm_inhibitor_store_lookup),
(gsm_inhibitor_store_foreach_remove), (gsm_inhibitor_store_add),
(gsm_inhibitor_store_set_property),
(gsm_inhibitor_store_get_property),
(gsm_inhibitor_store_class_init), (inhibitor_unref),
(gsm_inhibitor_store_init), (gsm_inhibitor_store_finalize),
(gsm_inhibitor_store_new):
* gnome-session/gsm-inhibitor-store.h:
* gnome-session/gsm-inhibitor.c (gsm_inhibitor_constructor),
(gsm_inhibitor_init), (gsm_inhibitor_set_bus_name),
(gsm_inhibitor_set_app_id), (gsm_inhibitor_set_reason),
(gsm_inhibitor_set_cookie), (gsm_inhibitor_set_flags),
(gsm_inhibitor_set_toplevel_xid), (gsm_inhibitor_get_bus_name),
(gsm_inhibitor_get_app_id), (gsm_inhibitor_get_reason),
(gsm_inhibitor_get_flags), (gsm_inhibitor_get_toplevel_xid),
(gsm_inhibitor_get_cookie), (gsm_inhibitor_set_property),
(gsm_inhibitor_get_property), (gsm_inhibitor_finalize),
(gsm_inhibitor_class_init), (gsm_inhibitor_new):
* gnome-session/gsm-inhibitor.h:
* gnome-session/gsm-logout-dialog.c (gsm_get_dialog):
* gnome-session/gsm-logout-dialog.h:
* gnome-session/gsm-logout-inhibit-dialog.c
(gsm_logout_inhibit_dialog_set_action),
(gsm_logout_inhibit_dialog_set_property),
(gsm_logout_inhibit_dialog_get_property), (on_response),
(setup_dialog), (gsm_logout_inhibit_dialog_constructor),
(gsm_logout_inhibit_dialog_dispose),
(gsm_logout_inhibit_dialog_class_init),
(gsm_logout_inhibit_dialog_init),
(gsm_logout_inhibit_dialog_finalize),
(gsm_logout_inhibit_dialog_new):
* gnome-session/gsm-logout-inhibit-dialog.glade:
* gnome-session/gsm-logout-inhibit-dialog.h:
* gnome-session/gsm-manager.c (inhibitor_has_bus_name),
(remove_inhibitors_for_connection), (bus_name_owner_changed),
(gsm_manager_init), (gsm_manager_finalize),
(gsm_manager_is_logout_inhibited), (do_action),
(logout_inhibit_dialog_response), (request_logout),
(logout_dialog_response), (initiate_logout),
(_generate_unique_cookie), (gsm_manager_inhibit),
(gsm_manager_uninhibit):
* gnome-session/gsm-manager.h:
* gnome-session/test-inhibit.c (do_inhibit):
Add an inhibitor class and store class to make it
easier to update the model for the inhibit dialog.
Add a stub for an inhibit dialog.
Added:
branches/dbus_based/gnome-session/gsm-inhibitor-store.c
branches/dbus_based/gnome-session/gsm-inhibitor-store.h
branches/dbus_based/gnome-session/gsm-inhibitor.c
branches/dbus_based/gnome-session/gsm-inhibitor.h
branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.c
branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.glade
branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.h
Modified:
branches/dbus_based/ChangeLog
branches/dbus_based/configure.in
branches/dbus_based/gnome-session/Makefile.am
branches/dbus_based/gnome-session/gsm-client-store.h
branches/dbus_based/gnome-session/gsm-logout-dialog.c
branches/dbus_based/gnome-session/gsm-logout-dialog.h
branches/dbus_based/gnome-session/gsm-manager.c
branches/dbus_based/gnome-session/gsm-manager.h
branches/dbus_based/gnome-session/test-inhibit.c
Modified: branches/dbus_based/configure.in
==============================================================================
--- branches/dbus_based/configure.in (original)
+++ branches/dbus_based/configure.in Tue Jun 24 17:09:28 2008
@@ -64,9 +64,22 @@
dnl ====================================================================
PKG_PROG_PKG_CONFIG()
-PKG_CHECK_MODULES(GNOME_SESSION, glib-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED)
-
-PKG_CHECK_MODULES(SESSION_PROPERTIES, glib-2.0 >= $GLIB_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libglade-2.0 >= $GLADE_REQUIRED)
+PKG_CHECK_MODULES(GNOME_SESSION,
+ glib-2.0 >= $GLIB_REQUIRED
+ gio-2.0 >= $GLIB_REQUIRED
+ gtk+-2.0 >= $GTK_REQUIRED
+ libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED
+ dbus-glib-1 >= $DBUS_GLIB_REQUIRED
+ libglade-2.0 >= $GLADE_REQUIRED
+ gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED
+)
+
+PKG_CHECK_MODULES(SESSION_PROPERTIES,
+ glib-2.0 >= $GLIB_REQUIRED
+ gtk+-2.0 >= $GTK_REQUIRED
+ libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED
+ libglade-2.0 >= $GLADE_REQUIRED
+)
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= $DBUS_GLIB_REQUIRED)
Modified: branches/dbus_based/gnome-session/Makefile.am
==============================================================================
--- branches/dbus_based/gnome-session/Makefile.am (original)
+++ branches/dbus_based/gnome-session/Makefile.am Tue Jun 24 17:09:28 2008
@@ -21,9 +21,15 @@
-DLOCALE_DIR=\""$(datadir)/locale"\" \
-DDATA_DIR=\""$(datadir)/gnome-session"\" \
-DDBUS_LAUNCH=\"dbus-launch\" \
+ -DGLADEDIR=\""$(pkgdatadir)"\" \
-DGCONF_SANITY_CHECK=\""$(GCONF_SANITY_CHECK)"\" \
-DGCONFTOOL_CMD=\"$(GCONFTOOL)\"
+gladedir = $(pkgdatadir)
+glade_DATA = \
+ gsm-logout-inhibit-dialog.glade \
+ $(NULL)
+
test_inhibit_SOURCES = \
test-inhibit.c \
$(NULL)
@@ -80,6 +86,8 @@
gsm-consolekit.h \
gsm-logout-dialog.h \
gsm-logout-dialog.c \
+ gsm-logout-inhibit-dialog.h \
+ gsm-logout-inhibit-dialog.c \
gsm-power-manager.h \
gsm-power-manager.c \
gconf.c \
@@ -89,6 +97,10 @@
main.c \
gsm-client-store.h \
gsm-client-store.c \
+ gsm-inhibitor.h \
+ gsm-inhibitor.c \
+ gsm-inhibitor-store.h \
+ gsm-inhibitor-store.c \
gsm-manager.c \
gsm-manager.h \
gsm-xsmp-server.c \
@@ -120,6 +132,11 @@
$(BUILT_SOURCES)
EXTRA_DIST = \
+ $(glade_DATA) \
README \
gsm-marshal.list \
gsm-manager.xml
+
+MAINTAINERCLEANFILES = \
+ *~ \
+ Makefile.in
Modified: branches/dbus_based/gnome-session/gsm-client-store.h
==============================================================================
--- branches/dbus_based/gnome-session/gsm-client-store.h (original)
+++ branches/dbus_based/gnome-session/gsm-client-store.h Tue Jun 24 17:09:28 2008
@@ -19,8 +19,8 @@
*/
-#ifndef __GSM_DISPLAY_STORE_H
-#define __GSM_DISPLAY_STORE_H
+#ifndef __GSM_CLIENT_STORE_H
+#define __GSM_CLIENT_STORE_H
#include <glib-object.h>
#include "gsm-client.h"
@@ -38,7 +38,7 @@
typedef struct
{
- GObject parent;
+ GObject parent;
GsmClientStorePrivate *priv;
} GsmClientStore;
@@ -47,9 +47,9 @@
GObjectClass parent_class;
void (* client_added) (GsmClientStore *client_store,
- const char *id);
+ const char *id);
void (* client_removed) (GsmClientStore *client_store,
- const char *id);
+ const char *id);
} GsmClientStoreClass;
typedef enum
Added: branches/dbus_based/gnome-session/gsm-inhibitor-store.c
==============================================================================
--- (empty file)
+++ branches/dbus_based/gnome-session/gsm-inhibitor-store.c Tue Jun 24 17:09:28 2008
@@ -0,0 +1,302 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 William Jon McCann <mccann jhu edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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 with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+
+#include "gsm-inhibitor-store.h"
+
+#define GSM_INHIBITOR_STORE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_INHIBITOR_STORE, GsmInhibitorStorePrivate))
+
+struct GsmInhibitorStorePrivate
+{
+ GHashTable *inhibitors;
+};
+
+enum {
+ INHIBITOR_ADDED,
+ INHIBITOR_REMOVED,
+ LAST_SIGNAL
+};
+
+enum {
+ PROP_0,
+};
+
+static guint signals [LAST_SIGNAL] = { 0, };
+
+static void gsm_inhibitor_store_class_init (GsmInhibitorStoreClass *klass);
+static void gsm_inhibitor_store_init (GsmInhibitorStore *inhibitor_store);
+static void gsm_inhibitor_store_finalize (GObject *object);
+
+G_DEFINE_TYPE (GsmInhibitorStore, gsm_inhibitor_store, G_TYPE_OBJECT)
+
+GQuark
+gsm_inhibitor_store_error_quark (void)
+{
+ static GQuark ret = 0;
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("gsm_inhibitor_store_error");
+ }
+
+ return ret;
+}
+
+guint
+gsm_inhibitor_store_size (GsmInhibitorStore *store)
+{
+ return g_hash_table_size (store->priv->inhibitors);
+}
+
+void
+gsm_inhibitor_store_clear (GsmInhibitorStore *store)
+{
+ g_return_if_fail (store != NULL);
+ g_debug ("GsmInhibitorStore: Clearing inhibitor store");
+ g_hash_table_remove_all (store->priv->inhibitors);
+}
+
+static gboolean
+remove_inhibitor (guint *cookie,
+ GsmInhibitor *inhibitor,
+ GsmInhibitor *inhibitor_to_remove)
+{
+ if (inhibitor == inhibitor_to_remove) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean
+gsm_inhibitor_store_remove (GsmInhibitorStore *store,
+ GsmInhibitor *inhibitor)
+{
+ g_return_val_if_fail (store != NULL, FALSE);
+
+ gsm_inhibitor_store_foreach_remove (store,
+ (GsmInhibitorStoreFunc)remove_inhibitor,
+ inhibitor);
+ return FALSE;
+}
+
+void
+gsm_inhibitor_store_foreach (GsmInhibitorStore *store,
+ GsmInhibitorStoreFunc func,
+ gpointer user_data)
+{
+ g_return_if_fail (store != NULL);
+ g_return_if_fail (func != NULL);
+
+ g_hash_table_find (store->priv->inhibitors,
+ (GHRFunc)func,
+ user_data);
+}
+
+GsmInhibitor *
+gsm_inhibitor_store_find (GsmInhibitorStore *store,
+ GsmInhibitorStoreFunc predicate,
+ gpointer user_data)
+{
+ GsmInhibitor *inhibitor;
+
+ g_return_val_if_fail (store != NULL, NULL);
+ g_return_val_if_fail (predicate != NULL, NULL);
+
+ inhibitor = g_hash_table_find (store->priv->inhibitors,
+ (GHRFunc)predicate,
+ user_data);
+ return inhibitor;
+}
+
+GsmInhibitor *
+gsm_inhibitor_store_lookup (GsmInhibitorStore *store,
+ guint *cookie)
+{
+ GsmInhibitor *inhibitor;
+
+ g_return_val_if_fail (store != NULL, NULL);
+ g_return_val_if_fail (cookie != NULL, NULL);
+
+ inhibitor = g_hash_table_lookup (store->priv->inhibitors,
+ cookie);
+
+ return inhibitor;
+}
+
+guint
+gsm_inhibitor_store_foreach_remove (GsmInhibitorStore *store,
+ GsmInhibitorStoreFunc func,
+ gpointer user_data)
+{
+ guint ret;
+
+ g_return_val_if_fail (store != NULL, 0);
+ g_return_val_if_fail (func != NULL, 0);
+
+ ret = g_hash_table_foreach_remove (store->priv->inhibitors,
+ (GHRFunc)func,
+ user_data);
+
+ return ret;
+}
+
+gboolean
+gsm_inhibitor_store_add (GsmInhibitorStore *store,
+ GsmInhibitor *inhibitor)
+{
+ guint cookie;
+
+ g_return_val_if_fail (store != NULL, FALSE);
+ g_return_val_if_fail (inhibitor != NULL, FALSE);
+
+ cookie = gsm_inhibitor_get_cookie (inhibitor);
+
+ g_debug ("GsmInhibitorStore: Adding inhibitor %u to store", cookie);
+ g_hash_table_insert (store->priv->inhibitors,
+ &cookie,
+ g_object_ref (inhibitor));
+
+ g_signal_emit (store, signals [INHIBITOR_ADDED], 0, cookie);
+
+ return TRUE;
+}
+
+static void
+gsm_inhibitor_store_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GsmInhibitorStore *self;
+
+ self = GSM_INHIBITOR_STORE (object);
+
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gsm_inhibitor_store_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GsmInhibitorStore *self;
+
+ self = GSM_INHIBITOR_STORE (object);
+
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gsm_inhibitor_store_class_init (GsmInhibitorStoreClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = gsm_inhibitor_store_get_property;
+ object_class->set_property = gsm_inhibitor_store_set_property;
+ object_class->finalize = gsm_inhibitor_store_finalize;
+
+ signals [INHIBITOR_ADDED] =
+ g_signal_new ("inhibitor-added",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsmInhibitorStoreClass, inhibitor_added),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE,
+ 1, G_TYPE_UINT);
+ signals [INHIBITOR_REMOVED] =
+ g_signal_new ("inhibitor-removed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsmInhibitorStoreClass, inhibitor_removed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE,
+ 1, G_TYPE_UINT);
+
+ g_type_class_add_private (klass, sizeof (GsmInhibitorStorePrivate));
+}
+
+static void
+inhibitor_unref (GsmInhibitor *inhibitor)
+{
+ g_debug ("GsmInhibitorStore: Unreffing inhibitor: %p", inhibitor);
+ g_object_unref (inhibitor);
+}
+
+static void
+gsm_inhibitor_store_init (GsmInhibitorStore *store)
+{
+
+ store->priv = GSM_INHIBITOR_STORE_GET_PRIVATE (store);
+
+ store->priv->inhibitors = g_hash_table_new_full (g_int_hash,
+ g_int_equal,
+ NULL,
+ (GDestroyNotify) inhibitor_unref);
+}
+
+static void
+gsm_inhibitor_store_finalize (GObject *object)
+{
+ GsmInhibitorStore *store;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GSM_IS_INHIBITOR_STORE (object));
+
+ store = GSM_INHIBITOR_STORE (object);
+
+ g_return_if_fail (store->priv != NULL);
+
+ g_hash_table_destroy (store->priv->inhibitors);
+
+ G_OBJECT_CLASS (gsm_inhibitor_store_parent_class)->finalize (object);
+}
+
+GsmInhibitorStore *
+gsm_inhibitor_store_new (void)
+{
+ GObject *object;
+
+ object = g_object_new (GSM_TYPE_INHIBITOR_STORE,
+ NULL);
+
+ return GSM_INHIBITOR_STORE (object);
+}
Added: branches/dbus_based/gnome-session/gsm-inhibitor-store.h
==============================================================================
--- (empty file)
+++ branches/dbus_based/gnome-session/gsm-inhibitor-store.h Tue Jun 24 17:09:28 2008
@@ -0,0 +1,91 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 William Jon McCann <mccann jhu edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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 with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+#ifndef __GSM_INHIBITOR_STORE_H
+#define __GSM_INHIBITOR_STORE_H
+
+#include <glib-object.h>
+#include "gsm-inhibitor.h"
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_INHIBITOR_STORE (gsm_inhibitor_store_get_type ())
+#define GSM_INHIBITOR_STORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_INHIBITOR_STORE, GsmInhibitorStore))
+#define GSM_INHIBITOR_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_INHIBITOR_STORE, GsmInhibitorStoreClass))
+#define GSM_IS_INHIBITOR_STORE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_INHIBITOR_STORE))
+#define GSM_IS_INHIBITOR_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_INHIBITOR_STORE))
+#define GSM_INHIBITOR_STORE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_INHIBITOR_STORE, GsmInhibitorStoreClass))
+
+typedef struct GsmInhibitorStorePrivate GsmInhibitorStorePrivate;
+
+typedef struct
+{
+ GObject parent;
+ GsmInhibitorStorePrivate *priv;
+} GsmInhibitorStore;
+
+typedef struct
+{
+ GObjectClass parent_class;
+
+ void (* inhibitor_added) (GsmInhibitorStore *inhibitor_store,
+ guint cookie);
+ void (* inhibitor_removed) (GsmInhibitorStore *inhibitor_store,
+ guint cookie);
+} GsmInhibitorStoreClass;
+
+typedef enum
+{
+ GSM_INHIBITOR_STORE_ERROR_GENERAL
+} GsmInhibitorStoreError;
+
+#define GSM_INHIBITOR_STORE_ERROR gsm_inhibitor_store_error_quark ()
+
+typedef gboolean (*GsmInhibitorStoreFunc) (guint *cookie,
+ GsmInhibitor *inhibitor,
+ gpointer user_data);
+
+GQuark gsm_inhibitor_store_error_quark (void);
+GType gsm_inhibitor_store_get_type (void);
+
+GsmInhibitorStore * gsm_inhibitor_store_new (void);
+
+guint gsm_inhibitor_store_size (GsmInhibitorStore *store);
+gboolean gsm_inhibitor_store_add (GsmInhibitorStore *store,
+ GsmInhibitor *inhibitor);
+void gsm_inhibitor_store_clear (GsmInhibitorStore *store);
+gboolean gsm_inhibitor_store_remove (GsmInhibitorStore *store,
+ GsmInhibitor *inhibitor);
+void gsm_inhibitor_store_foreach (GsmInhibitorStore *store,
+ GsmInhibitorStoreFunc func,
+ gpointer user_data);
+guint gsm_inhibitor_store_foreach_remove (GsmInhibitorStore *store,
+ GsmInhibitorStoreFunc func,
+ gpointer user_data);
+GsmInhibitor * gsm_inhibitor_store_find (GsmInhibitorStore *store,
+ GsmInhibitorStoreFunc predicate,
+ gpointer user_data);
+GsmInhibitor * gsm_inhibitor_store_lookup (GsmInhibitorStore *store,
+ guint *cookie);
+
+G_END_DECLS
+
+#endif /* __GSM_INHIBITOR_STORE_H */
Added: branches/dbus_based/gnome-session/gsm-inhibitor.c
==============================================================================
--- (empty file)
+++ branches/dbus_based/gnome-session/gsm-inhibitor.c Tue Jun 24 17:09:28 2008
@@ -0,0 +1,359 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "gsm-inhibitor.h"
+
+#define GSM_INHIBITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_INHIBITOR, GsmInhibitorPrivate))
+
+struct GsmInhibitorPrivate
+{
+ char *bus_name;
+ char *app_id;
+ char *reason;
+ guint flags;
+ guint toplevel_xid;
+ guint cookie;
+};
+
+enum {
+ PROP_0,
+ PROP_BUS_NAME,
+ PROP_REASON,
+ PROP_APP_ID,
+ PROP_FLAGS,
+ PROP_TOPLEVEL_XID,
+ PROP_COOKIE,
+};
+
+G_DEFINE_TYPE (GsmInhibitor, gsm_inhibitor, G_TYPE_OBJECT)
+
+static GObject *
+gsm_inhibitor_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GsmInhibitor *inhibitor;
+
+ inhibitor = GSM_INHIBITOR (G_OBJECT_CLASS (gsm_inhibitor_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties));
+
+ return G_OBJECT (inhibitor);
+}
+
+static void
+gsm_inhibitor_init (GsmInhibitor *inhibitor)
+{
+ inhibitor->priv = GSM_INHIBITOR_GET_PRIVATE (inhibitor);
+}
+
+static void
+gsm_inhibitor_set_bus_name (GsmInhibitor *inhibitor,
+ const char *bus_name)
+{
+ g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+ g_free (inhibitor->priv->bus_name);
+
+ inhibitor->priv->bus_name = g_strdup (bus_name);
+ g_object_notify (G_OBJECT (inhibitor), "bus-name");
+}
+
+static void
+gsm_inhibitor_set_app_id (GsmInhibitor *inhibitor,
+ const char *app_id)
+{
+ g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+ g_free (inhibitor->priv->app_id);
+
+ inhibitor->priv->app_id = g_strdup (app_id);
+ g_object_notify (G_OBJECT (inhibitor), "app-id");
+}
+
+static void
+gsm_inhibitor_set_reason (GsmInhibitor *inhibitor,
+ const char *reason)
+{
+ g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+ g_free (inhibitor->priv->reason);
+
+ inhibitor->priv->reason = g_strdup (reason);
+ g_object_notify (G_OBJECT (inhibitor), "reason");
+}
+
+static void
+gsm_inhibitor_set_cookie (GsmInhibitor *inhibitor,
+ guint cookie)
+{
+ g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+ if (inhibitor->priv->cookie != cookie) {
+ inhibitor->priv->cookie = cookie;
+ g_object_notify (G_OBJECT (inhibitor), "cookie");
+ }
+}
+
+static void
+gsm_inhibitor_set_flags (GsmInhibitor *inhibitor,
+ guint flags)
+{
+ g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+ if (inhibitor->priv->flags != flags) {
+ inhibitor->priv->flags = flags;
+ g_object_notify (G_OBJECT (inhibitor), "flags");
+ }
+}
+
+static void
+gsm_inhibitor_set_toplevel_xid (GsmInhibitor *inhibitor,
+ guint xid)
+{
+ g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+ if (inhibitor->priv->toplevel_xid != xid) {
+ inhibitor->priv->toplevel_xid = xid;
+ g_object_notify (G_OBJECT (inhibitor), "toplevel-xid");
+ }
+}
+
+const char *
+gsm_inhibitor_get_bus_name (GsmInhibitor *inhibitor)
+{
+ g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL);
+
+ return inhibitor->priv->bus_name;
+}
+
+const char *
+gsm_inhibitor_get_app_id (GsmInhibitor *inhibitor)
+{
+ g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL);
+
+ return inhibitor->priv->app_id;
+}
+
+const char *
+gsm_inhibitor_get_reason (GsmInhibitor *inhibitor)
+{
+ g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL);
+
+ return inhibitor->priv->reason;
+}
+
+guint
+gsm_inhibitor_get_flags (GsmInhibitor *inhibitor)
+{
+ g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0);
+
+ return inhibitor->priv->flags;
+}
+
+guint
+gsm_inhibitor_get_toplevel_xid (GsmInhibitor *inhibitor)
+{
+ g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0);
+
+ return inhibitor->priv->toplevel_xid;
+}
+
+guint
+gsm_inhibitor_get_cookie (GsmInhibitor *inhibitor)
+{
+ g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0);
+
+ return inhibitor->priv->cookie;
+}
+
+static void
+gsm_inhibitor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GsmInhibitor *self;
+
+ self = GSM_INHIBITOR (object);
+
+ switch (prop_id) {
+ case PROP_BUS_NAME:
+ gsm_inhibitor_set_bus_name (self, g_value_get_string (value));
+ break;
+ case PROP_APP_ID:
+ gsm_inhibitor_set_app_id (self, g_value_get_string (value));
+ break;
+ case PROP_REASON:
+ gsm_inhibitor_set_reason (self, g_value_get_string (value));
+ break;
+ case PROP_FLAGS:
+ gsm_inhibitor_set_flags (self, g_value_get_uint (value));
+ break;
+ case PROP_COOKIE:
+ gsm_inhibitor_set_cookie (self, g_value_get_uint (value));
+ break;
+ case PROP_TOPLEVEL_XID:
+ gsm_inhibitor_set_toplevel_xid (self, g_value_get_uint (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gsm_inhibitor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GsmInhibitor *self;
+
+ self = GSM_INHIBITOR (object);
+
+ switch (prop_id) {
+ case PROP_BUS_NAME:
+ g_value_set_string (value, self->priv->bus_name);
+ break;
+ case PROP_APP_ID:
+ g_value_set_string (value, self->priv->app_id);
+ break;
+ case PROP_REASON:
+ g_value_set_string (value, self->priv->reason);
+ break;
+ case PROP_FLAGS:
+ g_value_set_uint (value, self->priv->flags);
+ break;
+ case PROP_COOKIE:
+ g_value_set_uint (value, self->priv->cookie);
+ break;
+ case PROP_TOPLEVEL_XID:
+ g_value_set_uint (value, self->priv->toplevel_xid);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gsm_inhibitor_finalize (GObject *object)
+{
+ GsmInhibitor *inhibitor = (GsmInhibitor *) object;
+
+ g_free (inhibitor->priv->bus_name);
+ g_free (inhibitor->priv->app_id);
+ g_free (inhibitor->priv->reason);
+
+ G_OBJECT_CLASS (gsm_inhibitor_parent_class)->finalize (object);
+}
+
+static void
+gsm_inhibitor_class_init (GsmInhibitorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gsm_inhibitor_finalize;
+ object_class->constructor = gsm_inhibitor_constructor;
+ object_class->get_property = gsm_inhibitor_get_property;
+ object_class->set_property = gsm_inhibitor_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_BUS_NAME,
+ g_param_spec_string ("bus-name",
+ "bus-name",
+ "bus-name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_APP_ID,
+ g_param_spec_string ("app-id",
+ "app-id",
+ "app-id",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_REASON,
+ g_param_spec_string ("reason",
+ "reason",
+ "reason",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_FLAGS,
+ g_param_spec_uint ("flags",
+ "flags",
+ "flags",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_TOPLEVEL_XID,
+ g_param_spec_uint ("toplevel-xid",
+ "toplevel-xid",
+ "toplevel-xid",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_COOKIE,
+ g_param_spec_uint ("cookie",
+ "cookie",
+ "cookie",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_type_class_add_private (klass, sizeof (GsmInhibitorPrivate));
+}
+
+GsmInhibitor *
+gsm_inhibitor_new (const char *app_id,
+ guint toplevel_xid,
+ guint flags,
+ const char *reason,
+ const char *bus_name,
+ guint cookie)
+{
+ GsmInhibitor *inhibitor;
+
+ inhibitor = g_object_new (GSM_TYPE_INHIBITOR,
+ "app-id", app_id,
+ "reason", reason,
+ "bus-name", bus_name,
+ "flags", flags,
+ "toplevel-xid", toplevel_xid,
+ "cookie", cookie,
+ NULL);
+
+ return inhibitor;
+}
Added: branches/dbus_based/gnome-session/gsm-inhibitor.h
==============================================================================
--- (empty file)
+++ branches/dbus_based/gnome-session/gsm-inhibitor.h Tue Jun 24 17:09:28 2008
@@ -0,0 +1,77 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __GSM_INHIBITOR_H__
+#define __GSM_INHIBITOR_H__
+
+#include <glib-object.h>
+#include <sys/types.h>
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_INHIBITOR (gsm_inhibitor_get_type ())
+#define GSM_INHIBITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_INHIBITOR, GsmInhibitor))
+#define GSM_INHIBITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_INHIBITOR, GsmInhibitorClass))
+#define GSM_IS_INHIBITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_INHIBITOR))
+#define GSM_IS_INHIBITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_INHIBITOR))
+#define GSM_INHIBITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_INHIBITOR, GsmInhibitorClass))
+
+typedef struct _GsmInhibitor GsmInhibitor;
+typedef struct _GsmInhibitorClass GsmInhibitorClass;
+
+typedef struct GsmInhibitorPrivate GsmInhibitorPrivate;
+
+typedef enum {
+ GSM_INHIBITOR_UNREGISTERED = 0,
+ GSM_INHIBITOR_REGISTERED,
+ GSM_INHIBITOR_FINISHED,
+ GSM_INHIBITOR_FAILED,
+} GsmInhibitorStatus;
+
+struct _GsmInhibitor
+{
+ GObject parent;
+ GsmInhibitorPrivate *priv;
+};
+
+struct _GsmInhibitorClass
+{
+ GObjectClass parent_class;
+};
+
+GType gsm_inhibitor_get_type (void) G_GNUC_CONST;
+
+GsmInhibitor * gsm_inhibitor_new (const char *app_id,
+ guint toplevel_xid,
+ guint flags,
+ const char *reason,
+ const char *bus_name,
+ guint cookie);
+
+const char * gsm_inhibitor_get_app_id (GsmInhibitor *inhibitor);
+const char * gsm_inhibitor_get_reason (GsmInhibitor *inhibitor);
+const char * gsm_inhibitor_get_bus_name (GsmInhibitor *inhibitor);
+guint gsm_inhibitor_get_cookie (GsmInhibitor *inhibitor);
+guint gsm_inhibitor_get_flags (GsmInhibitor *inhibitor);
+guint gsm_inhibitor_get_toplevel_xid (GsmInhibitor *inhibitor);
+
+G_END_DECLS
+
+#endif /* __GSM_INHIBITOR_H__ */
Modified: branches/dbus_based/gnome-session/gsm-logout-dialog.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-logout-dialog.c (original)
+++ branches/dbus_based/gnome-session/gsm-logout-dialog.c Tue Jun 24 17:09:28 2008
@@ -373,13 +373,13 @@
if (gsm_power_manager_can_suspend (logout_dialog->priv->power_manager)) {
gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
_("S_uspend"),
- GSM_LOGOUT_RESPONSE_STR);
+ GSM_LOGOUT_RESPONSE_SLEEP);
}
if (gsm_power_manager_can_hibernate (logout_dialog->priv->power_manager)) {
gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
_("_Hibernate"),
- GSM_LOGOUT_RESPONSE_STD);
+ GSM_LOGOUT_RESPONSE_HIBERNATE);
}
if (gsm_logout_supports_reboot (logout_dialog)) {
Modified: branches/dbus_based/gnome-session/gsm-logout-dialog.h
==============================================================================
--- branches/dbus_based/gnome-session/gsm-logout-dialog.h (original)
+++ branches/dbus_based/gnome-session/gsm-logout-dialog.h Tue Jun 24 17:09:28 2008
@@ -34,8 +34,8 @@
GSM_LOGOUT_RESPONSE_SWITCH_USER,
GSM_LOGOUT_RESPONSE_SHUTDOWN,
GSM_LOGOUT_RESPONSE_REBOOT,
- GSM_LOGOUT_RESPONSE_STD,
- GSM_LOGOUT_RESPONSE_STR
+ GSM_LOGOUT_RESPONSE_HIBERNATE,
+ GSM_LOGOUT_RESPONSE_SLEEP
};
#define GSM_TYPE_LOGOUT_DIALOG (gsm_logout_dialog_get_type ())
Added: branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.c
==============================================================================
--- (empty file)
+++ branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.c Tue Jun 24 17:09:28 2008
@@ -0,0 +1,250 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <mccann jhu edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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 with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include <glade/glade-xml.h>
+#include <gconf/gconf-client.h>
+
+#include "gsm-logout-inhibit-dialog.h"
+
+#define GSM_LOGOUT_INHIBIT_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_LOGOUT_INHIBIT_DIALOG, GsmLogoutInhibitDialogPrivate))
+
+#define GLADE_XML_FILE "gsm-logout-inhibit-dialog.glade"
+
+struct GsmLogoutInhibitDialogPrivate
+{
+ GladeXML *xml;
+ int action;
+};
+
+enum {
+ PROP_0,
+ PROP_ACTION,
+};
+
+static void gsm_logout_inhibit_dialog_class_init (GsmLogoutInhibitDialogClass *klass);
+static void gsm_logout_inhibit_dialog_init (GsmLogoutInhibitDialog *logout_inhibit_dialog);
+static void gsm_logout_inhibit_dialog_finalize (GObject *object);
+
+G_DEFINE_TYPE (GsmLogoutInhibitDialog, gsm_logout_inhibit_dialog, GTK_TYPE_DIALOG)
+
+static void
+gsm_logout_inhibit_dialog_set_action (GsmLogoutInhibitDialog *dialog,
+ int action)
+{
+ dialog->priv->action = action;
+}
+
+
+static void
+gsm_logout_inhibit_dialog_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GsmLogoutInhibitDialog *dialog = GSM_LOGOUT_INHIBIT_DIALOG (object);
+
+ switch (prop_id) {
+ case PROP_ACTION:
+ gsm_logout_inhibit_dialog_set_action (dialog, g_value_get_int (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gsm_logout_inhibit_dialog_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GsmLogoutInhibitDialog *dialog = GSM_LOGOUT_INHIBIT_DIALOG (object);
+
+ switch (prop_id) {
+ case PROP_ACTION:
+ g_value_set_int (value, dialog->priv->action);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+on_response (GsmLogoutInhibitDialog *dialog,
+ gint response_id)
+{
+ switch (response_id) {
+ default:
+ break;
+ }
+}
+
+static void
+setup_dialog (GsmLogoutInhibitDialog *dialog)
+{
+ const char *button_text;
+
+ switch (dialog->priv->action) {
+ case GSM_LOGOUT_ACTION_SWITCH_USER:
+ button_text = _("Switch User Now");
+ break;
+ case GSM_LOGOUT_ACTION_LOGOUT:
+ button_text = _("Logout Now");
+ break;
+ case GSM_LOGOUT_ACTION_SLEEP:
+ button_text = _("Suspend Now");
+ break;
+ case GSM_LOGOUT_ACTION_HIBERNATE:
+ button_text = _("Hibernate Now");
+ break;
+ case GSM_LOGOUT_ACTION_SHUTDOWN:
+ button_text = _("Shutdown Now");
+ break;
+ case GSM_LOGOUT_ACTION_REBOOT:
+ button_text = _("Reboot Now");
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ button_text,
+ GTK_RESPONSE_ACCEPT);
+}
+
+static GObject *
+gsm_logout_inhibit_dialog_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GsmLogoutInhibitDialog *dialog;
+
+ dialog = GSM_LOGOUT_INHIBIT_DIALOG (G_OBJECT_CLASS (gsm_logout_inhibit_dialog_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties));
+
+ setup_dialog (dialog);
+ gtk_widget_show_all (GTK_WIDGET (dialog));
+
+ return G_OBJECT (dialog);
+}
+
+static void
+gsm_logout_inhibit_dialog_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (gsm_logout_inhibit_dialog_parent_class)->dispose (object);
+}
+
+static void
+gsm_logout_inhibit_dialog_class_init (GsmLogoutInhibitDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = gsm_logout_inhibit_dialog_get_property;
+ object_class->set_property = gsm_logout_inhibit_dialog_set_property;
+ object_class->constructor = gsm_logout_inhibit_dialog_constructor;
+ object_class->dispose = gsm_logout_inhibit_dialog_dispose;
+ object_class->finalize = gsm_logout_inhibit_dialog_finalize;
+
+ g_object_class_install_property (object_class,
+ PROP_ACTION,
+ g_param_spec_int ("action",
+ "action",
+ "action",
+ -1,
+ G_MAXINT,
+ -1,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (klass, sizeof (GsmLogoutInhibitDialogPrivate));
+}
+
+static void
+gsm_logout_inhibit_dialog_init (GsmLogoutInhibitDialog *dialog)
+{
+ GtkWidget *widget;
+
+ dialog->priv = GSM_LOGOUT_INHIBIT_DIALOG_GET_PRIVATE (dialog);
+
+ dialog->priv->xml = glade_xml_new (GLADEDIR "/" GLADE_XML_FILE,
+ "main-box",
+ PACKAGE);
+ g_assert (dialog->priv->xml != NULL);
+
+ widget = glade_xml_get_widget (dialog->priv->xml, "main-box");
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), widget);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 12);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "gnome-logout");
+ gtk_window_set_title (GTK_WINDOW (dialog), "");
+ g_object_set (dialog,
+ "allow-shrink", FALSE,
+ "allow-grow", FALSE,
+ NULL);
+
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (on_response),
+ dialog);
+}
+
+static void
+gsm_logout_inhibit_dialog_finalize (GObject *object)
+{
+ GsmLogoutInhibitDialog *dialog;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GSM_IS_LOGOUT_INHIBIT_DIALOG (object));
+
+ dialog = GSM_LOGOUT_INHIBIT_DIALOG (object);
+
+ g_return_if_fail (dialog->priv != NULL);
+
+ G_OBJECT_CLASS (gsm_logout_inhibit_dialog_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_logout_inhibit_dialog_new (int action)
+{
+ GObject *object;
+
+ object = g_object_new (GSM_TYPE_LOGOUT_INHIBIT_DIALOG,
+ "action", action,
+ NULL);
+
+ return GTK_WIDGET (object);
+}
Added: branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.glade
==============================================================================
--- (empty file)
+++ branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.glade Tue Jun 24 17:09:28 2008
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.4.4 on Tue Jun 24 11:01:14 2008 -->
+<glade-interface>
+ <widget class="GtkDialog" id="dialog1">
+ <property name="border_width">5</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkVBox" id="main-box">
+ <property name="visible">True</property>
+ <property name="border_width">10</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>Some programs are still running:</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTreeView" id="inhibitors-treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Interrupting these programs may cause you to lose work. </property>
+ <property name="wrap">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="button1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Added: branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.h
==============================================================================
--- (empty file)
+++ branches/dbus_based/gnome-session/gsm-logout-inhibit-dialog.h Tue Jun 24 17:09:28 2008
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <mccann jhu edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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 with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSM_LOGOUT_INHIBIT_DIALOG_H
+#define __GSM_LOGOUT_INHIBIT_DIALOG_H
+
+#include <glib-object.h>
+#include <gtk/gtkdialog.h>
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_LOGOUT_INHIBIT_DIALOG (gsm_logout_inhibit_dialog_get_type ())
+#define GSM_LOGOUT_INHIBIT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_LOGOUT_INHIBIT_DIALOG, GsmLogoutInhibitDialog))
+#define GSM_LOGOUT_INHIBIT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_LOGOUT_INHIBIT_DIALOG, GsmLogoutInhibitDialogClass))
+#define GSM_IS_LOGOUT_INHIBIT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_LOGOUT_INHIBIT_DIALOG))
+#define GSM_IS_LOGOUT_INHIBIT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_LOGOUT_INHIBIT_DIALOG))
+#define GSM_LOGOUT_INHIBIT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_LOGOUT_INHIBIT_DIALOG, GsmLogoutInhibitDialogClass))
+
+typedef struct GsmLogoutInhibitDialogPrivate GsmLogoutInhibitDialogPrivate;
+
+typedef enum
+{
+ GSM_LOGOUT_ACTION_LOGOUT,
+ GSM_LOGOUT_ACTION_SWITCH_USER,
+ GSM_LOGOUT_ACTION_SHUTDOWN,
+ GSM_LOGOUT_ACTION_REBOOT,
+ GSM_LOGOUT_ACTION_HIBERNATE,
+ GSM_LOGOUT_ACTION_SLEEP,
+} GsmLogoutAction;
+
+typedef struct
+{
+ GtkDialog parent;
+ GsmLogoutInhibitDialogPrivate *priv;
+} GsmLogoutInhibitDialog;
+
+typedef struct
+{
+ GtkDialogClass parent_class;
+} GsmLogoutInhibitDialogClass;
+
+GType gsm_logout_inhibit_dialog_get_type (void);
+
+GtkWidget * gsm_logout_inhibit_dialog_new (int action);
+GtkTreeModel * gsm_logout_inhibit_dialog_get_model (GsmLogoutInhibitDialog *dialog);
+
+G_END_DECLS
+
+#endif /* __GSM_LOGOUT_INHIBIT_DIALOG_H */
Modified: branches/dbus_based/gnome-session/gsm-manager.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-manager.c (original)
+++ branches/dbus_based/gnome-session/gsm-manager.c Tue Jun 24 17:09:28 2008
@@ -44,6 +44,10 @@
#include "gsm-manager.h"
#include "gsm-manager-glue.h"
+#include "gsm-client-store.h"
+#include "gsm-inhibitor-store.h"
+#include "gsm-inhibitor.h"
+
#include "gsm-xsmp-client.h"
#include "gsm-method-client.h"
#include "gsm-service-client.h"
@@ -54,6 +58,7 @@
#include "util.h"
#include "gdm.h"
#include "gsm-logout-dialog.h"
+#include "gsm-logout-inhibit-dialog.h"
#include "gsm-consolekit.h"
#include "gsm-power-manager.h"
@@ -67,21 +72,11 @@
#define GSM_GCONF_DEFAULT_SESSION_KEY "/desktop/gnome/session/default-session"
#define GSM_GCONF_REQUIRED_COMPONENTS_DIRECTORY "/desktop/gnome/session/required-components"
-typedef struct
-{
- char *app_id;
- guint32 toplevel_xid;
- char *reason;
- guint32 flags;
- char *bus_name;
- guint32 cookie;
- GTimeVal since;
-} GsmInhibitor;
-
struct GsmManagerPrivate
{
gboolean failsafe;
GsmClientStore *store;
+ GsmInhibitorStore *inhibitors;
/* Startup/resumed apps */
GHashTable *apps_by_id;
@@ -90,7 +85,7 @@
guint timeout_id;
GSList *pending_apps;
- GHashTable *inhibitors;
+ GtkWidget *inhibit_dialog;
/* List of clients which were disconnected due to disabled condition
* and shouldn't be automatically restarted */
@@ -162,15 +157,6 @@
return etype;
}
-static void
-gsm_inhibitor_free (GsmInhibitor *inhibitor)
-{
- g_free (inhibitor->bus_name);
- g_free (inhibitor->app_id);
- g_free (inhibitor->reason);
- g_free (inhibitor);
-}
-
static gboolean
_find_by_client_id (const char *id,
GsmClient *client,
@@ -507,18 +493,22 @@
static gboolean
inhibitor_has_bus_name (gpointer key,
GsmInhibitor *inhibitor,
- const char *bus_name)
+ const char *bus_name_a)
{
- gboolean matches;
+ gboolean matches;
+ const char *bus_name_b;
+
+ bus_name_b = gsm_inhibitor_get_bus_name (inhibitor);
+ g_debug ("GsmManager: comparing bus names %s %s", bus_name_a, bus_name_b);
matches = FALSE;
- if (bus_name != NULL && inhibitor->bus_name != NULL) {
- matches = (strcmp (bus_name, inhibitor->bus_name) == 0);
+ if (bus_name_a != NULL && bus_name_b != NULL) {
+ matches = (strcmp (bus_name_a, bus_name_b) == 0);
if (matches) {
- g_debug ("removing inhibitor from %s for reason '%s' on connection %s",
- inhibitor->app_id,
- inhibitor->reason,
- inhibitor->bus_name);
+ g_debug ("GsmManager: removing inhibitor from %s for reason '%s' on connection %s",
+ gsm_inhibitor_get_app_id (inhibitor),
+ gsm_inhibitor_get_reason (inhibitor),
+ gsm_inhibitor_get_bus_name (inhibitor));
}
}
@@ -526,27 +516,16 @@
}
static void
-inhibit_changed_check (GsmManager *manager)
-{
- gboolean inhibited;
-
- inhibited = g_hash_table_size (manager->priv->inhibitors) > 0;
-
- /* FIXME: do stuff */
-}
-
-static void
remove_inhibitors_for_connection (GsmManager *manager,
const char *service_name)
{
guint n_removed;
- n_removed = g_hash_table_foreach_remove (manager->priv->inhibitors,
- (GHRFunc)inhibitor_has_bus_name,
- (gpointer)service_name);
- if (n_removed > 0) {
- inhibit_changed_check (manager);
- }
+ g_debug ("GsmManager: removing inhibitors for bus name");
+
+ n_removed = gsm_inhibitor_store_foreach_remove (manager->priv->inhibitors,
+ (GsmInhibitorStoreFunc)inhibitor_has_bus_name,
+ (gpointer)service_name);
}
static gboolean
@@ -634,6 +613,9 @@
const char *new_service_name,
GsmManager *manager)
{
+ g_debug ("GsmManager: name owner changed old:'%s' new:'%s'",
+ old_service_name,
+ new_service_name);
if (strlen (new_service_name) == 0
&& strlen (old_service_name) > 0) {
/* service removed */
@@ -1283,10 +1265,7 @@
g_free,
g_object_unref);
- manager->priv->inhibitors = g_hash_table_new_full (g_int_hash,
- g_int_equal,
- NULL,
- (GDestroyNotify)gsm_inhibitor_free);
+ manager->priv->inhibitors = gsm_inhibitor_store_new ();
}
static void
@@ -1310,7 +1289,7 @@
}
if (manager->priv->inhibitors != NULL) {
- g_hash_table_destroy (manager->priv->inhibitors);
+ g_object_unref (manager->priv->inhibitors);
}
G_OBJECT_CLASS (gsm_manager_parent_class)->finalize (object);
@@ -1471,6 +1450,96 @@
g_object_unref (power_manager);
}
+static gboolean
+gsm_manager_is_logout_inhibited (GsmManager *manager)
+{
+ if (manager->priv->inhibitors == NULL) {
+ return FALSE;
+ }
+ if (gsm_inhibitor_store_size (manager->priv->inhibitors) == 0) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void
+do_action (GsmManager *manager,
+ int action)
+{
+ switch (action) {
+ case GSM_LOGOUT_ACTION_SWITCH_USER:
+ gdm_new_login ();
+ break;
+ case GSM_LOGOUT_ACTION_HIBERNATE:
+ manager_request_hibernate (manager);
+ break;
+ case GSM_LOGOUT_ACTION_SLEEP:
+ manager_request_sleep (manager);
+ break;
+ case GSM_LOGOUT_ACTION_SHUTDOWN:
+ manager_request_shutdown (manager);
+ break;
+ case GSM_LOGOUT_ACTION_REBOOT:
+ manager_request_reboot (manager);
+ break;
+ case GSM_LOGOUT_ACTION_LOGOUT:
+ manager_logout (manager);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static void
+logout_inhibit_dialog_response (GsmLogoutInhibitDialog *dialog,
+ guint response_id,
+ GsmManager *manager)
+{
+ int action;
+
+ g_debug ("GsmManager: Logout inhibit dialog response: %d", response_id);
+
+ /* In case of dialog cancel, switch user, hibernate and
+ * suspend, we just perform the respective action and return,
+ * without shutting down the session. */
+ switch (response_id) {
+ case GTK_RESPONSE_CANCEL:
+ case GTK_RESPONSE_NONE:
+ case GTK_RESPONSE_DELETE_EVENT:
+ break;
+ case GTK_RESPONSE_ACCEPT:
+ g_object_get (dialog, "action", &action, NULL);
+ g_debug ("GsmManager: doing action %d", action);
+ do_action (manager, action);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+request_logout (GsmManager *manager)
+{
+ g_debug ("GsmManager: requesting logout");
+
+ if (! gsm_manager_is_logout_inhibited (manager)) {
+ manager_logout (manager);
+ return;
+ }
+
+ manager->priv->inhibit_dialog = gsm_logout_inhibit_dialog_new (GSM_LOGOUT_ACTION_LOGOUT);
+
+ g_signal_connect (manager->priv->inhibit_dialog,
+ "response",
+ G_CALLBACK (logout_inhibit_dialog_response),
+ manager);
+ gtk_widget_show (manager->priv->inhibit_dialog);
+}
+
static void
logout_dialog_response (GsmLogoutDialog *logout_dialog,
guint response_id,
@@ -1491,10 +1560,10 @@
case GSM_LOGOUT_RESPONSE_SWITCH_USER:
gdm_new_login ();
break;
- case GSM_LOGOUT_RESPONSE_STD:
+ case GSM_LOGOUT_RESPONSE_HIBERNATE:
manager_request_hibernate (manager);
break;
- case GSM_LOGOUT_RESPONSE_STR:
+ case GSM_LOGOUT_RESPONSE_SLEEP:
manager_request_sleep (manager);
break;
case GSM_LOGOUT_RESPONSE_SHUTDOWN:
@@ -1504,7 +1573,7 @@
manager_request_reboot (manager);
break;
case GSM_LOGOUT_RESPONSE_LOGOUT:
- manager_logout (manager);
+ request_logout (manager);
break;
default:
g_assert_not_reached ();
@@ -1553,8 +1622,8 @@
}
static void
-initiate_logout (GsmManager *manager,
- gboolean show_confirmation)
+initiate_logout (GsmManager *manager,
+ gboolean show_confirmation)
{
gboolean logout_prompt;
GConfClient *client;
@@ -1578,7 +1647,7 @@
if (logout_prompt) {
show_logout_dialog (manager);
} else {
- manager_logout (manager);
+ request_logout (manager);
}
}
@@ -1852,7 +1921,7 @@
do {
cookie = generate_cookie ();
- } while (g_hash_table_lookup (manager->priv->inhibitors, &cookie) != NULL);
+ } while (gsm_inhibitor_store_lookup (manager->priv->inhibitors, &cookie) != NULL);
return cookie;
}
@@ -1866,6 +1935,7 @@
DBusGMethodInvocation *context)
{
GsmInhibitor *inhibitor;
+ guint cookie;
g_debug ("GsmManager: Inhibit xid=%u app_id=%s reason=%s flags=%u",
toplevel_xid,
@@ -1879,7 +1949,7 @@
new_error = g_error_new (GSM_MANAGER_ERROR,
GSM_MANAGER_ERROR_GENERAL,
"Application ID not specified");
- g_debug ("Unable to inhibit: %s", new_error->message);
+ g_debug ("GsmManager: Unable to inhibit: %s", new_error->message);
dbus_g_method_return_error (context, new_error);
g_error_free (new_error);
return FALSE;
@@ -1891,23 +1961,23 @@
new_error = g_error_new (GSM_MANAGER_ERROR,
GSM_MANAGER_ERROR_GENERAL,
"Reason not specified");
- g_debug ("Unable to inhibit: %s", new_error->message);
+ g_debug ("GsmManager: Unable to inhibit: %s", new_error->message);
dbus_g_method_return_error (context, new_error);
g_error_free (new_error);
return FALSE;
}
- inhibitor = g_new0 (GsmInhibitor, 1);
- inhibitor->app_id = g_strdup (app_id);
- inhibitor->toplevel_xid = toplevel_xid;
- inhibitor->reason = g_strdup (reason);
- inhibitor->flags = flags;
- inhibitor->bus_name = dbus_g_method_get_sender (context);
- inhibitor->cookie = _generate_unique_cookie (manager);
-
- g_hash_table_insert (manager->priv->inhibitors, &inhibitor->cookie, inhibitor);
+ cookie = _generate_unique_cookie (manager);
+ inhibitor = gsm_inhibitor_new (app_id,
+ toplevel_xid,
+ flags,
+ reason,
+ dbus_g_method_get_sender (context),
+ cookie);
+ gsm_inhibitor_store_add (manager->priv->inhibitors, inhibitor);
+ g_object_unref (inhibitor);
- dbus_g_method_return (context, inhibitor->cookie);
+ dbus_g_method_return (context, cookie);
return TRUE;
}
@@ -1918,11 +1988,10 @@
DBusGMethodInvocation *context)
{
GsmInhibitor *inhibitor;
- gboolean removed;
g_debug ("GsmManager: Uninhibit %u", cookie);
- inhibitor = g_hash_table_lookup (manager->priv->inhibitors, &cookie);
+ inhibitor = gsm_inhibitor_store_lookup (manager->priv->inhibitors, &cookie);
if (inhibitor == NULL) {
GError *new_error;
@@ -1936,16 +2005,13 @@
}
g_debug ("GsmManager: removing inhibitor %s %u reason '%s' %u connection %s",
- inhibitor->app_id,
- inhibitor->toplevel_xid,
- inhibitor->reason,
- inhibitor->flags,
- inhibitor->bus_name);
-
- removed = g_hash_table_remove (manager->priv->inhibitors, &cookie);
- if (removed) {
- inhibit_changed_check (manager);
- }
+ gsm_inhibitor_get_app_id (inhibitor),
+ gsm_inhibitor_get_toplevel_xid (inhibitor),
+ gsm_inhibitor_get_reason (inhibitor),
+ gsm_inhibitor_get_flags (inhibitor),
+ gsm_inhibitor_get_bus_name (inhibitor));
+
+ gsm_inhibitor_store_remove (manager->priv->inhibitors, inhibitor);
dbus_g_method_return (context);
Modified: branches/dbus_based/gnome-session/gsm-manager.h
==============================================================================
--- branches/dbus_based/gnome-session/gsm-manager.h (original)
+++ branches/dbus_based/gnome-session/gsm-manager.h Tue Jun 24 17:09:28 2008
@@ -102,8 +102,6 @@
GSM_MANAGER_INHIBIT_FLAG_NONE = 1 << 0,
GSM_MANAGER_INHIBIT_FLAG_ALLOW_USER_SWITCH = 1 << 1,
GSM_MANAGER_INHIBIT_FLAG_ALLOW_SUSPEND = 1 << 2,
- GSM_MANAGER_INHIBIT_FLAG_ALLOW_LOG_OUT = 1 << 3,
- GSM_MANAGER_INHIBIT_FLAG_ALLOW_SHUTDOWN = 1 << 4,
} GsmManagerInhibitFlag;
GType gsm_manager_error_get_type (void);
Modified: branches/dbus_based/gnome-session/test-inhibit.c
==============================================================================
--- branches/dbus_based/gnome-session/test-inhibit.c (original)
+++ branches/dbus_based/gnome-session/test-inhibit.c Tue Jun 24 17:09:28 2008
@@ -83,7 +83,7 @@
"Inhibit",
&error,
G_TYPE_STRING, app_id,
- G_TYPE_UINT, cookie,
+ G_TYPE_UINT, toplevel_xid,
G_TYPE_STRING, reason,
G_TYPE_UINT, flags,
G_TYPE_INVALID,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]