diff options
author | Matthias Clasen <mclasen@fedoraproject.org> | 2007-10-21 04:18:14 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@fedoraproject.org> | 2007-10-21 04:18:14 +0000 |
commit | 211c3040d604b58cec5f4355a36a6b816aa5a1c7 (patch) | |
tree | 131571e14e64b4de0a570e9df78162e25c364ada /gweather-network.patch | |
parent | 6be108934d924b2c1a9db6be7567d28f885947d6 (diff) | |
download | gnome-applets-211c3040d604b58cec5f4355a36a6b816aa5a1c7.tar.gz gnome-applets-211c3040d604b58cec5f4355a36a6b816aa5a1c7.tar.xz gnome-applets-211c3040d604b58cec5f4355a36a6b816aa5a1c7.zip |
Update weather info when going online
Diffstat (limited to 'gweather-network.patch')
-rw-r--r-- | gweather-network.patch | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/gweather-network.patch b/gweather-network.patch new file mode 100644 index 0000000..554cd93 --- /dev/null +++ b/gweather-network.patch @@ -0,0 +1,98 @@ +diff -up gnome-applets-2.20.0/gweather/gweather-applet.c.network gnome-applets-2.20.0/gweather/gweather-applet.c +--- gnome-applets-2.20.0/gweather/gweather-applet.c.network 2007-10-21 00:12:36.000000000 -0400 ++++ gnome-applets-2.20.0/gweather/gweather-applet.c 2007-10-21 00:12:41.000000000 -0400 +@@ -29,6 +29,10 @@ + #include <libnotify/notification.h> + #endif + ++#include <dbus/dbus-glib.h> ++#include <dbus/dbus-glib-lowlevel.h> ++#include <NetworkManager/NetworkManager.h> ++ + #include "gweather.h" + #include "gweather-about.h" + #include "gweather-pref.h" +@@ -291,6 +295,8 @@ applet_destroy (GtkWidget *widget, GWeat + weather_info_abort (gw_applet->gweather_info); + } + ++static void setup_network_monitor (GWeatherApplet *gw_applet); ++ + void gweather_applet_create (GWeatherApplet *gw_applet) + { + AtkObject *atk_obj; +@@ -326,7 +332,7 @@ void gweather_applet_create (GWeatherApp + g_signal_connect (GTK_OBJECT(gw_applet->applet), "button_press_event", + GTK_SIGNAL_FUNC(clicked_cb), gw_applet); + g_signal_connect (G_OBJECT(gw_applet->applet), "key_press_event", +- G_CALLBACK(key_press_cb), gw_applet); ++ G_CALLBACK(key_press_cb), gw_applet); + + gtk_widget_set_tooltip_text (GTK_WIDGET(gw_applet->applet), _("GNOME Weather")); + +@@ -356,9 +362,9 @@ void gweather_applet_create (GWeatherApp + NULL); + } + +- place_widgets(gw_applet); +- +- return; ++ place_widgets(gw_applet); ++ ++ setup_network_monitor (gw_applet); + } + + gint timeout_cb (gpointer data) +@@ -525,3 +531,52 @@ void gweather_update (GWeatherApplet *gw + update_finish, gw_applet); + } + } ++ ++static DBusHandlerResult ++filter_func (DBusConnection *connection, DBusMessage *message, void *user_data) ++{ ++ GWeatherApplet *gw_applet = user_data; ++ guint32 state = NM_DEVICE_STATE_UNKNOWN; ++ ++ if (dbus_message_is_signal (message, ++ NM_DBUS_INTERFACE_DEVICE, "StateChanged")) { ++ dbus_message_get_args (message, NULL, ++ DBUS_TYPE_UINT32, &state, ++ DBUS_TYPE_INVALID); ++ if (state == NM_DEVICE_STATE_ACTIVATED) { ++ gweather_update (gw_applet); ++ } ++ ++ return DBUS_HANDLER_RESULT_HANDLED; ++ } ++ ++ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; ++} ++ ++static void ++setup_network_monitor (GWeatherApplet *gw_applet) ++{ ++ GError *error; ++ static DBusGConnection *bus = NULL; ++ DBusConnection *dbus; ++ ++ if (bus == NULL) { ++ error = NULL; ++ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); ++ if (bus == NULL) { ++ g_warning ("Couldn't connect to system bus: %s", ++ error->message); ++ g_error_free (error); ++ ++ return; ++ } ++ ++ dbus = dbus_g_connection_get_connection (bus); ++ dbus_connection_add_filter (dbus, filter_func, gw_applet, NULL); ++ dbus_bus_add_match (dbus, ++ "type='signal'," ++ "interface='" NM_DBUS_INTERFACE_DEVICE "'", ++ NULL); ++ } ++} ++ |