Rejig menu order.
authorRoy Marples <roy@marples.name>
Fri, 20 Feb 2009 15:46:47 +0000 (15:46 +0000)
committerRoy Marples <roy@marples.name>
Fri, 20 Feb 2009 15:46:47 +0000 (15:46 +0000)
menu.c
prefs.c

diff --git a/menu.c b/menu.c
index 2168d7da9d9f80f4318c5f95f7f371fbc8c4c049..63cd2db0d588dfb4746896ca1530f865c0148d5e 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -214,14 +214,6 @@ on_popup(GtkStatusIcon *icon, guint button, guint32 atime, gpointer data)
            G_CALLBACK(on_pref), icon);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
-       item = gtk_image_menu_item_new_with_mnemonic(_("_Quit"));
-       image = gtk_image_new_from_icon_name(GTK_STOCK_QUIT,
-           GTK_ICON_SIZE_MENU);
-       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
-       g_signal_connect(G_OBJECT(item), "activate",
-           G_CALLBACK(on_quit), icon);
-       gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-
        item = gtk_separator_menu_item_new();
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
@@ -241,6 +233,14 @@ on_popup(GtkStatusIcon *icon, guint button, guint32 atime, gpointer data)
            G_CALLBACK(on_about), icon);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
+       item = gtk_image_menu_item_new_with_mnemonic(_("_Quit"));
+       image = gtk_image_new_from_icon_name(GTK_STOCK_QUIT,
+           GTK_ICON_SIZE_MENU);
+       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
+       g_signal_connect(G_OBJECT(item), "activate",
+           G_CALLBACK(on_quit), icon);
+       gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+
        gtk_widget_show_all(GTK_WIDGET(menu));
        gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
            gtk_status_icon_position_menu, data, button, atime);
diff --git a/prefs.c b/prefs.c
index a56783ffbcc5a3e76e39152461674dcdb534318f..2734803a40a95b5270bba8425f31cebe7da20278 100644 (file)
--- a/prefs.c
+++ b/prefs.c
@@ -73,6 +73,25 @@ read_config(const char *block, const char *name)
        return array;
 }
 
+static void
+save_config(const char *block, const char *name)
+{
+       GType otype;
+       GError *error;
+
+       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);
+       }
+}
+
 static gboolean
 get_config(GPtrArray *array, const char *option, const char **value)
 {
@@ -355,14 +374,41 @@ dhcpcd_prefs_close(void)
 }
 
 static void
-on_delete(void)
+on_redo(void)
 {
        char *block, *name;
+       GValueArray *array;
+       GValue val;
 
-       //delete_config();
-       //save_config();
        block = combo_active_text(blocks);
        name = combo_active_text(names);
+       free_config(&config);
+       if (g_strcmp0(block, "global") == 0) {
+               config = g_ptr_array_sized_new(3);
+               memset(&val, 0, sizeof(val));
+               g_value_init(&val, G_TYPE_STRING);
+               array = g_value_array_new(2);
+               g_value_set_static_string(&val, "hostname");
+               array = g_value_array_append(array, &val);
+               g_value_set_static_string(&val, "");
+               array = g_value_array_append(array, &val);
+               g_ptr_array_add(config, array);
+               array = g_value_array_new(2);
+               g_value_set_static_string(&val, "option");
+               array = g_value_array_append(array, &val);
+               g_value_set_static_string(&val, "domain_name_servers, "
+                   "domain_name, domain_search, host_name");
+               array = g_value_array_append(array, &val);
+               g_ptr_array_add(config, array);
+               array = g_value_array_new(2);
+               g_value_set_static_string(&val, "option");
+               array = g_value_array_append(array, &val);
+               g_value_set_static_string(&val, "ntp_servers");
+               array = g_value_array_append(array, &val);
+               g_ptr_array_add(config, array);
+       } else
+               config = g_ptr_array_new();
+       save_config(name ? block : NULL, name);
        show_config(name ? block : NULL, name);
        g_free(block);
        g_free(name);
@@ -481,9 +527,9 @@ dhcpcd_prefs_show(void)
 
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(dialog_vbox), hbox, TRUE, TRUE, 3);
-       label = gtk_button_new_from_stock(GTK_STOCK_DELETE);
+       label = gtk_button_new_from_stock(GTK_STOCK_REDO);
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-       gtk_signal_connect(GTK_OBJECT(label), "clicked", on_delete, NULL);
+       gtk_signal_connect(GTK_OBJECT(label), "clicked", on_redo, NULL);
        label = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
        gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
        gtk_signal_connect(GTK_OBJECT(label), "clicked",