gnome-power-manager r2920 - in trunk: . applets/brightness applets/inhibit libdbus-glib libhal-glib src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r2920 - in trunk: . applets/brightness applets/inhibit libdbus-glib libhal-glib src
- Date: Thu, 4 Sep 2008 12:01:56 +0000 (UTC)
Author: rhughes
Date: Thu Sep 4 12:01:56 2008
New Revision: 2920
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=2920&view=rev
Log:
2008-09-04 Richard Hughes <richard hughsie com>
* applets/brightness/Makefile.am:
* applets/brightness/brightness-applet.c:
(gpm_applet_get_brightness), (gpm_applet_set_brightness),
(gpm_applet_get_icon), (brightness_changed_cb),
(gpm_brightness_applet_dbus_connect),
(gpm_brightness_applet_dbus_disconnect):
* applets/inhibit/Makefile.am:
* applets/inhibit/inhibit-applet.c: (gpm_applet_inhibit),
(gpm_applet_uninhibit), (gpm_inhibit_applet_dbus_connect),
(gpm_inhibit_applet_dbus_disconnect):
* libdbus-glib/Makefile.am:
* libdbus-glib/egg-dbus-monitor.c:
* libdbus-glib/egg-dbus-monitor.h:
* libdbus-glib/egg-debug.c:
* libdbus-glib/egg-debug.h:
* libdbus-glib/libdbus-marshal.list:
* libdbus-glib/libdbus-monitor-session.c:
* libdbus-glib/libdbus-monitor-session.h:
* libdbus-glib/libdbus-monitor-system.c:
* libdbus-glib/libdbus-monitor-system.h:
* libdbus-glib/libdbus-proxy.c: (dbus_monitor_connection_cb),
(dbus_proxy_assign), (dbus_proxy_init), (dbus_proxy_finalize):
* libhal-glib/Makefile.am:
* src/Makefile.am:
Don't use DbusMonitorSystem or DbusMonitorSession, we can use
EggDbusMonitor and be much nicer.
* src/gpm-inhibit.c: (gpm_inhibit_name_owner_changed_cb),
(gpm_inhibit_init), (gpm_inhibit_finalize):
Convert to using plain dbus-glib
Added:
trunk/libdbus-glib/egg-dbus-monitor.c (contents, props changed)
trunk/libdbus-glib/egg-dbus-monitor.h (contents, props changed)
trunk/libdbus-glib/egg-debug.c (contents, props changed)
trunk/libdbus-glib/egg-debug.h (contents, props changed)
Removed:
trunk/libdbus-glib/libdbus-marshal.list
trunk/libdbus-glib/libdbus-monitor-session.c
trunk/libdbus-glib/libdbus-monitor-session.h
trunk/libdbus-glib/libdbus-monitor-system.c
trunk/libdbus-glib/libdbus-monitor-system.h
Modified:
trunk/ChangeLog
trunk/applets/brightness/Makefile.am
trunk/applets/brightness/brightness-applet.c
trunk/applets/inhibit/Makefile.am
trunk/applets/inhibit/inhibit-applet.c
trunk/libdbus-glib/Makefile.am
trunk/libdbus-glib/libdbus-proxy.c
trunk/libhal-glib/Makefile.am
trunk/src/Makefile.am
trunk/src/egg-dbus-monitor.h
trunk/src/gpm-inhibit.c
Modified: trunk/applets/brightness/Makefile.am
==============================================================================
--- trunk/applets/brightness/Makefile.am (original)
+++ trunk/applets/brightness/Makefile.am Thu Sep 4 12:01:56 2008
@@ -18,16 +18,10 @@
-I$(top_srcdir)/libdbus-glib \
$(NULL)
-LOCAL_LIBDBUS_LIBS = \
- $(top_builddir)/libdbus-glib/libdbus-monitor-session.la \
- $(top_builddir)/libdbus-glib/libdbus-monitor-system.la \
- $(top_builddir)/libdbus-glib/libdbus-watch.la
-
libexec_PROGRAMS=gnome-brightness-applet
gnome_brightness_applet_SOURCES = brightness-applet.c ../../src/egg-dbus-monitor.c ../../src/egg-debug.c
gnome_brightness_applet_LDADD = \
- $(LOCAL_LIBDBUS_LIBS) \
$(DBUS_LIBS) \
$(GNOME_LIBS)
Modified: trunk/applets/brightness/brightness-applet.c
==============================================================================
--- trunk/applets/brightness/brightness-applet.c (original)
+++ trunk/applets/brightness/brightness-applet.c Thu Sep 4 12:01:56 2008
@@ -35,6 +35,7 @@
#include <glib-object.h>
#include <dbus/dbus-glib.h>
+#include "../src/egg-debug.h"
#include "../src/egg-dbus-monitor.h"
#include "../src/gpm-common.h"
@@ -120,7 +121,7 @@
guint policy_brightness;
if (applet->proxy == NULL) {
- printf ("WARNING: not connected\n");
+ egg_warning ("not connected\n");
return FALSE;
}
@@ -129,14 +130,14 @@
G_TYPE_UINT, &policy_brightness,
G_TYPE_INVALID);
if (error) {
- printf ("DEBUG: ERROR: %s\n", error->message);
+ egg_debug ("ERROR: %s\n", error->message);
g_error_free (error);
}
if (ret) {
applet->level = policy_brightness;
} else {
/* abort as the DBUS method failed */
- printf ("WARNING: GetBrightness failed!\n");
+ egg_warning ("GetBrightness failed!\n");
}
return ret;
@@ -153,7 +154,7 @@
gboolean ret;
if (applet->proxy == NULL) {
- printf ("WARNING: not connected");
+ egg_warning ("not connected");
return FALSE;
}
@@ -162,12 +163,12 @@
G_TYPE_INVALID,
G_TYPE_INVALID);
if (error) {
- printf ("DEBUG: ERROR: %s", error->message);
+ egg_debug ("ERROR: %s", error->message);
g_error_free (error);
}
if (!ret) {
/* abort as the DBUS method failed */
- printf ("WARNING: SetBrightness failed!");
+ egg_warning ("SetBrightness failed!");
}
return ret;
@@ -207,9 +208,9 @@
icon, applet->size - 2, 0, NULL);
if (applet->icon == NULL) {
- printf ("WARNING: Cannot find %s!\n", icon);
+ egg_warning ("Cannot find %s!\n", icon);
} else {
- printf ("DEBUG: got icon %s!\n", icon);
+ egg_debug ("got icon %s!\n", icon);
/* update size cache */
applet->icon_height = gdk_pixbuf_get_height (applet->icon);
applet->icon_width = gdk_pixbuf_get_width (applet->icon);
@@ -846,7 +847,7 @@
guint brightness,
GpmBrightnessApplet *applet)
{
- printf ("DEBUG: BrightnessChanged detected: %i\n", brightness);
+ egg_debug ("BrightnessChanged detected: %i\n", brightness);
applet->level = brightness;
}
@@ -859,18 +860,18 @@
GError *error = NULL;
if (applet->connection == NULL) {
- printf ("DEBUG: get connection\n");
+ egg_debug ("get connection\n");
g_clear_error (&error);
applet->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (error != NULL) {
- printf ("WARNING: Could not connect to DBUS daemon: %s", error->message);
+ egg_warning ("Could not connect to DBUS daemon: %s", error->message);
g_error_free (error);
applet->connection = NULL;
return FALSE;
}
}
if (applet->proxy == NULL) {
- printf ("DEBUG: get proxy\n");
+ egg_debug ("get proxy\n");
g_clear_error (&error);
applet->proxy = dbus_g_proxy_new_for_name_owner (applet->connection,
GPM_DBUS_SERVICE,
@@ -878,7 +879,7 @@
GPM_DBUS_INTERFACE_BACKLIGHT,
&error);
if (error != NULL) {
- printf ("WARNING: Cannot connect, maybe the daemon is not running: %s\n", error->message);
+ egg_warning ("Cannot connect, maybe the daemon is not running: %s\n", error->message);
g_error_free (error);
applet->proxy = NULL;
return FALSE;
@@ -901,7 +902,7 @@
gpm_brightness_applet_dbus_disconnect (GpmBrightnessApplet *applet)
{
if (applet->proxy != NULL) {
- printf ("DEBUG: removing proxy\n");
+ egg_debug ("removing proxy\n");
g_object_unref (applet->proxy);
applet->proxy = NULL;
}
Modified: trunk/applets/inhibit/Makefile.am
==============================================================================
--- trunk/applets/inhibit/Makefile.am (original)
+++ trunk/applets/inhibit/Makefile.am Thu Sep 4 12:01:56 2008
@@ -18,16 +18,10 @@
-I$(top_srcdir)/libdbus-glib \
$(NULL)
-LOCAL_LIBDBUS_LIBS = \
- $(top_builddir)/libdbus-glib/libdbus-monitor-session.la \
- $(top_builddir)/libdbus-glib/libdbus-monitor-system.la \
- $(top_builddir)/libdbus-glib/libdbus-watch.la
-
libexec_PROGRAMS=gnome-inhibit-applet
gnome_inhibit_applet_SOURCES = inhibit-applet.c ../../src/egg-dbus-monitor.c ../../src/egg-debug.c
gnome_inhibit_applet_LDADD = \
- $(LOCAL_LIBDBUS_LIBS) \
$(DBUS_LIBS) \
$(GNOME_LIBS)
Modified: trunk/applets/inhibit/inhibit-applet.c
==============================================================================
--- trunk/applets/inhibit/inhibit-applet.c (original)
+++ trunk/applets/inhibit/inhibit-applet.c Thu Sep 4 12:01:56 2008
@@ -34,6 +34,7 @@
#include <glib-object.h>
#include <dbus/dbus-glib.h>
+#include "../src/egg-debug.h"
#include "../src/egg-dbus-monitor.h"
#include "../src/gpm-common.h"
@@ -105,7 +106,7 @@
g_return_val_if_fail (cookie != NULL, FALSE);
if (applet->proxy == NULL) {
- printf ("WARNING: not connected\n");
+ egg_warning ("not connected\n");
return FALSE;
}
@@ -136,7 +137,7 @@
gboolean ret;
if (applet->proxy == NULL) {
- printf ("WARNING: not connected");
+ egg_warning ("not connected");
return FALSE;
}
@@ -521,18 +522,18 @@
GError *error = NULL;
if (applet->connection == NULL) {
- printf ("DEBUG: get connection\n");
+ egg_debug ("get connection\n");
g_clear_error (&error);
applet->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (error != NULL) {
- printf ("WARNING: Could not connect to DBUS daemon: %s", error->message);
+ egg_warning ("Could not connect to DBUS daemon: %s", error->message);
g_error_free (error);
applet->connection = NULL;
return FALSE;
}
}
if (applet->proxy == NULL) {
- printf ("DEBUG: get proxy\n");
+ egg_debug ("get proxy\n");
g_clear_error (&error);
applet->proxy = dbus_g_proxy_new_for_name_owner (applet->connection,
GPM_DBUS_SERVICE,
@@ -540,7 +541,7 @@
GPM_DBUS_INTERFACE_INHIBIT,
&error);
if (error != NULL) {
- printf ("WARNING: Cannot connect, maybe the daemon is not running: %s\n", error->message);
+ egg_warning ("Cannot connect, maybe the daemon is not running: %s\n", error->message);
g_error_free (error);
applet->proxy = NULL;
return FALSE;
@@ -556,7 +557,7 @@
gpm_inhibit_applet_dbus_disconnect (GpmInhibitApplet *applet)
{
if (applet->proxy != NULL) {
- printf ("DEBUG: removing proxy\n");
+ egg_debug ("removing proxy\n");
g_object_unref (applet->proxy);
applet->proxy = NULL;
/* we have no inhibit, these are not persistant across reboots */
Modified: trunk/libdbus-glib/Makefile.am
==============================================================================
--- trunk/libdbus-glib/Makefile.am (original)
+++ trunk/libdbus-glib/Makefile.am Thu Sep 4 12:01:56 2008
@@ -2,65 +2,24 @@
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
-I$(top_srcdir)/libdbus-glib \
+ -DEGG_LOG_FILE=\""$(PK_LOG_DIR)/gnome-power-manager"\" \
-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
noinst_LTLIBRARIES = \
- libdbus-proxy.la \
- libdbus-monitor-session.la \
- libdbus-monitor-system.la
-
-libegg_dbus_monitor_la_SOURCES = \
- libdbus-marshal.h \
- libdbus-marshal.c \
- libdbus-monitor-session.c \
- libdbus-monitor-session.h \
- libdbus-monitor-system.c \
- libdbus-monitor-system.h \
-libegg_dbus_monitor_la_LIBADD = @DBUS_LIBS@ $(INTLLIBS) $(GLIB_LIBS)
+ libdbus-proxy.la
libdbus_proxy_la_SOURCES = \
- libdbus-marshal.h \
- libdbus-marshal.c \
- libdbus-monitor-session.c \
- libdbus-monitor-session.h \
- libdbus-monitor-system.c \
- libdbus-monitor-system.h \
+ egg-debug.h \
+ egg-debug.c \
+ egg-dbus-monitor.h \
+ egg-dbus-monitor.c \
libdbus-proxy.c \
libdbus-proxy.h
libdbus_proxy_la_LIBADD = @DBUS_LIBS@ $(INTLLIBS) $(GLIB_LIBS)
-libdbus_monitor_system_la_SOURCES = \
- libdbus-marshal.h \
- libdbus-marshal.c \
- libdbus-monitor-system.c \
- libdbus-monitor-system.h
-libdbus_monitor_system_la_LIBADD = @DBUS_LIBS@ $(INTLLIBS) $(GLIB_LIBS)
-
-libdbus_monitor_session_la_SOURCES = \
- libdbus-marshal.h \
- libdbus-marshal.c \
- libdbus-monitor-session.c \
- libdbus-monitor-session.h
-libdbus_monitor_session_la_LIBADD = @DBUS_LIBS@ $(INTLLIBS) $(GLIB_LIBS)
-
-EXTRA_DIST = \
- libdbus-marshal.list
-
-BUILT_SOURCES = \
- libdbus-marshal.c \
- libdbus-marshal.h
-
-libdbus-marshal.c: libdbus-marshal.list
- echo "#include \"libdbus-marshal.h\"" > $@ && \
- @GLIB_GENMARSHAL@ $< --prefix=libdbus_marshal --body >> $@
-
-libdbus-marshal.h: libdbus-marshal.list
- @GLIB_GENMARSHAL@ $< --prefix=libdbus_marshal --header > $@
-
clean-local:
rm -f *~
- rm -f libdbus-marshal.c libdbus-marshal.h
CLEANFILES = $(BUILT_SOURCES)
Added: trunk/libdbus-glib/egg-dbus-monitor.c
==============================================================================
--- (empty file)
+++ trunk/libdbus-glib/egg-dbus-monitor.c Thu Sep 4 12:01:56 2008
@@ -0,0 +1 @@
+link ../src/egg-dbus-monitor.c
\ No newline at end of file
Added: trunk/libdbus-glib/egg-dbus-monitor.h
==============================================================================
--- (empty file)
+++ trunk/libdbus-glib/egg-dbus-monitor.h Thu Sep 4 12:01:56 2008
@@ -0,0 +1 @@
+link ../src/egg-dbus-monitor.h
\ No newline at end of file
Added: trunk/libdbus-glib/egg-debug.c
==============================================================================
--- (empty file)
+++ trunk/libdbus-glib/egg-debug.c Thu Sep 4 12:01:56 2008
@@ -0,0 +1 @@
+link ../src/egg-debug.c
\ No newline at end of file
Added: trunk/libdbus-glib/egg-debug.h
==============================================================================
--- (empty file)
+++ trunk/libdbus-glib/egg-debug.h Thu Sep 4 12:01:56 2008
@@ -0,0 +1 @@
+link ../src/egg-debug.h
\ No newline at end of file
Modified: trunk/libdbus-glib/libdbus-proxy.c
==============================================================================
--- trunk/libdbus-glib/libdbus-proxy.c (original)
+++ trunk/libdbus-glib/libdbus-proxy.c Thu Sep 4 12:01:56 2008
@@ -26,9 +26,8 @@
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
+#include "egg-dbus-monitor.h"
#include <libdbus-proxy.h>
-#include <libdbus-monitor-session.h>
-#include <libdbus-monitor-system.h>
static void dbus_proxy_class_init (DbusProxyClass *klass);
static void dbus_proxy_init (DbusProxy *proxy);
@@ -44,12 +43,10 @@
gchar *interface;
gchar *path;
DBusGProxy *proxy;
- DbusMonitorSession *monitor_session;
- DbusMonitorSystem *monitor_system;
+ EggDbusMonitor *monitor;
gboolean assigned;
DBusGConnection *connection;
- gulong ses_sig_id;
- gulong sys_sig_id;
+ gulong monitor_callback_id;
};
enum {
@@ -130,75 +127,22 @@
return TRUE;
}
-
-/**
- * dbus_noc_session_cb:
- * @power: The power class instance
- * @name: The DBUS name, e.g. hal.freedesktop.org
- * @prev: The previous name, e.g. :0.13
- * @new: The new name, e.g. :0.14
- * @inhibit: This inhibit class instance
- *
- * The noc session DBUS callback.
- **/
-static void
-dbus_noc_session_cb (DbusMonitorSession *monitor_session,
- const gchar *name,
- const gchar *prev,
- const gchar *new,
- DbusProxy *dbus_proxy)
-{
- g_return_if_fail (DBUS_IS_PROXY (dbus_proxy));
- if (dbus_proxy->priv->assigned == FALSE) {
- return;
- }
- if (dbus_proxy->priv->bus_type == DBUS_PROXY_SYSTEM) {
- return;
- }
-
- if (strcmp (name, dbus_proxy->priv->service) == 0) {
- if (strlen (prev) != 0 && strlen (new) == 0) {
- dbus_proxy_disconnect (dbus_proxy);
- }
- if (strlen (prev) == 0 && strlen (new) != 0) {
- dbus_proxy_connect (dbus_proxy);
- }
- }
-}
-
/**
- * dbus_noc_system_cb:
- * @power: The power class instance
- * @name: The DBUS name, e.g. hal.freedesktop.org
- * @prev: The previous name, e.g. :0.13
- * @new: The new name, e.g. :0.14
- * @inhibit: This inhibit class instance
- *
- * The noc session DBUS callback.
+ * dbus_monitor_connection_cb:
+ * @proxy: The dbus raw proxy
+ * @status: The status of the service, where TRUE is connected
+ * @screensaver: This class instance
**/
static void
-dbus_noc_system_cb (DbusMonitorSystem *monitor_system,
- const gchar *name,
- const gchar *prev,
- const gchar *new,
- DbusProxy *dbus_proxy)
+dbus_monitor_connection_cb (EggDbusMonitor *monitor, gboolean status, DbusProxy *dbus_proxy)
{
g_return_if_fail (DBUS_IS_PROXY (dbus_proxy));
- if (dbus_proxy->priv->assigned == FALSE) {
- return;
- }
- if (dbus_proxy->priv->bus_type == DBUS_PROXY_SESSION) {
+ if (dbus_proxy->priv->assigned == FALSE)
return;
- }
-
- if (strcmp (name, dbus_proxy->priv->service) == 0) {
- if (strlen (prev) != 0 && strlen (new) == 0) {
- dbus_proxy_disconnect (dbus_proxy);
- }
- if (strlen (prev) == 0 && strlen (new) != 0) {
- dbus_proxy_connect (dbus_proxy);
- }
- }
+ if (status)
+ dbus_proxy_connect (dbus_proxy);
+ else
+ dbus_proxy_disconnect (dbus_proxy);
}
/**
@@ -255,19 +199,10 @@
/* We have to save the connection and remove the signal id later as
instances of this object are likely to be registering with a
singleton object many times */
- if (bus_type == DBUS_PROXY_SESSION) {
- dbus_proxy->priv->monitor_session = dbus_monitor_session_new ();
- dbus_proxy->priv->ses_sig_id = g_signal_connect (dbus_proxy->priv->monitor_session,
- "name-owner-changed",
- G_CALLBACK (dbus_noc_session_cb),
- dbus_proxy);
- } else {
- dbus_proxy->priv->monitor_system = dbus_monitor_system_new ();
- dbus_proxy->priv->sys_sig_id = g_signal_connect (dbus_proxy->priv->monitor_system,
- "name-owner-changed",
- G_CALLBACK (dbus_noc_system_cb),
- dbus_proxy);
- }
+ if (bus_type == DBUS_PROXY_SESSION)
+ egg_dbus_monitor_assign (dbus_proxy->priv->monitor, EGG_DBUS_MONITOR_SESSION, service);
+ else
+ egg_dbus_monitor_assign (dbus_proxy->priv->monitor, EGG_DBUS_MONITOR_SYSTEM, service);
/* try to connect and return proxy (or NULL if invalid) */
dbus_proxy_connect (dbus_proxy);
@@ -407,10 +342,11 @@
dbus_proxy->priv->path = NULL;
dbus_proxy->priv->bus_type = DBUS_PROXY_UNKNOWN;
dbus_proxy->priv->assigned = FALSE;
- dbus_proxy->priv->monitor_session = NULL;
- dbus_proxy->priv->monitor_system = NULL;
- dbus_proxy->priv->ses_sig_id = 0;
- dbus_proxy->priv->sys_sig_id = 0;
+ dbus_proxy->priv->monitor = egg_dbus_monitor_new ();
+ dbus_proxy->priv->monitor_callback_id =
+ g_signal_connect (dbus_proxy->priv->monitor, "connection-changed",
+ G_CALLBACK (dbus_monitor_connection_cb), dbus_proxy);
+ dbus_proxy->priv->monitor_callback_id = 0;
}
/**
@@ -427,25 +363,19 @@
dbus_proxy = DBUS_PROXY (object);
dbus_proxy->priv = DBUS_PROXY_GET_PRIVATE (dbus_proxy);
- if (dbus_proxy->priv->ses_sig_id != 0)
- g_signal_handler_disconnect (dbus_proxy->priv->monitor_session, dbus_proxy->priv->ses_sig_id);
- if (dbus_proxy->priv->sys_sig_id != 0)
- g_signal_handler_disconnect (dbus_proxy->priv->monitor_system, dbus_proxy->priv->sys_sig_id);
+ if (dbus_proxy->priv->monitor_callback_id != 0)
+ g_signal_handler_disconnect (dbus_proxy->priv->monitor,
+ dbus_proxy->priv->monitor_callback_id);
dbus_proxy_disconnect (dbus_proxy);
- if (dbus_proxy->priv->proxy != NULL) {
+ if (dbus_proxy->priv->proxy != NULL)
g_object_unref (dbus_proxy->priv->proxy);
- }
- if (dbus_proxy->priv->monitor_session != NULL) {
- g_object_unref (dbus_proxy->priv->monitor_session);
- }
- if (dbus_proxy->priv->monitor_system != NULL) {
- g_object_unref (dbus_proxy->priv->monitor_system);
- }
+ g_object_unref (dbus_proxy->priv->monitor);
g_free (dbus_proxy->priv->service);
g_free (dbus_proxy->priv->interface);
g_free (dbus_proxy->priv->path);
+
G_OBJECT_CLASS (dbus_proxy_parent_class)->finalize (object);
}
Modified: trunk/libhal-glib/Makefile.am
==============================================================================
--- trunk/libhal-glib/Makefile.am (original)
+++ trunk/libhal-glib/Makefile.am Thu Sep 4 12:01:56 2008
@@ -6,8 +6,6 @@
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
LOCAL_LIBDBUS_LIBS = \
- $(top_builddir)/libdbus-glib/libdbus-monitor-session.la \
- $(top_builddir)/libdbus-glib/libdbus-monitor-system.la \
$(top_builddir)/libdbus-glib/libdbus-proxy.la
noinst_LTLIBRARIES = \
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Thu Sep 4 12:01:56 2008
@@ -42,8 +42,6 @@
$(top_builddir)/libhal-glib/libhal-gpower.la
LOCAL_LIBDBUS_LIBS = \
- $(top_builddir)/libdbus-glib/libdbus-monitor-session.la \
- $(top_builddir)/libdbus-glib/libdbus-monitor-system.la \
$(top_builddir)/libdbus-glib/libdbus-proxy.la
bin_PROGRAMS = \
Modified: trunk/src/egg-dbus-monitor.h
==============================================================================
--- trunk/src/egg-dbus-monitor.h (original)
+++ trunk/src/egg-dbus-monitor.h Thu Sep 4 12:01:56 2008
@@ -58,7 +58,7 @@
GType egg_dbus_monitor_get_type (void) G_GNUC_CONST;
EggDbusMonitor *egg_dbus_monitor_new (void);
-gboolean egg_dbus_monitor_assign (EggDbusMonitor *monitor,
+gboolean egg_dbus_monitor_assign (EggDbusMonitor *monitor,
EggDbusMonitorType bus_type,
const gchar *service);
gboolean egg_dbus_monitor_is_connected (EggDbusMonitor *monitor);
Modified: trunk/src/gpm-inhibit.c
==============================================================================
--- trunk/src/gpm-inhibit.c (original)
+++ trunk/src/gpm-inhibit.c Thu Sep 4 12:01:56 2008
@@ -26,10 +26,9 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <glib/gi18n.h>
#include <string.h>
-#include <libdbus-monitor-session.h>
-#include "gpm-inhibit.h"
#include "egg-debug.h"
+#include "gpm-inhibit.h"
#include "gpm-conf.h"
static void gpm_inhibit_class_init (GpmInhibitClass *klass);
@@ -49,7 +48,7 @@
struct GpmInhibitPrivate
{
GSList *list;
- DbusMonitorSession *dbus_monitor;
+ DBusGProxy *proxy;
GpmConf *conf;
gboolean ignore_inhibits;
};
@@ -289,25 +288,15 @@
}
/**
- * dbus_noc_session_cb:
- * @power: The power class instance
- * @name: The DBUS name, e.g. hal.freedesktop.org
- * @prev: The previous name, e.g. :0.13
- * @new: The new name, e.g. :0.14
- * @inhibit: This inhibit class instance
- *
- * The noc session DBUS callback.
+ * gpm_inhibit_name_owner_changed_cb:
**/
static void
-dbus_noc_session_cb (DbusMonitorSession *dbus_monitor,
- const gchar *name,
- const gchar *prev,
- const gchar *new,
- GpmInhibit *inhibit)
+gpm_inhibit_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name,
+ const gchar *prev, const gchar *new,
+ GpmInhibit *inhibit)
{
- if (strlen (new) == 0) {
+ if (strlen (new) == 0)
gpm_inhibit_remove_dbus (inhibit, name);
- }
}
/**
@@ -467,16 +456,29 @@
static void
gpm_inhibit_init (GpmInhibit *inhibit)
{
+ DBusGConnection *connection;
+ GError *error = NULL;
+
inhibit->priv = GPM_INHIBIT_GET_PRIVATE (inhibit);
inhibit->priv->list = NULL;
- inhibit->priv->dbus_monitor = dbus_monitor_session_new ();
- g_signal_connect (inhibit->priv->dbus_monitor, "name-owner-changed",
- G_CALLBACK (dbus_noc_session_cb), inhibit);
-
inhibit->priv->conf = gpm_conf_new ();
g_signal_connect (inhibit->priv->conf, "value-changed",
G_CALLBACK (conf_key_changed_cb), inhibit);
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (error != NULL) {
+ egg_warning ("Cannot connect to bus: %s", error->message);
+ g_error_free (error);
+ }
+ inhibit->priv->proxy = dbus_g_proxy_new_for_name_owner (connection,
+ DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS, NULL);
+ dbus_g_proxy_add_signal (inhibit->priv->proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (inhibit->priv->proxy, "NameOwnerChanged",
+ G_CALLBACK (gpm_inhibit_name_owner_changed_cb),
+ inhibit, NULL);
+
/* Do we ignore inhibit requests? */
gpm_conf_get_bool (inhibit->priv->conf, GPM_CONF_IGNORE_INHIBITS, &inhibit->priv->ignore_inhibits);
}
@@ -502,7 +504,7 @@
g_slist_free (inhibit->priv->list);
g_object_unref (inhibit->priv->conf);
- g_object_unref (inhibit->priv->dbus_monitor);
+ g_object_unref (inhibit->priv->proxy);
G_OBJECT_CLASS (gpm_inhibit_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]