Redraw the menu when we get or lose an AP from the scan results.
authorRoy Marples <roy@marples.name>
Fri, 7 Nov 2014 11:31:57 +0000 (11:31 +0000)
committerRoy Marples <roy@marples.name>
Fri, 7 Nov 2014 11:31:57 +0000 (11:31 +0000)
Another fix to [6b883fb943] based on a suggestion from Simon Long.

src/dhcpcd-gtk/menu.c

index 58049ebdc96b2cd1412a4a6f68c78dacb3ade122..4cfbcb082f4d9819dd4b1b15ebb680ed69a4b520 100644 (file)
@@ -214,8 +214,7 @@ menu_update_scans(WI_SCAN *wi, DHCPCD_WI_SCAN *scans)
 {
        WI_MENU *wim, *win;
        DHCPCD_WI_SCAN *s;
 {
        WI_MENU *wim, *win;
        DHCPCD_WI_SCAN *s;
-       bool found;
-       int adjust = 0;
+       bool found, update;
 
        if (menu == NULL) {
                dhcpcd_wi_scans_free(wi->scans);
 
        if (menu == NULL) {
                dhcpcd_wi_scans_free(wi->scans);
@@ -223,6 +222,7 @@ menu_update_scans(WI_SCAN *wi, DHCPCD_WI_SCAN *scans)
                return;
        }
 
                return;
        }
 
+       update = false;
        TAILQ_FOREACH_SAFE(wim, &wi->menus, next, win) {
                found = false;
                for (s = scans; s; s = s->next) {
        TAILQ_FOREACH_SAFE(wim, &wi->menus, next, win) {
                found = false;
                for (s = scans; s; s = s->next) {
@@ -237,7 +237,7 @@ menu_update_scans(WI_SCAN *wi, DHCPCD_WI_SCAN *scans)
                        TAILQ_REMOVE(&wi->menus, wim, next);
                        gtk_widget_destroy(wim->menu);
                        g_free(wim);
                        TAILQ_REMOVE(&wi->menus, wim, next);
                        gtk_widget_destroy(wim->menu);
                        g_free(wim);
-                       adjust--;
+                       update = true;
                }
        }
 
                }
        }
 
@@ -255,14 +255,14 @@ menu_update_scans(WI_SCAN *wi, DHCPCD_WI_SCAN *scans)
                        wim = create_menu(wi->ifmenu, wi, s);
                        TAILQ_INSERT_TAIL(&wi->menus, wim, next);
                        gtk_widget_show_all(wim->menu);
                        wim = create_menu(wi->ifmenu, wi, s);
                        TAILQ_INSERT_TAIL(&wi->menus, wim, next);
                        gtk_widget_show_all(wim->menu);
-                       adjust++;
+                       update = true;
                }
        }
 
        dhcpcd_wi_scans_free(wi->scans);
        wi->scans = scans;
 
                }
        }
 
        dhcpcd_wi_scans_free(wi->scans);
        wi->scans = scans;
 
-       if (adjust && gtk_widget_get_visible(wi->ifmenu))
+       if (update && gtk_widget_get_visible(wi->ifmenu))
                gtk_menu_reposition(GTK_MENU(wi->ifmenu));
 }
 
                gtk_menu_reposition(GTK_MENU(wi->ifmenu));
 }