We now have a working preference screen and can rebind the interface!
authorRoy Marples <roy@marples.name>
Thu, 5 Mar 2009 16:38:08 +0000 (16:38 +0000)
committerRoy Marples <roy@marples.name>
Thu, 5 Mar 2009 16:38:08 +0000 (16:38 +0000)
Stop using glibisms such as gboolean, gint, etc.

dhcpcd-config.c
dhcpcd-config.h
main.c
prefs.c
wpa.c
wpa.h

index 77122d36f2174eaff798f2effe9ef626fc74d875..19934fefbeaabf24654c1a9a3c592a1ec151cb6a 100644 (file)
@@ -42,7 +42,7 @@ free_config(GPtrArray **config)
 }      
 
 GPtrArray *
-read_config(const char *block, const char *name)
+load_config(const char *block, const char *name)
 {
        GType otype;
        GError *error;
@@ -63,8 +63,8 @@ read_config(const char *block, const char *name)
        return config;
 }
 
-int
-get_config(GPtrArray *config, int idx, const char *opt, const char **value)
+static int
+_get_config(GPtrArray *config, int idx, const char *opt, const char **value)
 {
        GValueArray *c;
        GValue *val;
@@ -94,13 +94,20 @@ get_config(GPtrArray *config, int idx, const char *opt, const char **value)
 }
 
 int
-get_static_config(GPtrArray *config, const char *var, const char **value)
+get_config(GPtrArray *config, const char *opt, const char **value)
+{
+
+       return _get_config(config, 0, opt, value);
+}
+
+int
+get_config_static(GPtrArray *config, const char *var, const char **value)
 {
        int idx;
        const char *val;
 
        idx = -1;
-       while ((idx = get_config(config, idx + 1, "static", &val)) != -1) {
+       while ((idx = _get_config(config, idx + 1, "static", &val)) != -1) {
                if (g_str_has_prefix(val, var)) {
                        if (value)
                                *value = val + strlen(var);
@@ -112,40 +119,8 @@ get_static_config(GPtrArray *config, const char *var, const char **value)
        return -1;
 }
 
-GPtrArray *
-save_config(const char *block, const char *name, GPtrArray *config)
-{
-       GError *error;
-       GType otype;
-       
-       error = NULL;
-       otype = dbus_g_type_get_struct("GValueArray",
-           G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
-       otype = dbus_g_type_get_collection("GPtrArray", otype);
-       if (!dbus_g_proxy_call(dbus, "SetConfig", &error,
-               G_TYPE_STRING, block,
-               G_TYPE_STRING, name,
-               otype, config,
-               G_TYPE_INVALID,
-               G_TYPE_INVALID))
-       {
-               g_critical("SetConfig: %s", error->message);
-               g_clear_error(&error);
-               return NULL;
-       }
-       return config;
-}
-
-GPtrArray *
-load_config(const char *block, const char *name, GPtrArray *array)
-{
-
-       free_config(&array);
-       return read_config(block, name);
-}
-
 void
-set_option(GPtrArray *array, bool sopt, const char *var, const char *val)
+set_option(GPtrArray *config, bool sopt, const char *var, const char *val)
 {
        int i;
        GValueArray *va;
@@ -153,12 +128,12 @@ set_option(GPtrArray *array, bool sopt, const char *var, const char *val)
        char *n;
 
        if (sopt)
-               i = get_static_config(array, var, NULL);
+               i = get_config_static(config, var, NULL);
        else
-               i = get_config(array, 0, var, NULL);
+               i = get_config(config, var, NULL);
        if (val == NULL) {
                if (i != -1) {
-                       va = g_ptr_array_remove_index(array, i);
+                       va = g_ptr_array_remove_index(config, i);
                        g_value_array_free(va);
                }
        } else {
@@ -166,22 +141,43 @@ set_option(GPtrArray *array, bool sopt, const char *var, const char *val)
                        n = g_strconcat(var, val, NULL);
                else
                        n = NULL;
+               memset(&nv, 0, sizeof(v));
+               g_value_init(&nv, G_TYPE_STRING);
                if (i == -1) {
                        va = g_value_array_new(2);
-                       memset(&nv, 0, sizeof(v));
-                       g_value_init(&nv, G_TYPE_STRING);
+                       g_ptr_array_add(config, va);
                        g_value_set_static_string(&nv, sopt ? "static" : var);
                        va = g_value_array_append(va, &nv);
-                       g_value_set_static_string(&nv, sopt ? n : val);
-                       va = g_value_array_append(va, &nv);
-                       g_ptr_array_add(array, va);
-               } else if (val != NULL) {
-                       va = g_ptr_array_index(array, i);
-                       v = g_value_array_get_nth(va, 1);
-                       g_value_unset(v);
-                       g_value_init(v, G_TYPE_STRING);
-                       g_value_set_static_string(v, sopt ? n : val);
+               } else {
+                       va = g_ptr_array_index(config, i);
+                       va = g_value_array_remove(va, 1);
                }
+               g_value_set_static_string(&nv, sopt ? n : val);
+               va = g_value_array_append(va, &nv);
                g_free(n);
        }
 }
+
+bool
+save_config(const char *block, const char *name, GPtrArray *config)
+{
+       GError *error;
+       GType otype;
+       
+       error = NULL;
+       otype = dbus_g_type_get_struct("GValueArray",
+           G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+       otype = dbus_g_type_get_collection("GPtrArray", otype);
+       if (!dbus_g_proxy_call(dbus, "SetConfig", &error,
+               G_TYPE_STRING, block,
+               G_TYPE_STRING, name,
+               otype, config,
+               G_TYPE_INVALID,
+               G_TYPE_INVALID))
+       {
+               g_critical("SetConfig: %s", error->message);
+               g_clear_error(&error);
+               return false;
+       }
+       return true;
+}
index 194137d1a36cabde54f33b5b896bfb2b41cfaae7..f0bc2934f9724a05277aeae4e36280332bdd17d6 100644 (file)
 #include <glib.h>
 
 void free_config(GPtrArray **);
-GPtrArray *read_config(const char *, const char *);
-int get_config(GPtrArray *, int, const char *, const char **);
-int get_static_config(GPtrArray *, const char *, const char **);
-GPtrArray *save_config(const char *, const char *, GPtrArray *);
-GPtrArray *load_config(const char *, const char *, GPtrArray *);
+GPtrArray *load_config(const char *, const char *);
+int get_config(GPtrArray *, const char *, const char **);
+int get_config_static(GPtrArray *, const char *, const char **);
 void set_option(GPtrArray *, bool, const char *, const char *);
+bool save_config(const char *, const char *, GPtrArray *);
 
 #endif
diff --git a/main.c b/main.c
index a1b9b906fc25d2c6178c4b1d261a14f158d4cbbc..3965699dfd9f8867c67877ce90e27d04e16ee8d9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -41,10 +41,10 @@ DBusGProxy *dbus = NULL;
 GSList *interfaces = NULL;
 
 static GtkStatusIcon *status_icon;
-static gint ani_timer;
+static int ani_timer;
 static int ani_counter;
-static gboolean online;
-static gboolean carrier;
+static bool online;
+static bool carrier;
 static char **interface_order;
 static NotifyNotification *nn;
 
@@ -55,6 +55,7 @@ const char *const up_reasons[] = {
        "REBOOT",
        "IPV4LL",
        "INFORM",
+       "STATIC",
        "TIMEOUT",
        NULL
 };
@@ -68,13 +69,13 @@ const char *const down_reasons[] = {
        NULL
 };
 
-static gboolean
+static bool
 ignore_if_msg(const struct if_msg *ifm)
 {
        if (g_strcmp0(ifm->reason, "STOP") == 0 ||
            g_strcmp0(ifm->reason, "RELEASE") == 0)
-               return TRUE;
-       return FALSE;
+               return true;
+       return false;
 }
 
 static struct if_msg *
@@ -226,15 +227,15 @@ make_if_msg(GHashTable *config)
        return ifm;
 }
 
-static gboolean
+static bool
 if_up(const struct if_msg *ifm)
 {
        const char *const *r;
 
        for (r = up_reasons; *r; r++)
                if (g_strcmp0(*r, ifm->reason) == 0)
-                       return TRUE;
-       return FALSE;
+                       return true;
+       return false;
 }
 
 static char *
@@ -243,10 +244,10 @@ print_if_msg(const struct if_msg *ifm)
        char *msg, *p;
        const char *reason = NULL;
        size_t len;
-       gboolean showip, showssid;
+       bool showip, showssid;
     
-       showip = TRUE;
-       showssid = FALSE;
+       showip = true;
+       showssid = false;
        if (if_up(ifm))
                reason = N_("Acquired address");
        else {
@@ -256,20 +257,20 @@ print_if_msg(const struct if_msg *ifm)
                        if (ifm->wireless) {
                                reason = N_("Asssociated with");
                                if (ifm->ssid != NULL)
-                                       showssid = TRUE;
+                                       showssid = true;
                        } else
                                reason = N_("Cable plugged in");
-                       showip = FALSE;
+                       showip = false;
                } else if (g_strcmp0(ifm->reason, "NOCARRIER") == 0) {
                        if (ifm->wireless) {
                                if (ifm->ssid != NULL || ifm->ip.s_addr != 0) {
                                        reason = N_("Disassociated from");
-                                       showssid = TRUE;
+                                       showssid = true;
                                } else
                                        reason = N_("Not associated");
                        } else
                                reason = N_("Cable unplugged");
-                       showip = FALSE;
+                       showip = false;
                }
        }
        if (reason == NULL)
@@ -296,7 +297,7 @@ print_if_msg(const struct if_msg *ifm)
        return msg;
 }
 
-static gint
+static int
 if_msg_comparer(gconstpointer a, gconstpointer b)
 {
        const struct if_msg *ifa, *ifb;
@@ -319,7 +320,7 @@ animate_carrier(_unused gpointer data)
        const char *icon;
        
        if (ani_timer == 0)
-               return FALSE;
+               return false;
 
        switch(ani_counter++) {
        case 0:
@@ -334,7 +335,7 @@ animate_carrier(_unused gpointer data)
                break;
        }
        gtk_status_icon_set_from_icon_name(status_icon, icon);
-       return TRUE;
+       return true;
 }
 
 static gboolean
@@ -343,12 +344,12 @@ animate_online(_unused gpointer data)
        const char *icon;
        
        if (ani_timer == 0)
-               return FALSE;
+               return false;
 
        if (ani_counter++ > 6) {
                ani_timer = 0;
                ani_counter = 0;
-               return FALSE;
+               return false;
        }
 
        if (ani_counter % 2 == 0)
@@ -356,25 +357,25 @@ animate_online(_unused gpointer data)
        else
                icon = "network-transmit-receive";
        gtk_status_icon_set_from_icon_name(status_icon, icon);
-       return TRUE;
+       return true;
 }
 
 static void
 update_online(void)
 {
-       gboolean ison, iscarrier;
+       bool ison, iscarrier;
        char *msg, *msgs, *tmp;
        const GSList *gl;
        const struct if_msg *ifm;
 
-       ison = iscarrier = FALSE;
+       ison = iscarrier = false;
        msgs = NULL;
        for (gl = interfaces; gl; gl = gl->next) {
                ifm = (const struct if_msg *)gl->data;
                if (if_up(ifm))
-                       ison = iscarrier = TRUE;
+                       ison = iscarrier = true;
                if (!iscarrier && g_strcmp0(ifm->reason, "CARRIER") == 0)
-                       iscarrier = TRUE;
+                       iscarrier = true;
                msg = print_if_msg(ifm);
                if (msgs) {
                        tmp = g_strconcat(msgs, "\n", msg, NULL);
@@ -445,7 +446,7 @@ static void
 dhcpcd_event(_unused DBusGProxy *proxy, GHashTable *config, _unused void *data)
 {
        struct if_msg *ifm, *ifp;
-       gboolean rem;
+       bool rem;
        GSList *gl;
        char *msg, *title;
        const char *act, *net;
@@ -466,7 +467,7 @@ dhcpcd_event(_unused DBusGProxy *proxy, GHashTable *config, _unused void *data)
                        free_if_msg(ifp);
                        if (rem)
                                interfaces =
-                                       g_slist_delete_link(interfaces, gl);
+                                   g_slist_delete_link(interfaces, gl);
                        else
                                gl->data = ifm;
                        break;
@@ -584,7 +585,7 @@ check_status(const char *status)
        GSList *gl;
        char *version;
        const char *msg;
-       gboolean refresh;
+       bool refresh;
        GError *error = NULL;
 
        g_message("Status changed to %s", status);
@@ -600,15 +601,15 @@ check_status(const char *status)
                notify(_("No network"), msg, GTK_STOCK_NETWORK);
        }
 
-       refresh = FALSE;
+       refresh = false;
        if (last == NULL) {
                if (g_strcmp0(status, "down") != 0)
-                       refresh = TRUE;
+                       refresh = true;
        } else {
                if (g_strcmp0(status, last) == 0)
                        return;
                if (g_strcmp0(last, "down") == 0)
-                       refresh = TRUE;
+                       refresh = true;
                g_free(last);
        }
        last = g_strdup(status);
@@ -692,12 +693,12 @@ main(int argc, char *argv[])
        status_icon = gtk_status_icon_new_from_icon_name("network-offline");
        if (status_icon == NULL)
                status_icon =
-                       gtk_status_icon_new_from_stock(GTK_STOCK_DISCONNECT);
+                   gtk_status_icon_new_from_stock(GTK_STOCK_DISCONNECT);
        //network_offline = gtk_status_icon_get_pixbuf(status_icon);
        
        gtk_status_icon_set_tooltip(status_icon,
            _("Connecting to dhcpcd ..."));
-       gtk_status_icon_set_visible(status_icon, TRUE);
+       gtk_status_icon_set_visible(status_icon, true);
 
        notify_init(PACKAGE);
 
@@ -724,7 +725,7 @@ main(int argc, char *argv[])
        g_free(version);
 
        gtk_status_icon_set_tooltip(status_icon, _("Triggering dhcpcd ..."));
-       online = FALSE;
+       online = false;
        menu_init(status_icon);
 
        if (!dbus_g_proxy_call(dbus, "GetStatus", &error,
diff --git a/prefs.c b/prefs.c
index 2e872d2c4ea19d5f1f27394cd31fe6857b01b8d7..35b0ecd3699b4ebd66276b2141139e729044c9df 100644 (file)
--- a/prefs.c
+++ b/prefs.c
 #include "dhcpcd-gtk.h"
 #include "prefs.h"
 
-static GtkWidget *dialog, *blocks, *names, *controls;
+static GtkWidget *dialog, *blocks, *names, *controls, *clear, *rebind;
 static GtkWidget *autoconf, *address, *router, *dns_servers, *dns_search;
-static GtkWidget *ntp_servers;
 static GPtrArray *config;
 static char *block, *name;
-static bool ignore_change;
 
 static void
 show_config(GPtrArray *array)
@@ -43,24 +41,20 @@ show_config(GPtrArray *array)
        const char *val;
        bool autocnf;
 
-       ignore_change = TRUE;
-       if (get_static_config(array, "ip_address=", &val) != -1)
+       if (get_config_static(array, "ip_address=", &val) != -1)
                autocnf = false;
        else {
-               get_config(array, 0, "inform", &val);
+               get_config(array, "inform", &val);
                autocnf = true;
        }
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoconf), autocnf);
        gtk_entry_set_text(GTK_ENTRY(address), val ? val : "");
-       get_static_config(array, "routers=", &val);
+       get_config_static(array, "routers=", &val);
        gtk_entry_set_text(GTK_ENTRY(router), val ? val : "");
-       get_static_config(array, "domain_name_servers=", &val);
+       get_config_static(array, "domain_name_servers=", &val);
        gtk_entry_set_text(GTK_ENTRY(dns_servers), val ? val : "");
-       get_static_config(array, "domain_name_search=", &val);
+       get_config_static(array, "domain_search=", &val);
        gtk_entry_set_text(GTK_ENTRY(dns_search), val ? val : "");
-       get_static_config(array, "ntp_servers=", &val);
-       gtk_entry_set_text(GTK_ENTRY(ntp_servers), val ? val : "");
-       ignore_change = FALSE;
 }
 
 static char *
@@ -107,12 +101,7 @@ make_config(GPtrArray *array)
        val = gtk_entry_get_text(GTK_ENTRY(dns_search));
        if (a && *val == '\0')
                val = NULL;
-       set_option(array, true, "domain_name_search=", val);
-       
-       val = gtk_entry_get_text(GTK_ENTRY(ntp_servers));
-       if (a && *val == '\0')
-               val = NULL;
-       set_option(array, true, "ntp_servers=", val);
+       set_option(array, true, "domain_search=", val);
 }
 
 static void
@@ -194,6 +183,8 @@ blocks_on_change(GtkWidget *widget)
        if (name) {
                make_config(config);
                save_config(block, name, config);
+               free_config(&config);
+               show_config(config);
                g_free(block);
                g_free(name);
                name = NULL;
@@ -249,7 +240,6 @@ blocks_on_change(GtkWidget *widget)
                n++;
        }
        gtk_widget_set_sensitive(names, n);
-       gtk_widget_set_sensitive(controls, FALSE);
        g_slist_free(new_names);
        g_strfreev(list);
 }
@@ -263,10 +253,13 @@ names_on_change(void)
                save_config(block, name, config);
                g_free(name);
        }
-       gtk_widget_set_sensitive(controls, TRUE);
        name = combo_active_text(names);
-       config = load_config(block, name, config);
+       free_config(&config);
+       config = load_config(block, name);
        show_config(config);
+       gtk_widget_set_sensitive(controls, name ? true : false);
+       gtk_widget_set_sensitive(clear, name ? true : false);
+       gtk_widget_set_sensitive(rebind, name ? true : false);
 }
 
 static bool
@@ -343,9 +336,52 @@ on_clear(void)
 }
 
 static void
+rebind_interface(const char *iface)
+{
+       GError *error;
+       
+       error = NULL;
+       if (!dbus_g_proxy_call(dbus, "Rebind", &error,
+               G_TYPE_STRING, iface, G_TYPE_INVALID, G_TYPE_INVALID))
+       {
+               g_critical("Rebind: %s: %s", iface, error->message);
+               g_clear_error(&error);
+       }
+}
+
+static void
+on_rebind(void)
+{
+       GSList *l;
+       const struct if_msg *ifm;
+
+       make_config(config);
+       if (save_config(block, name, config)) {
+               set_name_active_icon("document-save");
+               show_config(config);
+               if (g_strcmp0(block, "interface") == 0)
+                       rebind_interface(name);
+               else {
+                       for (l = interfaces; l; l = l->next) {
+                               ifm = (const struct if_msg *)l->data;
+                               if (g_strcmp0(ifm->ssid, name) == 0)
+                                       rebind_interface(ifm->ifname);
+                       }
+               }
+       }
+}
+
+static void
 on_destroy(void)
 {
        
+       if (name != NULL) {
+               make_config(config);
+               save_config(block, name, config);
+               g_free(block);
+               g_free(name);
+               block = name = NULL;
+       }
        free_config(&config);
        dialog = NULL;
 }
@@ -355,10 +391,6 @@ dhcpcd_prefs_close(void)
 {
        
        if (dialog != NULL) {
-               if (name != NULL) {
-                       make_config(config);
-                       save_config(block, name, config);
-               }
                gtk_widget_destroy(dialog);
                dialog = NULL;
        }
@@ -384,20 +416,20 @@ dhcpcd_prefs_show(void)
        g_signal_connect(G_OBJECT(dialog), "destroy", on_destroy, NULL);
 
        gtk_window_set_title(GTK_WINDOW(dialog), _("dhcpcd preferences"));
-       gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+       gtk_window_set_resizable(GTK_WINDOW(dialog), false);
        gtk_window_set_icon_name(GTK_WINDOW(dialog), "config-users");
        gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
        gtk_window_set_type_hint(GTK_WINDOW(dialog),
-                                GDK_WINDOW_TYPE_HINT_DIALOG);
+           GDK_WINDOW_TYPE_HINT_DIALOG);
 
-       dialog_vbox = gtk_vbox_new(FALSE, 10);
+       dialog_vbox = gtk_vbox_new(false, 10);
        gtk_container_set_border_width(GTK_CONTAINER(dialog), 10);
        gtk_container_add(GTK_CONTAINER(dialog), dialog_vbox);
 
-       hbox = gtk_hbox_new(FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(dialog_vbox), hbox, FALSE, FALSE, 3);
+       hbox = gtk_hbox_new(false, 0);
+       gtk_box_pack_start(GTK_BOX(dialog_vbox), hbox, false, false, 3);
        w = gtk_label_new("Configure:");
-       gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 3);
+       gtk_box_pack_start(GTK_BOX(hbox), w, false, false, 3);
        store = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
        it = gtk_icon_theme_get_default();
        error = NULL;
@@ -413,42 +445,43 @@ dhcpcd_prefs_show(void)
        g_object_unref(pb);
        blocks = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
        rend = gtk_cell_renderer_pixbuf_new();
-       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(blocks), rend, FALSE);
+       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(blocks), rend, false);
        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(blocks),
            rend, "pixbuf", 0);
        rend = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(blocks), rend, TRUE);
+       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(blocks), rend, true);
        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(blocks),
            rend, "text", 1);
        gtk_combo_box_set_active(GTK_COMBO_BOX(blocks), 0);
-       gtk_box_pack_start(GTK_BOX(hbox), blocks, FALSE, FALSE, 3);
+       gtk_box_pack_start(GTK_BOX(hbox), blocks, false, false, 3);
        store = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
        names = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
        rend = gtk_cell_renderer_pixbuf_new();
-       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(names), rend, FALSE);
+       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(names), rend, false);
        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(names),
            rend, "pixbuf", 0);
        rend = gtk_cell_renderer_text_new();
-       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(names), rend, TRUE);
+       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(names), rend, true);
        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(names), rend, "text", 1);
-       gtk_widget_set_sensitive(names, FALSE);
-       gtk_box_pack_start(GTK_BOX(hbox), names, FALSE, FALSE, 3);
+       gtk_widget_set_sensitive(names, false);
+       gtk_box_pack_start(GTK_BOX(hbox), names, false, false, 3);
        g_signal_connect(G_OBJECT(blocks), "changed",
            G_CALLBACK(blocks_on_change), NULL);
        g_signal_connect(G_OBJECT(names), "changed",
            G_CALLBACK(names_on_change), NULL);
        
        w = gtk_hseparator_new();
-       gtk_box_pack_start(GTK_BOX(dialog_vbox), w, TRUE, FALSE, 3);
-       controls = gtk_vbox_new(FALSE, 10);
-       gtk_box_pack_start(GTK_BOX(dialog_vbox), controls, TRUE, TRUE, 0);
-       vbox = gtk_vbox_new(FALSE, 3);
-       gtk_box_pack_start(GTK_BOX(controls), vbox, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(dialog_vbox), w, true, false, 3);
+       controls = gtk_vbox_new(false, 10);
+       gtk_widget_set_sensitive(controls, false);
+       gtk_box_pack_start(GTK_BOX(dialog_vbox), controls, true, true, 0);
+       vbox = gtk_vbox_new(false, 3);
+       gtk_box_pack_start(GTK_BOX(controls), vbox, false, false, 0);
        autoconf = gtk_check_button_new_with_label(
                _("Automatically configure empty options"));
-       gtk_box_pack_start(GTK_BOX(vbox), autoconf, FALSE, FALSE, 3);
-       table = gtk_table_new(6, 2, FALSE);
-       gtk_box_pack_start(GTK_BOX(controls), table, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox), autoconf, false, false, 3);
+       table = gtk_table_new(6, 2, false);
+       gtk_box_pack_start(GTK_BOX(controls), table, false, false, 0);
 
 #define attach_label(a, b, c, d, e)                                          \
        do {                                                                  \
@@ -459,7 +492,7 @@ dhcpcd_prefs_show(void)
 #define attach_entry(a, b, c, d, e)                                          \
        gtk_table_attach(GTK_TABLE(table), a, b, c, d, e,                     \
            GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 3, 3); \
-       
+                                                                             \
        w = gtk_label_new(_("IP Address:"));
        address = gtk_entry_new();
        gtk_entry_set_max_length(GTK_ENTRY(address), 15);
@@ -488,20 +521,21 @@ dhcpcd_prefs_show(void)
        attach_label(w, 0, 1, 4, 5);
        attach_entry(dns_search, 1, 2, 4, 5);
 
-       w = gtk_label_new(_("NTP Servers:"));
-       ntp_servers = gtk_entry_new();
-       g_signal_connect(G_OBJECT(ntp_servers), "focus-out-event",
-           G_CALLBACK(entry_lost_focus), NULL);
-       attach_label(w, 0, 1, 5, 6);
-       attach_entry(ntp_servers, 1, 2, 5, 6);
-
-       hbox = gtk_hbox_new(FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(dialog_vbox), hbox, TRUE, TRUE, 3);
-       w = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
-       gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
-       g_signal_connect(G_OBJECT(w), "clicked", on_clear, NULL);
+       hbox = gtk_hbox_new(false, 10);
+       gtk_box_pack_start(GTK_BOX(dialog_vbox), hbox, true, true, 3);
+       clear = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
+       gtk_widget_set_sensitive(clear, false);
+       gtk_box_pack_start(GTK_BOX(hbox), clear, false, false, 0);
+       g_signal_connect(G_OBJECT(clear), "clicked", on_clear, NULL);
+       rebind = gtk_button_new_with_mnemonic(_("_Rebind"));
+       gtk_widget_set_sensitive(rebind, false);
+       w = gtk_image_new_from_stock(GTK_STOCK_EXECUTE,
+           GTK_ICON_SIZE_BUTTON);
+       gtk_button_set_image(GTK_BUTTON(rebind), w);
+       gtk_box_pack_start(GTK_BOX(hbox), rebind, false, false, 0);
+       g_signal_connect(G_OBJECT(rebind), "clicked", on_rebind, NULL);
        w = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
-       gtk_box_pack_end(GTK_BOX(hbox), w, FALSE, FALSE, 0);
+       gtk_box_pack_end(GTK_BOX(hbox), w, false, false, 0);
        g_signal_connect(G_OBJECT(w), "clicked",
            dhcpcd_prefs_close, NULL);
        
diff --git a/wpa.c b/wpa.c
index a90462ed5c96958963800d38c138c9ef1270e633..27ec8eb50ed2d1ecbda75821b35a71d180478575 100644 (file)
--- a/wpa.c
+++ b/wpa.c
 #include "dhcpcd-gtk.h"
 #include "wpa.h"
 
-static gint
+static int
 find_network(const char *ifname, const char *ssid)
 {
        GType otype;
        GError *error;
-       gint id;
+       int id;
        size_t i;
        GPtrArray *array;
        GValueArray *varray;
@@ -98,11 +98,11 @@ find_network(const char *ifname, const char *ssid)
 static int
 configure_network(const char *ifname, int id, const char *mgmt,
     const char *var, const char *val,
-    gboolean quote)
+    bool quote)
 {
        GError *error;
        char *str;
-       static gboolean warned = FALSE;
+       static bool warned = false;
        GtkWidget *dialog;
 
        if (id == -1)
@@ -163,7 +163,7 @@ configure_network(const char *ifname, int id, const char *mgmt,
        {
                g_warning("SaveConfig: %s", error->message);
                if (!warned) {
-                       warned = TRUE;
+                       warned = true;
                        dialog = gtk_message_dialog_new(NULL,
                            GTK_DIALOG_MODAL,
                            GTK_MESSAGE_ERROR,
@@ -204,12 +204,12 @@ onEnter(_unused GtkWidget *widget, gpointer *data)
        gtk_dialog_response(GTK_DIALOG(data), GTK_RESPONSE_ACCEPT);
 }
 
-gboolean
+bool
 wpa_configure(const struct if_ap *ifa)
 {
        GtkWidget *dialog, *label, *psk, *vbox, *hbox;
        const char *var, *mgt;
-       gint result, id, retval;
+       int result, id, retval;
 
        dialog = gtk_dialog_new_with_buttons(ifa->ssid,
            NULL,
@@ -217,19 +217,19 @@ wpa_configure(const struct if_ap *ifa)
            GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
            GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
            NULL);
-       gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+       gtk_window_set_resizable(GTK_WINDOW(dialog), false);
        gtk_window_set_icon_name(GTK_WINDOW(dialog), "config-users");
        gtk_dialog_set_default_response(GTK_DIALOG(dialog),
            GTK_RESPONSE_ACCEPT);
        vbox = GTK_DIALOG(dialog)->vbox;
 
-       hbox = gtk_hbox_new(FALSE, 2);
+       hbox = gtk_hbox_new(false, 2);
        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, 0);
        psk = gtk_entry_new();
        gtk_entry_set_max_length(GTK_ENTRY(psk), 130);
        g_signal_connect(G_OBJECT(psk), "activate", G_CALLBACK(onEnter), dialog);
-       gtk_box_pack_start(GTK_BOX(hbox), psk, TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), psk, true, true, 0);
        gtk_container_add(GTK_CONTAINER(vbox), hbox);
 
        gtk_widget_show_all(dialog);
@@ -248,9 +248,9 @@ wpa_configure(const struct if_ap *ifa)
                }
                if (id != -1) {
                        retval = configure_network(ifa->ifname, id, mgt, var,
-                           gtk_entry_get_text(GTK_ENTRY(psk)), TRUE);
+                           gtk_entry_get_text(GTK_ENTRY(psk)), true);
                }
        }
        gtk_widget_destroy(dialog);
-       return retval == -1 ? FALSE : TRUE;
+       return retval == -1 ? false : true;
 }
diff --git a/wpa.h b/wpa.h
index b490aa2fef101b6650f21ebda829ced51b9b967c..204d2896ae82bcd4af41db43cf5d000c98c45d4f 100644 (file)
--- a/wpa.h
+++ b/wpa.h
 #ifndef WPA_H
 #define WPA_H
 
+#include <stdbool.h>
+
 #include "dhcpcd-gtk.h"
 
-gboolean wpa_configure(const struct if_ap *);
+bool wpa_configure(const struct if_ap *);
 
 #endif