~ubuntu-branches/ubuntu/karmic/gtk-gnutella/karmic

« back to all changes in this revision

Viewing changes to src/settings_cb.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Kleineidam
  • Date: 2004-05-22 15:26:55 UTC
  • Revision ID: james.westby@ubuntu.com-20040522152655-lyi6iaswmy4hq4wy
Tags: upstream-0.93.3.0
ImportĀ upstreamĀ versionĀ 0.93.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: settings_cb.c,v 1.22 2004/01/14 20:52:33 rmanfredi Exp $
 
3
 *
 
4
 * Copyright (c) 2001-2003, Raphael Manfredi, Richard Eckart
 
5
 *
 
6
 * GUI stuff used by share.c
 
7
 *
 
8
 *----------------------------------------------------------------------
 
9
 * This file is part of gtk-gnutella.
 
10
 *
 
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.
 
15
 *
 
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.
 
20
 *
 
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
 
23
 *  Foundation, Inc.:
 
24
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
25
 *----------------------------------------------------------------------
 
26
 */
 
27
 
 
28
#include "gui.h"
 
29
 
 
30
#include "adns.h"
 
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 */
 
35
 
 
36
RCSID("$Id: settings_cb.c,v 1.22 2004/01/14 20:52:33 rmanfredi Exp $");
 
37
 
 
38
/* 
 
39
 * Create a function for the focus out signal and make it call
 
40
 * the callback for the activate signal.
 
41
 */
 
42
#define FOCUS_TO_ACTIVATE(a)                                            \
 
43
    gboolean CAT3(on_,a,_focus_out_event)                               \
 
44
        (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)   \
 
45
    {                                                                   \
 
46
        CAT3(on_,a,_activate)(GTK_EDITABLE(widget), NULL);              \
 
47
        return FALSE;                                                   \
 
48
    }
 
49
 
 
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);                    \
 
53
    } while (0)
 
54
 
 
55
void on_spinbutton_search_reissue_timeout_changed
 
56
    (GtkEditable *editable, gpointer user_data)
 
57
{
 
58
    static gboolean lock = FALSE;
 
59
    search_t *current_search;
 
60
    guint32 timeout_real;
 
61
    guint32 timeout;
 
62
 
 
63
    if (lock)
 
64
        return;
 
65
 
 
66
    lock = TRUE;
 
67
 
 
68
    current_search = search_gui_get_current_search();
 
69
 
 
70
    if (!current_search || search_is_passive(current_search->search_handle)) {
 
71
        lock = FALSE;
 
72
        return;
 
73
    }
 
74
 
 
75
    timeout = gtk_spin_button_get_value(GTK_SPIN_BUTTON(editable));
 
76
 
 
77
    search_set_reissue_timeout(current_search->search_handle, timeout);
 
78
    timeout_real = search_get_reissue_timeout(current_search->search_handle);
 
79
 
 
80
    if (timeout != timeout_real)
 
81
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(editable), timeout_real);
 
82
 
 
83
    lock = FALSE;
 
84
}
 
85
 
 
86
static void on_entry_config_proxy_ip_activate_helper(
 
87
        guint32 ip, gpointer user_data)
 
88
{
 
89
    gnet_prop_set_guint32_val(PROP_PROXY_IP, ip);
 
90
}
 
91
 
 
92
void on_entry_config_proxy_ip_activate
 
93
    (GtkEditable *editable, gpointer user_data)
 
94
{
 
95
        gchar *e = g_strstrip(STRTRACK(gtk_editable_get_chars(editable, 0, -1)));
 
96
 
 
97
        adns_resolve(e, &on_entry_config_proxy_ip_activate_helper, NULL);
 
98
        g_free(e);
 
99
}
 
100
FOCUS_TO_ACTIVATE(entry_config_proxy_ip)
 
101
 
 
102
void on_entry_config_socks_username_activate
 
103
    (GtkEditable *editable, gpointer user_data)
 
104
{
 
105
        gchar *e = g_strstrip(STRTRACK(gtk_editable_get_chars(editable, 0, -1)));
 
106
 
 
107
    gnet_prop_set_string(PROP_SOCKS_USER, e);
 
108
        
 
109
    g_free(e);
 
110
}
 
111
FOCUS_TO_ACTIVATE(entry_config_socks_username)
 
112
 
 
113
void on_entry_config_socks_password_activate
 
114
    (GtkEditable * editable, gpointer user_data)
 
115
{
 
116
        gchar *e = g_strstrip(STRTRACK(gtk_editable_get_chars(editable, 0, -1)));
 
117
 
 
118
    gnet_prop_set_string(PROP_SOCKS_PASS, e);
 
119
        
 
120
    g_free(e);
 
121
}
 
122
FOCUS_TO_ACTIVATE(entry_config_socks_password)
 
123
 
 
124
void on_entry_config_extensions_activate(GtkEditable *editable, gpointer data)
 
125
{
 
126
    gchar *ext;
 
127
 
 
128
    ext = STRTRACK(gtk_editable_get_chars(editable, 0, -1));
 
129
 
 
130
    gnet_prop_set_string(PROP_SCAN_EXTENSIONS, ext);
 
131
 
 
132
    g_free(ext);
 
133
}
 
134
FOCUS_TO_ACTIVATE(entry_config_extensions)
 
135
 
 
136
void on_entry_config_path_activate(GtkEditable *editable, gpointer user_data)
 
137
{
 
138
    gchar *path = STRTRACK(gtk_editable_get_chars(editable, 0, -1));
 
139
 
 
140
    gnet_prop_set_string(PROP_SHARED_DIRS_PATHS, path);
 
141
 
 
142
    g_free(path);
 
143
}
 
144
FOCUS_TO_ACTIVATE(entry_config_path)
 
145
 
 
146
void on_entry_config_force_ip_activate
 
147
    (GtkEditable *editable, gpointer user_data)
 
148
{
 
149
        gchar *e;
 
150
        guint32 ip;
 
151
        e = STRTRACK(gtk_editable_get_chars(
 
152
        GTK_EDITABLE(lookup_widget(main_window, "entry_config_force_ip")), 
 
153
        0, -1));
 
154
        g_strstrip(e);
 
155
        ip = gchar_to_ip(e);
 
156
        gnet_prop_set_guint32_val(PROP_FORCED_LOCAL_IP, ip);
 
157
        g_free(e);
 
158
}
 
159
FOCUS_TO_ACTIVATE(entry_config_force_ip)
 
160
 
 
161
void on_entry_config_force_ip_changed
 
162
    (GtkEditable *editable,  gpointer user_data)
 
163
{
 
164
    gchar *e = STRTRACK(gtk_editable_get_chars(editable, 0, -1));
 
165
 
 
166
        g_strstrip(e);
 
167
 
 
168
        gtk_widget_set_sensitive(
 
169
        lookup_widget(main_window, "checkbutton_config_force_ip"),
 
170
        is_string_ip(e));
 
171
 
 
172
        g_free(e);
 
173
}
 
174
 
 
175
void on_entry_server_hostname_activate
 
176
    (GtkEditable *editable, gpointer user_data)
 
177
{
 
178
        gchar *e;
 
179
 
 
180
        e = STRTRACK(gtk_editable_get_chars(
 
181
        GTK_EDITABLE(lookup_widget(main_window, "entry_server_hostname")), 
 
182
        0, -1));
 
183
        g_strstrip(e);
 
184
        gnet_prop_set_string(PROP_SERVER_HOSTNAME, e);
 
185
        g_free(e);
 
186
}
 
187
FOCUS_TO_ACTIVATE(entry_server_hostname)
 
188
 
 
189
void on_entry_server_hostname_changed
 
190
    (GtkEditable *editable,  gpointer user_data)
 
191
{
 
192
    gchar *e = STRTRACK(gtk_editable_get_chars(editable, 0, -1));
 
193
 
 
194
        g_strstrip(e);
 
195
 
 
196
        gtk_widget_set_sensitive(
 
197
        lookup_widget(main_window, "checkbutton_give_server_hostname"),
 
198
        strlen(e) > 4);         /* Minimum: "a.com" */
 
199
 
 
200
        g_free(e);
 
201
}
 
202
 
 
203
 
 
204
void on_menu_toolbar_visible_activate
 
205
    (GtkMenuItem *menuitem, gpointer user_data)
 
206
{
 
207
        checkmenu_changed(gui, PROP_TOOLBAR_VISIBLE, menuitem);
 
208
}
 
209
 
 
210
void on_menu_statusbar_visible_activate
 
211
    (GtkMenuItem *menuitem, gpointer user_data)
 
212
{
 
213
        checkmenu_changed(gui, PROP_STATUSBAR_VISIBLE, menuitem);
 
214
}
 
215
 
 
216
void on_menu_downloads_visible_activate(GtkMenuItem * menuitem,
 
217
                                                                         gpointer user_data)
 
218
{
 
219
        checkmenu_changed(gui, PROP_PROGRESSBAR_DOWNLOADS_VISIBLE, menuitem);
 
220
}
 
221
 
 
222
void on_menu_uploads_visible_activate(GtkMenuItem * menuitem,
 
223
                                                                   gpointer user_data)
 
224
{
 
225
        checkmenu_changed(gui, PROP_PROGRESSBAR_UPLOADS_VISIBLE, menuitem);
 
226
}
 
227
 
 
228
void on_menu_connections_visible_activate(GtkMenuItem * menuitem,
 
229
                                                                           gpointer user_data)
 
230
{
 
231
        checkmenu_changed(gui, PROP_PROGRESSBAR_CONNECTIONS_VISIBLE, menuitem);
 
232
}
 
233
 
 
234
void on_menu_bws_in_visible_activate(GtkMenuItem * menuitem,
 
235
                                                                     gpointer user_data)
 
236
{
 
237
        checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_IN_VISIBLE, menuitem);
 
238
}
 
239
 
 
240
void on_menu_bws_out_visible_activate(GtkMenuItem * menuitem,
 
241
                                                                      gpointer user_data)
 
242
{
 
243
        checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_OUT_VISIBLE, menuitem);
 
244
}
 
245
 
 
246
void on_menu_bws_gin_visible_activate(GtkMenuItem * menuitem,
 
247
                                                                      gpointer user_data)
 
248
{
 
249
        checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_GIN_VISIBLE, menuitem);
 
250
}
 
251
 
 
252
void on_menu_bws_gout_visible_activate(GtkMenuItem * menuitem,
 
253
                                                                       gpointer user_data)
 
254
{
 
255
        checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_GOUT_VISIBLE, menuitem);
 
256
}
 
257
 
 
258
void on_menu_bws_glin_visible_activate(GtkMenuItem * menuitem,
 
259
                                                                      gpointer user_data)
 
260
{
 
261
        checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_GLIN_VISIBLE, menuitem);
 
262
}
 
263
 
 
264
void on_menu_bws_glout_visible_activate(GtkMenuItem * menuitem,
 
265
                                                                       gpointer user_data)
 
266
{
 
267
        checkmenu_changed(gui, PROP_PROGRESSBAR_BWS_GLOUT_VISIBLE, menuitem);
 
268
}
 
269
 
 
270
 
 
271
 
 
272
void on_menu_autohide_bws_gleaf_activate(GtkMenuItem * menuitem,
 
273
                                        gpointer user_data)
 
274
{
 
275
        checkmenu_changed(gui, PROP_AUTOHIDE_BWS_GLEAF, menuitem);
 
276
}
 
277
 
 
278
 
 
279
 
 
280
void on_popup_search_toggle_tabs_activate
 
281
    (GtkMenuItem *menuitem, gpointer user_data)
 
282
{
 
283
    gboolean val;
 
284
 
 
285
    gui_prop_get_boolean(PROP_SEARCH_RESULTS_SHOW_TABS, &val, 0, 1);
 
286
    val = !val;
 
287
    gui_prop_set_boolean(PROP_SEARCH_RESULTS_SHOW_TABS, &val, 0, 1);
 
288
}