summaryrefslogtreecommitdiff
path: root/applets/brightness/brightness-applet.c
diff options
context:
space:
mode:
Diffstat (limited to 'applets/brightness/brightness-applet.c')
-rw-r--r--applets/brightness/brightness-applet.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/applets/brightness/brightness-applet.c b/applets/brightness/brightness-applet.c
index a35ce2f..154101a 100644
--- a/applets/brightness/brightness-applet.c
+++ b/applets/brightness/brightness-applet.c
@@ -40,7 +40,6 @@
#include <libmate-desktop/mate-aboutdialog.h>
#include "egg-debug.h"
-#include "egg-dbus-monitor.h"
#include "gpm-common.h"
#define GPM_TYPE_BRIGHTNESS_APPLET (gpm_brightness_applet_get_type ())
@@ -63,7 +62,7 @@ typedef struct{
/* connection to g-p-m */
DBusGProxy *proxy;
DBusGConnection *connection;
- EggDbusMonitor *monitor;
+ guint bus_watch_id;
guint level;
/* a cache for panel size */
gint size;
@@ -983,12 +982,9 @@ gpm_applet_destroy_cb (GtkWidget *widget)
{
GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET(widget);
- if (applet->monitor != NULL) {
- g_object_unref (applet->monitor);
- }
- if (applet->icon != NULL) {
+ g_bus_unwatch_name (applet->bus_watch_id);
+ if (applet->icon != NULL)
g_object_unref (applet->icon);
- }
}
/**
@@ -1069,25 +1065,30 @@ gpm_brightness_applet_dbus_disconnect (GpmBrightnessApplet *applet)
}
/**
- * monitor_connection_cb:
- * @proxy: The dbus raw proxy
- * @status: The status of the service, where TRUE is connected
- * @screensaver: This class instance
+ * gpm_brightness_applet_name_appeared_cb:
**/
static void
-monitor_connection_cb (EggDbusMonitor *monitor,
- gboolean status,
- GpmBrightnessApplet *applet)
+gpm_brightness_applet_name_appeared_cb (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ GpmBrightnessApplet *applet)
{
- if (status) {
- gpm_brightness_applet_dbus_connect (applet);
- gpm_applet_update_tooltip (applet);
- gpm_applet_draw_cb (applet);
- } else {
- gpm_brightness_applet_dbus_disconnect (applet);
- gpm_applet_update_tooltip (applet);
- gpm_applet_draw_cb (applet);
- }
+ gpm_brightness_applet_dbus_connect (applet);
+ gpm_applet_update_tooltip (applet);
+ gpm_applet_draw_cb (applet);
+}
+
+/**
+ * gpm_brightness_applet_name_vanished_cb:
+ **/
+void
+gpm_brightness_applet_name_vanished_cb (GDBusConnection *connection,
+ const gchar *name,
+ GpmBrightnessApplet *applet)
+{
+ gpm_brightness_applet_dbus_disconnect (applet);
+ gpm_applet_update_tooltip (applet);
+ gpm_applet_draw_cb (applet);
}
/**
@@ -1113,12 +1114,14 @@ gpm_brightness_applet_init (GpmBrightnessApplet *applet)
GPM_DATA G_DIR_SEPARATOR_S "icons");
- applet->monitor = egg_dbus_monitor_new ();
- g_signal_connect (applet->monitor, "connection-changed",
- G_CALLBACK (monitor_connection_cb), applet);
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
- egg_dbus_monitor_assign (applet->monitor, connection, GPM_DBUS_SERVICE);
- gpm_brightness_applet_dbus_connect (applet);
+ /* monitor the daemon */
+ applet->bus_watch_id =
+ g_bus_watch_name (G_BUS_TYPE_SESSION,
+ GPM_DBUS_SERVICE,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ (GBusNameAppearedCallback) gpm_brightness_applet_name_appeared_cb,
+ (GBusNameVanishedCallback) gpm_brightness_applet_name_vanished_cb,
+ applet, NULL);
/* coldplug */
applet->call_worked = gpm_applet_get_brightness (applet);