# HG changeset patch # User Tomasz Mon # Date 1195927012 -3600 # Node ID fa3d61ea0a6e0b10d7ca9c55c028ee78f712dda4 # Parent 351dc6ef07b980b02cec248684a755e324fdae3e remove some duplicated code diff -r 351dc6ef07b9 -r fa3d61ea0a6e src/audacious/ui_preferences.c --- 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);