Tue, 07 May 2013 05:04:46 -0400
Rewrite debug window filter in JS.
Note, this does cause a couple regressions, but they are probably not
that big a deal. First, the JS regular expression syntax is slightly
different. Second, the JS regex API lacks a way to reliably determine
the location of matched groups, so we can't highlight just the groups
and must highlight the entire expression.
I suspect that none of our users ever had to use any fancy regex in the
debug window, and that most of our developers didn't even know it could
be done. So I doubt these regressions will cause much pain.
| 9179 | 1 | /* |
| 15884 | 2 | * Extra conversation placement options for Purple |
| 9179 | 3 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 9179 | 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17022
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. |
| 9179 | 21 | */ |
| 22 | ||
| 9157 | 23 | #include "internal.h" |
| 15577 | 24 | #include "pidgin.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 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
32 | conv_placement_by_number(PidginConversation *conv) |
| 9157 | 33 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
34 | PidginWindow *win = NULL; |
|
12168
f1cb35825de9
[gaim-migrate @ 14469]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11581
diff
changeset
|
35 | GList *wins = NULL; |
| 9157 | 36 | |
| 15884 | 37 | if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate")) |
| 38 | win = pidgin_conv_window_last_with_type(purple_conversation_get_type(conv->active_conv)); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
39 | else if ((wins = pidgin_conv_windows_get_list()) != NULL) |
|
12168
f1cb35825de9
[gaim-migrate @ 14469]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11581
diff
changeset
|
40 | win = g_list_last(wins)->data; |
| 9157 | 41 | |
| 42 | if (win == NULL) { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
43 | win = pidgin_conv_window_new(); |
| 9157 | 44 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
45 | pidgin_conv_window_add_gtkconv(win, conv); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
46 | pidgin_conv_window_show(win); |
| 9157 | 47 | } else { |
| 15884 | 48 | int max_count = purple_prefs_get_int("/plugins/gtk/extplacement/placement_number"); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
49 | int count = pidgin_conv_window_get_gtkconv_count(win); |
| 9157 | 50 | |
| 51 | if (count < max_count) | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
52 | pidgin_conv_window_add_gtkconv(win, conv); |
| 9157 | 53 | else { |
| 54 | GList *l = NULL; | |
| 55 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
56 | for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) { |
| 11581 | 57 | win = l->data; |
| 9157 | 58 | |
| 15884 | 59 | if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") && |
| 60 | purple_conversation_get_type(pidgin_conv_window_get_active_conversation(win)) != purple_conversation_get_type(conv->active_conv)) | |
| 9425 | 61 | continue; |
| 62 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
63 | count = pidgin_conv_window_get_gtkconv_count(win); |
| 9157 | 64 | if (count < max_count) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
65 | pidgin_conv_window_add_gtkconv(win, conv); |
| 9157 | 66 | return; |
| 67 | } | |
| 68 | } | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
69 | win = pidgin_conv_window_new(); |
| 9157 | 70 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
71 | pidgin_conv_window_add_gtkconv(win, conv); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
72 | pidgin_conv_window_show(win); |
| 9157 | 73 | } |
| 74 | } | |
| 75 | } | |
| 76 | ||
| 77 | static gboolean | |
| 15884 | 78 | plugin_load(PurplePlugin *plugin) |
| 9157 | 79 | { |
| 15563 | 80 | pidgin_conv_placement_add_fnc("number", _("By conversation count"), |
| 9157 | 81 | &conv_placement_by_number); |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
82 | purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement"); |
| 9157 | 83 | return TRUE; |
| 84 | } | |
| 85 | ||
| 86 | static gboolean | |
| 15884 | 87 | plugin_unload(PurplePlugin *plugin) |
| 9157 | 88 | { |
| 15563 | 89 | pidgin_conv_placement_remove_fnc("number"); |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
90 | purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement"); |
| 9157 | 91 | return TRUE; |
| 92 | } | |
| 93 | ||
| 15884 | 94 | static PurplePluginPrefFrame * |
| 95 | get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 96 | PurplePluginPrefFrame *frame; | |
| 97 | PurplePluginPref *ppref; | |
| 9157 | 98 | |
| 15884 | 99 | frame = purple_plugin_pref_frame_new(); |
| 9157 | 100 | |
| 15884 | 101 | ppref = purple_plugin_pref_new_with_label(_("Conversation Placement")); |
| 102 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9157 | 103 | |
|
17022
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
104 | /* Translators: "New conversations" should match the text in the preferences dialog and "By conversation count" should be the same text used above */ |
|
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
105 | ppref = purple_plugin_pref_new_with_label(_("Note: The preference for \"New conversations\" must be set to \"By conversation count\".")); |
|
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
106 | purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_INFO); |
|
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
107 | purple_plugin_pref_frame_add(frame, ppref); |
|
d0ca12792153
Add note about using "By conversation count" for the "New conversations" preference to the extplacement plugin. Hopefully this reduces confusion (including for me).
Daniel Atallah <datallah@pidgin.im>
parents:
16749
diff
changeset
|
108 | |
| 15884 | 109 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 9425 | 110 | "/plugins/gtk/extplacement/placement_number", |
| 111 | _("Number of conversations per window")); | |
| 15884 | 112 | purple_plugin_pref_set_bounds(ppref, 1, 50); |
| 113 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9157 | 114 | |
| 15884 | 115 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 9425 | 116 | "/plugins/gtk/extplacement/placement_number_separate", |
| 117 | _("Separate IM and Chat windows when placing by number")); | |
| 15884 | 118 | purple_plugin_pref_frame_add(frame, ppref); |
| 9425 | 119 | |
| 9157 | 120 | return frame; |
| 121 | } | |
| 122 | ||
| 15884 | 123 | static PurplePluginUiInfo prefs_info = { |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12168
diff
changeset
|
124 | get_plugin_pref_frame, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12168
diff
changeset
|
125 | 0, /* page_num (Reserved) */ |
|
16749
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
126 | NULL, /* frame (Reserved) */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
127 | |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
128 | /* padding */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
129 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
130 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
131 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
132 | NULL |
| 9157 | 133 | }; |
| 134 | ||
| 15884 | 135 | static PurplePluginInfo info = |
| 9157 | 136 | { |
| 15884 | 137 | PURPLE_PLUGIN_MAGIC, |
| 138 | PURPLE_MAJOR_VERSION, | |
| 139 | PURPLE_MINOR_VERSION, | |
| 140 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 16133 | 141 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
| 9157 | 142 | 0, /**< flags */ |
| 143 | NULL, /**< dependencies */ | |
| 16133 | 144 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 9179 | 145 | "gtk-extplacement", /**< id */ |
| 9157 | 146 | N_("ExtPlacement"), /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
147 | DISPLAY_VERSION, /**< version */ |
| 9179 | 148 | N_("Extra conversation placement options."), /**< summary */ |
| 9157 | 149 | /** description */ |
| 9425 | 150 | N_("Restrict the number of conversations per windows," |
| 151 | " optionally separating IMs and Chats"), | |
| 9157 | 152 | "Stu Tomlinson <stu@nosnilmot.com>", /**< author */ |
| 15884 | 153 | PURPLE_WEBSITE, /**< homepage */ |
| 9157 | 154 | plugin_load, /**< load */ |
| 155 | plugin_unload, /**< unload */ | |
| 156 | NULL, /**< destroy */ | |
| 157 | NULL, /**< ui_info */ | |
| 158 | NULL, /**< extra_info */ | |
| 159 | &prefs_info, /**< prefs_info */ | |
|
16749
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
160 | NULL, /**< actions */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
161 | |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
162 | /* padding */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
163 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
164 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
165 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16133
diff
changeset
|
166 | NULL |
| 9157 | 167 | }; |
| 168 | ||
| 169 | static void | |
| 15884 | 170 | init_plugin(PurplePlugin *plugin) |
| 9157 | 171 | { |
| 15884 | 172 | purple_prefs_add_none("/plugins/gtk/extplacement"); |
| 173 | purple_prefs_add_int("/plugins/gtk/extplacement/placement_number", 4); | |
| 174 | purple_prefs_add_bool("/plugins/gtk/extplacement/placement_number_separate", FALSE); | |
| 9157 | 175 | } |
| 176 | ||
| 15884 | 177 | PURPLE_INIT_PLUGIN(extplacement, init_plugin, info) |