2 * Extra conversation placement options for Purple
4 * Pidgin 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
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
25 #include "conversation.h"
27 #include "gtkplugin.h"
29 #include "gtkconvwin.h"
32 conv_placement_by_number(PidginConversation
*conv
)
34 PidginConvWindow
*win
= NULL
;
37 if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate"))
38 win
= PURPLE_IS_IM_CONVERSATION(conv
->active_conv
) ?
39 pidgin_conv_window_last_im() : pidgin_conv_window_last_chat();
40 else if ((wins
= pidgin_conv_windows_get_list()) != NULL
)
41 win
= g_list_last(wins
)->data
;
44 win
= pidgin_conv_window_new();
46 pidgin_conv_window_add_gtkconv(win
, conv
);
47 pidgin_conv_window_show(win
);
49 int max_count
= purple_prefs_get_int("/plugins/gtk/extplacement/placement_number");
50 int count
= pidgin_conv_window_get_gtkconv_count(win
);
52 if (count
< max_count
)
53 pidgin_conv_window_add_gtkconv(win
, conv
);
57 for (l
= pidgin_conv_windows_get_list(); l
!= NULL
; l
= l
->next
) {
60 if (!conv
|| !conv
->active_conv
||
61 !G_TYPE_FROM_INSTANCE(conv
->active_conv
))
67 if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") &&
68 G_TYPE_FROM_INSTANCE(pidgin_conv_window_get_active_conversation(win
)) != G_TYPE_FROM_INSTANCE(conv
->active_conv
))
71 count
= pidgin_conv_window_get_gtkconv_count(win
);
72 if (count
< max_count
) {
73 pidgin_conv_window_add_gtkconv(win
, conv
);
77 win
= pidgin_conv_window_new();
79 pidgin_conv_window_add_gtkconv(win
, conv
);
80 pidgin_conv_window_show(win
);
85 static PurplePluginPrefFrame
*
86 get_plugin_pref_frame(PurplePlugin
*plugin
) {
87 PurplePluginPrefFrame
*frame
;
88 PurplePluginPref
*ppref
;
90 frame
= purple_plugin_pref_frame_new();
92 ppref
= purple_plugin_pref_new_with_label(_("Conversation Placement"));
93 purple_plugin_pref_frame_add(frame
, ppref
);
95 /* Translators: "New conversations" should match the text in the preferences dialog and "By conversation count" should be the same text used above */
96 ppref
= purple_plugin_pref_new_with_label(_("Note: The preference for \"New conversations\" must be set to \"By conversation count\"."));
97 purple_plugin_pref_set_pref_type(ppref
, PURPLE_PLUGIN_PREF_INFO
);
98 purple_plugin_pref_frame_add(frame
, ppref
);
100 ppref
= purple_plugin_pref_new_with_name_and_label(
101 "/plugins/gtk/extplacement/placement_number",
102 _("Number of conversations per window"));
103 purple_plugin_pref_set_bounds(ppref
, 1, 50);
104 purple_plugin_pref_frame_add(frame
, ppref
);
106 ppref
= purple_plugin_pref_new_with_name_and_label(
107 "/plugins/gtk/extplacement/placement_number_separate",
108 _("Separate IM and Chat windows when placing by number"));
109 purple_plugin_pref_frame_add(frame
, ppref
);
114 static PidginPluginInfo
*
115 plugin_query(GError
**error
)
117 const gchar
* const authors
[] = {
118 "Stu Tomlinson <stu@nosnilmot.com>",
122 return pidgin_plugin_info_new(
123 "id", "gtk-extplacement",
124 "name", N_("ExtPlacement"),
125 "version", DISPLAY_VERSION
,
126 "category", N_("User interface"),
127 "summary", N_("Extra conversation placement options."),
128 "description", N_("Restrict the number of conversations per "
129 "windows, optionally separating IMs and "
132 "website", PURPLE_WEBSITE
,
133 "abi-version", PURPLE_ABI_VERSION
,
134 "pref-frame-cb", get_plugin_pref_frame
,
140 plugin_load(PurplePlugin
*plugin
, GError
**error
)
142 purple_prefs_add_none("/plugins/gtk/extplacement");
143 purple_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4);
144 purple_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE
);
146 pidgin_conv_placement_add_fnc("number", _("By conversation count"),
147 &conv_placement_by_number
);
148 purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT
"/conversations/placement");
153 plugin_unload(PurplePlugin
*plugin
, GError
**error
)
155 pidgin_conv_placement_remove_fnc("number");
156 purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT
"/conversations/placement");
160 PURPLE_PLUGIN_INIT(extplacement
, plugin_query
, plugin_load
, plugin_unload
);