diff options
author | Ross Burton <ross@linux.intel.com> | 2010-04-19 15:27:59 +0100 |
---|---|---|
committer | Ross Burton <ross@linux.intel.com> | 2010-04-19 15:28:38 +0100 |
commit | efbb0fb19b9253ce7b3e083b19181593ca18e10c (patch) | |
tree | a94838475f5d8522d33ed03871f165c127c821d3 /moblin | |
parent | 9719157d7d46a7401e30b8a8dbfca58a725be5c6 (diff) | |
download | gnome-bluetooth-efbb0fb19b9253ce7b3e083b19181593ca18e10c.tar.gz |
meego: clean up PIN selection logic (#322)
Diffstat (limited to 'moblin')
-rw-r--r-- | moblin/moblin-panel.c | 73 | ||||
-rw-r--r-- | moblin/pin.ui | 21 |
2 files changed, 44 insertions, 50 deletions
diff --git a/moblin/moblin-panel.c b/moblin/moblin-panel.c index abc88c01..94d03fd2 100644 --- a/moblin/moblin-panel.c +++ b/moblin/moblin-panel.c @@ -434,42 +434,27 @@ static void set_user_pincode (GtkWidget *button, gpointer user_data) { MoblinPanelPrivate *priv = MOBLIN_PANEL_GET_PRIVATE (user_data); - GSList *list, *l; + GtkEntry *entry; + const char *pin; - list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - for (l = list; l ; l = l->next) { - GtkEntry *entry; - GtkWidget *radio; - const char *pin; - - if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) - continue; - - /* Is it radio_fixed that changed? */ - radio = g_object_get_data (G_OBJECT (button), "button"); - if (radio != NULL) { - set_user_pincode (radio, user_data); - return; - } + if (! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) + return; - pin = g_object_get_data (G_OBJECT (button), "pin"); - entry = g_object_get_data (G_OBJECT (button), "entry"); - - if (entry != NULL) { - g_free (priv->user_pincode); - priv->user_pincode = g_strdup (gtk_entry_get_text(entry)); - gtk_dialog_set_response_sensitive (GTK_DIALOG (priv->pin_dialog), - GTK_RESPONSE_ACCEPT, - gtk_entry_get_text_length (entry) >= 1); - } else if (pin != NULL) { - g_free (priv->user_pincode); - if (*pin == '\0') - priv->user_pincode = NULL; - else - priv->user_pincode = g_strdup (pin); - } + pin = g_object_get_data (G_OBJECT (button), "pin"); + entry = g_object_get_data (G_OBJECT (button), "entry"); - break; + if (entry != NULL) { + g_free (priv->user_pincode); + priv->user_pincode = g_strdup (gtk_entry_get_text(entry)); + gtk_dialog_set_response_sensitive (GTK_DIALOG (priv->pin_dialog), + GTK_RESPONSE_ACCEPT, + gtk_entry_get_text_length (entry) >= 1); + } else if (pin != NULL) { + g_free (priv->user_pincode); + if (*pin == '\0') + priv->user_pincode = NULL; + else + priv->user_pincode = g_strdup (pin); } } @@ -515,31 +500,27 @@ pin_options_button_clicked_cb (GtkButton *button, g_object_set_data (G_OBJECT (priv->radio_1111), "pin", "1111"); g_object_set_data (G_OBJECT (priv->radio_1234), "pin", "1234"); g_object_set_data (G_OBJECT (priv->radio_custom), "entry", priv->entry_custom); - - gtk_dialog_add_button (GTK_DIALOG (priv->pin_dialog), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); } - oldpin = priv->user_pincode; - priv->user_pincode = NULL; + oldpin = g_strdup (priv->user_pincode); gtk_window_present (GTK_WINDOW (priv->pin_dialog)); - if (oldpin == NULL) + if (priv->user_pincode == NULL) { radio = priv->radio_auto; - else if (g_str_equal (oldpin, "0000")) + } else if (g_str_equal (priv->user_pincode, "0000")) { radio = priv->radio_0000; - else if (g_str_equal (oldpin, "1111")) + } else if (g_str_equal (priv->user_pincode, "1111")) { radio = priv->radio_1111; - else if (g_str_equal (oldpin, "1234")) + } else if (g_str_equal (priv->user_pincode, "1234")) { radio = priv->radio_1234; - else + } else { radio = priv->radio_custom; - + gtk_entry_set_text (GTK_ENTRY (priv->entry_custom), priv->user_pincode); + } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - if (radio == priv->radio_custom) - gtk_entry_set_text (GTK_ENTRY (priv->entry_custom), oldpin); - if (gtk_dialog_run (GTK_DIALOG (priv->pin_dialog)) != GTK_RESPONSE_ACCEPT) { + if (gtk_dialog_run (GTK_DIALOG (priv->pin_dialog)) != GTK_RESPONSE_OK) { g_free (priv->user_pincode); priv->user_pincode = oldpin; } else { diff --git a/moblin/pin.ui b/moblin/pin.ui index 8b7e1d6b..dd304c55 100644 --- a/moblin/pin.ui +++ b/moblin/pin.ui @@ -1,6 +1,7 @@ <?xml version="1.0"?> <interface> <requires lib="gtk+" version="2.16"/> + <!-- interface-naming-policy toplevel-contextual --> <object class="GtkDialog" id="pin_dialog"> <property name="border_width">5</property> <property name="title" translatable="yes">PIN Options</property> @@ -119,8 +120,8 @@ <property name="can_focus">True</property> <property name="max_length">20</property> <property name="width_chars">20</property> - <signal name="key-press-event" handler="entry_custom_event"/> <signal name="changed" handler="entry_custom_changed"/> + <signal name="key_press_event" handler="entry_custom_event"/> </object> <packing> <property name="position">1</property> @@ -144,11 +145,22 @@ <property name="visible">True</property> <property name="layout_style">end</property> <child> - <placeholder/> + <object class="GtkButton" id="button2"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkButton" id="button1"> - <property name="label">gtk-close</property> + <property name="label">gtk-ok</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -170,7 +182,8 @@ </object> </child> <action-widgets> - <action-widget response="-3">button1</action-widget> + <action-widget response="-6">button2</action-widget> + <action-widget response="-5">button1</action-widget> </action-widgets> </object> </interface> |