pidgin/plugins/timestamp.c

Tue, 07 May 2013 05:04:46 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Tue, 07 May 2013 05:04:46 -0400
changeset 33923
0fcc5635daba
parent 33133
9a31f084f259
permissions
-rw-r--r--

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.

7237
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
2 * Purple - iChat-style timestamps
7237
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
3 *
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
4 * Copyright (C) 2002-2003, Sean Egan
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
5 * Copyright (C) 2003, Chris J. Friesen <Darth_Sebulba04@yahoo.com>
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
6 * Copyright (C) 2007, Andrew Gaul <andrew@gaul.org>
7237
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
7 *
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
8 * This program is free software; you can redistribute it and/or modify
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
9 * it under the terms of the GNU General Public License as published by
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
11 * (at your option) any later version.
4220
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
12 *
7237
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
13 * This program is distributed in the hope that it will be useful,
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
16 * GNU General Public License for more details.
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
17 *
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
18 * You should have received a copy of the GNU General Public License
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
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: 16749
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7237
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
21 *
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
22 */
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
23
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
24 #include "internal.h"
4202
8b92de3b1c07 [gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents: 4201
diff changeset
25
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
26 #include "conversation.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
27 #include "debug.h"
7237
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
28 #include "prefs.h"
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
29 #include "signals.h"
9943
b54a762f60fa [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9863
diff changeset
30 #include "version.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
31
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
32 #include "gtkimhtml.h"
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
33 #include "gtkplugin.h"
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
34 #include "gtkprefs.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
35 #include "gtkutils.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
36
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
37 #define TIMESTAMP_PLUGIN_ID "gtk-timestamp"
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
38
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
39 /* minutes externally, seconds internally, and milliseconds in preferences */
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
40 static int interval = 5 * 60;
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
41
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
42 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
43 timestamp_display(PurpleConversation *conv, time_t then, time_t now)
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
44 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
45 PidginConversation *gtk_conv = PIDGIN_CONVERSATION(conv);
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
46 GtkWidget *imhtml = gtk_conv->imhtml;
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
47 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(imhtml));
10389
6c8d0ef5b6c4 [gaim-migrate @ 11616]
Sean Egan <seanegan@pidgin.im>
parents: 10104
diff changeset
48 GtkTextIter iter;
13105
8f9c66e4af87 [gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents: 12604
diff changeset
49 const char *mdate;
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
50 int y, height;
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
51 GdkRectangle rect;
29294
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
52 gboolean scrolled = FALSE;
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
53 GtkTextTag *tag;
21720
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
54
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
55 /* display timestamp */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
56 mdate = purple_utf8_strftime(then == 0 ? "%H:%M" : "\n%H:%M",
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
57 localtime(&now));
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
58 gtk_text_buffer_get_end_iter(buffer, &iter);
21720
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
59
29294
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
60 /* is the view already scrolled? */
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
61 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
62 gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
63 if (((y + height) - (rect.y + rect.height)) > height)
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
64 scrolled = TRUE;
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
65
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
66 if ((tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), "TIMESTAMP")) == NULL)
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
67 tag = gtk_text_buffer_create_tag(buffer, "TIMESTAMP",
21720
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
68 "foreground", "#888888", "justification", GTK_JUSTIFY_CENTER,
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
69 "weight", PANGO_WEIGHT_BOLD, NULL);
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
70
29294
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
71 gtk_text_buffer_insert_with_tags(buffer, &iter, mdate,
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
72 strlen(mdate), tag, NULL);
10404
9d66d897e96d [gaim-migrate @ 11649]
Mark Doliner <markdoliner@pidgin.im>
parents: 10400
diff changeset
73
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
74 /* scroll view if necessary */
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
75 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect);
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
76 gtk_text_view_get_line_yrange(
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
77 GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
29294
ee2180f692c1 timestamp: Do not scroll down if it was scrolled up.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25633
diff changeset
78 if (!scrolled && ((y + height) - (rect.y + rect.height)) > height &&
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
79 gtk_text_buffer_get_char_count(buffer)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
80 gboolean smooth = purple_prefs_get_bool(
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
81 PIDGIN_PREFS_ROOT "/conversations/use_smooth_scrolling");
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
82 gtk_imhtml_scroll_to_end(GTK_IMHTML(imhtml), smooth);
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
83 }
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
84 }
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
85
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
86 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
87 timestamp_displaying_conv_msg(PurpleAccount *account, const char *who,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
88 char **buffer, PurpleConversation *conv,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
89 PurpleMessageFlags flags, void *data)
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
90 {
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
91 time_t now = time(NULL) / interval * interval;
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
92 time_t then;
10404
9d66d897e96d [gaim-migrate @ 11649]
Mark Doliner <markdoliner@pidgin.im>
parents: 10400
diff changeset
93
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
94 if (!g_list_find(purple_get_conversations(), conv))
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
95 return FALSE;
10404
9d66d897e96d [gaim-migrate @ 11649]
Mark Doliner <markdoliner@pidgin.im>
parents: 10400
diff changeset
96
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
97 then = GPOINTER_TO_INT(purple_conversation_get_data(
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
98 conv, "timestamp-last"));
10404
9d66d897e96d [gaim-migrate @ 11649]
Mark Doliner <markdoliner@pidgin.im>
parents: 10400
diff changeset
99
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
100 if (now - then >= interval) {
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
101 timestamp_display(conv, then, now);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
102 purple_conversation_set_data(
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
103 conv, "timestamp-last", GINT_TO_POINTER(now));
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
104 }
10404
9d66d897e96d [gaim-migrate @ 11649]
Mark Doliner <markdoliner@pidgin.im>
parents: 10400
diff changeset
105
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
106 return FALSE;
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
107 }
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
108
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
109 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
110 timestamp_new_convo(PurpleConversation *conv)
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
111 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
112 if (!g_list_find(purple_get_conversations(), conv))
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
113 return;
10404
9d66d897e96d [gaim-migrate @ 11649]
Mark Doliner <markdoliner@pidgin.im>
parents: 10400
diff changeset
114
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
115 purple_conversation_set_data(conv, "timestamp-last", GINT_TO_POINTER(0));
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
116 }
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
117
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
118 static void
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
119 set_timestamp(GtkWidget *spinner, void *null)
9191
4d79d6e499b8 [gaim-migrate @ 9986]
Eddie Sohn
parents: 8993
diff changeset
120 {
4220
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
121 int tm;
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
122
12204
77be85a65fe8 [gaim-migrate @ 14506]
Richard Laager <rlaager@pidgin.im>
parents: 11740
diff changeset
123 tm = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
124 purple_debug(PURPLE_DEBUG_MISC, "timestamp",
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
125 "setting interval to %d minutes\n", tm);
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
126
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
127 interval = tm * 60;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
128 purple_prefs_set_int("/plugins/gtk/timestamp/interval", interval * 1000);
4220
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
129 }
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
130
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
131 static GtkWidget *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
132 get_config_frame(PurplePlugin *plugin)
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
133 {
4220
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
134 GtkWidget *ret;
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
135 GtkWidget *frame, *label;
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
136 GtkWidget *vbox, *hbox;
33133
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32438
diff changeset
137 GtkAdjustment *adj;
11740
2b605228ec11 [gaim-migrate @ 14031]
Sean Egan <seanegan@pidgin.im>
parents: 11256
diff changeset
138 GtkWidget *spinner;
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
139
4220
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
140 ret = gtk_vbox_new(FALSE, 18);
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
141 gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
142
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
143 frame = pidgin_make_frame(ret, _("Display Timestamps Every"));
4220
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
144 vbox = gtk_vbox_new(FALSE, 5);
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
145 gtk_container_add(GTK_CONTAINER(frame), vbox);
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
146
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
147 hbox = gtk_hbox_new(FALSE, 5);
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
148 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
149
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
150 /* XXX limit to divisors of 60? */
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
151 adj = gtk_adjustment_new(interval / 60, 1, 60, 1, 0, 0);
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
152 spinner = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0, 0);
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
153 gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0);
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
154 g_signal_connect(G_OBJECT(spinner), "value-changed",
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
155 G_CALLBACK(set_timestamp), NULL);
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
156 label = gtk_label_new(_("minutes"));
6485
3c7ba18e32f1 [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
157 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
4220
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
158
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
159 gtk_widget_show_all(ret);
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
160 return ret;
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
161 }
37fb7ec45980 [gaim-migrate @ 4464]
Chris
parents: 4202
diff changeset
162
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
163 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
164 plugin_load(PurplePlugin *plugin)
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
165 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
166 void *conv_handle = purple_conversations_get_handle();
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
167 void *gtkconv_handle = pidgin_conversations_get_handle();
10404
9d66d897e96d [gaim-migrate @ 11649]
Mark Doliner <markdoliner@pidgin.im>
parents: 10400
diff changeset
168
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
169 /* lower priority to display initial timestamp after logged messages */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
170 purple_signal_connect_priority(conv_handle, "conversation-created",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
171 plugin, PURPLE_CALLBACK(timestamp_new_convo), NULL,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
172 PURPLE_SIGNAL_PRIORITY_DEFAULT + 1);
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
173
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
174 purple_signal_connect(gtkconv_handle, "displaying-chat-msg",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
175 plugin, PURPLE_CALLBACK(timestamp_displaying_conv_msg), NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
176 purple_signal_connect(gtkconv_handle, "displaying-im-msg",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
177 plugin, PURPLE_CALLBACK(timestamp_displaying_conv_msg), NULL);
7237
da128ba7a4de [gaim-migrate @ 7812]
Mark Doliner <markdoliner@pidgin.im>
parents: 6982
diff changeset
178
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
179 interval = purple_prefs_get_int("/plugins/gtk/timestamp/interval") / 1000;
10389
6c8d0ef5b6c4 [gaim-migrate @ 11616]
Sean Egan <seanegan@pidgin.im>
parents: 10104
diff changeset
180
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
181 return TRUE;
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
182 }
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
183
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
184 static PidginPluginUiInfo ui_info =
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
185 {
12600
7ecd4441fdc7 [gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents: 12560
diff changeset
186 get_config_frame,
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: 16123
diff changeset
187 0, /* page_num (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: 16123
diff changeset
188
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: 16123
diff changeset
189 /* 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: 16123
diff changeset
190 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: 16123
diff changeset
191 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: 16123
diff changeset
192 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: 16123
diff changeset
193 NULL
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
194 };
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
195
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
196 static PurplePluginInfo info =
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
197 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
198 PURPLE_PLUGIN_MAGIC,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
199 PURPLE_MAJOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
200 PURPLE_MINOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
201 PURPLE_PLUGIN_STANDARD, /**< type */
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
202 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
203 0, /**< flags */
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
204 NULL, /**< dependencies */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
205 PURPLE_PRIORITY_DEFAULT, /**< priority */
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
206
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
207 TIMESTAMP_PLUGIN_ID, /**< id */
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
208 N_("Timestamp"), /**< name */
20288
5ca925a094e2 applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
209 DISPLAY_VERSION, /**< version */
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
210 /** summary */
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
211 N_("Display iChat-style timestamps"),
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
212 /** description */
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
213 N_("Display iChat-style timestamps every N minutes."),
12406
89863d2d9b8d [gaim-migrate @ 14713]
Richard Laager <rlaager@pidgin.im>
parents: 12204
diff changeset
214 "Sean Egan <seanegan@gmail.com>", /**< author */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
215 PURPLE_WEBSITE, /**< homepage */
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
216
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
217 plugin_load, /**< load */
15415
ed1c30414686 [gaim-migrate @ 18146]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
218 NULL, /**< unload */
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
219 NULL, /**< destroy */
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
220
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
221 &ui_info, /**< ui_info */
8993
41f67bceab41 [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8866
diff changeset
222 NULL, /**< extra_info */
10404
9d66d897e96d [gaim-migrate @ 11649]
Mark Doliner <markdoliner@pidgin.im>
parents: 10400
diff changeset
223 NULL,
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: 16123
diff changeset
224 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: 16123
diff changeset
225
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: 16123
diff changeset
226 /* 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: 16123
diff changeset
227 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: 16123
diff changeset
228 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: 16123
diff changeset
229 NULL,
8993
41f67bceab41 [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8866
diff changeset
230 NULL
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
231 };
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
232
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
233 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
234 init_plugin(PurplePlugin *plugin)
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4586
diff changeset
235 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
236 purple_prefs_add_none("/plugins/gtk/timestamp");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
237 purple_prefs_add_int("/plugins/gtk/timestamp/interval", interval * 1000);
3598
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
238 }
03d03049ecd6 [gaim-migrate @ 3700]
Sean Egan <seanegan@pidgin.im>
parents:
diff changeset
239
25633
feee0c7e503f Fix some more mis-identified plugins, like 3b3526a0...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21720
diff changeset
240 PURPLE_INIT_PLUGIN(timestamp, init_plugin, info)

mercurial