9179
|
1 /*
|
|
2 * Extra conversation placement options for Gaim
|
|
3 *
|
|
4 * Gaim 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
|
|
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
|
|
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
21 */
|
|
22
|
9157
|
23 #include "internal.h"
|
|
24 #include "conversation.h"
|
9215
|
25 #include "gtkplugin.h"
|
9157
|
26
|
|
27 static void
|
|
28 conv_placement_by_number(GaimConversation *conv)
|
|
29 {
|
|
30 GaimConvWindow *win = NULL;
|
|
31
|
9425
|
32 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate"))
|
|
33 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv));
|
|
34 else
|
|
35 win = g_list_last(gaim_get_windows())->data;
|
9157
|
36
|
|
37 if (win == NULL) {
|
|
38 win = gaim_conv_window_new();
|
|
39
|
|
40 gaim_conv_window_add_conversation(win, conv);
|
|
41 gaim_conv_window_show(win);
|
|
42 } else {
|
9179
|
43 int max_count = gaim_prefs_get_int("/plugins/gtk/extplacement/placement_number");
|
9157
|
44 int count = gaim_conv_window_get_conversation_count(win);
|
|
45
|
|
46 if (count < max_count)
|
|
47 gaim_conv_window_add_conversation(win, conv);
|
|
48 else {
|
|
49 GList *l = NULL;
|
|
50
|
|
51 for (l = gaim_get_windows(); l != NULL; l = l->next) {
|
|
52 win = (GaimConvWindow *)l->data;
|
|
53
|
9425
|
54 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") &&
|
|
55 gaim_conversation_get_type(gaim_conv_window_get_active_conversation(win)) != gaim_conversation_get_type(conv))
|
|
56 continue;
|
|
57
|
9157
|
58 count = gaim_conv_window_get_conversation_count(win);
|
|
59 if (count < max_count) {
|
|
60 gaim_conv_window_add_conversation(win, conv);
|
|
61 return;
|
|
62 }
|
|
63 }
|
|
64 win = gaim_conv_window_new();
|
|
65
|
|
66 gaim_conv_window_add_conversation(win, conv);
|
|
67 gaim_conv_window_show(win);
|
|
68 }
|
|
69 }
|
|
70 }
|
|
71
|
|
72 static gboolean
|
|
73 plugin_load(GaimPlugin *plugin)
|
|
74 {
|
|
75 gaim_conv_placement_add_fnc("number", _("By conversation count"),
|
|
76 &conv_placement_by_number);
|
9179
|
77 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement");
|
9157
|
78 return TRUE;
|
|
79 }
|
|
80
|
|
81 static gboolean
|
|
82 plugin_unload(GaimPlugin *plugin)
|
|
83 {
|
|
84 gaim_conv_placement_remove_fnc("number");
|
9179
|
85 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement");
|
9157
|
86 return TRUE;
|
|
87 }
|
|
88
|
|
89 static GaimPluginPrefFrame *
|
|
90 get_plugin_pref_frame(GaimPlugin *plugin) {
|
|
91 GaimPluginPrefFrame *frame;
|
|
92 GaimPluginPref *ppref;
|
|
93
|
|
94 frame = gaim_plugin_pref_frame_new();
|
|
95
|
9217
|
96 ppref = gaim_plugin_pref_new_with_label(_("Conversation Placement"));
|
9157
|
97 gaim_plugin_pref_frame_add(frame, ppref);
|
|
98
|
|
99 ppref = gaim_plugin_pref_new_with_name_and_label(
|
9425
|
100 "/plugins/gtk/extplacement/placement_number",
|
|
101 _("Number of conversations per window"));
|
9157
|
102 gaim_plugin_pref_set_bounds(ppref, 1, 50);
|
|
103 gaim_plugin_pref_frame_add(frame, ppref);
|
|
104
|
9425
|
105 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
106 "/plugins/gtk/extplacement/placement_number_separate",
|
|
107 _("Separate IM and Chat windows when placing by number"));
|
|
108 gaim_plugin_pref_frame_add(frame, ppref);
|
|
109
|
9157
|
110 return frame;
|
|
111 }
|
|
112
|
|
113 static GaimPluginUiInfo prefs_info = {
|
|
114 get_plugin_pref_frame
|
|
115 };
|
|
116
|
|
117 static GaimPluginInfo info =
|
|
118 {
|
|
119 GAIM_PLUGIN_API_VERSION, /**< api_version */
|
|
120 GAIM_PLUGIN_STANDARD, /**< type */
|
9179
|
121 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */
|
9157
|
122 0, /**< flags */
|
|
123 NULL, /**< dependencies */
|
|
124 GAIM_PRIORITY_DEFAULT, /**< priority */
|
9179
|
125 "gtk-extplacement", /**< id */
|
9157
|
126 N_("ExtPlacement"), /**< name */
|
|
127 VERSION, /**< version */
|
9179
|
128 N_("Extra conversation placement options."), /**< summary */
|
9157
|
129 /** description */
|
9425
|
130 N_("Restrict the number of conversations per windows,"
|
|
131 " optionally separating IMs and Chats"),
|
9157
|
132 "Stu Tomlinson <stu@nosnilmot.com>", /**< author */
|
9179
|
133 GAIM_WEBSITE, /**< homepage */
|
9157
|
134 plugin_load, /**< load */
|
|
135 plugin_unload, /**< unload */
|
|
136 NULL, /**< destroy */
|
|
137 NULL, /**< ui_info */
|
|
138 NULL, /**< extra_info */
|
|
139 &prefs_info, /**< prefs_info */
|
|
140 NULL /**< actions */
|
|
141 };
|
|
142
|
|
143 static void
|
|
144 init_plugin(GaimPlugin *plugin)
|
|
145 {
|
9179
|
146 gaim_prefs_add_none("/plugins/gtk/extplacement");
|
|
147 gaim_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4);
|
9425
|
148 gaim_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE);
|
9157
|
149 }
|
|
150
|
|
151 GAIM_INIT_PLUGIN(extplacement, init_plugin, info)
|