Mercurial > pidgin
annotate plugins/extplacement.c @ 12468:6faefbebcd24
[gaim-migrate @ 14778]
SF Patch #1372898 from charkins
"This patch updates the unseen conversation api in
gtkconv to ensure consistancy and avoid code
duplication. The ...first_unseen() function is renamed
and expanded to return a list of conversations that
match the specified criteria. A max_count parameter is
used to allow this to short circuit early (using 1
gives old behavior). An additional flag was added to
allow this function to only consider hidden
conversations (used by the buddy list). The blist is
currently inconsistant in which conversations it loops
over for showing the menu tray icon, creating the
tooltip and the unseen menu. This patch fixes that.
The ...find_unseen_list() now handles contact-aware
conversations correctly as well (based on sadrul's
patches in #1362579 which are obsoleted by this patch).
I also included the fix from #1362579 which increments
unseen_count only when state>=UNSEEN_TEXT."
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Mon, 12 Dec 2005 18:59:29 +0000 |
| parents | dd7392cce819 |
| children | e856f985a0b9 |
| 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 = { | |
| 119 get_plugin_pref_frame | |
| 120 }; | |
| 121 | |
| 122 static GaimPluginInfo info = | |
| 123 { | |
| 9943 | 124 GAIM_PLUGIN_MAGIC, |
| 125 GAIM_MAJOR_VERSION, | |
| 126 GAIM_MINOR_VERSION, | |
| 9157 | 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 */ |
| 9425 | 137 N_("Restrict the number of conversations per windows," |
| 138 " optionally separating IMs and Chats"), | |
| 9157 | 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); | |
| 9425 | 155 gaim_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE); |
| 9157 | 156 } |
| 157 | |
| 158 GAIM_INIT_PLUGIN(extplacement, init_plugin, info) |
