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