Fri, 23 Aug 2013 15:07:32 +0530
Merged default branch
| 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 | ||
| 78 | static gboolean | |
| 15884 | 79 | plugin_load(PurplePlugin *plugin) |
| 9157 | 80 | { |
| 15563 | 81 | pidgin_conv_placement_add_fnc("number", _("By conversation count"), |
| 9157 | 82 | &conv_placement_by_number); |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
83 | purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement"); |
| 9157 | 84 | return TRUE; |
| 85 | } | |
| 86 | ||
| 87 | static gboolean | |
| 15884 | 88 | plugin_unload(PurplePlugin *plugin) |
| 9157 | 89 | { |
| 15563 | 90 | pidgin_conv_placement_remove_fnc("number"); |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
91 | purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement"); |
| 9157 | 92 | return TRUE; |
| 93 | } | |
| 94 | ||
| 15884 | 95 | static PurplePluginPrefFrame * |
| 96 | get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 97 | PurplePluginPrefFrame *frame; | |
| 98 | PurplePluginPref *ppref; | |
| 9157 | 99 | |
| 15884 | 100 | frame = purple_plugin_pref_frame_new(); |
| 9157 | 101 | |
| 15884 | 102 | ppref = purple_plugin_pref_new_with_label(_("Conversation Placement")); |
| 103 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9157 | 104 | |
|
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
|
105 | /* 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | |
| 15884 | 110 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 9425 | 111 | "/plugins/gtk/extplacement/placement_number", |
| 112 | _("Number of conversations per window")); | |
| 15884 | 113 | purple_plugin_pref_set_bounds(ppref, 1, 50); |
| 114 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9157 | 115 | |
| 15884 | 116 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 9425 | 117 | "/plugins/gtk/extplacement/placement_number_separate", |
| 118 | _("Separate IM and Chat windows when placing by number")); | |
| 15884 | 119 | purple_plugin_pref_frame_add(frame, ppref); |
| 9425 | 120 | |
| 9157 | 121 | return frame; |
| 122 | } | |
| 123 | ||
| 15884 | 124 | static PurplePluginUiInfo prefs_info = { |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12168
diff
changeset
|
125 | get_plugin_pref_frame, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12168
diff
changeset
|
126 | 0, /* page_num (Reserved) */ |
|
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
|
127 | NULL, /* frame (Reserved) */ |
|
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
|
128 | |
|
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
|
129 | /* padding */ |
|
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
|
130 | NULL, |
|
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
|
131 | NULL, |
|
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
|
132 | NULL, |
|
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
|
133 | NULL |
| 9157 | 134 | }; |
| 135 | ||
| 15884 | 136 | static PurplePluginInfo info = |
| 9157 | 137 | { |
| 15884 | 138 | PURPLE_PLUGIN_MAGIC, |
| 139 | PURPLE_MAJOR_VERSION, | |
| 140 | PURPLE_MINOR_VERSION, | |
| 141 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 16133 | 142 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
| 9157 | 143 | 0, /**< flags */ |
| 144 | NULL, /**< dependencies */ | |
| 16133 | 145 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 9179 | 146 | "gtk-extplacement", /**< id */ |
| 9157 | 147 | N_("ExtPlacement"), /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
148 | DISPLAY_VERSION, /**< version */ |
| 9179 | 149 | N_("Extra conversation placement options."), /**< summary */ |
| 9157 | 150 | /** description */ |
| 9425 | 151 | N_("Restrict the number of conversations per windows," |
| 152 | " optionally separating IMs and Chats"), | |
| 9157 | 153 | "Stu Tomlinson <stu@nosnilmot.com>", /**< author */ |
| 15884 | 154 | PURPLE_WEBSITE, /**< homepage */ |
| 9157 | 155 | plugin_load, /**< load */ |
| 156 | plugin_unload, /**< unload */ | |
| 157 | NULL, /**< destroy */ | |
| 158 | NULL, /**< ui_info */ | |
| 159 | NULL, /**< extra_info */ | |
| 160 | &prefs_info, /**< prefs_info */ | |
|
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
|
161 | NULL, /**< actions */ |
|
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
|
162 | |
|
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
|
163 | /* padding */ |
|
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
|
164 | NULL, |
|
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
|
165 | NULL, |
|
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
|
166 | NULL, |
|
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
|
167 | NULL |
| 9157 | 168 | }; |
| 169 | ||
| 170 | static void | |
| 15884 | 171 | init_plugin(PurplePlugin *plugin) |
| 9157 | 172 | { |
| 15884 | 173 | purple_prefs_add_none("/plugins/gtk/extplacement"); |
| 174 | purple_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4); | |
| 175 | purple_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE); | |
| 9157 | 176 | } |
| 177 | ||
| 15884 | 178 | PURPLE_INIT_PLUGIN(extplacement, init_plugin, info) |