pidgin/prefs/pidginprefs.c

changeset 41397
91e5ee47f5a1
parent 41394
1327e58acce3
child 41490
2b1695327414
equal deleted inserted replaced
41396:2ef3d6eeffb3 41397:91e5ee47f5a1
1 /* pidgin 1 /*
2 * Pidgin - Internet Messenger
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
2 * 4 *
3 * Pidgin is the legal property of its developers, whose names are too numerous 5 * Pidgin is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this 6 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution. 7 * source distribution.
6 * 8 *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 17 * GNU General Public License for more details.
16 * 18 *
17 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
20 *
21 */ 21 */
22 22
23 #ifdef HAVE_CONFIG_H 23 #ifdef HAVE_CONFIG_H
24 # include <config.h> 24 # include <config.h>
25 #endif 25 #endif
27 #include <errno.h> 27 #include <errno.h>
28 #include <math.h> 28 #include <math.h>
29 29
30 #include <glib/gi18n-lib.h> 30 #include <glib/gi18n-lib.h>
31 #include <glib/gstdio.h> 31 #include <glib/gstdio.h>
32 #include <nice.h>
33 #include <talkatu.h>
34 32
35 #include <purple.h> 33 #include <purple.h>
36 34
37 #include "gtkblist.h" 35 #include "pidginprefs.h"
38 #include "gtkconv.h" 36 #include "pidginprefsinternal.h"
39 #include "gtkdialogs.h"
40 #include "gtkutils.h" 37 #include "gtkutils.h"
41 #include "pidgincore.h" 38 #include "pidgincore.h"
42 #include "pidgindebug.h"
43 #include "pidginprefs.h"
44 #include "pidginprefsinternal.h"
45 #ifdef USE_VV 39 #ifdef USE_VV
46 #include "pidginvvprefs.h" 40 #include "pidginvvprefs.h"
47 #endif 41 #endif
48 #include <libsoup/soup.h>
49
50 #define PREFS_OPTIMAL_ICON_SIZE 32
51
52 /* 25MB */
53 #define PREFS_MAX_DOWNLOADED_THEME_SIZE 26214400
54 42
55 struct _PidginPrefsWindow { 43 struct _PidginPrefsWindow {
56 GtkDialog parent; 44 GtkDialog parent;
57 45
58 /* Stack */ 46 /* Stack */
60 }; 48 };
61 49
62 /* Main dialog */ 50 /* Main dialog */
63 static PidginPrefsWindow *prefs = NULL; 51 static PidginPrefsWindow *prefs = NULL;
64 52
65 /*
66 * PROTOTYPES
67 */
68 G_DEFINE_TYPE(PidginPrefsWindow, pidgin_prefs_window, GTK_TYPE_DIALOG); 53 G_DEFINE_TYPE(PidginPrefsWindow, pidgin_prefs_window, GTK_TYPE_DIALOG);
69 static void delete_prefs(GtkWidget *, void *); 54
70 55 /******************************************************************************
56 * Helpers
57 *****************************************************************************/
71 static void 58 static void
72 update_spin_value(GtkWidget *w, GtkWidget *spin) 59 update_spin_value(GtkWidget *w, GtkWidget *spin)
73 { 60 {
74 const char *key = g_object_get_data(G_OBJECT(spin), "val"); 61 const char *key = g_object_get_data(G_OBJECT(spin), "val");
75 int value; 62 int value;
124 const char *key = (const char*)data; 111 const char *key = (const char*)data;
125 112
126 purple_prefs_set_string(key, gtk_entry_get_text(entry)); 113 purple_prefs_set_string(key, gtk_entry_get_text(entry));
127 } 114 }
128 115
129 GtkWidget *
130 pidgin_prefs_labeled_entry(GtkWidget *page, const gchar *title,
131 const char *key, GtkSizeGroup *sg)
132 {
133 GtkWidget *entry;
134 const gchar *value;
135
136 value = purple_prefs_get_string(key);
137
138 entry = gtk_entry_new();
139 gtk_entry_set_text(GTK_ENTRY(entry), value);
140 g_signal_connect(G_OBJECT(entry), "changed",
141 G_CALLBACK(entry_set), (char*)key);
142 gtk_widget_show(entry);
143
144 return pidgin_add_widget_to_vbox(GTK_BOX(page), title, sg, entry, TRUE, NULL);
145 }
146
147 void 116 void
148 pidgin_prefs_bind_entry(const char *key, GtkWidget *entry) 117 pidgin_prefs_bind_entry(const char *key, GtkWidget *entry)
149 { 118 {
150 const gchar *value; 119 const gchar *value;
151 120
152 value = purple_prefs_get_string(key); 121 value = purple_prefs_get_string(key);
153 122
154 gtk_entry_set_text(GTK_ENTRY(entry), value); 123 gtk_entry_set_text(GTK_ENTRY(entry), value);
155 g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(entry_set), 124 g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(entry_set),
156 (char*)key); 125 (char*)key);
157 }
158
159 GtkWidget *
160 pidgin_prefs_labeled_password(GtkWidget *page, const gchar *title,
161 const char *key, GtkSizeGroup *sg)
162 {
163 GtkWidget *entry;
164 const gchar *value;
165
166 value = purple_prefs_get_string(key);
167
168 entry = gtk_entry_new();
169 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
170 gtk_entry_set_text(GTK_ENTRY(entry), value);
171 g_signal_connect(G_OBJECT(entry), "changed",
172 G_CALLBACK(entry_set), (char*)key);
173 gtk_widget_show(entry);
174
175 return pidgin_add_widget_to_vbox(GTK_BOX(page), title, sg, entry, TRUE, NULL);
176 } 126 }
177 127
178 static void 128 static void
179 dropdown_set(GtkComboBox *combo_box, G_GNUC_UNUSED gpointer data) 129 dropdown_set(GtkComboBox *combo_box, G_GNUC_UNUSED gpointer data)
180 { 130 {
460 static void 410 static void
461 delete_prefs(GtkWidget *asdf, void *gdsa) 411 delete_prefs(GtkWidget *asdf, void *gdsa)
462 { 412 {
463 /* Close any request dialogs */ 413 /* Close any request dialogs */
464 purple_request_close_with_handle(prefs); 414 purple_request_close_with_handle(prefs);
465
466 purple_notify_close_with_handle(prefs); 415 purple_notify_close_with_handle(prefs);
467 416
468 /* Unregister callbacks. */ 417 /* Unregister callbacks. */
469 purple_prefs_disconnect_by_handle(prefs); 418 purple_prefs_disconnect_by_handle(prefs);
470 419
483 pidgin_vv_prefs_disable_test_pipelines(vv_prefs); 432 pidgin_vv_prefs_disable_test_pipelines(vv_prefs);
484 } 433 }
485 } 434 }
486 #endif 435 #endif
487 436
437 /******************************************************************************
438 * GObject Implementation
439 *****************************************************************************/
488 static void 440 static void
489 pidgin_prefs_window_class_init(PidginPrefsWindowClass *klass) 441 pidgin_prefs_window_class_init(PidginPrefsWindowClass *klass)
490 { 442 {
491 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); 443 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
492 444
505 pidgin_prefs_window_init(PidginPrefsWindow *win) 457 pidgin_prefs_window_init(PidginPrefsWindow *win)
506 { 458 {
507 #ifdef USE_VV 459 #ifdef USE_VV
508 GtkWidget *vv = NULL; 460 GtkWidget *vv = NULL;
509 #endif 461 #endif
510 /* copy the preferences to tmp values... 462
511 * I liked "take affect immediately" Oh well :-( */
512 /* (that should have been "effect," right?) */
513
514 /* Back to instant-apply! I win! BU-HAHAHA! */
515
516 /* Create the window */
517 gtk_widget_init_template(GTK_WIDGET(win)); 463 gtk_widget_init_template(GTK_WIDGET(win));
518 464
519 #ifdef USE_VV 465 #ifdef USE_VV
520 vv = pidgin_vv_prefs_new(); 466 vv = pidgin_vv_prefs_new();
521 gtk_stack_add_titled(GTK_STACK(win->stack), vv, "vv", _("Voice/Video")); 467 gtk_stack_add_titled(GTK_STACK(win->stack), vv, "vv", _("Voice/Video"));
522 g_signal_connect(win->stack, "notify::visible-child", 468 g_signal_connect(win->stack, "notify::visible-child",
523 G_CALLBACK(vv_test_switch_page_cb), vv); 469 G_CALLBACK(vv_test_switch_page_cb), vv);
524 #endif 470 #endif
525 } 471 }
526 472
473 /******************************************************************************
474 * API
475 *****************************************************************************/
527 void 476 void
528 pidgin_prefs_show(void) 477 pidgin_prefs_show(void)
529 { 478 {
530 if (prefs == NULL) { 479 if (prefs == NULL) {
531 prefs = PIDGIN_PREFS_WINDOW(g_object_new( 480 prefs = PIDGIN_PREFS_WINDOW(g_object_new(

mercurial