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