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