changeset 3999:fa3d61ea0a6e

remove some duplicated code
author Tomasz Mon <desowin@gmail.com>
date Sat, 24 Nov 2007 18:56:52 +0100
parents 351dc6ef07b9
children a0bb67450552
files src/audacious/ui_preferences.c
diffstat 1 files changed, 24 insertions(+), 109 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_preferences.c	Sat Nov 24 17:51:18 2007 +0100
+++ b/src/audacious/ui_preferences.c	Sat Nov 24 18:56:52 2007 +0100
@@ -698,122 +698,37 @@
 }
 
 static void
-on_proxy_host_realize(GtkEntry * entry,
-                     gpointer data)
+on_proxy_entry_changed(GtkEntry *entry, gchar *cfg)
 {
-    ConfigDb *db;
-    gchar *ret;
-
-    db = cfg_db_open();
-
-    if (cfg_db_get_string(db, NULL, "proxy_host", &ret) != FALSE)
-        gtk_entry_set_text(entry, ret);
-
-    cfg_db_close(db);
-}
-
-static void
-on_proxy_host_changed(GtkEntry * entry,
-                     gpointer data)
-{
+    g_return_if_fail(cfg != NULL);
+
     ConfigDb *db;
     gchar *ret = g_strdup(gtk_entry_get_text(entry));
 
     db = cfg_db_open();
-    cfg_db_set_string(db, NULL, "proxy_host", ret);
+    cfg_db_set_string(db, NULL, cfg, ret);
     cfg_db_close(db);
 
     g_free(ret);
 }
 
 static void
-on_proxy_port_realize(GtkEntry * entry,
-                     gpointer data)
+on_proxy_entry_realize(GtkEntry *entry, gchar *cfg)
 {
-    ConfigDb *db;
-    gchar *ret;
-
-    db = cfg_db_open();
-
-    if (cfg_db_get_string(db, NULL, "proxy_port", &ret) != FALSE)
-        gtk_entry_set_text(entry, ret);
-
-    cfg_db_close(db);
-}
-
-static void
-on_proxy_port_changed(GtkEntry * entry,
-                     gpointer data)
-{
-    ConfigDb *db;
-    gchar *ret = g_strdup(gtk_entry_get_text(entry));
-
-    db = cfg_db_open();
-    cfg_db_set_string(db, NULL, "proxy_port", ret);
-    cfg_db_close(db);
-
-    g_free(ret);
-}
-
-static void
-on_proxy_user_realize(GtkEntry * entry,
-                     gpointer data)
-{
+    g_return_if_fail(cfg != NULL);
+
     ConfigDb *db;
     gchar *ret;
 
     db = cfg_db_open();
 
-    if (cfg_db_get_string(db, NULL, "proxy_user", &ret) != FALSE)
+    if (cfg_db_get_string(db, NULL, cfg, &ret) != FALSE)
         gtk_entry_set_text(entry, ret);
 
     cfg_db_close(db);
 }
 
 static void
-on_proxy_user_changed(GtkEntry * entry,
-                     gpointer data)
-{
-    ConfigDb *db;
-    gchar *ret = g_strdup(gtk_entry_get_text(entry));
-
-    db = cfg_db_open();
-    cfg_db_set_string(db, NULL, "proxy_user", ret);
-    cfg_db_close(db);
-
-    g_free(ret);
-}
-
-static void
-on_proxy_pass_realize(GtkEntry * entry,
-                     gpointer data)
-{
-    ConfigDb *db;
-    gchar *ret;
-
-    db = cfg_db_open();
-
-    if (cfg_db_get_string(db, NULL, "proxy_pass", &ret) != FALSE)
-        gtk_entry_set_text(entry, ret);
-
-    cfg_db_close(db);
-}
-
-static void
-on_proxy_pass_changed(GtkEntry * entry,
-                     gpointer data)
-{
-    ConfigDb *db;
-    gchar *ret = g_strdup(gtk_entry_get_text(entry));
-
-    db = cfg_db_open();
-    cfg_db_set_string(db, NULL, "proxy_pass", ret);
-    cfg_db_close(db);
-
-    g_free(ret);
-}
-
-static void
 plugin_treeview_open_prefs(GtkTreeView *treeview)
 {
     GtkTreeSelection *selection;
@@ -3544,17 +3459,17 @@
                      G_CALLBACK(on_proxy_use_realize),
                      NULL);
     g_signal_connect(G_OBJECT(proxy_port), "changed",
-                     G_CALLBACK(on_proxy_port_changed),
-                     NULL);
+                     G_CALLBACK(on_proxy_entry_changed),
+                     "proxy_port");
     g_signal_connect(G_OBJECT(proxy_port), "realize",
-                     G_CALLBACK(on_proxy_port_realize),
-                     NULL);
+                     G_CALLBACK(on_proxy_entry_realize),
+                     "proxy_port");
     g_signal_connect(G_OBJECT(proxy_host), "changed",
-                     G_CALLBACK(on_proxy_host_changed),
-                     NULL);
+                     G_CALLBACK(on_proxy_entry_changed),
+                     "proxy_host");
     g_signal_connect(G_OBJECT(proxy_host), "realize",
-                     G_CALLBACK(on_proxy_host_realize),
-                     NULL);
+                     G_CALLBACK(on_proxy_entry_realize),
+                     "proxy_host");
     g_signal_connect(G_OBJECT(proxy_auth), "toggled",
                      G_CALLBACK(on_proxy_auth_toggled),
                      NULL);
@@ -3562,17 +3477,17 @@
                      G_CALLBACK(on_proxy_auth_realize),
                      NULL);
     g_signal_connect(G_OBJECT(proxy_pass), "changed",
-                     G_CALLBACK(on_proxy_pass_changed),
-                     NULL);
+                     G_CALLBACK(on_proxy_entry_changed),
+                     "proxy_pass");
     g_signal_connect(G_OBJECT(proxy_pass), "realize",
-                     G_CALLBACK(on_proxy_pass_realize),
-                     NULL);
+                     G_CALLBACK(on_proxy_entry_realize),
+                     "proxy_pass");
     g_signal_connect(G_OBJECT(proxy_user), "changed",
-                     G_CALLBACK(on_proxy_user_changed),
-                     NULL);
+                     G_CALLBACK(on_proxy_entry_changed),
+                     "proxy_user");
     g_signal_connect(G_OBJECT(proxy_user), "realize",
-                     G_CALLBACK(on_proxy_user_realize),
-                     NULL);
+                     G_CALLBACK(on_proxy_entry_realize),
+                     "proxy_user");
     g_signal_connect(G_OBJECT(output_plugin_bufsize), "value_changed",
                      G_CALLBACK(on_output_plugin_bufsize_value_changed),
                      NULL);