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