[netspeed/unstable] Handle changes in settings



commit 597ff638e35f4b40d31e760d2f22373f9a167009
Author: Jörgen Scheibengruber <mfcn gmx de>
Date:   Tue Jun 22 23:56:20 2010 +0300

    Handle changes in settings

 src/netspeed.c        |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 src/settings-dialog.c |    6 ------
 2 files changed, 47 insertions(+), 6 deletions(-)
---
diff --git a/src/netspeed.c b/src/netspeed.c
index d4a1ab1..f187b5e 100644
--- a/src/netspeed.c
+++ b/src/netspeed.c
@@ -932,6 +932,40 @@ netspeed_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
 }
 
 static void
+settings_display_sum_changed_cb (GObject *object,
+	GParamSpec *pspec,
+	gpointer    user_data)
+{
+	Netspeed *applet = NETSPEED (user_data);
+	applet_change_size_or_orient (PANEL_APPLET (applet), -1, NULL);
+	change_icons (applet);
+}
+
+static void
+settings_display_specific_icon_changed_cb (GObject *object,
+	GParamSpec *pspec,
+	gpointer    user_data)
+{
+	Netspeed *applet = NETSPEED (user_data);
+	change_icons (applet);
+}
+
+static void
+settings_device_changed_cb (GObject *object,
+	GParamSpec *pspec,
+	gpointer    user_data)
+{
+	Netspeed *applet = NETSPEED (user_data);
+	NetspeedPrivate *priv = applet->priv;
+	char *device;
+
+	g_object_get (object, "device", &device, NULL);
+	get_device_info (device, &priv->stuff->devinfo);
+	priv->stuff->device_has_changed = TRUE;
+	update_applet (applet);
+}
+
+static void
 netspeed_class_init (NetspeedClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -1104,6 +1138,19 @@ netspeed_factory (PanelApplet *applet, const gchar *iid, gpointer data)
 	get_device_info(device, &priv->stuff->devinfo);
 	g_free (device);
 
+	g_signal_connect (G_OBJECT (priv->settings),
+					"notify::display-sum",
+					G_CALLBACK (settings_display_sum_changed_cb),
+					applet);
+	g_signal_connect (G_OBJECT (priv->settings),
+					"notify::display-specific-icon",
+					G_CALLBACK (settings_display_specific_icon_changed_cb),
+					applet);
+	g_signal_connect (G_OBJECT (priv->settings),
+					"notify::device",
+					G_CALLBACK (settings_device_changed_cb),
+					applet);
+
 	if (!priv->stuff->devinfo.name) {
 		GList *ptr, *devices = get_available_devices();
 		ptr = devices;
diff --git a/src/settings-dialog.c b/src/settings-dialog.c
index a5f6ee1..930934d 100644
--- a/src/settings-dialog.c
+++ b/src/settings-dialog.c
@@ -83,9 +83,6 @@ device_change_cb(GtkComboBox *combo, gpointer user_data)
 						device,
 						NULL);
 	}
-
-	//applet->device_has_changed = TRUE;
-	//update_applet(applet);
 }
 
 
@@ -100,8 +97,6 @@ showsum_change_cb(GtkToggleButton *togglebutton, gpointer user_data)
 			"display-sum",
 			gtk_toggle_button_get_active (togglebutton),
 			NULL);
-	//applet_change_size_or_orient(applet->applet, -1, (gpointer)applet);
-	//change_icons(applet);
 }
 
 /* Called when the showbits checkbutton is toggled...
@@ -128,7 +123,6 @@ changeicon_change_cb(GtkToggleButton *togglebutton, gpointer user_data)
 			"display-specific-icon",
 			gtk_toggle_button_get_active (togglebutton),
 			NULL);
-	//change_icons(applet);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]