|
|
211c304 |
diff -up gnome-applets-2.20.0/gweather/gweather-applet.c.network gnome-applets-2.20.0/gweather/gweather-applet.c
|
|
|
211c304 |
--- gnome-applets-2.20.0/gweather/gweather-applet.c.network 2007-10-21 00:12:36.000000000 -0400
|
|
|
211c304 |
+++ gnome-applets-2.20.0/gweather/gweather-applet.c 2007-10-21 00:12:41.000000000 -0400
|
|
|
211c304 |
@@ -29,6 +29,10 @@
|
|
|
211c304 |
#include <libnotify/notification.h>
|
|
|
211c304 |
#endif
|
|
|
211c304 |
|
|
|
211c304 |
+#include <dbus/dbus-glib.h>
|
|
|
211c304 |
+#include <dbus/dbus-glib-lowlevel.h>
|
|
|
211c304 |
+#include <NetworkManager/NetworkManager.h>
|
|
|
211c304 |
+
|
|
|
211c304 |
#include "gweather.h"
|
|
|
211c304 |
#include "gweather-about.h"
|
|
|
211c304 |
#include "gweather-pref.h"
|
|
|
211c304 |
@@ -291,6 +295,8 @@ applet_destroy (GtkWidget *widget, GWeat
|
|
|
211c304 |
weather_info_abort (gw_applet->gweather_info);
|
|
|
211c304 |
}
|
|
|
211c304 |
|
|
|
211c304 |
+static void setup_network_monitor (GWeatherApplet *gw_applet);
|
|
|
211c304 |
+
|
|
|
211c304 |
void gweather_applet_create (GWeatherApplet *gw_applet)
|
|
|
211c304 |
{
|
|
|
211c304 |
AtkObject *atk_obj;
|
|
|
211c304 |
@@ -326,7 +332,7 @@ void gweather_applet_create (GWeatherApp
|
|
|
211c304 |
g_signal_connect (GTK_OBJECT(gw_applet->applet), "button_press_event",
|
|
|
211c304 |
GTK_SIGNAL_FUNC(clicked_cb), gw_applet);
|
|
|
211c304 |
g_signal_connect (G_OBJECT(gw_applet->applet), "key_press_event",
|
|
|
211c304 |
- G_CALLBACK(key_press_cb), gw_applet);
|
|
|
211c304 |
+ G_CALLBACK(key_press_cb), gw_applet);
|
|
|
211c304 |
|
|
|
211c304 |
gtk_widget_set_tooltip_text (GTK_WIDGET(gw_applet->applet), _("GNOME Weather"));
|
|
|
211c304 |
|
|
|
211c304 |
@@ -356,9 +362,9 @@ void gweather_applet_create (GWeatherApp
|
|
|
211c304 |
NULL);
|
|
|
211c304 |
}
|
|
|
211c304 |
|
|
|
211c304 |
- place_widgets(gw_applet);
|
|
|
211c304 |
-
|
|
|
211c304 |
- return;
|
|
|
211c304 |
+ place_widgets(gw_applet);
|
|
|
211c304 |
+
|
|
|
211c304 |
+ setup_network_monitor (gw_applet);
|
|
|
211c304 |
}
|
|
|
211c304 |
|
|
|
211c304 |
gint timeout_cb (gpointer data)
|
|
|
211c304 |
@@ -525,3 +531,52 @@ void gweather_update (GWeatherApplet *gw
|
|
|
211c304 |
update_finish, gw_applet);
|
|
|
211c304 |
}
|
|
|
211c304 |
}
|
|
|
211c304 |
+
|
|
|
211c304 |
+static DBusHandlerResult
|
|
|
211c304 |
+filter_func (DBusConnection *connection, DBusMessage *message, void *user_data)
|
|
|
211c304 |
+{
|
|
|
211c304 |
+ GWeatherApplet *gw_applet = user_data;
|
|
|
211c304 |
+ guint32 state = NM_DEVICE_STATE_UNKNOWN;
|
|
|
211c304 |
+
|
|
|
211c304 |
+ if (dbus_message_is_signal (message,
|
|
|
211c304 |
+ NM_DBUS_INTERFACE_DEVICE, "StateChanged")) {
|
|
|
211c304 |
+ dbus_message_get_args (message, NULL,
|
|
|
211c304 |
+ DBUS_TYPE_UINT32, &state,
|
|
|
211c304 |
+ DBUS_TYPE_INVALID);
|
|
|
211c304 |
+ if (state == NM_DEVICE_STATE_ACTIVATED) {
|
|
|
211c304 |
+ gweather_update (gw_applet);
|
|
|
211c304 |
+ }
|
|
|
211c304 |
+
|
|
|
211c304 |
+ return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
211c304 |
+ }
|
|
|
211c304 |
+
|
|
|
211c304 |
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
211c304 |
+}
|
|
|
211c304 |
+
|
|
|
211c304 |
+static void
|
|
|
211c304 |
+setup_network_monitor (GWeatherApplet *gw_applet)
|
|
|
211c304 |
+{
|
|
|
211c304 |
+ GError *error;
|
|
|
211c304 |
+ static DBusGConnection *bus = NULL;
|
|
|
211c304 |
+ DBusConnection *dbus;
|
|
|
211c304 |
+
|
|
|
211c304 |
+ if (bus == NULL) {
|
|
|
211c304 |
+ error = NULL;
|
|
|
211c304 |
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
|
|
|
211c304 |
+ if (bus == NULL) {
|
|
|
211c304 |
+ g_warning ("Couldn't connect to system bus: %s",
|
|
|
211c304 |
+ error->message);
|
|
|
211c304 |
+ g_error_free (error);
|
|
|
211c304 |
+
|
|
|
211c304 |
+ return;
|
|
|
211c304 |
+ }
|
|
|
211c304 |
+
|
|
|
211c304 |
+ dbus = dbus_g_connection_get_connection (bus);
|
|
|
211c304 |
+ dbus_connection_add_filter (dbus, filter_func, gw_applet, NULL);
|
|
|
211c304 |
+ dbus_bus_add_match (dbus,
|
|
|
211c304 |
+ "type='signal',"
|
|
|
211c304 |
+ "interface='" NM_DBUS_INTERFACE_DEVICE "'",
|
|
|
211c304 |
+ NULL);
|
|
|
211c304 |
+ }
|
|
|
211c304 |
+}
|
|
|
211c304 |
+
|