Thu, 24 Oct 2013 04:21:28 +0530
Merged soc.2013.gobjectification branch.
Added ui_data to PurplePluginInfo, as well as purple_plugin_info_[gs]et_ui_data functions.
| 9179 | 1 | /* |
| 15884 | 2 | * Extra conversation placement options for Purple |
| 9179 | 3 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 9179 | 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 | |
| 9 | * modify it under the terms of the GNU General Public License | |
| 10 | * as published by the Free Software Foundation; either version 2 | |
| 11 | * of the License, or (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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17022
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. |
| 9179 | 21 | */ |
| 22 | ||
| 9157 | 23 | #include "internal.h" |
| 15577 | 24 | #include "pidgin.h" |
| 9157 | 25 | #include "conversation.h" |
| 9943 | 26 | #include "version.h" |
| 9215 | 27 | #include "gtkplugin.h" |
| 11581 | 28 | #include "gtkconv.h" |
| 29 | #include "gtkconvwin.h" | |
| 9157 | 30 | |
| 31 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
32 | conv_placement_by_number(PidginConversation *conv) |
| 9157 | 33 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
34 | PidginWindow *win = NULL; |
|
12168
f1cb35825de9
[gaim-migrate @ 14469]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11581
diff
changeset
|
35 | GList *wins = NULL; |
| 9157 | 36 | |
| 15884 | 37 | if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate")) |
|
34659
4fc616843cb2
Removed conversation type argument from pidgin conversation functions.
Ankit Vani <a@nevitus.org>
parents:
20288
diff
changeset
|
38 | win = PURPLE_IS_IM_CONVERSATION(conv->active_conv) ? |
|
4fc616843cb2
Removed conversation type argument from pidgin conversation functions.
Ankit Vani <a@nevitus.org>
parents:
20288
diff
changeset
|
39 | pidgin_conv_window_last_im() : pidgin_conv_window_last_chat(); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
40 | else if ((wins = pidgin_conv_windows_get_list()) != NULL) |
|
12168
f1cb35825de9
[gaim-migrate @ 14469]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11581
diff
changeset
|
41 | win = g_list_last(wins)->data; |
| 9157 | 42 | |
| 43 | if (win == NULL) { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
44 | win = pidgin_conv_window_new(); |
| 9157 | 45 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
46 | pidgin_conv_window_add_gtkconv(win, conv); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
47 | pidgin_conv_window_show(win); |
| 9157 | 48 | } else { |
| 15884 | 49 | int max_count = purple_prefs_get_int("/plugins/gtk/extplacement/placement_number"); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
50 | int count = pidgin_conv_window_get_gtkconv_count(win); |
| 9157 | 51 | |
| 52 | if (count < max_count) | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
53 | pidgin_conv_window_add_gtkconv(win, conv); |
| 9157 | 54 | else { |
| 55 | GList *l = NULL; | |
| 56 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
57 | for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) { |
| 11581 | 58 | win = l->data; |
| 9157 | 59 | |
| 15884 | 60 | if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") && |
|
34660
68c776e3436e
Refactored pidgin plugins to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34659
diff
changeset
|
61 | PURPLE_IS_IM_CONVERSATION(pidgin_conv_window_get_active_conversation(win)) != PURPLE_IS_IM_CONVERSATION(conv->active_conv)) |
| 9425 | 62 | continue; |
| 63 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
64 | count = pidgin_conv_window_get_gtkconv_count(win); |
| 9157 | 65 | if (count < max_count) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
66 | pidgin_conv_window_add_gtkconv(win, conv); |
| 9157 | 67 | return; |
| 68 | } | |
| 69 | } | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
70 | win = pidgin_conv_window_new(); |
| 9157 | 71 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
72 | pidgin_conv_window_add_gtkconv(win, conv); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
73 | pidgin_conv_window_show(win); |
| 9157 | 74 | } |
| 75 | } | |
| 76 | } | |
| 77 | ||
| 15884 | 78 | static PurplePluginPrefFrame * |
| 79 | get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 80 | PurplePluginPrefFrame *frame; | |
| 81 | PurplePluginPref *ppref; | |
| 9157 | 82 | |
| 15884 | 83 | frame = purple_plugin_pref_frame_new(); |
| 9157 | 84 | |
| 15884 | 85 | ppref = purple_plugin_pref_new_with_label(_("Conversation Placement")); |
| 86 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9157 | 87 | |
|
17022
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
88 | /* Translators: "New conversations" should match the text in the preferences dialog and "By conversation count" should be the same text used above */ |
|
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
89 | ppref = purple_plugin_pref_new_with_label(_("Note: The preference for \"New conversations\" must be set to \"By conversation count\".")); |
|
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
90 | purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_INFO); |
|
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
91 | purple_plugin_pref_frame_add(frame, ppref); |
|
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
92 | |
| 15884 | 93 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 9425 | 94 | "/plugins/gtk/extplacement/placement_number", |
| 95 | _("Number of conversations per window")); | |
| 15884 | 96 | purple_plugin_pref_set_bounds(ppref, 1, 50); |
| 97 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9157 | 98 | |
| 15884 | 99 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 9425 | 100 | "/plugins/gtk/extplacement/placement_number_separate", |
| 101 | _("Separate IM and Chat windows when placing by number")); | |
| 15884 | 102 | purple_plugin_pref_frame_add(frame, ppref); |
| 9425 | 103 | |
| 9157 | 104 | return frame; |
| 105 | } | |
| 106 | ||
|
36757
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
107 | static PidginPluginInfo * |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
108 | plugin_query(GError **error) |
| 9157 | 109 | { |
|
36757
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
110 | const gchar * const authors[] = { |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
111 | "Stu Tomlinson <stu@nosnilmot.com>", |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
112 | NULL |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
113 | }; |
|
16749
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
114 | |
|
36757
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
115 | return pidgin_plugin_info_new( |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
116 | "id", "gtk-extplacement", |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
117 | "name", N_("ExtPlacement"), |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
118 | "version", DISPLAY_VERSION, |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
119 | "category", N_("User interface"), |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
120 | "summary", N_("Extra conversation placement options."), |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
121 | "description", N_("Restrict the number of conversations per " |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
122 | "windows, optionally separating IMs and " |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
123 | "Chats"), |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
124 | "authors", authors, |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
125 | "website", PURPLE_WEBSITE, |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
126 | "abi-version", PURPLE_ABI_VERSION, |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
127 | "preferences-frame", get_plugin_pref_frame, |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
128 | NULL |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
129 | ); |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
130 | } |
| 9157 | 131 | |
|
36757
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
132 | static gboolean |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
133 | plugin_load(PurplePlugin *plugin, GError **error) |
| 9157 | 134 | { |
| 15884 | 135 | purple_prefs_add_none("/plugins/gtk/extplacement"); |
| 136 | purple_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4); | |
| 137 | purple_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE); | |
|
36757
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
138 | |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
139 | pidgin_conv_placement_add_fnc("number", _("By conversation count"), |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
140 | &conv_placement_by_number); |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
141 | purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement"); |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
142 | return TRUE; |
| 9157 | 143 | } |
| 144 | ||
|
36757
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
145 | static gboolean |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
146 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
147 | { |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
148 | pidgin_conv_placement_remove_fnc("number"); |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
149 | purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement"); |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
150 | return TRUE; |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
151 | } |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
152 | |
|
2e04586cf6e8
Refactored some pidgin plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34660
diff
changeset
|
153 | PURPLE_PLUGIN_INIT(extplacement, plugin_query, plugin_load, plugin_unload); |