Mercurial > pidgin.yaz
annotate plugins/extplacement.c @ 13197:22f8ed4e5294
[gaim-migrate @ 15560]
Never auto-delete our currently in-use status. I ran into this
when I was doing some crazy shit.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 09 Feb 2006 03:14:59 +0000 |
parents | e856f985a0b9 |
children |
rev | line source |
---|---|
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" |
11581 | 28 #include "gtkconv.h" |
29 #include "gtkconvwin.h" | |
9157 | 30 |
31 static void | |
11581 | 32 conv_placement_by_number(GaimGtkConversation *conv) |
9157 | 33 { |
11581 | 34 GaimGtkWindow *win = NULL; |
12168
dd7392cce819
[gaim-migrate @ 14469]
Richard Laager <rlaager@wiktel.com>
parents:
11581
diff
changeset
|
35 GList *wins = NULL; |
9157 | 36 |
9425 | 37 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate")) |
11581 | 38 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); |
12168
dd7392cce819
[gaim-migrate @ 14469]
Richard Laager <rlaager@wiktel.com>
parents:
11581
diff
changeset
|
39 else if ((wins = gaim_gtk_conv_windows_get_list()) != NULL) |
dd7392cce819
[gaim-migrate @ 14469]
Richard Laager <rlaager@wiktel.com>
parents:
11581
diff
changeset
|
40 win = g_list_last(wins)->data; |
9157 | 41 |
42 if (win == NULL) { | |
11581 | 43 win = gaim_gtk_conv_window_new(); |
9157 | 44 |
11581 | 45 gaim_gtk_conv_window_add_gtkconv(win, conv); |
46 gaim_gtk_conv_window_show(win); | |
9157 | 47 } else { |
9179 | 48 int max_count = gaim_prefs_get_int("/plugins/gtk/extplacement/placement_number"); |
11581 | 49 int count = gaim_gtk_conv_window_get_gtkconv_count(win); |
9157 | 50 |
51 if (count < max_count) | |
11581 | 52 gaim_gtk_conv_window_add_gtkconv(win, conv); |
9157 | 53 else { |
54 GList *l = NULL; | |
55 | |
11581 | 56 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
57 win = l->data; | |
9157 | 58 |
9425 | 59 if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") && |
11581 | 60 gaim_conversation_get_type(gaim_gtk_conv_window_get_active_conversation(win)) != gaim_conversation_get_type(conv->active_conv)) |
9425 | 61 continue; |
62 | |
11581 | 63 count = gaim_gtk_conv_window_get_gtkconv_count(win); |
9157 | 64 if (count < max_count) { |
11581 | 65 gaim_gtk_conv_window_add_gtkconv(win, conv); |
9157 | 66 return; |
67 } | |
68 } | |
11581 | 69 win = gaim_gtk_conv_window_new(); |
9157 | 70 |
11581 | 71 gaim_gtk_conv_window_add_gtkconv(win, conv); |
72 gaim_gtk_conv_window_show(win); | |
9157 | 73 } |
74 } | |
75 } | |
76 | |
77 static gboolean | |
78 plugin_load(GaimPlugin *plugin) | |
79 { | |
11581 | 80 gaim_gtkconv_placement_add_fnc("number", _("By conversation count"), |
9157 | 81 &conv_placement_by_number); |
9179 | 82 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
9157 | 83 return TRUE; |
84 } | |
85 | |
86 static gboolean | |
87 plugin_unload(GaimPlugin *plugin) | |
88 { | |
11581 | 89 gaim_gtkconv_placement_remove_fnc("number"); |
9179 | 90 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
9157 | 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 | |
9217 | 101 ppref = gaim_plugin_pref_new_with_label(_("Conversation Placement")); |
9157 | 102 gaim_plugin_pref_frame_add(frame, ppref); |
103 | |
104 ppref = gaim_plugin_pref_new_with_name_and_label( | |
9425 | 105 "/plugins/gtk/extplacement/placement_number", |
106 _("Number of conversations per window")); | |
9157 | 107 gaim_plugin_pref_set_bounds(ppref, 1, 50); |
108 gaim_plugin_pref_frame_add(frame, ppref); | |
109 | |
9425 | 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 | |
9157 | 115 return frame; |
116 } | |
117 | |
118 static GaimPluginUiInfo prefs_info = { | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12168
diff
changeset
|
119 get_plugin_pref_frame, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12168
diff
changeset
|
120 0, /* page_num (Reserved) */ |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12168
diff
changeset
|
121 NULL /* frame (Reserved) */ |
9157 | 122 }; |
123 | |
124 static GaimPluginInfo info = | |
125 { | |
9943 | 126 GAIM_PLUGIN_MAGIC, |
127 GAIM_MAJOR_VERSION, | |
128 GAIM_MINOR_VERSION, | |
9157 | 129 GAIM_PLUGIN_STANDARD, /**< type */ |
9179 | 130 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
9157 | 131 0, /**< flags */ |
132 NULL, /**< dependencies */ | |
133 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
9179 | 134 "gtk-extplacement", /**< id */ |
9157 | 135 N_("ExtPlacement"), /**< name */ |
136 VERSION, /**< version */ | |
9179 | 137 N_("Extra conversation placement options."), /**< summary */ |
9157 | 138 /** description */ |
9425 | 139 N_("Restrict the number of conversations per windows," |
140 " optionally separating IMs and Chats"), | |
9157 | 141 "Stu Tomlinson <stu@nosnilmot.com>", /**< author */ |
9179 | 142 GAIM_WEBSITE, /**< homepage */ |
9157 | 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 { | |
9179 | 155 gaim_prefs_add_none("/plugins/gtk/extplacement"); |
156 gaim_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4); | |
9425 | 157 gaim_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE); |
9157 | 158 } |
159 | |
160 GAIM_INIT_PLUGIN(extplacement, init_plugin, info) |