dhcpcd-qt now has the same document-save and new icons as dhcpcd-gtk.
authorRoy Marples <roy@marples.name>
Wed, 19 Nov 2014 08:22:47 +0000 (08:22 +0000)
committerRoy Marples <roy@marples.name>
Wed, 19 Nov 2014 08:22:47 +0000 (08:22 +0000)
src/dhcpcd-gtk/prefs.c
src/dhcpcd-qt/dhcpcd-preferences.cpp
src/libdhcpcd/config.c
src/libdhcpcd/dhcpcd.h

index 0b7e55e24b2ed1023a8a079ef145ca7d384056dd..855b518c2d053c434baec79e756ee3f36920136f 100644 (file)
@@ -306,7 +306,7 @@ blocks_on_change(GtkWidget *widget, gpointer data)
        }
        gtk_widget_set_sensitive(names, n);
        g_slist_free(new_names);
-       g_strfreev(list);
+       dhcpcd_config_blocks_free(list);
 }
 
 static void
index 12f0020caa325108beced19cc2eeb9bdc54caf63..86708c41a22e53c379386a17a34e55561631aee7 100644 (file)
@@ -171,6 +171,8 @@ void DhcpcdPreferences::closeEvent(QCloseEvent *e)
 
 void DhcpcdPreferences::listBlocks(const QString &txt)
 {
+       char **list, **lp;
+       QIcon icon;
 
        /* clear and then disconnect so we trigger a save */
        blocks->clear();
@@ -179,6 +181,9 @@ void DhcpcdPreferences::listBlocks(const QString &txt)
        free(eWhat);
        eWhat = strdup(txt.toLower().toAscii());
 
+       list = dhcpcd_config_blocks(parent->getConnection(),
+           txt.toLower().toAscii());
+
        if (txt == "interface") {
                DHCPCD_IF *i;
 
@@ -187,9 +192,13 @@ void DhcpcdPreferences::listBlocks(const QString &txt)
                    i; i = i->next)
                {
                        if (strcmp(i->type, "link") == 0) {
-                               QIcon icon = DhcpcdQt::getIcon("devices",
-                                   i->wireless ?
-                                   "network-wireless" : "network-wired");
+                               for (lp = list; lp && *lp; lp++) {
+                                       if (strcmp(i->ifname, *lp) == 0)
+                                               break;
+                               }
+                               icon = DhcpcdQt::getIcon("devices",
+                                   lp && *lp ?
+                                   "document-save" : "document-new");
                                blocks->addItem(icon, i->ifname);
                        }
                }
@@ -202,17 +211,20 @@ void DhcpcdPreferences::listBlocks(const QString &txt)
                        DhcpcdWi *wi = wis->at(i);
 
                        for (scan = wi->getScans(); scan; scan = scan->next) {
-                               QIcon icon;
-
-                               icon = DhcpcdQt::getIcon(
-                                   scan->flags[0] == '\0' ?"devices" :"status",
-                                   scan->flags[0] == '\0' ?"network-wireless" :
-                                       "network-wireless-encrypted");
+                               for (lp = list; lp && *lp; lp++) {
+                                       if (strcmp(scan->ssid, *lp) == 0)
+                                               break;
+                               }
+                               icon = DhcpcdQt::getIcon("devices",
+                                   lp && *lp ?
+                                   "document-save" : "document-new");
                                blocks->addItem(icon, scan->ssid);
                        }
                }
        }
 
+       dhcpcd_config_blocks_free(list);
+
        /* Now make the 1st item unselectable and reconnect */
        qobject_cast<QStandardItemModel *>
            (blocks->model())->item(0)->setEnabled(false);
index 92aad29f6225faac19f5fcb918414b3569d15f91..0cea6c8dec4dfc5f2b0c9db4d23338f415d6c116 100644 (file)
@@ -429,3 +429,16 @@ dhcpcd_config_blocks(DHCPCD_CONNECTION *con, const char *block)
        config(con, ACT_LIST, block, NULL, NULL, &blocks);
        return blocks;
 }
+
+void
+dhcpcd_config_blocks_free(char **blocks)
+{
+       char **b;
+
+       assert(blocks);
+       if (blocks) {
+               for (b = blocks; *b; b++)
+                       free(b);
+               free(blocks);
+       }
+}
index fc4bcc9c9707ff56253eb8e585782190811d7701..8b898e5eeb26d95dfb340187e0973a3fffea9942 100644 (file)
@@ -254,6 +254,7 @@ bool dhcpcd_wpa_network_set(DHCPCD_WPA *, int, const char *, const char *);
 int dhcpcd_wpa_configure_psk(DHCPCD_WPA *w, DHCPCD_WI_SCAN *s, const char *p);
 
 char ** dhcpcd_config_blocks(DHCPCD_CONNECTION *, const char *);
+void dhcpcd_config_blocks_free(char **);
 DHCPCD_OPTION *dhcpcd_config_read(DHCPCD_CONNECTION *,
     const char *, const char *);
 void dhcpcd_config_free(DHCPCD_OPTION *);