Commit 629d98bb authored by William Jon McCann's avatar William Jon McCann Committed by William Jon McCann

Add an inhibitor class and store class to make it easier to update the

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.


svn path=/branches/dbus_based/; revision=4767
parent b2c50ae4
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.
2008-06-23 William Jon McCann <jmccann@redhat.com>
* gnome-session/Makefile.am:
......
......@@ -64,9 +64,22 @@ dnl Dependency Checks
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)
......
......@@ -21,9 +21,15 @@ INCLUDES = \
-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 @@ gnome_session_SOURCES = \
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 @@ gnome_session_SOURCES = \
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 @@ CLEANFILES = \
$(BUILT_SOURCES)
EXTRA_DIST = \
$(glade_DATA) \
README \
gsm-marshal.list \
gsm-manager.xml
MAINTAINERCLEANFILES = \
*~ \
Makefile.in
......@@ -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 GsmClientStorePrivate GsmClientStorePrivate;
typedef struct
{
GObject parent;
GObject parent;
GsmClientStorePrivate *priv;
} GsmClientStore;
......@@ -47,9 +47,9 @@ typedef struct
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
......
/* -*- 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);
}
/* -*- 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 */
/* -*- 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;