Mercurial > pidgin.yaz
comparison pidgin/plugins/timestamp_format.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | b6615958d87c |
children | fde34f782314 |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
9 #include "gtkconv.h" | 9 #include "gtkconv.h" |
10 #include "gtkplugin.h" | 10 #include "gtkplugin.h" |
11 | 11 |
12 #include <time.h> | 12 #include <time.h> |
13 | 13 |
14 static GaimPluginPrefFrame * | 14 static PurplePluginPrefFrame * |
15 get_plugin_pref_frame(GaimPlugin *plugin) | 15 get_plugin_pref_frame(PurplePlugin *plugin) |
16 { | 16 { |
17 GaimPluginPrefFrame *frame; | 17 PurplePluginPrefFrame *frame; |
18 GaimPluginPref *ppref; | 18 PurplePluginPref *ppref; |
19 | 19 |
20 frame = gaim_plugin_pref_frame_new(); | 20 frame = purple_plugin_pref_frame_new(); |
21 | 21 |
22 ppref = gaim_plugin_pref_new_with_label(_("Timestamp Format Options")); | 22 ppref = purple_plugin_pref_new_with_label(_("Timestamp Format Options")); |
23 gaim_plugin_pref_frame_add(frame, ppref); | 23 purple_plugin_pref_frame_add(frame, ppref); |
24 | 24 |
25 ppref = gaim_plugin_pref_new_with_name_and_label( | 25 ppref = purple_plugin_pref_new_with_name_and_label( |
26 "/plugins/gtk/timestamp_format/force_24hr", | 26 "/plugins/gtk/timestamp_format/force_24hr", |
27 _("_Force (traditional " PIDGIN_NAME ") 24-hour time format")); | 27 _("_Force (traditional " PIDGIN_NAME ") 24-hour time format")); |
28 gaim_plugin_pref_frame_add(frame, ppref); | 28 purple_plugin_pref_frame_add(frame, ppref); |
29 | 29 |
30 ppref = gaim_plugin_pref_new_with_label(_("Show dates in...")); | 30 ppref = purple_plugin_pref_new_with_label(_("Show dates in...")); |
31 gaim_plugin_pref_frame_add(frame, ppref); | 31 purple_plugin_pref_frame_add(frame, ppref); |
32 | 32 |
33 ppref = gaim_plugin_pref_new_with_name_and_label( | 33 ppref = purple_plugin_pref_new_with_name_and_label( |
34 "/plugins/gtk/timestamp_format/use_dates/conversation", | 34 "/plugins/gtk/timestamp_format/use_dates/conversation", |
35 _("Co_nversations:")); | 35 _("Co_nversations:")); |
36 gaim_plugin_pref_set_type(ppref, GAIM_PLUGIN_PREF_CHOICE); | 36 purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE); |
37 gaim_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic"); | 37 purple_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic"); |
38 gaim_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats"); | 38 purple_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats"); |
39 gaim_plugin_pref_add_choice(ppref, _("Always"), "always"); | 39 purple_plugin_pref_add_choice(ppref, _("Always"), "always"); |
40 gaim_plugin_pref_frame_add(frame, ppref); | 40 purple_plugin_pref_frame_add(frame, ppref); |
41 | 41 |
42 ppref = gaim_plugin_pref_new_with_name_and_label( | 42 ppref = purple_plugin_pref_new_with_name_and_label( |
43 "/plugins/gtk/timestamp_format/use_dates/log", | 43 "/plugins/gtk/timestamp_format/use_dates/log", |
44 _("_Message Logs:")); | 44 _("_Message Logs:")); |
45 gaim_plugin_pref_set_type(ppref, GAIM_PLUGIN_PREF_CHOICE); | 45 purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE); |
46 gaim_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic"); | 46 purple_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic"); |
47 gaim_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats"); | 47 purple_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats"); |
48 gaim_plugin_pref_add_choice(ppref, _("Always"), "always"); | 48 purple_plugin_pref_add_choice(ppref, _("Always"), "always"); |
49 gaim_plugin_pref_frame_add(frame, ppref); | 49 purple_plugin_pref_frame_add(frame, ppref); |
50 | 50 |
51 return frame; | 51 return frame; |
52 } | 52 } |
53 | 53 |
54 static char *timestamp_cb_common(GaimConversation *conv, | 54 static char *timestamp_cb_common(PurpleConversation *conv, |
55 time_t t, | 55 time_t t, |
56 gboolean show_date, | 56 gboolean show_date, |
57 gboolean force, | 57 gboolean force, |
58 const char *dates) | 58 const char *dates) |
59 { | 59 { |
60 g_return_val_if_fail(dates != NULL, NULL); | 60 g_return_val_if_fail(dates != NULL, NULL); |
61 | 61 |
62 if (show_date || | 62 if (show_date || |
63 !strcmp(dates, "always") || | 63 !strcmp(dates, "always") || |
64 (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && !strcmp(dates, "chats"))) | 64 (conv != NULL && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && !strcmp(dates, "chats"))) |
65 { | 65 { |
66 struct tm *tm = localtime(&t); | 66 struct tm *tm = localtime(&t); |
67 if (force) | 67 if (force) |
68 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); | 68 return g_strdup(purple_utf8_strftime("%Y-%m-%d %H:%M:%S", tm)); |
69 else | 69 else |
70 return g_strdup(gaim_date_format_long(tm)); | 70 return g_strdup(purple_date_format_long(tm)); |
71 } | 71 } |
72 | 72 |
73 if (force) | 73 if (force) |
74 { | 74 { |
75 struct tm *tm = localtime(&t); | 75 struct tm *tm = localtime(&t); |
76 return g_strdup(gaim_utf8_strftime("%H:%M:%S", tm)); | 76 return g_strdup(purple_utf8_strftime("%H:%M:%S", tm)); |
77 } | 77 } |
78 | 78 |
79 return NULL; | 79 return NULL; |
80 } | 80 } |
81 | 81 |
82 static char *conversation_timestamp_cb(GaimConversation *conv, | 82 static char *conversation_timestamp_cb(PurpleConversation *conv, |
83 time_t t, gboolean show_date, gpointer data) | 83 time_t t, gboolean show_date, gpointer data) |
84 { | 84 { |
85 gboolean force = gaim_prefs_get_bool( | 85 gboolean force = purple_prefs_get_bool( |
86 "/plugins/gtk/timestamp_format/force_24hr"); | 86 "/plugins/gtk/timestamp_format/force_24hr"); |
87 const char *dates = gaim_prefs_get_string( | 87 const char *dates = purple_prefs_get_string( |
88 "/plugins/gtk/timestamp_format/use_dates/conversation"); | 88 "/plugins/gtk/timestamp_format/use_dates/conversation"); |
89 | 89 |
90 g_return_val_if_fail(conv != NULL, NULL); | 90 g_return_val_if_fail(conv != NULL, NULL); |
91 | 91 |
92 return timestamp_cb_common(conv, t, show_date, force, dates); | 92 return timestamp_cb_common(conv, t, show_date, force, dates); |
93 } | 93 } |
94 | 94 |
95 static char *log_timestamp_cb(GaimLog *log, time_t t, gboolean show_date, gpointer data) | 95 static char *log_timestamp_cb(PurpleLog *log, time_t t, gboolean show_date, gpointer data) |
96 { | 96 { |
97 gboolean force = gaim_prefs_get_bool( | 97 gboolean force = purple_prefs_get_bool( |
98 "/plugins/gtk/timestamp_format/force_24hr"); | 98 "/plugins/gtk/timestamp_format/force_24hr"); |
99 const char *dates = gaim_prefs_get_string( | 99 const char *dates = purple_prefs_get_string( |
100 "/plugins/gtk/timestamp_format/use_dates/log"); | 100 "/plugins/gtk/timestamp_format/use_dates/log"); |
101 | 101 |
102 g_return_val_if_fail(log != NULL, NULL); | 102 g_return_val_if_fail(log != NULL, NULL); |
103 | 103 |
104 return timestamp_cb_common(log->conv, t, show_date, force, dates); | 104 return timestamp_cb_common(log->conv, t, show_date, force, dates); |
105 } | 105 } |
106 | 106 |
107 static gboolean | 107 static gboolean |
108 plugin_load(GaimPlugin *plugin) | 108 plugin_load(PurplePlugin *plugin) |
109 { | 109 { |
110 gaim_signal_connect(pidgin_conversations_get_handle(), "conversation-timestamp", | 110 purple_signal_connect(pidgin_conversations_get_handle(), "conversation-timestamp", |
111 plugin, GAIM_CALLBACK(conversation_timestamp_cb), NULL); | 111 plugin, PURPLE_CALLBACK(conversation_timestamp_cb), NULL); |
112 gaim_signal_connect(gaim_log_get_handle(), "log-timestamp", | 112 purple_signal_connect(purple_log_get_handle(), "log-timestamp", |
113 plugin, GAIM_CALLBACK(log_timestamp_cb), NULL); | 113 plugin, PURPLE_CALLBACK(log_timestamp_cb), NULL); |
114 return TRUE; | 114 return TRUE; |
115 } | 115 } |
116 | 116 |
117 static gboolean | 117 static gboolean |
118 plugin_unload(GaimPlugin *plugin) | 118 plugin_unload(PurplePlugin *plugin) |
119 { | 119 { |
120 return TRUE; | 120 return TRUE; |
121 } | 121 } |
122 | 122 |
123 static GaimPluginUiInfo prefs_info = { | 123 static PurplePluginUiInfo prefs_info = { |
124 get_plugin_pref_frame, | 124 get_plugin_pref_frame, |
125 0, /* page num (Reserved) */ | 125 0, /* page num (Reserved) */ |
126 NULL /* frame (Reserved) */ | 126 NULL /* frame (Reserved) */ |
127 }; | 127 }; |
128 | 128 |
129 static GaimPluginInfo info = | 129 static PurplePluginInfo info = |
130 { | 130 { |
131 GAIM_PLUGIN_MAGIC, | 131 PURPLE_PLUGIN_MAGIC, |
132 GAIM_MAJOR_VERSION, | 132 PURPLE_MAJOR_VERSION, |
133 GAIM_MINOR_VERSION, | 133 PURPLE_MINOR_VERSION, |
134 GAIM_PLUGIN_STANDARD, /**< type */ | 134 PURPLE_PLUGIN_STANDARD, /**< type */ |
135 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ | 135 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
136 0, /**< flags */ | 136 0, /**< flags */ |
137 NULL, /**< dependencies */ | 137 NULL, /**< dependencies */ |
138 GAIM_PRIORITY_DEFAULT, /**< priority */ | 138 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
139 | 139 |
140 NULL, /**< id */ | 140 NULL, /**< id */ |
141 N_("Message Timestamp Formats"), /**< name */ | 141 N_("Message Timestamp Formats"), /**< name */ |
142 VERSION, /**< version */ | 142 VERSION, /**< version */ |
143 /** summary */ | 143 /** summary */ |
145 /** description */ | 145 /** description */ |
146 N_("This plugin allows the user to customize " | 146 N_("This plugin allows the user to customize " |
147 "conversation and logging message timestamp " | 147 "conversation and logging message timestamp " |
148 "formats."), | 148 "formats."), |
149 "Richard Laager <rlaager@pidgin.im>", /**< author */ | 149 "Richard Laager <rlaager@pidgin.im>", /**< author */ |
150 GAIM_WEBSITE, /**< homepage */ | 150 PURPLE_WEBSITE, /**< homepage */ |
151 | 151 |
152 plugin_load, /**< load */ | 152 plugin_load, /**< load */ |
153 plugin_unload, /**< unload */ | 153 plugin_unload, /**< unload */ |
154 NULL, /**< destroy */ | 154 NULL, /**< destroy */ |
155 | 155 |
158 &prefs_info, /**< prefs_info */ | 158 &prefs_info, /**< prefs_info */ |
159 NULL /**< actions */ | 159 NULL /**< actions */ |
160 }; | 160 }; |
161 | 161 |
162 static void | 162 static void |
163 init_plugin(GaimPlugin *plugin) | 163 init_plugin(PurplePlugin *plugin) |
164 { | 164 { |
165 gaim_prefs_add_none("/plugins/gtk"); | 165 purple_prefs_add_none("/plugins/gtk"); |
166 gaim_prefs_add_none("/plugins/gtk/timestamp_format"); | 166 purple_prefs_add_none("/plugins/gtk/timestamp_format"); |
167 | 167 |
168 gaim_prefs_add_bool("/plugins/gtk/timestamp_format/force_24hr", TRUE); | 168 purple_prefs_add_bool("/plugins/gtk/timestamp_format/force_24hr", TRUE); |
169 | 169 |
170 gaim_prefs_add_none("/plugins/gtk/timestamp_format/use_dates"); | 170 purple_prefs_add_none("/plugins/gtk/timestamp_format/use_dates"); |
171 gaim_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/conversation", "automatic"); | 171 purple_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/conversation", "automatic"); |
172 gaim_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/log", "automatic"); | 172 purple_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/log", "automatic"); |
173 } | 173 } |
174 | 174 |
175 GAIM_INIT_PLUGIN(timestamp_format, init_plugin, info) | 175 PURPLE_INIT_PLUGIN(timestamp_format, init_plugin, info) |