Thu, 22 Feb 2007 20:01:17 +0000
remove old tray icon stock items
| 12737 | 1 | #include "internal.h" |
| 2 | ||
| 3 | #include "debug.h" | |
| 4 | #include "log.h" | |
| 5 | #include "plugin.h" | |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13090
diff
changeset
|
6 | #include "util.h" |
| 12737 | 7 | #include "version.h" |
| 8 | ||
| 9 | #include "gtkconv.h" | |
| 10 | #include "gtkplugin.h" | |
| 11 | ||
|
12851
96079cc66acf
[gaim-migrate @ 15201]
Richard Laager <rlaager@pidgin.im>
parents:
12848
diff
changeset
|
12 | #include <time.h> |
|
96079cc66acf
[gaim-migrate @ 15201]
Richard Laager <rlaager@pidgin.im>
parents:
12848
diff
changeset
|
13 | |
| 12737 | 14 | static GaimPluginPrefFrame * |
| 15 | get_plugin_pref_frame(GaimPlugin *plugin) | |
| 16 | { | |
| 17 | GaimPluginPrefFrame *frame; | |
| 18 | GaimPluginPref *ppref; | |
| 19 | ||
| 20 | frame = gaim_plugin_pref_frame_new(); | |
| 21 | ||
| 22 | ppref = gaim_plugin_pref_new_with_label(_("Timestamp Format Options")); | |
| 23 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 24 | ||
| 25 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 26 | "/plugins/gtk/timestamp_format/force_24hr", | |
|
15442
2ff7f5308727
I think this is all the instances of 'Gaim' within pidgin/
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
27 | _("_Force (traditional " PIDGIN_NAME ") 24-hour time format")); |
| 12737 | 28 | gaim_plugin_pref_frame_add(frame, ppref); |
| 29 | ||
| 30 | ppref = gaim_plugin_pref_new_with_label(_("Show dates in...")); | |
| 31 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 32 | ||
| 33 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 34 | "/plugins/gtk/timestamp_format/use_dates/conversation", | |
| 35 | _("Co_nversations:")); | |
| 36 | gaim_plugin_pref_set_type(ppref, GAIM_PLUGIN_PREF_CHOICE); | |
|
13090
aee4ed853ff3
[gaim-migrate @ 15451]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13054
diff
changeset
|
37 | gaim_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic"); |
|
aee4ed853ff3
[gaim-migrate @ 15451]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13054
diff
changeset
|
38 | gaim_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats"); |
|
aee4ed853ff3
[gaim-migrate @ 15451]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13054
diff
changeset
|
39 | gaim_plugin_pref_add_choice(ppref, _("Always"), "always"); |
| 12737 | 40 | gaim_plugin_pref_frame_add(frame, ppref); |
| 41 | ||
| 42 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 43 | "/plugins/gtk/timestamp_format/use_dates/log", | |
|
12848
a6cc4c3c950f
[gaim-migrate @ 15198]
Richard Laager <rlaager@pidgin.im>
parents:
12737
diff
changeset
|
44 | _("_Message Logs:")); |
| 12737 | 45 | gaim_plugin_pref_set_type(ppref, GAIM_PLUGIN_PREF_CHOICE); |
|
13090
aee4ed853ff3
[gaim-migrate @ 15451]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13054
diff
changeset
|
46 | gaim_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic"); |
|
aee4ed853ff3
[gaim-migrate @ 15451]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13054
diff
changeset
|
47 | gaim_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats"); |
|
aee4ed853ff3
[gaim-migrate @ 15451]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13054
diff
changeset
|
48 | gaim_plugin_pref_add_choice(ppref, _("Always"), "always"); |
| 12737 | 49 | gaim_plugin_pref_frame_add(frame, ppref); |
| 50 | ||
| 51 | return frame; | |
| 52 | } | |
| 53 | ||
| 54 | static char *timestamp_cb_common(GaimConversation *conv, | |
|
14049
c15c41423e19
[gaim-migrate @ 16559]
Richard Laager <rlaager@pidgin.im>
parents:
13115
diff
changeset
|
55 | 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
|
56 | gboolean show_date, |
| 12737 | 57 | gboolean force, |
| 58 | const char *dates) | |
| 59 | { | |
| 60 | g_return_val_if_fail(dates != NULL, NULL); | |
| 61 | ||
|
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
|
62 | if (show_date || |
|
bd1e13b63e4b
In Pidgin, display a full date on the timestamp of the first message to
Richard Laager <rlaager@pidgin.im>
parents:
15562
diff
changeset
|
63 | !strcmp(dates, "always") || |
|
15626
6210ee4beccc
With the refactoring I did, it's now possible to reach timestamp_cb_common
Richard Laager <rlaager@pidgin.im>
parents:
15575
diff
changeset
|
64 | (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && !strcmp(dates, "chats"))) |
| 12737 | 65 | { |
|
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
|
66 | struct tm *tm = localtime(&t); |
| 12737 | 67 | if (force) |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13090
diff
changeset
|
68 | return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); |
| 12737 | 69 | else |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13090
diff
changeset
|
70 | return g_strdup(gaim_date_format_long(tm)); |
| 12737 | 71 | } |
| 72 | ||
| 73 | if (force) | |
|
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
|
74 | { |
|
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 | struct tm *tm = localtime(&t); |
|
13115
ed3680c839d8
[gaim-migrate @ 15476]
Richard Laager <rlaager@pidgin.im>
parents:
13105
diff
changeset
|
76 | return g_strdup(gaim_utf8_strftime("%H:%M:%S", tm)); |
|
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
|
77 | } |
| 12737 | 78 | |
| 79 | return NULL; | |
| 80 | } | |
| 81 | ||
| 82 | static char *conversation_timestamp_cb(GaimConversation *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
|
83 | time_t t, gboolean show_date, gpointer data) |
| 12737 | 84 | { |
| 85 | gboolean force = gaim_prefs_get_bool( | |
| 86 | "/plugins/gtk/timestamp_format/force_24hr"); | |
| 87 | const char *dates = gaim_prefs_get_string( | |
| 88 | "/plugins/gtk/timestamp_format/use_dates/conversation"); | |
|
13054
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
89 | |
|
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
90 | g_return_val_if_fail(conv != NULL, NULL); |
|
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
91 | |
|
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
|
92 | return timestamp_cb_common(conv, t, show_date, force, dates); |
| 12737 | 93 | } |
| 94 | ||
|
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
|
95 | static char *log_timestamp_cb(GaimLog *log, time_t t, gboolean show_date, gpointer data) |
| 12737 | 96 | { |
| 97 | gboolean force = gaim_prefs_get_bool( | |
| 98 | "/plugins/gtk/timestamp_format/force_24hr"); | |
| 99 | const char *dates = gaim_prefs_get_string( | |
| 100 | "/plugins/gtk/timestamp_format/use_dates/log"); | |
| 101 | ||
|
13054
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
102 | g_return_val_if_fail(log != NULL, NULL); |
|
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
103 | |
|
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
|
104 | return timestamp_cb_common(log->conv, t, show_date, force, dates); |
| 12737 | 105 | } |
| 106 | ||
| 107 | static gboolean | |
| 108 | plugin_load(GaimPlugin *plugin) | |
| 109 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
110 | gaim_signal_connect(pidgin_conversations_get_handle(), "conversation-timestamp", |
| 12737 | 111 | plugin, GAIM_CALLBACK(conversation_timestamp_cb), NULL); |
| 112 | gaim_signal_connect(gaim_log_get_handle(), "log-timestamp", | |
| 113 | plugin, GAIM_CALLBACK(log_timestamp_cb), NULL); | |
| 114 | return TRUE; | |
| 115 | } | |
| 116 | ||
| 117 | static gboolean | |
| 118 | plugin_unload(GaimPlugin *plugin) | |
| 119 | { | |
| 120 | return TRUE; | |
| 121 | } | |
| 122 | ||
| 123 | static GaimPluginUiInfo prefs_info = { | |
| 124 | get_plugin_pref_frame, | |
| 125 | 0, /* page num (Reserved) */ | |
| 126 | NULL /* frame (Reserved) */ | |
| 127 | }; | |
| 128 | ||
| 129 | static GaimPluginInfo info = | |
| 130 | { | |
| 131 | GAIM_PLUGIN_MAGIC, | |
| 132 | GAIM_MAJOR_VERSION, | |
| 133 | GAIM_MINOR_VERSION, | |
| 134 | GAIM_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
|
135 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
| 12737 | 136 | 0, /**< flags */ |
| 137 | NULL, /**< dependencies */ | |
| 138 | GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 139 | ||
| 140 | NULL, /**< id */ | |
| 141 | N_("Message Timestamp Formats"), /**< name */ | |
| 142 | VERSION, /**< version */ | |
| 143 | /** summary */ | |
| 144 | N_("Customizes the message timestamp formats."), | |
| 145 | /** description */ | |
| 146 | N_("This plugin allows the user to customize " | |
| 147 | "conversation and logging message timestamp " | |
| 148 | "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
|
149 | "Richard Laager <rlaager@pidgin.im>", /**< author */ |
| 12737 | 150 | GAIM_WEBSITE, /**< homepage */ |
| 151 | ||
| 152 | plugin_load, /**< load */ | |
| 153 | plugin_unload, /**< unload */ | |
| 154 | NULL, /**< destroy */ | |
| 155 | ||
| 156 | NULL, /**< ui_info */ | |
| 157 | NULL, /**< extra_info */ | |
| 158 | &prefs_info, /**< prefs_info */ | |
| 159 | NULL /**< actions */ | |
| 160 | }; | |
| 161 | ||
| 162 | static void | |
| 163 | init_plugin(GaimPlugin *plugin) | |
| 164 | { | |
| 165 | gaim_prefs_add_none("/plugins/gtk"); | |
| 166 | gaim_prefs_add_none("/plugins/gtk/timestamp_format"); | |
| 167 | ||
| 168 | gaim_prefs_add_bool("/plugins/gtk/timestamp_format/force_24hr", TRUE); | |
| 169 | ||
| 170 | gaim_prefs_add_none("/plugins/gtk/timestamp_format/use_dates"); | |
| 171 | gaim_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/conversation", "automatic"); | |
| 172 | gaim_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/log", "automatic"); | |
| 173 | } | |
| 174 | ||
| 175 | GAIM_INIT_PLUGIN(timestamp_format, init_plugin, info) |