Fix menu position when new AP's are lost/found.
authorRoy Marples <roy@marples.name>
Thu, 2 Oct 2014 16:27:43 +0000 (16:27 +0000)
committerRoy Marples <roy@marples.name>
Thu, 2 Oct 2014 16:27:43 +0000 (16:27 +0000)
Pad psk key dialog a little more.

src/dhcpcd-gtk/menu.c
src/dhcpcd-gtk/wpa.c

index df7213ee18831dd9c356c0e0bd4609eceff505b7..ac452825a717559739cc3d3a93029c6d3df9c74f 100644 (file)
@@ -177,12 +177,14 @@ create_menu(GtkWidget *m, WI_SCAN *wis, DHCPCD_WI_SCAN *scan)
            g_strcmp0(scan->ssid, wis->interface->ssid) == 0)
                gtk_check_menu_item_set_active(
                    GTK_CHECK_MENU_ITEM(wim->menu), true);
+
        if (scan->flags[0] == '\0')
                icon = "network-wireless";
        else
                icon = "network-wireless-encrypted";
        wim->icon = gtk_image_new_from_icon_name(icon,
            GTK_ICON_SIZE_MENU);
+
        gtk_box_pack_start(GTK_BOX(box), wim->icon, FALSE, FALSE, 0);
 
        wim->bar = gtk_progress_bar_new();
@@ -212,7 +214,8 @@ menu_update_scans(WI_SCAN *wi, DHCPCD_WI_SCAN *scans)
 {
        WI_MENU *wim, *win;
        DHCPCD_WI_SCAN *s;
-       bool found, added;
+       bool found;
+       int adjust = 0;
 
        if (menu == NULL) {
                dhcpcd_wi_scans_free(wi->scans);
@@ -232,14 +235,13 @@ menu_update_scans(WI_SCAN *wi, DHCPCD_WI_SCAN *scans)
                }
                if (!found) {
                        TAILQ_REMOVE(&wi->menus, wim, next);
-                       g_message("removed %s", wim->scan->ssid);
                        gtk_widget_destroy(wim->menu);
                        g_free(wim->scan);
                        g_free(wim);
+                       adjust--;
                }
        }
 
-       added = false;
        for (s = scans; s; s = s->next) {
                found = false;
                TAILQ_FOREACH(wim, &wi->menus, next) {
@@ -251,24 +253,18 @@ menu_update_scans(WI_SCAN *wi, DHCPCD_WI_SCAN *scans)
                        }
                }
                if (!found) {
-                       added = true;
                        wim = create_menu(wi->ifmenu, wi, s);
                        TAILQ_INSERT_TAIL(&wi->menus, wim, next);
                        gtk_widget_show_all(wim->menu);
-                       g_message("added %s", wim->scan->ssid);
+                       adjust++;
                }
        }
 
        dhcpcd_wi_scans_free(wi->scans);
        wi->scans = scans;
 
-       if (added && gtk_widget_get_visible(wi->ifmenu)) {
-//             gtk_widget_hide(wi->ifmenu);
-//             gtk_menu_popup(GTK_MENU(wi->ifmenu), NULL, NULL,
-//                 gtk_status_icon_position_menu, sicon,
-//                 1, gtk_get_current_event_time());
-//             gtk_widget_show(wi->ifmenu);
-       }
+       if (adjust && gtk_widget_get_visible(wi->ifmenu))
+               gtk_menu_reposition(GTK_MENU(wi->ifmenu));
 }
 
 
index 3e220207a9cece5229ec18efe693b7d1ec2d56c9..9d49d7564661194ff8bf65b65e7d819e3098dee5 100644 (file)
@@ -93,14 +93,14 @@ wpa_configure(DHCPCD_WPA *wpa, DHCPCD_WI_SCAN *scan)
            GTK_RESPONSE_ACCEPT);
        vbox = gtk_dialog_get_content_area(GTK_DIALOG(wpa_dialog));
 
-       hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
+       hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
        label = gtk_label_new(_("Pre Shared Key:"));
-       gtk_box_pack_start(GTK_BOX(hbox), label, false, false, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), label, false, false, 5);
        psk = gtk_entry_new();
        gtk_entry_set_max_length(GTK_ENTRY(psk), 130);
        g_signal_connect(G_OBJECT(psk), "activate",
            G_CALLBACK(onEnter), wpa_dialog);
-       gtk_box_pack_start(GTK_BOX(hbox), psk, true, true, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), psk, true, true, 5);
        gtk_container_add(GTK_CONTAINER(vbox), hbox);
 
        gtk_widget_show_all(wpa_dialog);