Sat, 17 Apr 2010 01:27:04 +0000
Add network listen functions that accept a family argument (AF_INET(6?)).
These allow code to portably support IPv6 for listeners (mostly file
transfers and Bonjour). Callers should use the purple_socket_speaks_ipv4
to determine whether they need two sockets or just an IPv6 one. I used
GIO's g_socket_speaks_ipv4 as the inspiration for that.
| 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" | |
|
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 | 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 | |
| 15884 | 15 | static PurplePluginPrefFrame * |
| 16 | get_plugin_pref_frame(PurplePlugin *plugin) | |
| 12737 | 17 | { |
| 15884 | 18 | PurplePluginPrefFrame *frame; |
| 19 | PurplePluginPref *ppref; | |
|
16073
e70e589dde54
more help for translators (I removed a few PIDGIN_NAME references
Nathan Walp <nwalp@pidgin.im>
parents:
15939
diff
changeset
|
20 | char *tmp; |
| 12737 | 21 | |
| 15884 | 22 | frame = purple_plugin_pref_frame_new(); |
| 12737 | 23 | |
| 15884 | 24 | ppref = purple_plugin_pref_new_with_label(_("Timestamp Format Options")); |
| 25 | purple_plugin_pref_frame_add(frame, ppref); | |
| 12737 | 26 | |
|
16976
3a4c6c96e2cf
Traditional Pidgin doesn't make any sense. It was only ever the case for
Richard Laager <rlaager@pidgin.im>
parents:
16865
diff
changeset
|
27 | tmp = g_strdup_printf(_("_Force 24-hour time format")); |
| 15884 | 28 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 12737 | 29 | "/plugins/gtk/timestamp_format/force_24hr", |
|
16073
e70e589dde54
more help for translators (I removed a few PIDGIN_NAME references
Nathan Walp <nwalp@pidgin.im>
parents:
15939
diff
changeset
|
30 | tmp); |
| 15884 | 31 | 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
|
32 | g_free(tmp); |
| 12737 | 33 | |
| 15884 | 34 | ppref = purple_plugin_pref_new_with_label(_("Show dates in...")); |
| 35 | purple_plugin_pref_frame_add(frame, ppref); | |
| 12737 | 36 | |
| 15884 | 37 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 12737 | 38 | "/plugins/gtk/timestamp_format/use_dates/conversation", |
| 39 | _("Co_nversations:")); | |
| 15884 | 40 | purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE); |
| 41 | purple_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic"); | |
| 42 | purple_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats"); | |
| 43 | purple_plugin_pref_add_choice(ppref, _("Always"), "always"); | |
| 44 | purple_plugin_pref_frame_add(frame, ppref); | |
| 12737 | 45 | |
| 15884 | 46 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 12737 | 47 | "/plugins/gtk/timestamp_format/use_dates/log", |
|
12848
a6cc4c3c950f
[gaim-migrate @ 15198]
Richard Laager <rlaager@pidgin.im>
parents:
12737
diff
changeset
|
48 | _("_Message Logs:")); |
| 15884 | 49 | purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE); |
| 50 | purple_plugin_pref_add_choice(ppref, _("For delayed messages"), "automatic"); | |
| 51 | purple_plugin_pref_add_choice(ppref, _("For delayed messages and in chats"), "chats"); | |
| 52 | purple_plugin_pref_add_choice(ppref, _("Always"), "always"); | |
| 53 | purple_plugin_pref_frame_add(frame, ppref); | |
| 12737 | 54 | |
| 55 | return frame; | |
| 56 | } | |
| 57 | ||
| 15884 | 58 | static char *timestamp_cb_common(PurpleConversation *conv, |
|
14049
c15c41423e19
[gaim-migrate @ 16559]
Richard Laager <rlaager@pidgin.im>
parents:
13115
diff
changeset
|
59 | 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
|
60 | gboolean show_date, |
| 12737 | 61 | gboolean force, |
| 16865 | 62 | const char *dates, |
| 63 | gboolean parens) | |
| 12737 | 64 | { |
| 65 | g_return_val_if_fail(dates != NULL, NULL); | |
| 66 | ||
|
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
|
67 | 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
|
68 | !strcmp(dates, "always") || |
| 15884 | 69 | (conv != NULL && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && !strcmp(dates, "chats"))) |
| 12737 | 70 | { |
|
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
|
71 | struct tm *tm = localtime(&t); |
| 12737 | 72 | if (force) |
| 16865 | 73 | return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_utf8_strftime("%Y-%m-%d %H:%M:%S", tm), parens ? ")" : ""); |
| 12737 | 74 | else |
| 16865 | 75 | return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_date_format_long(tm), parens ? ")" : ""); |
| 12737 | 76 | } |
| 77 | ||
| 78 | 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
|
79 | { |
|
bd1e13b63e4b
In Pidgin, display a full date on the timestamp of the first message to
Richard Laager <rlaager@pidgin.im>
parents:
15562
diff
changeset
|
80 | struct tm *tm = localtime(&t); |
| 16865 | 81 | return g_strdup_printf("%s%s%s", parens ? "(" : "", purple_utf8_strftime("%H:%M:%S", tm), parens ? ")" : ""); |
|
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
|
82 | } |
| 12737 | 83 | |
| 84 | return NULL; | |
| 85 | } | |
| 86 | ||
| 15884 | 87 | 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
|
88 | time_t t, gboolean show_date, gpointer data) |
| 12737 | 89 | { |
| 15884 | 90 | gboolean force = purple_prefs_get_bool( |
| 12737 | 91 | "/plugins/gtk/timestamp_format/force_24hr"); |
| 15884 | 92 | const char *dates = purple_prefs_get_string( |
| 12737 | 93 | "/plugins/gtk/timestamp_format/use_dates/conversation"); |
|
13054
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
94 | |
|
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
95 | g_return_val_if_fail(conv != NULL, NULL); |
|
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
96 | |
| 16865 | 97 | return timestamp_cb_common(conv, t, show_date, force, dates, TRUE); |
| 12737 | 98 | } |
| 99 | ||
| 15884 | 100 | static char *log_timestamp_cb(PurpleLog *log, time_t t, gboolean show_date, gpointer data) |
| 12737 | 101 | { |
| 15884 | 102 | gboolean force = purple_prefs_get_bool( |
| 12737 | 103 | "/plugins/gtk/timestamp_format/force_24hr"); |
| 15884 | 104 | const char *dates = purple_prefs_get_string( |
| 12737 | 105 | "/plugins/gtk/timestamp_format/use_dates/log"); |
| 106 | ||
|
13054
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
107 | g_return_val_if_fail(log != NULL, NULL); |
|
6d323387986e
[gaim-migrate @ 15416]
Richard Laager <rlaager@pidgin.im>
parents:
12851
diff
changeset
|
108 | |
| 16865 | 109 | return timestamp_cb_common(log->conv, t, show_date, force, dates, FALSE); |
| 12737 | 110 | } |
| 111 | ||
|
30000
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
112 | static void |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
113 | 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
|
114 | { |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
115 | 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
|
116 | 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
|
117 | if (!frame) |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
118 | return; |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
119 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | NULL); |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
124 | 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
|
125 | #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
|
126 | 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
|
127 | #else |
|
30000
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
128 | 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
|
129 | #endif |
|
30000
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | } |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
134 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
135 | static gboolean |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
136 | 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
|
137 | 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
|
138 | { |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
139 | 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
|
140 | 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
|
141 | GtkTextBuffer *buffer; |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
142 | GtkTextIter cursor; |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
143 | 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
|
144 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
145 | 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
|
146 | return TRUE; |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
147 | |
|
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
|
148 | #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
|
149 | 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
|
150 | 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
|
151 | #else |
|
30000
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
152 | 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
|
153 | 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
|
154 | #endif |
|
30000
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
155 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
156 | 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
|
157 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
158 | 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
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | return TRUE; |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
163 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
164 | 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
|
165 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
166 | 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
|
167 | 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
|
168 | 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
|
169 | 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
|
170 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
171 | 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
|
172 | 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
|
173 | 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
|
174 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
175 | return TRUE; |
|
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 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
178 | 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
|
179 | 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
|
180 | |
| 12737 | 181 | static gboolean |
| 15884 | 182 | plugin_load(PurplePlugin *plugin) |
| 12737 | 183 | { |
|
30000
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
184 | 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
|
185 | |
| 15884 | 186 | purple_signal_connect(pidgin_conversations_get_handle(), "conversation-timestamp", |
| 187 | plugin, PURPLE_CALLBACK(conversation_timestamp_cb), NULL); | |
| 188 | purple_signal_connect(purple_log_get_handle(), "log-timestamp", | |
| 189 | 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
|
190 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
191 | 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
|
192 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
193 | /* 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
|
194 | 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
|
195 | 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
|
196 | plugin, NULL); |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
197 | |
|
a6ceec33f2c1
Add a context option for the timestamps in the conversation log.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20288
diff
changeset
|
198 | 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
|
199 | |
| 12737 | 200 | return TRUE; |
| 201 | } | |
| 202 | ||
| 203 | static gboolean | |
| 15884 | 204 | plugin_unload(PurplePlugin *plugin) |
| 12737 | 205 | { |
|
30000
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_remove_emission_hook(signal_id, hook_id); |
| 12737 | 207 | return TRUE; |
| 208 | } | |
| 209 | ||
| 15884 | 210 | static PurplePluginUiInfo prefs_info = { |
| 12737 | 211 | get_plugin_pref_frame, |
| 212 | 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
|
213 | 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
|
214 | |
|
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
|
215 | /* 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
|
216 | 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
|
217 | 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
|
218 | 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
|
219 | NULL |
| 12737 | 220 | }; |
| 221 | ||
| 15884 | 222 | static PurplePluginInfo info = |
| 12737 | 223 | { |
| 15884 | 224 | PURPLE_PLUGIN_MAGIC, |
| 225 | PURPLE_MAJOR_VERSION, | |
| 226 | PURPLE_MINOR_VERSION, | |
|
15939
efc69ea48720
The Message Timestamp Formats plugin lacked an ID before.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
227 | 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
|
228 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
| 12737 | 229 | 0, /**< flags */ |
| 230 | NULL, /**< dependencies */ | |
|
15939
efc69ea48720
The Message Timestamp Formats plugin lacked an ID before.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
231 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 12737 | 232 | |
|
15939
efc69ea48720
The Message Timestamp Formats plugin lacked an ID before.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
233 | "core-timestamp_format", /**< id */ |
| 12737 | 234 | N_("Message Timestamp Formats"), /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16976
diff
changeset
|
235 | DISPLAY_VERSION, /**< version */ |
| 12737 | 236 | /** summary */ |
| 237 | N_("Customizes the message timestamp formats."), | |
| 238 | /** description */ | |
| 239 | N_("This plugin allows the user to customize " | |
| 240 | "conversation and logging message timestamp " | |
| 241 | "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
|
242 | "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
|
243 | PURPLE_WEBSITE, /**< homepage */ |
| 12737 | 244 | |
| 245 | plugin_load, /**< load */ | |
| 246 | plugin_unload, /**< unload */ | |
| 247 | NULL, /**< destroy */ | |
| 248 | ||
| 249 | NULL, /**< ui_info */ | |
| 250 | NULL, /**< extra_info */ | |
| 251 | &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
|
252 | 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
|
253 | |
|
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 | /* 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
|
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, |
|
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
|
258 | NULL |
| 12737 | 259 | }; |
| 260 | ||
| 261 | static void | |
| 15884 | 262 | init_plugin(PurplePlugin *plugin) |
| 12737 | 263 | { |
| 15884 | 264 | purple_prefs_add_none("/plugins/gtk"); |
| 265 | purple_prefs_add_none("/plugins/gtk/timestamp_format"); | |
| 12737 | 266 | |
| 15884 | 267 | purple_prefs_add_bool("/plugins/gtk/timestamp_format/force_24hr", TRUE); |
| 12737 | 268 | |
| 15884 | 269 | purple_prefs_add_none("/plugins/gtk/timestamp_format/use_dates"); |
| 270 | purple_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/conversation", "automatic"); | |
| 271 | purple_prefs_add_string("/plugins/gtk/timestamp_format/use_dates/log", "automatic"); | |
| 12737 | 272 | } |
| 273 | ||
| 15884 | 274 | PURPLE_INIT_PLUGIN(timestamp_format, init_plugin, info) |