[network-manager-applet] editor: set active combo box item in ce_page_setup_mac_combo()



commit f9c208d4856a6f9ea9b3ae531eeb86ac8ea2bbb4
Author: Jiří Klimeš <jklimes redhat com>
Date:   Tue Mar 26 17:56:50 2013 +0100

    editor: set active combo box item in ce_page_setup_mac_combo()
    
    Failing to do so makes gtk_combo_box_get_active() keep returning -1, even if
    the combo box entry text was set (until the user manually selects an item).

 src/connection-editor/ce-page.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 69102fd..4846bf3 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -157,6 +157,7 @@ ce_page_setup_mac_combo (CEPage *self, GtkComboBox *combo,
                          const char *current_mac, char **mac_list)
 {
        char **iter, *active_mac = NULL;
+       int i, active_idx = -1;
        int current_mac_len;
        GtkWidget *entry;
 
@@ -165,15 +166,20 @@ ce_page_setup_mac_combo (CEPage *self, GtkComboBox *combo,
        else
                current_mac_len = -1;
 
-       for (iter = mac_list; iter && *iter; iter++) {
+       for (iter = mac_list, i = 0; iter && *iter; iter++, i++) {
                gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), *iter);
                if (   current_mac
                    && g_ascii_strncasecmp (*iter, current_mac, current_mac_len) == 0
-                   && ((*iter)[current_mac_len] == '\0' || (*iter)[current_mac_len] == ' '))
+                   && ((*iter)[current_mac_len] == '\0' || (*iter)[current_mac_len] == ' ')) {
                        active_mac = *iter;
+                       active_idx = i;
+               }
        }
 
        if (current_mac) {
+               /* set active item */
+               gtk_combo_box_set_active (combo, active_idx);
+               
                if (!active_mac)
                        gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (combo), current_mac);
 


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