pidgin/plugins/timestamp_format.c

Sun, 07 Feb 2021 01:33:01 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Sun, 07 Feb 2021 01:33:01 -0600
branch
release-2.x.y
changeset 40755
fb2056ce3c58
parent 38258
9a6551eba09c
permissions
-rw-r--r--

Implement mitigation for GHSL-2021-045

This add a static inline version of `g_memdup2` if the version of glib we're
compiling against doesn't have the function.

GHSL-2021-045 was originally reported to glib at
https://gitlab.gnome.org/GNOME/glib/-/issues/2319.

More information about the entire situation can be found on the gnome
desktop-devel-list at
https://mail.gnome.org/archives/desktop-devel-list/2021-February/msg00000.html

Testing Done:
Compiled and ran tests locally.

Reviewed at https://reviews.imfreedom.org/r/483/

12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
1 #include "internal.h"
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
2
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
3 #include "debug.h"
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
4 #include "log.h"
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
5 #include "plugin.h"
13105
8f9c66e4af87 [gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents: 13090
diff changeset
6 #include "util.h"
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
7 #include "version.h"
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
8
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
9 #include "gtkconv.h"
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
10 #include "gtkplugin.h"
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
11 #include "gtkimhtml.h"
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
12
12851
96079cc66acf [gaim-migrate @ 15201]
Richard Laager <rlaager@pidgin.im>
parents: 12848
diff changeset
13 #include <time.h>
96079cc66acf [gaim-migrate @ 15201]
Richard Laager <rlaager@pidgin.im>
parents: 12848
diff changeset
14
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
15 static const char *format_12hour_hour(const struct tm *tm)
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
16 {
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
17 static char hr[3];
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
18 int hour = tm->tm_hour % 12;
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
19 if (hour == 0)
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
20 hour = 12;
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
21
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
22 g_snprintf(hr, sizeof(hr), "%d", hour);
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
23 return hr;
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
24 }
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
25
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
26 static PurplePluginPrefFrame *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
27 get_plugin_pref_frame(PurplePlugin *plugin)
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
28 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
29 PurplePluginPrefFrame *frame;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
30 PurplePluginPref *ppref;
16073
e70e589dde54 more help for translators (I removed a few PIDGIN_NAME references
Nathan Walp <nwalp@pidgin.im>
parents: 15939
diff changeset
31 char *tmp;
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
32
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
33 frame = purple_plugin_pref_frame_new();
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
34
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
35 ppref = purple_plugin_pref_new_with_label(_("Timestamp Format Options"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
36 purple_plugin_pref_frame_add(frame, ppref);
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
37
33740
261e15fb8b91 Fix a few warnings
Daniel Atallah <datallah@pidgin.im>
parents: 30062
diff changeset
38 tmp = g_strdup(_("_Force timestamp format:"));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
39 ppref = purple_plugin_pref_new_with_name_and_label(
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
40 "/plugins/gtk/timestamp_format/force",
16073
e70e589dde54 more help for translators (I removed a few PIDGIN_NAME references
Nathan Walp <nwalp@pidgin.im>
parents: 15939
diff changeset
41 tmp);
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
42 purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE);
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
43 purple_plugin_pref_add_choice(ppref, _("Use system default"), "default");
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
44 purple_plugin_pref_add_choice(ppref, _("12 hour time format"), "force12");
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
45 purple_plugin_pref_add_choice(ppref, _("24 hour time format"), "force24");
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
46 purple_plugin_pref_frame_add(frame, ppref);
16073
e70e589dde54 more help for translators (I removed a few PIDGIN_NAME references
Nathan Walp <nwalp@pidgin.im>
parents: 15939
diff changeset
47 g_free(tmp);
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
48
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
49 ppref = purple_plugin_pref_new_with_label(_("Show dates in..."));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
50 purple_plugin_pref_frame_add(frame, ppref);
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
51
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
52 ppref = purple_plugin_pref_new_with_name_and_label(
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
53 "/plugins/gtk/timestamp_format/use_dates/conversation",
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
54 _("Co_nversations:"));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
55 purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
56 purple_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
57 purple_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
58 purple_plugin_pref_add_choice(ppref, _("Always"), "always");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
59 purple_plugin_pref_frame_add(frame, ppref);
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
60
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
61 ppref = purple_plugin_pref_new_with_name_and_label(
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
62 "/plugins/gtk/timestamp_format/use_dates/log",
12848
a6cc4c3c950f [gaim-migrate @ 15198]
Richard Laager <rlaager@pidgin.im>
parents: 12737
diff changeset
63 _("_Message Logs:"));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
64 purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
65 purple_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
66 purple_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
67 purple_plugin_pref_add_choice(ppref, _("Always"), "always");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
68 purple_plugin_pref_frame_add(frame, ppref);
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
69
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
70 return frame;
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
71 }
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
72
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
73 static char *timestamp_cb_common(PurpleConversation *conv,
14049
c15c41423e19 [gaim-migrate @ 16559]
Richard Laager <rlaager@pidgin.im>
parents: 13115
diff changeset
74 time_t t,
15575
bd1e13b63e4b In Pidgin, display a full date on the timestamp of the first message to
Richard Laager <rlaager@pidgin.im>
parents: 15562
diff changeset
75 gboolean show_date,
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
76 const char *force,
16865
5c22d0ab003e Fix ticket #559:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16749
diff changeset
77 const char *dates,
5c22d0ab003e Fix ticket #559:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16749
diff changeset
78 gboolean parens)
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
79 {
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
80 struct tm *tm;
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
81
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
82 g_return_val_if_fail(dates != NULL, NULL);
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
83
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
84 tm = localtime(&t);
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
85
15575
bd1e13b63e4b In Pidgin, display a full date on the timestamp of the first message to
Richard Laager <rlaager@pidgin.im>
parents: 15562
diff changeset
86 if (show_date ||
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
87 purple_strequal(dates, "always") ||
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
88 (conv != NULL && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && purple_strequal(dates, "chats")))
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
89 {
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33740
diff changeset
90 if (purple_strequal(force, "force24"))
16865
5c22d0ab003e Fix ticket #559:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16749
diff changeset
91 return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_utf8_strftime("%Y-%m-%d %H:%M:%S", tm), parens ? ")" : "");
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33740
diff changeset
92 else if (purple_strequal(force, "force12")) {
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
93 char *date = g_strdup_printf("%s", purple_utf8_strftime("%Y-%m-%d ", tm));
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
94 char *remtime = g_strdup_printf("%s", purple_utf8_strftime(":%M:%S %p", tm));
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
95 const char *hour = format_12hour_hour(tm);
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
96 char *output;
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
97
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
98 output = g_strdup_printf("%s%s%s%s%s",
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
99 parens ? "(" : "", date,
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
100 hour, remtime, parens ? ")" : "");
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
101
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
102 g_free(date);
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
103 g_free(remtime);
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
104
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
105 return output;
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
106 } else
16865
5c22d0ab003e Fix ticket #559:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16749
diff changeset
107 return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_date_format_long(tm), parens ? ")" : "");
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
108 }
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
109
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33740
diff changeset
110 if (purple_strequal(force, "force24"))
16865
5c22d0ab003e Fix ticket #559:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16749
diff changeset
111 return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_utf8_strftime("%H:%M:%S", tm), parens ? ")" : "");
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33740
diff changeset
112 else if (purple_strequal(force, "force12")) {
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
113 const char *hour = format_12hour_hour(tm);
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
114 char *remtime = g_strdup_printf("%s", purple_utf8_strftime(":%M:%S %p", tm));
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
115 char *output = g_strdup_printf("%s%s%s%s", parens ? "(" : "", hour, remtime, parens ? ")" : "");
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
116
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
117 g_free(remtime);
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
118
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
119 return output;
15575
bd1e13b63e4b In Pidgin, display a full date on the timestamp of the first message to
Richard Laager <rlaager@pidgin.im>
parents: 15562
diff changeset
120 }
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
121
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
122 return NULL;
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
123 }
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
124
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
125 static char *conversation_timestamp_cb(PurpleConversation *conv,
15575
bd1e13b63e4b In Pidgin, display a full date on the timestamp of the first message to
Richard Laager <rlaager@pidgin.im>
parents: 15562
diff changeset
126 time_t t, gboolean show_date, gpointer data)
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
127 {
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
128 const char *force = purple_prefs_get_string(
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
129 "/plugins/gtk/timestamp_format/force");
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
130 const char *dates = purple_prefs_get_string(
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
131 "/plugins/gtk/timestamp_format/use_dates/conversation");
13054
6d323387986e [gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents: 12851
diff changeset
132
6d323387986e [gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents: 12851
diff changeset
133 g_return_val_if_fail(conv != NULL, NULL);
6d323387986e [gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents: 12851
diff changeset
134
16865
5c22d0ab003e Fix ticket #559:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16749
diff changeset
135 return timestamp_cb_common(conv, t, show_date, force, dates, TRUE);
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
136 }
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
137
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
138 static char *log_timestamp_cb(PurpleLog *log, time_t t, gboolean show_date, gpointer data)
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
139 {
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
140 const char *force = purple_prefs_get_string(
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
141 "/plugins/gtk/timestamp_format/force");
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
142 const char *dates = purple_prefs_get_string(
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
143 "/plugins/gtk/timestamp_format/use_dates/log");
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
144
13054
6d323387986e [gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents: 12851
diff changeset
145 g_return_val_if_fail(log != NULL, NULL);
6d323387986e [gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents: 12851
diff changeset
146
16865
5c22d0ab003e Fix ticket #559:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16749
diff changeset
147 return timestamp_cb_common(log->conv, t, show_date, force, dates, FALSE);
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
148 }
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
149
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
150 static void
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
151 menu_cb(GtkWidget *item, gpointer data)
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
152 {
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
153 PurplePlugin *plugin = data;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
154 GtkWidget *frame = pidgin_plugin_get_config_frame(plugin), *dialog;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
155 if (!frame)
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
156 return;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
157
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
158 dialog = gtk_dialog_new_with_buttons(PIDGIN_ALERT_TITLE, NULL,
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
159 GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT,
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
160 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
161 NULL);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
162 g_signal_connect_after(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), dialog);
30010
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
163 #if GTK_CHECK_VERSION(2,14,0)
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
164 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), frame);
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
165 #else
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
166 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), frame);
30010
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
167 #endif
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
168 gtk_window_set_role(GTK_WINDOW(dialog), "plugin_config");
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
169 gtk_window_set_title(GTK_WINDOW(dialog), _(purple_plugin_get_name(plugin)));
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
170 gtk_widget_show_all(dialog);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
171 }
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
172
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
173 static gboolean
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
174 textview_emission_hook(GSignalInvocationHint *hint, guint n_params,
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
175 const GValue *pvalues, gpointer data)
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
176 {
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
177 GtkTextView *view = GTK_TEXT_VIEW(g_value_get_object(pvalues));
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
178 GtkWidget *menu, *item;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
179 GtkTextBuffer *buffer;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
180 GtkTextIter cursor;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
181 int cx, cy, bx, by;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
182
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
183 if (!GTK_IS_IMHTML(view))
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
184 return TRUE;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
185
30010
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
186 #if GTK_CHECK_VERSION(2,14,0)
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
187 if (!gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(view)), &cx, &cy, NULL))
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
188 return TRUE;
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
189 #else
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
190 if (!gdk_window_get_pointer(GTK_WIDGET(view)->window, &cx, &cy, NULL))
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
191 return TRUE;
30010
2b3e5bbd0492 Prepare Pidgin plugins for GTK+3.0. They're almost GSeal-compliant, except
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30000
diff changeset
192 #endif
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
193
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
194 buffer = gtk_text_view_get_buffer(view);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
195
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
196 gtk_text_view_window_to_buffer_coords(view, GTK_TEXT_WINDOW_TEXT, cx, cy, &bx, &by);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
197 gtk_text_view_get_iter_at_location(view, &cursor, bx, by);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
198 if (!gtk_text_iter_has_tag(&cursor,
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
199 gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), "comment")))
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
200 return TRUE;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
201
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
202 menu = g_value_get_object(&pvalues[1]);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
203
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
204 item = gtk_menu_item_new_with_label(_("Timestamp Format Options"));
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
205 gtk_widget_show_all(item);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
206 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(menu_cb), data);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
207 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item, 0);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
208
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
209 item = gtk_separator_menu_item_new();
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
210 gtk_widget_show(item);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
211 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item, 1);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
212
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
213 return TRUE;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
214 }
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
215
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
216 static guint signal_id;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
217 static gulong hook_id;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
218
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
219 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
220 plugin_load(PurplePlugin *plugin)
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
221 {
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
222 gpointer klass = NULL;
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
223
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
224 purple_signal_connect(pidgin_conversations_get_handle(), "conversation-timestamp",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
225 plugin, PURPLE_CALLBACK(conversation_timestamp_cb), NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
226 purple_signal_connect(purple_log_get_handle(), "log-timestamp",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
227 plugin, PURPLE_CALLBACK(log_timestamp_cb), NULL);
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
228
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
229 klass = g_type_class_ref(GTK_TYPE_TEXT_VIEW);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
230
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
231 /* In 3.0.0, use purple_g_signal_connect_flags */
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
232 g_signal_parse_name("populate_popup", GTK_TYPE_TEXT_VIEW, &signal_id, NULL, FALSE);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
233 hook_id = g_signal_add_emission_hook(signal_id, 0, textview_emission_hook,
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
234 plugin, NULL);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
235
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
236 g_type_class_unref(klass);
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
237
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
238 return TRUE;
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
239 }
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
240
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
241 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
242 plugin_unload(PurplePlugin *plugin)
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
243 {
30000
a6ceec33f2c1 Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
244 g_signal_remove_emission_hook(signal_id, hook_id);
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
245 return TRUE;
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
246 }
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
247
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
248 static PurplePluginUiInfo prefs_info = {
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
249 get_plugin_pref_frame,
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
250 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: 16073
diff changeset
251 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: 16073
diff changeset
252
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: 16073
diff changeset
253 /* 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: 16073
diff changeset
254 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: 16073
diff changeset
255 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: 16073
diff changeset
256 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: 16073
diff changeset
257 NULL
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
258 };
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
259
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
260 static PurplePluginInfo info =
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
261 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
262 PURPLE_PLUGIN_MAGIC,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
263 PURPLE_MAJOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
264 PURPLE_MINOR_VERSION,
15939
efc69ea48720 The Message Timestamp Formats plugin lacked an ID before.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
265 PURPLE_PLUGIN_STANDARD, /**< type */
15575
bd1e13b63e4b In Pidgin, display a full date on the timestamp of the first message to
Richard Laager <rlaager@pidgin.im>
parents: 15562
diff changeset
266 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
267 0, /**< flags */
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
268 NULL, /**< dependencies */
15939
efc69ea48720 The Message Timestamp Formats plugin lacked an ID before.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
269 PURPLE_PRIORITY_DEFAULT, /**< priority */
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
270
15939
efc69ea48720 The Message Timestamp Formats plugin lacked an ID before.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
271 "core-timestamp_format", /**< id */
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
272 N_("Message Timestamp Formats"), /**< name */
20288
5ca925a094e2 applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16976
diff changeset
273 DISPLAY_VERSION, /**< version */
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
274 /** summary */
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
275 N_("Customizes the message timestamp formats."),
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
276 /** description */
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
277 N_("This plugin allows the user to customize "
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
278 "conversation and logging message timestamp "
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
279 "formats."),
15629
a2261cb315e2 Switching to my pidgin.im e-mail address, which I think fits nicely and seems professional.
Richard Laager <rlaager@pidgin.im>
parents: 15626
diff changeset
280 "Richard Laager <rlaager@pidgin.im>", /**< author */
15939
efc69ea48720 The Message Timestamp Formats plugin lacked an ID before.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
281 PURPLE_WEBSITE, /**< homepage */
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
282
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
283 plugin_load, /**< load */
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
284 plugin_unload, /**< unload */
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
285 NULL, /**< destroy */
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
286
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
287 NULL, /**< ui_info */
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
288 NULL, /**< extra_info */
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
289 &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: 16073
diff changeset
290 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: 16073
diff changeset
291
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: 16073
diff changeset
292 /* 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: 16073
diff changeset
293 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: 16073
diff changeset
294 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: 16073
diff changeset
295 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: 16073
diff changeset
296 NULL
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
297 };
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
298
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
299 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
300 init_plugin(PurplePlugin *plugin)
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
301 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
302 purple_prefs_add_none("/plugins/gtk");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
303 purple_prefs_add_none("/plugins/gtk/timestamp_format");
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
304
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
305 if (!purple_prefs_exists("/plugins/gtk/timestamp_format/force") &&
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
306 purple_prefs_exists("/plugins/gtk/timestamp_format/force_24hr"))
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
307 {
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
308 if (purple_prefs_get_bool(
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
309 "/plugins/gtk/timestamp_format/force_24hr"))
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
310 purple_prefs_add_string("/plugins/gtk/timestamp_format/force", "force24");
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
311 else
30062
0ede207843b0 timestamp formats: Default to the 'default' ones (as pointed out by Jonathan)
Paul Aurich <darkrain42@pidgin.im>
parents: 30061
diff changeset
312 purple_prefs_add_string("/plugins/gtk/timestamp_format/force", "default");
30061
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
313 }
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
314 else
0b85fd231104 timestamp formats: Allow forcing 12-hour time formats. Closes #11667.
Jonathan Maltz <jemaltz@gmail.com>
parents: 30010
diff changeset
315 purple_prefs_add_string("/plugins/gtk/timestamp_format/force", "default");
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
316
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
317 purple_prefs_add_none("/plugins/gtk/timestamp_format/use_dates");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
318 purple_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/conversation", "automatic");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
319 purple_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/log", "automatic");
12737
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
320 }
e1300804318e [gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
321
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15629
diff changeset
322 PURPLE_INIT_PLUGIN(timestamp_format, init_plugin, info)

mercurial