Mercurial > pidgin
comparison plugins/extplacement.c @ 9179:fb09ed68fbd2
[gaim-migrate @ 9974]
updates from nosnilmot
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sat, 05 Jun 2004 17:11:31 +0000 |
| parents | bd1ea0a717d7 |
| children | 6b96a5a13e68 |
comparison
equal
deleted
inserted
replaced
| 9178:3b25c1042973 | 9179:fb09ed68fbd2 |
|---|---|
| 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 | |
| 1 #include "internal.h" | 23 #include "internal.h" |
| 2 #include "conversation.h" | 24 #include "conversation.h" |
| 3 | |
| 4 #define EXTPLACEMENT_OPT "/plugins/core/nosnilmot/extplacement" | |
| 5 | 25 |
| 6 static void | 26 static void |
| 7 conv_placement_last_created_win_split(GaimConversation *conv) | 27 conv_placement_last_created_win_split(GaimConversation *conv) |
| 8 { | 28 { |
| 9 GaimConvWindow *win; | 29 GaimConvWindow *win; |
| 23 static void | 43 static void |
| 24 conv_placement_by_number(GaimConversation *conv) | 44 conv_placement_by_number(GaimConversation *conv) |
| 25 { | 45 { |
| 26 GaimConvWindow *win = NULL; | 46 GaimConvWindow *win = NULL; |
| 27 | 47 |
| 28 if (gaim_prefs_get_bool("/core/conversations/combine_chat_im")) | 48 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv)); |
| 29 win = g_list_last(gaim_get_windows())->data; | |
| 30 else | |
| 31 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv)); | |
| 32 | 49 |
| 33 if (win == NULL) { | 50 if (win == NULL) { |
| 34 win = gaim_conv_window_new(); | 51 win = gaim_conv_window_new(); |
| 35 | 52 |
| 36 gaim_conv_window_add_conversation(win, conv); | 53 gaim_conv_window_add_conversation(win, conv); |
| 37 gaim_conv_window_show(win); | 54 gaim_conv_window_show(win); |
| 38 } else { | 55 } else { |
| 39 int max_count = gaim_prefs_get_int(EXTPLACEMENT_OPT "/placement_number"); | 56 int max_count = gaim_prefs_get_int("/plugins/gtk/extplacement/placement_number"); |
| 40 int count = gaim_conv_window_get_conversation_count(win); | 57 int count = gaim_conv_window_get_conversation_count(win); |
| 41 | 58 |
| 42 if (count < max_count) | 59 if (count < max_count) |
| 43 gaim_conv_window_add_conversation(win, conv); | 60 gaim_conv_window_add_conversation(win, conv); |
| 44 else { | 61 else { |
| 62 } | 79 } |
| 63 | 80 |
| 64 static gboolean | 81 static gboolean |
| 65 plugin_load(GaimPlugin *plugin) | 82 plugin_load(GaimPlugin *plugin) |
| 66 { | 83 { |
| 67 gaim_prefs_add_none("/plugins/core/nosnilmot"); | |
| 68 gaim_prefs_add_none("/plugins/core/nosnilmot/extplacement"); | |
| 69 gaim_prefs_add_int(EXTPLACEMENT_OPT "/placement_number", 4); | |
| 70 gaim_conv_placement_add_fnc("im_chat", _("Separate IM and Chat windows"), | 84 gaim_conv_placement_add_fnc("im_chat", _("Separate IM and Chat windows"), |
| 71 &conv_placement_last_created_win_split); | 85 &conv_placement_last_created_win_split); |
| 72 gaim_conv_placement_add_fnc("number", _("By conversation count"), | 86 gaim_conv_placement_add_fnc("number", _("By conversation count"), |
| 73 &conv_placement_by_number); | 87 &conv_placement_by_number); |
| 88 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); | |
| 74 return TRUE; | 89 return TRUE; |
| 75 } | 90 } |
| 76 | 91 |
| 77 static gboolean | 92 static gboolean |
| 78 plugin_unload(GaimPlugin *plugin) | 93 plugin_unload(GaimPlugin *plugin) |
| 79 { | 94 { |
| 80 gaim_conv_placement_remove_fnc("im_chat"); | 95 gaim_conv_placement_remove_fnc("im_chat"); |
| 81 gaim_conv_placement_remove_fnc("number"); | 96 gaim_conv_placement_remove_fnc("number"); |
| 97 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); | |
| 82 return TRUE; | 98 return TRUE; |
| 83 } | 99 } |
| 84 | 100 |
| 85 static GaimPluginPrefFrame * | 101 static GaimPluginPrefFrame * |
| 86 get_plugin_pref_frame(GaimPlugin *plugin) { | 102 get_plugin_pref_frame(GaimPlugin *plugin) { |
| 91 | 107 |
| 92 ppref = gaim_plugin_pref_new_with_label("Conversation Placement"); | 108 ppref = gaim_plugin_pref_new_with_label("Conversation Placement"); |
| 93 gaim_plugin_pref_frame_add(frame, ppref); | 109 gaim_plugin_pref_frame_add(frame, ppref); |
| 94 | 110 |
| 95 ppref = gaim_plugin_pref_new_with_name_and_label( | 111 ppref = gaim_plugin_pref_new_with_name_and_label( |
| 96 EXTPLACEMENT_OPT "/placement_number", | 112 "/plugins/gtk/extplacement/placement_number", |
| 97 "Number of conversations per window"); | 113 "Number of conversations per window"); |
| 98 gaim_plugin_pref_set_bounds(ppref, 1, 50); | 114 gaim_plugin_pref_set_bounds(ppref, 1, 50); |
| 99 gaim_plugin_pref_frame_add(frame, ppref); | 115 gaim_plugin_pref_frame_add(frame, ppref); |
| 100 | 116 |
| 101 return frame; | 117 return frame; |
| 107 | 123 |
| 108 static GaimPluginInfo info = | 124 static GaimPluginInfo info = |
| 109 { | 125 { |
| 110 GAIM_PLUGIN_API_VERSION, /**< api_version */ | 126 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
| 111 GAIM_PLUGIN_STANDARD, /**< type */ | 127 GAIM_PLUGIN_STANDARD, /**< type */ |
| 112 NULL, /**< ui_requirement */ | 128 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
| 113 0, /**< flags */ | 129 0, /**< flags */ |
| 114 NULL, /**< dependencies */ | 130 NULL, /**< dependencies */ |
| 115 GAIM_PRIORITY_DEFAULT, /**< priority */ | 131 GAIM_PRIORITY_DEFAULT, /**< priority */ |
| 116 | 132 "gtk-extplacement", /**< id */ |
| 117 "core-nosnilmot-extplacement", /**< id */ | |
| 118 N_("ExtPlacement"), /**< name */ | 133 N_("ExtPlacement"), /**< name */ |
| 119 VERSION, /**< version */ | 134 VERSION, /**< version */ |
| 120 /** summary */ | 135 N_("Extra conversation placement options."), /**< summary */ |
| 121 N_("Extra conversation placement options."), | |
| 122 /** description */ | 136 /** description */ |
| 123 N_("Either restrict the number of conversations per windows" | 137 N_("Either restrict the number of conversations per windows" |
| 124 " or use separate windows for IMs and Chats"), | 138 " or use separate windows for IMs and Chats"), |
| 125 "Stu Tomlinson <stu@nosnilmot.com>", /**< author */ | 139 "Stu Tomlinson <stu@nosnilmot.com>", /**< author */ |
| 126 "http://www.nosnilmot.com/gaim/plugins/", /**< homepage */ | 140 GAIM_WEBSITE, /**< homepage */ |
| 127 | |
| 128 plugin_load, /**< load */ | 141 plugin_load, /**< load */ |
| 129 plugin_unload, /**< unload */ | 142 plugin_unload, /**< unload */ |
| 130 NULL, /**< destroy */ | 143 NULL, /**< destroy */ |
| 131 | |
| 132 NULL, /**< ui_info */ | 144 NULL, /**< ui_info */ |
| 133 NULL, /**< extra_info */ | 145 NULL, /**< extra_info */ |
| 134 &prefs_info, /**< prefs_info */ | 146 &prefs_info, /**< prefs_info */ |
| 135 NULL /**< actions */ | 147 NULL /**< actions */ |
| 136 }; | 148 }; |
| 137 | 149 |
| 138 static void | 150 static void |
| 139 init_plugin(GaimPlugin *plugin) | 151 init_plugin(GaimPlugin *plugin) |
| 140 { | 152 { |
| 153 gaim_prefs_add_none("/plugins/gtk/extplacement"); | |
| 154 gaim_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4); | |
| 141 } | 155 } |
| 142 | 156 |
| 143 GAIM_INIT_PLUGIN(extplacement, init_plugin, info) | 157 GAIM_INIT_PLUGIN(extplacement, init_plugin, info) |
