Mercurial > pidgin.yaz
comparison src/gtkpluginpref.c @ 8713:7024b595b6ae
[gaim-migrate @ 9467]
" Expansion from my original protocol prefs to plugin prefs.
Things are handled a bit different in this iteration of
it, but I have already modified msn and jabber to use
it, and included an example plugin to show how to use
it. It will also generate pages with doxygen. The
example plugin doesn't not contain any translatable
strings seeing as we're in the string freeze. And it's
an example, whats the point of translating it..?
Also, I tweaked the documentation for 2 functions in
gtkprefs, gaim_gtk_prefs_dropdown and
gaim_gtk_prefs_dropdown_from_list. Nothing major in
that, just made it say that the list should be a list
of pairs label/value.
Also there's 5 new files that will need to be added to cvs:
src/pluginpref.h
src/pluginpref.c
src/gtkpluginpref.h
src/gtkpluginpref.c
plugins/pluginpref_example.c
the tarball already has them structured correctly and
contains the diff" --Gary Kramlich - amc_grim
and the german translator pointed out that sean missed the novell file for POTFILES.in
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 19 Apr 2004 21:12:45 +0000 |
parents | |
children | 803e642650e1 |
comparison
equal
deleted
inserted
replaced
8712:a4ff6e79c5fc | 8713:7024b595b6ae |
---|---|
1 /** | |
2 * gaim | |
3 * | |
4 * Gaim is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
22 #ifdef HAVE_CONFIG_H | |
23 # include <config.h> | |
24 #endif | |
25 | |
26 #include <glib.h> | |
27 #include <gtk/gtk.h> | |
28 | |
29 #include "debug.h" | |
30 #include "internal.h" | |
31 #include "pluginpref.h" | |
32 #include "prefs.h" | |
33 | |
34 #include "gtkpluginpref.h" | |
35 #include "gtkprefs.h" | |
36 #include "gtkutils.h" | |
37 | |
38 static gboolean | |
39 entry_cb(GtkWidget *entry, gpointer data) { | |
40 char *pref = data; | |
41 | |
42 gaim_prefs_set_string(pref, gtk_entry_get_text(GTK_ENTRY(entry))); | |
43 | |
44 return FALSE; | |
45 } | |
46 | |
47 static void | |
48 make_string_pref(GtkWidget *parent, GaimPluginPref *pref, GtkSizeGroup *sg) { | |
49 GtkWidget *hbox, *gtk_label, *entry; | |
50 gchar *pref_name, *pref_label; | |
51 | |
52 pref_name = gaim_plugin_pref_get_name(pref); | |
53 pref_label = gaim_plugin_pref_get_label(pref); | |
54 | |
55 switch(gaim_plugin_pref_get_type(pref)) { | |
56 case GAIM_PLUGIN_PREF_CHOICE: | |
57 gtk_label = gaim_gtk_prefs_dropdown_from_list(parent, pref_label, | |
58 GAIM_PREF_STRING, pref_name, | |
59 gaim_plugin_pref_get_choices(pref)); | |
60 gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5); | |
61 | |
62 if(sg) | |
63 gtk_size_group_add_widget(sg, gtk_label); | |
64 | |
65 break; | |
66 case GAIM_PLUGIN_PREF_NONE: | |
67 default: | |
68 hbox = gtk_hbox_new(FALSE, 6); | |
69 gtk_widget_show(hbox); | |
70 gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0); | |
71 | |
72 gtk_label = gtk_label_new_with_mnemonic(pref_label); | |
73 gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5); | |
74 gtk_widget_show(gtk_label); | |
75 gtk_box_pack_start(GTK_BOX(hbox), gtk_label, FALSE, FALSE, 0); | |
76 | |
77 if(sg) | |
78 gtk_size_group_add_widget(sg, gtk_label); | |
79 | |
80 entry = gtk_entry_new(); | |
81 gtk_entry_set_text(GTK_ENTRY(entry), gaim_prefs_get_string(pref_name)); | |
82 gtk_entry_set_max_length(GTK_ENTRY(entry), | |
83 gaim_plugin_pref_get_max_length(pref)); | |
84 g_signal_connect(G_OBJECT(entry), "changed", | |
85 G_CALLBACK(entry_cb), | |
86 (gpointer)pref_name); | |
87 gtk_label_set_mnemonic_widget(GTK_LABEL(gtk_label), entry); | |
88 gtk_widget_show(entry); | |
89 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
90 | |
91 break; | |
92 } | |
93 } | |
94 | |
95 static void | |
96 make_int_pref(GtkWidget *parent, GaimPluginPref *pref, GtkSizeGroup *sg) { | |
97 GtkWidget *gtk_label; | |
98 gchar *pref_name, *pref_label; | |
99 gint max, min; | |
100 | |
101 pref_name = gaim_plugin_pref_get_name(pref); | |
102 pref_label = gaim_plugin_pref_get_label(pref); | |
103 | |
104 switch(gaim_plugin_pref_get_type(pref)) { | |
105 case GAIM_PLUGIN_PREF_CHOICE: | |
106 gtk_label = gaim_gtk_prefs_dropdown_from_list(parent, pref_label, | |
107 GAIM_PREF_INT, pref_name, | |
108 gaim_plugin_pref_get_choices(pref)); | |
109 gtk_misc_set_alignment(GTK_MISC(gtk_label), 0, 0.5); | |
110 | |
111 if(sg) | |
112 gtk_size_group_add_widget(sg, gtk_label); | |
113 | |
114 break; | |
115 case GAIM_PLUGIN_PREF_NONE: | |
116 default: | |
117 gaim_plugin_pref_get_bounds(pref, &min, &max); | |
118 gaim_gtk_prefs_labeled_spin_button(parent, pref_label, | |
119 pref_name, min, max, sg); | |
120 break; | |
121 } | |
122 } | |
123 | |
124 GtkWidget * | |
125 gaim_gtk_plugin_pref_create_frame(GaimPluginPrefFrame *frame) { | |
126 GaimPluginPref *pref; | |
127 GtkWidget *ret, *parent; | |
128 GtkSizeGroup *sg; | |
129 GList *pp; | |
130 gchar *name, *label; | |
131 | |
132 g_return_val_if_fail(frame, NULL); | |
133 | |
134 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
135 | |
136 parent = ret = gtk_vbox_new(FALSE, 16); | |
137 gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
138 gtk_widget_show(ret); | |
139 | |
140 for(pp = gaim_plugin_pref_frame_get_prefs(frame); | |
141 pp != NULL; | |
142 pp = pp->next) | |
143 { | |
144 pref = (GaimPluginPref *)pp->data; | |
145 | |
146 name = gaim_plugin_pref_get_name(pref); | |
147 label = gaim_plugin_pref_get_label(pref); | |
148 | |
149 if(name == NULL) { | |
150 if(label == NULL) | |
151 continue; | |
152 | |
153 parent = gaim_gtk_make_frame(ret, label); | |
154 gtk_widget_show(parent); | |
155 | |
156 continue; | |
157 } | |
158 | |
159 switch(gaim_prefs_get_type(name)) { | |
160 case GAIM_PREF_BOOLEAN: | |
161 gaim_gtk_prefs_checkbox(label, name, parent); | |
162 break; | |
163 case GAIM_PREF_INT: | |
164 make_int_pref(parent, pref, sg); | |
165 break; | |
166 case GAIM_PREF_STRING: | |
167 make_string_pref(parent, pref, sg); | |
168 break; | |
169 default: | |
170 break; | |
171 } | |
172 } | |
173 | |
174 return ret; | |
175 } |