[phonemgr] ui: no need to explicitely set inactive radio buttons



commit cb30a88d2cf7d370cee907aa4ef7688b9a907b70
Author: Daniele Forsi <dforsi src gnome org>
Date:   Thu May 3 09:57:56 2012 +0200

    ui: no need to explicitely set inactive radio buttons
    
    Since they are in the same group, setting one radio button to active
    makes inactive the one set at design time in glade; the "toggled"
    callback is called for both and the UI is kept in sync with the prefs.

 src/ui.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/ui.c b/src/ui.c
index 5fff574..d37a7b6 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -201,24 +201,36 @@ s_connect (MyApp *app, const gchar *wname, const gchar *dependentname, gint port
 				 (gpointer)app);
 }
 
-#define S_ACTIVE(x, y) \
-	w = GTK_WIDGET (gtk_builder_get_object (app->ui, (x))); \
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), ctype==y);
-
 static void
 populate_prefs (MyApp *app)
 {
 	GtkWidget *w;
+	char *widgetname;
 	int ctype;
 
 	ctype = gconf_client_get_int (app->client,
 				      CONFBASE"/connection_type", NULL);
-
-	S_ACTIVE("btdevice", CONNECTION_BLUETOOTH);
-	S_ACTIVE("serialport1", CONNECTION_SERIAL1);
-	S_ACTIVE("serialport2", CONNECTION_SERIAL2);
-	S_ACTIVE("irdaport", CONNECTION_IRCOMM);
-	S_ACTIVE("otherport", CONNECTION_OTHER);
+	switch (ctype) {
+	case CONNECTION_BLUETOOTH:
+		widgetname = "btdevice";
+		break;
+	case CONNECTION_SERIAL1:
+		widgetname = "serialport1";
+		break;
+	case CONNECTION_SERIAL2:
+		widgetname = "serialport2";
+		break;
+	case CONNECTION_IRCOMM:
+		widgetname = "irdaport";
+		break;
+	case CONNECTION_OTHER:
+		/* fall through */
+	default:
+		widgetname = "otherport";
+		break;
+	}
+	w = GTK_WIDGET (gtk_builder_get_object (app->ui, widgetname));
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);
 }
 
 static void



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