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 PidginWindow
*win
= NULL
;
37 if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate"))
38 win
= pidgin_conv_window_last_with_type(purple_conversation_get_type(conv
->active_conv
));
39 else if ((wins
= pidgin_conv_windows_get_list()) != NULL
)
40 win
= g_list_last(wins
)->data
;
43 win
= pidgin_conv_window_new();
45 pidgin_conv_window_add_gtkconv(win
, conv
);
46 pidgin_conv_window_show(win
);
48 int max_count
= purple_prefs_get_int("/plugins/gtk/extplacement/placement_number");
49 int count
= pidgin_conv_window_get_gtkconv_count(win
);
51 if (count
< max_count
)
52 pidgin_conv_window_add_gtkconv(win
, conv
);
56 for (l
= pidgin_conv_windows_get_list(); l
!= NULL
; l
= l
->next
) {
59 if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") &&
60 purple_conversation_get_type(pidgin_conv_window_get_active_conversation(win
)) != purple_conversation_get_type(conv
->active_conv
))
63 count
= pidgin_conv_window_get_gtkconv_count(win
);
64 if (count
< max_count
) {
65 pidgin_conv_window_add_gtkconv(win
, conv
);
69 win
= pidgin_conv_window_new();
71 pidgin_conv_window_add_gtkconv(win
, conv
);
72 pidgin_conv_window_show(win
);
78 plugin_load(PurplePlugin
*plugin
)
80 pidgin_conv_placement_add_fnc("number", _("By conversation count"),
81 &conv_placement_by_number
);
82 purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT
"/conversations/placement");
87 plugin_unload(PurplePlugin
*plugin
)
89 pidgin_conv_placement_remove_fnc("number");
90 purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT
"/conversations/placement");
94 static PurplePluginPrefFrame
*
95 get_plugin_pref_frame(PurplePlugin
*plugin
) {
96 PurplePluginPrefFrame
*frame
;
97 PurplePluginPref
*ppref
;
99 frame
= purple_plugin_pref_frame_new();
101 ppref
= purple_plugin_pref_new_with_label(_("Conversation Placement"));
102 purple_plugin_pref_frame_add(frame
, ppref
);
104 /* Translators: "New conversations" should match the text in the preferences dialog and "By conversation count" should be the same text used above */
105 ppref
= purple_plugin_pref_new_with_label(_("Note: The preference for \"New conversations\" must be set to \"By conversation count\"."));
106 purple_plugin_pref_set_type(ppref
, PURPLE_PLUGIN_PREF_INFO
);
107 purple_plugin_pref_frame_add(frame
, ppref
);
109 ppref
= purple_plugin_pref_new_with_name_and_label(
110 "/plugins/gtk/extplacement/placement_number",
111 _("Number of conversations per window"));
112 purple_plugin_pref_set_bounds(ppref
, 1, 50);
113 purple_plugin_pref_frame_add(frame
, ppref
);
115 ppref
= purple_plugin_pref_new_with_name_and_label(
116 "/plugins/gtk/extplacement/placement_number_separate",
117 _("Separate IM and Chat windows when placing by number"));
118 purple_plugin_pref_frame_add(frame
, ppref
);
123 static PurplePluginUiInfo prefs_info
= {
124 get_plugin_pref_frame
,
125 0, /* page_num (Reserved) */
126 NULL
, /* frame (Reserved) */
135 static PurplePluginInfo info
=
138 PURPLE_MAJOR_VERSION
,
139 PURPLE_MINOR_VERSION
,
140 PURPLE_PLUGIN_STANDARD
, /**< type */
141 PIDGIN_PLUGIN_TYPE
, /**< ui_requirement */
143 NULL
, /**< dependencies */
144 PURPLE_PRIORITY_DEFAULT
, /**< priority */
145 "gtk-extplacement", /**< id */
146 N_("ExtPlacement"), /**< name */
147 DISPLAY_VERSION
, /**< version */
148 N_("Extra conversation placement options."), /**< summary */
150 N_("Restrict the number of conversations per windows,"
151 " optionally separating IMs and Chats"),
152 "Stu Tomlinson <stu@nosnilmot.com>", /**< author */
153 PURPLE_WEBSITE
, /**< homepage */
154 plugin_load
, /**< load */
155 plugin_unload
, /**< unload */
156 NULL
, /**< destroy */
157 NULL
, /**< ui_info */
158 NULL
, /**< extra_info */
159 &prefs_info
, /**< prefs_info */
160 NULL
, /**< actions */
170 init_plugin(PurplePlugin
*plugin
)
172 purple_prefs_add_none("/plugins/gtk/extplacement");
173 purple_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4);
174 purple_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE
);
177 PURPLE_INIT_PLUGIN(extplacement
, init_plugin
, info
)