2
* $Id: settings_cb.c,v 1.22 2004/01/14 20:52:33 rmanfredi Exp $
4
* Copyright (c) 2001-2003, Raphael Manfredi, Richard Eckart
6
* GUI stuff used by share.c
8
*----------------------------------------------------------------------
9
* This file is part of gtk-gnutella.
11
* gtk-gnutella is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* gtk-gnutella is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with gtk-gnutella; if not, write to the Free Software
24
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
*----------------------------------------------------------------------
31
#include "settings_cb.h"
32
#include "settings_gui.h"
33
#include "search_gui.h"
34
#include "override.h" /* Must be the last header included */
36
RCSID("$Id: settings_cb.c,v 1.22 2004/01/14 20:52:33 rmanfredi Exp $");
39
* Create a function for the focus out signal and make it call
40
* the callback for the activate signal.
42
#define FOCUS_TO_ACTIVATE(a) \
43
gboolean CAT3(on_,a,_focus_out_event) \
44
(GtkWidget *widget, GdkEventFocus *event, gpointer user_data) \
46
CAT3(on_,a,_activate)(GTK_EDITABLE(widget), NULL); \
50
#define checkmenu_changed(pref,p, cb) do { \
51
gboolean val = GTK_CHECK_MENU_ITEM(cb)->active; \
52
CAT2(pref,_prop_set_boolean)(p, &val, 0, 1); \
55
void on_spinbutton_search_reissue_timeout_changed
56
(GtkEditable *editable, gpointer user_data)
58
static gboolean lock = FALSE;
59
search_t *current_search;
68
current_search = search_gui_get_current_search();
70
if (!current_search || search_is_passive(current_search->search_handle)) {
75
timeout = gtk_spin_button_get_value(GTK_SPIN_BUTTON(editable));
77
search_set_reissue_timeout(current_search->search_handle, timeout);
78
timeout_real = search_get_reissue_timeout(current_search->search_handle);
80
if (timeout != timeout_real)
81
gtk_spin_button_set_value(GTK_SPIN_BUTTON(editable), timeout_real);
86
static void on_entry_config_proxy_ip_activate_helper(
87
guint32 ip, gpointer user_data)
89
gnet_prop_set_guint32_val(PROP_PROXY_IP, ip);
92
void on_entry_config_proxy_ip_activate
93
(GtkEditable *editable, gpointer user_data)
95
gchar *e = g_strstrip(STRTRACK(gtk_editable_get_chars(editable, 0, -1)));
97
adns_resolve(e, &on_entry_config_proxy_ip_activate_helper, NULL);
100
FOCUS_TO_ACTIVATE(entry_config_proxy_ip)
102
void on_entry_config_socks_username_activate
103
(GtkEditable *editable, gpointer user_data)
105
gchar *e = g_strstrip(STRTRACK(gtk_editable_get_chars(editable, 0, -1)));
107
gnet_prop_set_string(PROP_SOCKS_USER, e);
111
FOCUS_TO_ACTIVATE(entry_config_socks_username)
113
void on_entry_config_socks_password_activate
114
(GtkEditable * editable, gpointer user_data)
116
gchar *e = g_strstrip(STRTRACK(gtk_editable_get_chars(editable, 0, -1)));
118
gnet_prop_set_string(PROP_SOCKS_PASS, e);
122
FOCUS_TO_ACTIVATE(entry_config_socks_password)
124
void on_entry_config_extensions_activate(GtkEditable *editable, gpointer data)
128
ext = STRTRACK(gtk_editable_get_chars(editable, 0, -1));
130
gnet_prop_set_string(PROP_SCAN_EXTENSIONS, ext);
134
FOCUS_TO_ACTIVATE(entry_config_extensions)
136
void on_entry_config_path_activate(GtkEditable *editable, gpointer user_data)
138
gchar *path = STRTRACK(gtk_editable_get_chars(editable, 0, -1));
140
gnet_prop_set_string(PROP_SHARED_DIRS_PATHS, path);
144
FOCUS_TO_ACTIVATE(entry_config_path)
146
void on_entry_config_force_ip_activate
147
(GtkEditable *editable, gpointer user_data)
151
e = STRTRACK(gtk_editable_get_chars(
152
GTK_EDITABLE(lookup_widget(main_window, "entry_config_force_ip")),
156
gnet_prop_set_guint32_val(PROP_FORCED_LOCAL_IP, ip);
159
FOCUS_TO_ACTIVATE(entry_config_force_ip)
161
void on_entry_config_force_ip_changed
162
(GtkEditable *editable, gpointer user_data)
164
gchar *e = STRTRACK(gtk_editable_get_chars(editable, 0, -1));
168
gtk_widget_set_sensitive(
169
lookup_widget(main_window, "checkbutton_config_force_ip"),
175
void on_entry_server_hostname_activate
176
(GtkEditable *editable, gpointer user_data)
180
e = STRTRACK(gtk_editable_get_chars(
181
GTK_EDITABLE(lookup_widget(main_window, "entry_server_hostname")),
184
gnet_prop_set_string(PROP_SERVER_HOSTNAME, e);
187
FOCUS_TO_ACTIVATE(entry_server_hostname)
189
void on_entry_server_hostname_changed
190
(GtkEditable *editable, gpointer user_data)
192
gchar *e = STRTRACK(gtk_editable_get_chars(editable, 0, -1));
196
gtk_widget_set_sensitive(
197
lookup_widget(main_window, "checkbutton_give_server_hostname"),
198
strlen(e) > 4); /* Minimum: "a.com" */
204
void on_menu_toolbar_visible_activate
205
(GtkMenuItem *menuitem, gpointer user_data)
207
checkmenu_changed(gui, PROP_TOOLBAR_VISIBLE, menuitem);
210
void on_menu_statusbar_visible_activate
211
(GtkMenuItem *menuitem, gpointer user_data)
213
checkmenu_changed(gui, PROP_STATUSBAR_VISIBLE, menuitem);
216
void on_menu_downloads_visible_activate(GtkMenuItem * menuitem,
219
checkmenu_changed(gui, PROP_PROGRESSBAR_DOWNLOADS_VISIBLE, menuitem);
222
void on_menu_uploads_visible_activate(GtkMenuItem * menuitem,
225
checkmenu_changed(gui, PROP_PROGRESSBAR_UPLOADS_VISIBLE, menuitem);
228
void on_menu_connections_visible_activate(GtkMenuItem * menuitem,
231
checkmenu_changed(gui, PROP_PROGRESSBAR_CONNECTIONS_VISIBLE, menuitem);
234
void on_menu_bws_in_visible_activate(GtkMenuItem * menuitem,
237
checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_IN_VISIBLE, menuitem);
240
void on_menu_bws_out_visible_activate(GtkMenuItem * menuitem,
243
checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_OUT_VISIBLE, menuitem);
246
void on_menu_bws_gin_visible_activate(GtkMenuItem * menuitem,
249
checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_GIN_VISIBLE, menuitem);
252
void on_menu_bws_gout_visible_activate(GtkMenuItem * menuitem,
255
checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_GOUT_VISIBLE, menuitem);
258
void on_menu_bws_glin_visible_activate(GtkMenuItem * menuitem,
261
checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_GLIN_VISIBLE, menuitem);
264
void on_menu_bws_glout_visible_activate(GtkMenuItem * menuitem,
267
checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_GLOUT_VISIBLE, menuitem);
272
void on_menu_autohide_bws_gleaf_activate(GtkMenuItem * menuitem,
275
checkmenu_changed(gui, PROP_AUTOHIDE_BWS_GLEAF, menuitem);
280
void on_popup_search_toggle_tabs_activate
281
(GtkMenuItem *menuitem, gpointer user_data)
285
gui_prop_get_boolean(PROP_SEARCH_RESULTS_SHOW_TABS, &val, 0, 1);
287
gui_prop_set_boolean(PROP_SEARCH_RESULTS_SHOW_TABS, &val, 0, 1);