comparison pidgin/plugins/extplacement.c @ 15374:5fe8042783c1

Rename gtk/ and libgaim/ to pidgin/ and libpurple/
author Sean Egan <seanegan@gmail.com>
date Sat, 20 Jan 2007 02:32:10 +0000
parents
children d75099d2567e
comparison
equal deleted inserted replaced
15373:f79e0f4df793 15374:5fe8042783c1
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
23 #include "internal.h"
24 #include "gtkgaim.h"
25 #include "conversation.h"
26 #include "version.h"
27 #include "gtkplugin.h"
28 #include "gtkconv.h"
29 #include "gtkconvwin.h"
30
31 static void
32 conv_placement_by_number(GaimGtkConversation *conv)
33 {
34 GaimGtkWindow *win = NULL;
35 GList *wins = NULL;
36
37 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate"))
38 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv));
39 else if ((wins = gaim_gtk_conv_windows_get_list()) != NULL)
40 win = g_list_last(wins)->data;
41
42 if (win == NULL) {
43 win = gaim_gtk_conv_window_new();
44
45 gaim_gtk_conv_window_add_gtkconv(win, conv);
46 gaim_gtk_conv_window_show(win);
47 } else {
48 int max_count = gaim_prefs_get_int("/plugins/gtk/extplacement/placement_number");
49 int count = gaim_gtk_conv_window_get_gtkconv_count(win);
50
51 if (count < max_count)
52 gaim_gtk_conv_window_add_gtkconv(win, conv);
53 else {
54 GList *l = NULL;
55
56 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) {
57 win = l->data;
58
59 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") &&
60 gaim_conversation_get_type(gaim_gtk_conv_window_get_active_conversation(win)) != gaim_conversation_get_type(conv->active_conv))
61 continue;
62
63 count = gaim_gtk_conv_window_get_gtkconv_count(win);
64 if (count < max_count) {
65 gaim_gtk_conv_window_add_gtkconv(win, conv);
66 return;
67 }
68 }
69 win = gaim_gtk_conv_window_new();
70
71 gaim_gtk_conv_window_add_gtkconv(win, conv);
72 gaim_gtk_conv_window_show(win);
73 }
74 }
75 }
76
77 static gboolean
78 plugin_load(GaimPlugin *plugin)
79 {
80 gaim_gtkconv_placement_add_fnc("number", _("By conversation count"),
81 &conv_placement_by_number);
82 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement");
83 return TRUE;
84 }
85
86 static gboolean
87 plugin_unload(GaimPlugin *plugin)
88 {
89 gaim_gtkconv_placement_remove_fnc("number");
90 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement");
91 return TRUE;
92 }
93
94 static GaimPluginPrefFrame *
95 get_plugin_pref_frame(GaimPlugin *plugin) {
96 GaimPluginPrefFrame *frame;
97 GaimPluginPref *ppref;
98
99 frame = gaim_plugin_pref_frame_new();
100
101 ppref = gaim_plugin_pref_new_with_label(_("Conversation Placement"));
102 gaim_plugin_pref_frame_add(frame, ppref);
103
104 ppref = gaim_plugin_pref_new_with_name_and_label(
105 "/plugins/gtk/extplacement/placement_number",
106 _("Number of conversations per window"));
107 gaim_plugin_pref_set_bounds(ppref, 1, 50);
108 gaim_plugin_pref_frame_add(frame, ppref);
109
110 ppref = gaim_plugin_pref_new_with_name_and_label(
111 "/plugins/gtk/extplacement/placement_number_separate",
112 _("Separate IM and Chat windows when placing by number"));
113 gaim_plugin_pref_frame_add(frame, ppref);
114
115 return frame;
116 }
117
118 static GaimPluginUiInfo prefs_info = {
119 get_plugin_pref_frame,
120 0, /* page_num (Reserved) */
121 NULL /* frame (Reserved) */
122 };
123
124 static GaimPluginInfo info =
125 {
126 GAIM_PLUGIN_MAGIC,
127 GAIM_MAJOR_VERSION,
128 GAIM_MINOR_VERSION,
129 GAIM_PLUGIN_STANDARD, /**< type */
130 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */
131 0, /**< flags */
132 NULL, /**< dependencies */
133 GAIM_PRIORITY_DEFAULT, /**< priority */
134 "gtk-extplacement", /**< id */
135 N_("ExtPlacement"), /**< name */
136 VERSION, /**< version */
137 N_("Extra conversation placement options."), /**< summary */
138 /** description */
139 N_("Restrict the number of conversations per windows,"
140 " optionally separating IMs and Chats"),
141 "Stu Tomlinson <stu@nosnilmot.com>", /**< author */
142 GAIM_WEBSITE, /**< homepage */
143 plugin_load, /**< load */
144 plugin_unload, /**< unload */
145 NULL, /**< destroy */
146 NULL, /**< ui_info */
147 NULL, /**< extra_info */
148 &prefs_info, /**< prefs_info */
149 NULL /**< actions */
150 };
151
152 static void
153 init_plugin(GaimPlugin *plugin)
154 {
155 gaim_prefs_add_none("/plugins/gtk/extplacement");
156 gaim_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4);
157 gaim_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE);
158 }
159
160 GAIM_INIT_PLUGIN(extplacement, init_plugin, info)