Thu, 20 Sep 2018 20:59:22 -0500
Use the correct buffers for multiline/html
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* pidgin |
| 8713 | 2 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
3 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8713 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16254
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8713 | 20 | */ |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
21 | #include <talkatu.h> |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
22 | |
| 8713 | 23 | #ifdef HAVE_CONFIG_H |
| 24 | # include <config.h> | |
| 25 | #endif | |
| 26 | ||
| 27 | #include "debug.h" | |
| 28 | #include "internal.h" | |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
29 | #include "pidgin.h" |
| 8713 | 30 | #include "pluginpref.h" |
| 31 | #include "prefs.h" | |
| 32 | ||
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
33 | #include "gtk3compat.h" |
| 8713 | 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 | ||
| 15884 | 42 | purple_prefs_set_string(pref, gtk_entry_get_text(GTK_ENTRY(entry))); |
| 8713 | 43 | |
| 44 | return FALSE; | |
| 45 | } | |
| 46 | ||
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
47 | |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
48 | static void |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
49 | multiline_cb(GtkWidget *view, gpointer data) { |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
50 | GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
51 | gchar *pref = NULL, *text = NULL; |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
52 | |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
53 | pref = g_object_get_data(G_OBJECT(view), "pref-key"); |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
54 | g_return_if_fail(pref); |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
55 | |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
56 | text = talkatu_markup_get_html(buffer, NULL); |
| 15884 | 57 | purple_prefs_set_string(pref, text); |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
58 | g_free(text); |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
59 | } |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
60 | |
| 8713 | 61 | static void |
| 15884 | 62 | make_string_pref(GtkWidget *parent, PurplePluginPref *pref, GtkSizeGroup *sg) { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
63 | GtkWidget *box, *gtk_label, *entry; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
64 | const gchar *pref_name; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
65 | const gchar *pref_label; |
| 15884 | 66 | PurpleStringFormatType format; |
| 8713 | 67 | |
| 15884 | 68 | pref_name = purple_plugin_pref_get_name(pref); |
| 69 | pref_label = purple_plugin_pref_get_label(pref); | |
| 70 | format = purple_plugin_pref_get_format_type(pref); | |
| 8713 | 71 | |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
34274
diff
changeset
|
72 | switch(purple_plugin_pref_get_pref_type(pref)) { |
| 15884 | 73 | case PURPLE_PLUGIN_PREF_CHOICE: |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
74 | gtk_label = pidgin_prefs_dropdown_from_list(parent, pref_label, |
| 15884 | 75 | PURPLE_PREF_STRING, pref_name, |
| 76 | purple_plugin_pref_get_choices(pref)); | |
|
38007
3b971d2ecae1
Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37990
diff
changeset
|
77 | gtk_label_set_xalign(GTK_LABEL(gtk_label), 0); |
| 8713 | 78 | |
| 79 | if(sg) | |
| 80 | gtk_size_group_add_widget(sg, gtk_label); | |
| 81 | ||
| 82 | break; | |
| 15884 | 83 | case PURPLE_PLUGIN_PREF_NONE: |
| 8713 | 84 | default: |
| 15884 | 85 | if (format == PURPLE_STRING_FORMAT_TYPE_NONE) |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25457
diff
changeset
|
86 | { |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
87 | entry = gtk_entry_new(); |
| 15884 | 88 | gtk_entry_set_text(GTK_ENTRY(entry), purple_prefs_get_string(pref_name)); |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
89 | gtk_entry_set_max_length(GTK_ENTRY(entry), |
| 15884 | 90 | purple_plugin_pref_get_max_length(pref)); |
| 91 | if (purple_plugin_pref_get_masked(pref)) | |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
92 | { |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
93 | gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
94 | } |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
95 | g_signal_connect(G_OBJECT(entry), "changed", |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
96 | G_CALLBACK(entry_cb), |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
97 | (gpointer)pref_name); |
|
22139
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
98 | pidgin_add_widget_to_vbox(GTK_BOX(parent), pref_label, sg, entry, TRUE, NULL); |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
99 | } |
|
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
100 | else |
|
11986
21d2ab6421a7
[gaim-migrate @ 14279]
Mark Doliner <markdoliner@pidgin.im>
parents:
11243
diff
changeset
|
101 | { |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
102 | GtkWidget *hbox; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
103 | GtkWidget *spacer; |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
104 | GtkWidget *editor; |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
105 | GtkWidget *view; |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
106 | GtkTextBuffer *buffer; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
107 | |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
108 | box = gtk_box_new(GTK_ORIENTATION_VERTICAL, PIDGIN_HIG_BOX_SPACE); |
|
22139
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
109 | |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
110 | gtk_widget_show(box); |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
111 | gtk_box_pack_start(GTK_BOX(parent), box, FALSE, FALSE, 0); |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
112 | |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
113 | gtk_label = gtk_label_new_with_mnemonic(pref_label); |
|
38007
3b971d2ecae1
Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37990
diff
changeset
|
114 | gtk_label_set_xalign(GTK_LABEL(gtk_label), 0); |
|
22139
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
115 | gtk_widget_show(gtk_label); |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
116 | gtk_box_pack_start(GTK_BOX(box), gtk_label, FALSE, FALSE, 0); |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
117 | |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
118 | if(sg) |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
119 | gtk_size_group_add_widget(sg, gtk_label); |
|
f0f4a10114ea
An additional push from Gabriel's omgp.pidgin.add-widget-util branch.
Ethan Blanton <elb@pidgin.im>
parents:
20289
diff
changeset
|
120 | |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
121 | hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, PIDGIN_HIG_BOX_SPACE); |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
122 | gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
123 | gtk_widget_show(hbox); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
124 | |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
125 | spacer = gtk_label_new(" "); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
126 | gtk_box_pack_start(GTK_BOX(hbox), spacer, FALSE, FALSE, 0); |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
127 | gtk_widget_show(spacer); |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
128 | |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
129 | editor = talkatu_editor_new(); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
130 | view = talkatu_editor_get_view(TALKATU_EDITOR(editor)); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
131 | |
|
34274
9169710b5af5
Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33683
diff
changeset
|
132 | if ((format & PURPLE_STRING_FORMAT_TYPE_HTML) != 0) { |
|
39228
d8b87c16c8a6
Use the correct buffers for multiline/html
Gary Kramlich <grim@reaperworld.com>
parents:
39227
diff
changeset
|
133 | buffer = talkatu_html_buffer_new(); |
|
34274
9169710b5af5
Hide GtkWebViewToolbar stuff within the GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33683
diff
changeset
|
134 | } else { |
|
39228
d8b87c16c8a6
Use the correct buffers for multiline/html
Gary Kramlich <grim@reaperworld.com>
parents:
39227
diff
changeset
|
135 | buffer = talkatu_buffer_new(NULL); |
|
33252
abcaf61b570d
Disable formatting if the pluginpref doesn't allow HTML.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33199
diff
changeset
|
136 | } |
|
12712
21ea46d3dee9
[gaim-migrate @ 15056]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11986
diff
changeset
|
137 | |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
138 | gtk_text_view_set_buffer(GTK_TEXT_VIEW(view), buffer); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
139 | |
|
33199
e82a9f0fa7ec
Convert plugin prefs to GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
140 | if (format & PURPLE_STRING_FORMAT_TYPE_MULTILINE) { |
|
e82a9f0fa7ec
Convert plugin prefs to GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
141 | gchar *tmp = purple_strreplace(purple_prefs_get_string(pref_name), "\n", "<br>"); |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
142 | talkatu_markup_set_html(TALKATU_BUFFER(buffer), tmp, -1); |
|
33199
e82a9f0fa7ec
Convert plugin prefs to GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
143 | g_free(tmp); |
|
39227
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
144 | } else { |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
145 | talkatu_markup_set_html(TALKATU_BUFFER(buffer), purple_prefs_get_string(pref_name), -1); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
146 | } |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
147 | |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
148 | gtk_label_set_mnemonic_widget(GTK_LABEL(gtk_label), view); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
149 | gtk_widget_show_all(editor); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
150 | g_object_set_data(G_OBJECT(view), "pref-key", (gpointer)pref_name); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
151 | g_signal_connect(G_OBJECT(view), "changed", |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
152 | G_CALLBACK(multiline_cb), NULL); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
153 | g_signal_connect(G_OBJECT(view), "format-toggled", |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
154 | G_CALLBACK(multiline_cb), NULL); |
|
291b3c800668
Move GtkPluginPref to use Talkatu instead of Webkit
Gary Kramlich <grim@reaperworld.com>
parents:
38007
diff
changeset
|
155 | gtk_box_pack_start(GTK_BOX(hbox), editor, TRUE, TRUE, 0); |
|
11986
21d2ab6421a7
[gaim-migrate @ 14279]
Mark Doliner <markdoliner@pidgin.im>
parents:
11243
diff
changeset
|
156 | } |
| 8713 | 157 | |
| 158 | break; | |
| 159 | } | |
| 160 | } | |
| 161 | ||
| 162 | static void | |
| 15884 | 163 | make_int_pref(GtkWidget *parent, PurplePluginPref *pref, GtkSizeGroup *sg) { |
| 8713 | 164 | GtkWidget *gtk_label; |
|
13107
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
165 | const gchar *pref_name; |
|
704041197f4d
[gaim-migrate @ 15468]
Richard Laager <rlaager@pidgin.im>
parents:
12794
diff
changeset
|
166 | const gchar *pref_label; |
| 8713 | 167 | gint max, min; |
| 168 | ||
| 15884 | 169 | pref_name = purple_plugin_pref_get_name(pref); |
| 170 | pref_label = purple_plugin_pref_get_label(pref); | |
| 8713 | 171 | |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
34274
diff
changeset
|
172 | switch(purple_plugin_pref_get_pref_type(pref)) { |
| 15884 | 173 | case PURPLE_PLUGIN_PREF_CHOICE: |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
174 | gtk_label = pidgin_prefs_dropdown_from_list(parent, pref_label, |
| 15884 | 175 | PURPLE_PREF_INT, pref_name, purple_plugin_pref_get_choices(pref)); |
|
38007
3b971d2ecae1
Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37990
diff
changeset
|
176 | gtk_label_set_xalign(GTK_LABEL(gtk_label), 0); |
| 8713 | 177 | |
| 178 | if(sg) | |
| 179 | gtk_size_group_add_widget(sg, gtk_label); | |
| 180 | ||
| 181 | break; | |
| 15884 | 182 | case PURPLE_PLUGIN_PREF_NONE: |
| 8713 | 183 | default: |
| 15884 | 184 | purple_plugin_pref_get_bounds(pref, &min, &max); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
185 | pidgin_prefs_labeled_spin_button(parent, pref_label, |
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
186 | pref_name, min, max, sg); |
| 8713 | 187 | break; |
| 188 | } | |
| 189 | } | |
| 190 | ||
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
191 | |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
192 | static void |
| 15884 | 193 | make_info_pref(GtkWidget *parent, PurplePluginPref *pref) { |
| 194 | GtkWidget *gtk_label = gtk_label_new(purple_plugin_pref_get_label(pref)); | |
|
38007
3b971d2ecae1
Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37990
diff
changeset
|
195 | gtk_label_set_xalign(GTK_LABEL(gtk_label), 0); |
|
3b971d2ecae1
Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37990
diff
changeset
|
196 | gtk_label_set_yalign(GTK_LABEL(gtk_label), 0); |
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
197 | gtk_label_set_line_wrap(GTK_LABEL(gtk_label), TRUE); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
198 | gtk_box_pack_start(GTK_BOX(parent), gtk_label, FALSE, FALSE, 0); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
199 | gtk_widget_show(gtk_label); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
200 | } |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
201 | |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
202 | |
| 8713 | 203 | GtkWidget * |
| 15884 | 204 | pidgin_plugin_pref_create_frame(PurplePluginPrefFrame *frame) { |
| 8713 | 205 | GtkWidget *ret, *parent; |
| 206 | GtkSizeGroup *sg; | |
| 207 | GList *pp; | |
| 208 | ||
| 209 | g_return_val_if_fail(frame, NULL); | |
| 210 | ||
| 211 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 212 | ||
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
213 | parent = ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 16); |
| 8713 | 214 | gtk_widget_show(ret); |
| 215 | ||
| 15884 | 216 | for(pp = purple_plugin_pref_frame_get_prefs(frame); |
| 8713 | 217 | pp != NULL; |
| 218 | pp = pp->next) | |
| 219 | { | |
| 15884 | 220 | PurplePluginPref *pref = (PurplePluginPref *)pp->data; |
| 8713 | 221 | |
| 15884 | 222 | const char *name = purple_plugin_pref_get_name(pref); |
| 223 | const char *label = purple_plugin_pref_get_label(pref); | |
| 8713 | 224 | |
| 225 | if(name == NULL) { | |
| 226 | if(label == NULL) | |
| 227 | continue; | |
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
228 | |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
34274
diff
changeset
|
229 | if(purple_plugin_pref_get_pref_type(pref) == PURPLE_PLUGIN_PREF_INFO) { |
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
230 | make_info_pref(parent, pref); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
231 | } else { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
232 | parent = pidgin_make_frame(ret, label); |
|
9529
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
233 | gtk_widget_show(parent); |
|
377b70382202
[gaim-migrate @ 10356]
Christopher O'Brien <siege@pidgin.im>
parents:
8713
diff
changeset
|
234 | } |
| 8713 | 235 | |
| 236 | continue; | |
| 237 | } | |
| 238 | ||
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
34274
diff
changeset
|
239 | switch(purple_prefs_get_pref_type(name)) { |
| 15884 | 240 | case PURPLE_PREF_BOOLEAN: |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
241 | pidgin_prefs_checkbox(label, name, parent); |
| 8713 | 242 | break; |
| 15884 | 243 | case PURPLE_PREF_INT: |
| 8713 | 244 | make_int_pref(parent, pref, sg); |
| 245 | break; | |
| 15884 | 246 | case PURPLE_PREF_STRING: |
| 8713 | 247 | make_string_pref(parent, pref, sg); |
| 248 | break; | |
| 249 | default: | |
| 250 | break; | |
| 251 | } | |
| 252 | } | |
| 253 | ||
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
254 | g_object_unref(sg); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20147
diff
changeset
|
255 | |
| 8713 | 256 | return ret; |
| 257 | } |