Mon, 31 Oct 2005 05:40:35 +0000
[gaim-migrate @ 14215]
This seems to fix a crash for me when going offline --> online --> offline
--> online with an AIM account.
See the backtrace at http://nosnilmot.com/nopaste/296
| 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; |
| 9157 | 35 | |
| 9425 | 36 | if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate")) |
| 11581 | 37 | win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); |
| 9425 | 38 | else |
| 11581 | 39 | win = g_list_last(gaim_gtk_conv_windows_get_list())->data; |
| 9157 | 40 | |
| 41 | if (win == NULL) { | |
| 11581 | 42 | win = gaim_gtk_conv_window_new(); |
| 9157 | 43 | |
| 11581 | 44 | gaim_gtk_conv_window_add_gtkconv(win, conv); |
| 45 | gaim_gtk_conv_window_show(win); | |
| 9157 | 46 | } else { |
| 9179 | 47 | int max_count = gaim_prefs_get_int("/plugins/gtk/extplacement/placement_number"); |
| 11581 | 48 | int count = gaim_gtk_conv_window_get_gtkconv_count(win); |
| 9157 | 49 | |
| 50 | if (count < max_count) | |
| 11581 | 51 | gaim_gtk_conv_window_add_gtkconv(win, conv); |
| 9157 | 52 | else { |
| 53 | GList *l = NULL; | |
| 54 | ||
| 11581 | 55 | for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
| 56 | win = l->data; | |
| 9157 | 57 | |
| 9425 | 58 | if (gaim_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") && |
| 11581 | 59 | gaim_conversation_get_type(gaim_gtk_conv_window_get_active_conversation(win)) != gaim_conversation_get_type(conv->active_conv)) |
| 9425 | 60 | continue; |
| 61 | ||
| 11581 | 62 | count = gaim_gtk_conv_window_get_gtkconv_count(win); |
| 9157 | 63 | if (count < max_count) { |
| 11581 | 64 | gaim_gtk_conv_window_add_gtkconv(win, conv); |
| 9157 | 65 | return; |
| 66 | } | |
| 67 | } | |
| 11581 | 68 | win = gaim_gtk_conv_window_new(); |
| 9157 | 69 | |
| 11581 | 70 | gaim_gtk_conv_window_add_gtkconv(win, conv); |
| 71 | gaim_gtk_conv_window_show(win); | |
| 9157 | 72 | } |
| 73 | } | |
| 74 | } | |
| 75 | ||
| 76 | static gboolean | |
| 77 | plugin_load(GaimPlugin *plugin) | |
| 78 | { | |
| 11581 | 79 | gaim_gtkconv_placement_add_fnc("number", _("By conversation count"), |
| 9157 | 80 | &conv_placement_by_number); |
| 9179 | 81 | gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
| 9157 | 82 | return TRUE; |
| 83 | } | |
| 84 | ||
| 85 | static gboolean | |
| 86 | plugin_unload(GaimPlugin *plugin) | |
| 87 | { | |
| 11581 | 88 | gaim_gtkconv_placement_remove_fnc("number"); |
| 9179 | 89 | gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
| 9157 | 90 | return TRUE; |
| 91 | } | |
| 92 | ||
| 93 | static GaimPluginPrefFrame * | |
| 94 | get_plugin_pref_frame(GaimPlugin *plugin) { | |
| 95 | GaimPluginPrefFrame *frame; | |
| 96 | GaimPluginPref *ppref; | |
| 97 | ||
| 98 | frame = gaim_plugin_pref_frame_new(); | |
| 99 | ||
|
9217
e24b8de727d7
[gaim-migrate @ 10013]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9215
diff
changeset
|
100 | ppref = gaim_plugin_pref_new_with_label(_("Conversation Placement")); |
| 9157 | 101 | gaim_plugin_pref_frame_add(frame, ppref); |
| 102 | ||
| 103 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 9425 | 104 | "/plugins/gtk/extplacement/placement_number", |
| 105 | _("Number of conversations per window")); | |
| 9157 | 106 | gaim_plugin_pref_set_bounds(ppref, 1, 50); |
| 107 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 108 | ||
| 9425 | 109 | ppref = gaim_plugin_pref_new_with_name_and_label( |
| 110 | "/plugins/gtk/extplacement/placement_number_separate", | |
| 111 | _("Separate IM and Chat windows when placing by number")); | |
| 112 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 113 | ||
| 9157 | 114 | return frame; |
| 115 | } | |
| 116 | ||
| 117 | static GaimPluginUiInfo prefs_info = { | |
| 118 | get_plugin_pref_frame | |
| 119 | }; | |
| 120 | ||
| 121 | static GaimPluginInfo info = | |
| 122 | { | |
| 9943 | 123 | GAIM_PLUGIN_MAGIC, |
| 124 | GAIM_MAJOR_VERSION, | |
| 125 | GAIM_MINOR_VERSION, | |
| 9157 | 126 | GAIM_PLUGIN_STANDARD, /**< type */ |
| 9179 | 127 | GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
| 9157 | 128 | 0, /**< flags */ |
| 129 | NULL, /**< dependencies */ | |
| 130 | GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 9179 | 131 | "gtk-extplacement", /**< id */ |
| 9157 | 132 | N_("ExtPlacement"), /**< name */ |
| 133 | VERSION, /**< version */ | |
| 9179 | 134 | N_("Extra conversation placement options."), /**< summary */ |
| 9157 | 135 | /** description */ |
| 9425 | 136 | N_("Restrict the number of conversations per windows," |
| 137 | " optionally separating IMs and Chats"), | |
| 9157 | 138 | "Stu Tomlinson <stu@nosnilmot.com>", /**< author */ |
| 9179 | 139 | GAIM_WEBSITE, /**< homepage */ |
| 9157 | 140 | plugin_load, /**< load */ |
| 141 | plugin_unload, /**< unload */ | |
| 142 | NULL, /**< destroy */ | |
| 143 | NULL, /**< ui_info */ | |
| 144 | NULL, /**< extra_info */ | |
| 145 | &prefs_info, /**< prefs_info */ | |
| 146 | NULL /**< actions */ | |
| 147 | }; | |
| 148 | ||
| 149 | static void | |
| 150 | init_plugin(GaimPlugin *plugin) | |
| 151 | { | |
| 9179 | 152 | gaim_prefs_add_none("/plugins/gtk/extplacement"); |
| 153 | gaim_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4); | |
| 9425 | 154 | gaim_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE); |
| 9157 | 155 | } |
| 156 | ||
| 157 | GAIM_INIT_PLUGIN(extplacement, init_plugin, info) |