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