annotate src/gtkpluginpref.c @ 13344:1c2f284986b7

[gaim-migrate @ 15714] really fix x:data user searches committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 28 Feb 2006 02:00:15 +0000
parents 3de53fe8345f
children 8bda65b88e49
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /**
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9841
diff changeset
2 * @file gtkpluginpref.c GTK+ Plugin preferences
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9841
diff changeset
3 * @ingroup gtkui
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9841
diff changeset
4 *
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 * gaim
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * source distribution.
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * (at your option) any later version.
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 */
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26 # include <config.h>
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27 #endif
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29 #include "debug.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30 #include "internal.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
31 #include "pluginpref.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32 #include "prefs.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
34 #include "gtkimhtml.h"
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35 #include "gtkpluginpref.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36 #include "gtkprefs.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
37 #include "gtkutils.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
39 static gboolean
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
40 entry_cb(GtkWidget *entry, gpointer data) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
41 char *pref = data;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
42
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
43 gaim_prefs_set_string(pref, gtk_entry_get_text(GTK_ENTRY(entry)));
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
44
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
45 return FALSE;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
46 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
47
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
48
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
49 static void
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
50 imhtml_cb(GtkTextBuffer *buffer, gpointer data)
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
51 {
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
52 char *pref;
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
53 char *text;
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
54 GtkIMHtml *imhtml = data;
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
55
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
56 pref = g_object_get_data(G_OBJECT(imhtml), "pref-key");
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
57 g_return_if_fail(pref);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
58
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
59 text = gtk_imhtml_get_markup(imhtml);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
60
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
61 if (!text)
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
62 text = "";
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
63 gaim_prefs_set_string(pref, text);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
64 g_free(text);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
65 }
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
66
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67 static void
12794
4e3dde2b2641 [gaim-migrate @ 15141]
Richard Laager <rlaager@wiktel.com>
parents: 12712
diff changeset
68 imhtml_format_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, gpointer data)
4e3dde2b2641 [gaim-migrate @ 15141]
Richard Laager <rlaager@wiktel.com>
parents: 12712
diff changeset
69 {
4e3dde2b2641 [gaim-migrate @ 15141]
Richard Laager <rlaager@wiktel.com>
parents: 12712
diff changeset
70 imhtml_cb(gtk_text_view_get_buffer(GTK_TEXT_VIEW(imhtml)), data);
4e3dde2b2641 [gaim-migrate @ 15141]
Richard Laager <rlaager@wiktel.com>
parents: 12712
diff changeset
71 }
4e3dde2b2641 [gaim-migrate @ 15141]
Richard Laager <rlaager@wiktel.com>
parents: 12712
diff changeset
72
4e3dde2b2641 [gaim-migrate @ 15141]
Richard Laager <rlaager@wiktel.com>
parents: 12712
diff changeset
73 static void
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
74 make_string_pref(GtkWidget *parent, GaimPluginPref *pref, GtkSizeGroup *sg) {
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
75 GtkWidget *box, *gtk_label, *entry;
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
76 const gchar *pref_name;
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
77 const gchar *pref_label;
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
78 GaimStringFormatType format;
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80 pref_name = gaim_plugin_pref_get_name(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
81 pref_label = gaim_plugin_pref_get_label(pref);
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
82 format = gaim_plugin_pref_get_format_type(pref);
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
83
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
84 switch(gaim_plugin_pref_get_type(pref)) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85 case GAIM_PLUGIN_PREF_CHOICE:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
86 gtk_label = gaim_gtk_prefs_dropdown_from_list(parent, pref_label,
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
87 GAIM_PREF_STRING, pref_name,
10414
26eac2362c32 [gaim-migrate @ 11664]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
88 gaim_plugin_pref_get_choices(pref));
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89 gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
90
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 if(sg)
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 gtk_size_group_add_widget(sg, gtk_label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
93
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
94 break;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95 case GAIM_PLUGIN_PREF_NONE:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96 default:
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
97 if (format == GAIM_STRING_FORMAT_TYPE_NONE)
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
98 box = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
99 else
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
100 box = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE);
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
101
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
102 gtk_widget_show(box);
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
103 gtk_box_pack_start(GTK_BOX(parent), box, FALSE, FALSE, 0);
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 gtk_label = gtk_label_new_with_mnemonic(pref_label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 gtk_widget_show(gtk_label);
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
108 gtk_box_pack_start(GTK_BOX(box), gtk_label, FALSE, FALSE, 0);
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110 if(sg)
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111 gtk_size_group_add_widget(sg, gtk_label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
113 if (format == GAIM_STRING_FORMAT_TYPE_NONE)
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
114 {
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
115 entry = gtk_entry_new();
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
116 gtk_entry_set_text(GTK_ENTRY(entry), gaim_prefs_get_string(pref_name));
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
117 gtk_entry_set_max_length(GTK_ENTRY(entry),
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 gaim_plugin_pref_get_max_length(pref));
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
119 if (gaim_plugin_pref_get_masked(pref))
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
120 {
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
121 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
122 gtk_entry_set_invisible_char(GTK_ENTRY(entry), GAIM_INVISIBLE_CHAR);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
123 }
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
124 g_signal_connect(G_OBJECT(entry), "changed",
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
125 G_CALLBACK(entry_cb),
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
126 (gpointer)pref_name);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
127 gtk_label_set_mnemonic_widget(GTK_LABEL(gtk_label), entry);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
128 gtk_widget_show(entry);
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
129 gtk_box_pack_start(GTK_BOX(box), entry, FALSE, FALSE, 0);
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
130 }
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
131 else
11986
bfbb1798535e [gaim-migrate @ 14279]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
132 {
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
133 GtkWidget *hbox;
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
134 GtkWidget *spacer;
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
135 GtkWidget *imhtml;
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
136 GtkWidget *toolbar;
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
137 GtkWidget *frame;
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
138
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
139 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
140 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
141 gtk_widget_show(hbox);
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
142
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
143 spacer = gtk_label_new(" ");
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
144 gtk_box_pack_start(GTK_BOX(hbox), spacer, FALSE, FALSE, 0);
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
145 gtk_widget_show(spacer);
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
146
13280
3de53fe8345f [gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents: 13106
diff changeset
147 frame = gaim_gtk_create_imhtml(TRUE, &imhtml, &toolbar, NULL);
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
148 if (!(format & GAIM_STRING_FORMAT_TYPE_HTML))
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
149 gtk_widget_destroy(toolbar);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
150
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
151 gtk_imhtml_append_text(GTK_IMHTML(imhtml), gaim_prefs_get_string(pref_name),
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
152 (format & GAIM_STRING_FORMAT_TYPE_MULTILINE) ? 0 : GTK_IMHTML_NO_NEWLINE);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
153 gtk_label_set_mnemonic_widget(GTK_LABEL(gtk_label), imhtml);
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
154 gtk_widget_show_all(frame);
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
155 g_object_set_data(G_OBJECT(imhtml), "pref-key", (gpointer)pref_name);
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
156 g_signal_connect(G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT_VIEW(imhtml))),
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
157 "changed", G_CALLBACK(imhtml_cb), imhtml);
12794
4e3dde2b2641 [gaim-migrate @ 15141]
Richard Laager <rlaager@wiktel.com>
parents: 12712
diff changeset
158 g_signal_connect(G_OBJECT(imhtml),
4e3dde2b2641 [gaim-migrate @ 15141]
Richard Laager <rlaager@wiktel.com>
parents: 12712
diff changeset
159 "format_function_toggle", G_CALLBACK(imhtml_format_cb), imhtml);
12712
8ae981f2c9cb [gaim-migrate @ 15056]
Richard Laager <rlaager@wiktel.com>
parents: 11986
diff changeset
160 gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, FALSE, 0);
11986
bfbb1798535e [gaim-migrate @ 14279]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
161 }
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 break;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 static void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 make_int_pref(GtkWidget *parent, GaimPluginPref *pref, GtkSizeGroup *sg) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 GtkWidget *gtk_label;
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
170 const gchar *pref_name;
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
171 const gchar *pref_label;
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 gint max, min;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 pref_name = gaim_plugin_pref_get_name(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175 pref_label = gaim_plugin_pref_get_label(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177 switch(gaim_plugin_pref_get_type(pref)) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 case GAIM_PLUGIN_PREF_CHOICE:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 gtk_label = gaim_gtk_prefs_dropdown_from_list(parent, pref_label,
9529
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
180 GAIM_PREF_INT, pref_name, gaim_plugin_pref_get_choices(pref));
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
181 gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183 if(sg)
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
184 gtk_size_group_add_widget(sg, gtk_label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
185
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
186 break;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
187 case GAIM_PLUGIN_PREF_NONE:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
188 default:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
189 gaim_plugin_pref_get_bounds(pref, &min, &max);
10414
26eac2362c32 [gaim-migrate @ 11664]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
190 gaim_gtk_prefs_labeled_spin_button(parent, pref_label,
9529
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
191 pref_name, min, max, sg);
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
192 break;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
193 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
194 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
195
9529
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
196
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
197 static void
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
198 make_info_pref(GtkWidget *parent, GaimPluginPref *pref) {
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
199 GtkWidget *gtk_label = gtk_label_new(gaim_plugin_pref_get_label(pref));
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
200 gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0);
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
201 gtk_label_set_line_wrap(GTK_LABEL(gtk_label), TRUE);
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
202 gtk_box_pack_start(GTK_BOX(parent), gtk_label, FALSE, FALSE, 0);
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
203 gtk_widget_show(gtk_label);
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
204 }
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
205
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
206
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
207 GtkWidget *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
208 gaim_gtk_plugin_pref_create_frame(GaimPluginPrefFrame *frame) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
209 GtkWidget *ret, *parent;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
210 GtkSizeGroup *sg;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
211 GList *pp;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
212
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
213 g_return_val_if_fail(frame, NULL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
214
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
215 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
216
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
217 parent = ret = gtk_vbox_new(FALSE, 16);
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10414
diff changeset
218 gtk_container_set_border_width(GTK_CONTAINER(ret), GAIM_HIG_BORDER);
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
219 gtk_widget_show(ret);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
220
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
221 for(pp = gaim_plugin_pref_frame_get_prefs(frame);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
222 pp != NULL;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
223 pp = pp->next)
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
224 {
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
225 GaimPluginPref *pref = (GaimPluginPref *)pp->data;
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
226
13106
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
227 const char *name = gaim_plugin_pref_get_name(pref);
a0a4b44239e8 [gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents: 12794
diff changeset
228 const char *label = gaim_plugin_pref_get_label(pref);
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
229
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
230 if(name == NULL) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
231 if(label == NULL)
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
232 continue;
9529
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
233
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
234 if(gaim_plugin_pref_get_type(pref) == GAIM_PLUGIN_PREF_INFO) {
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
235 make_info_pref(parent, pref);
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
236 } else {
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
237 parent = gaim_gtk_make_frame(ret, label);
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
238 gtk_widget_show(parent);
803e642650e1 [gaim-migrate @ 10356]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
239 }
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
240
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
241 continue;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
242 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
243
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
244 switch(gaim_prefs_get_type(name)) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
245 case GAIM_PREF_BOOLEAN:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
246 gaim_gtk_prefs_checkbox(label, name, parent);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
247 break;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
248 case GAIM_PREF_INT:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 make_int_pref(parent, pref, sg);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
250 break;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
251 case GAIM_PREF_STRING:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
252 make_string_pref(parent, pref, sg);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
253 break;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
254 default:
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
255 break;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
256 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
257 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
259 return ret;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260 }