Mercurial > pidgin.yaz
comparison plugins/timestamp.c @ 10389:c432b927b0b1
[gaim-migrate @ 11616]
Cleaned up "use_server_alias" some more and removed the timestamp option.
Default: Yes. The timestamp plugin will override this, however; also the
timestamp is now centered in the conversation.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 16 Dec 2004 05:34:34 +0000 |
parents | 60db14d54914 |
children | de92a8da82c3 |
comparison
equal
deleted
inserted
replaced
10388:088633feb846 | 10389:c432b927b0b1 |
---|---|
42 static GSList *timestamp_timeouts = NULL; | 42 static GSList *timestamp_timeouts = NULL; |
43 | 43 |
44 static gboolean do_timestamp (gpointer data) | 44 static gboolean do_timestamp (gpointer data) |
45 { | 45 { |
46 GaimConversation *c = (GaimConversation *)data; | 46 GaimConversation *c = (GaimConversation *)data; |
47 char *buf; | 47 GaimGtkConversation *conv = GAIM_GTK_CONVERSATION(c); |
48 GtkTextIter iter; | |
48 char mdate[6]; | 49 char mdate[6]; |
49 int is_conversation_active; | 50 int is_conversation_active; |
50 time_t tim = time(NULL); | 51 time_t tim = time(NULL); |
51 | 52 |
52 if (!g_list_find(gaim_get_conversations(), c)) | 53 if (!g_list_find(gaim_get_conversations(), c)) |
54 | 55 |
55 /* is_conversation_active is true if an im has been displayed since the last timestamp */ | 56 /* is_conversation_active is true if an im has been displayed since the last timestamp */ |
56 is_conversation_active = GPOINTER_TO_INT(gaim_conversation_get_data(c, "timestamp-conv-active")); | 57 is_conversation_active = GPOINTER_TO_INT(gaim_conversation_get_data(c, "timestamp-conv-active")); |
57 | 58 |
58 if (is_conversation_active){ | 59 if (is_conversation_active){ |
60 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(conv->imhtml)); | |
61 gtk_text_buffer_get_end_iter(buffer, &iter); | |
59 gaim_conversation_set_data(c, "timestamp-conv-active", GINT_TO_POINTER(FALSE)); | 62 gaim_conversation_set_data(c, "timestamp-conv-active", GINT_TO_POINTER(FALSE)); |
60 strftime(mdate, sizeof(mdate), "%H:%M", localtime(&tim)); | 63 strftime(mdate, sizeof(mdate), "%H:%M", localtime(&tim)); |
61 buf = g_strdup_printf(" %s", mdate); | 64 gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, mdate, strlen(mdate), "TIMESTAMP", NULL); |
62 gaim_conversation_write(c, NULL, buf, GAIM_MESSAGE_NO_LOG, tim); | |
63 g_free(buf); | |
64 } | 65 } |
65 else | 66 else |
66 gaim_conversation_set_data(c, "timestamp-enabled", GINT_TO_POINTER(FALSE)); | 67 gaim_conversation_set_data(c, "timestamp-enabled", GINT_TO_POINTER(FALSE)); |
67 | 68 |
68 return TRUE; | 69 return TRUE; |
101 } | 102 } |
102 | 103 |
103 | 104 |
104 static void timestamp_new_convo(GaimConversation *conv) | 105 static void timestamp_new_convo(GaimConversation *conv) |
105 { | 106 { |
107 GaimGtkConversation *c = GAIM_GTK_CONVERSATION(conv); | |
108 | |
106 if (!g_list_find(gaim_get_conversations(), conv)) | 109 if (!g_list_find(gaim_get_conversations(), conv)) |
107 return; | 110 return; |
108 | 111 |
112 gtk_imhtml_show_comments(GTK_IMHTML(c->imhtml), FALSE); | |
113 | |
109 /* | 114 /* |
110 This if statement stops conversations that have already been initialized for timestamps | 115 This if statement stops conversations that have already been initialized for timestamps |
111 from being reinitialized. This prevents every active conversation from immediately being spammed | 116 from being reinitialized. This prevents every active conversation from immediately being spammed |
112 with a new timestamp when the user modifies the timer interval. | 117 with a new timestamp when the user modifies the timer interval. |
113 */ | 118 */ |
114 if (!gaim_conversation_get_data(conv, "timestamp-initialized")){ | 119 if (!gaim_conversation_get_data(conv, "timestamp-initialized")){ |
120 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(c->imhtml)); | |
115 gaim_conversation_set_data(conv, "timestamp-initialized", GINT_TO_POINTER(TRUE)); | 121 gaim_conversation_set_data(conv, "timestamp-initialized", GINT_TO_POINTER(TRUE)); |
116 gaim_conversation_set_data(conv, "timestamp-enabled", GINT_TO_POINTER(TRUE)); | 122 gaim_conversation_set_data(conv, "timestamp-enabled", GINT_TO_POINTER(TRUE)); |
117 gaim_conversation_set_data(conv, "timestamp-conv-active", GINT_TO_POINTER(TRUE)); | 123 gaim_conversation_set_data(conv, "timestamp-conv-active", GINT_TO_POINTER(TRUE)); |
124 gtk_text_buffer_create_tag (buffer, "TIMESTAMP", "foreground", "#888888", "justification", GTK_JUSTIFY_CENTER, | |
125 "weight", PANGO_WEIGHT_BOLD, NULL); | |
118 do_timestamp(conv); | 126 do_timestamp(conv); |
119 } | 127 } |
120 | 128 |
121 timestamp_timeouts = g_slist_append(timestamp_timeouts, | 129 timestamp_timeouts = g_slist_append(timestamp_timeouts, |
122 GINT_TO_POINTER(g_timeout_add(interval, do_timestamp, conv))); | 130 GINT_TO_POINTER(g_timeout_add(interval, do_timestamp, conv))); |
233 | 241 |
234 | 242 |
235 static gboolean | 243 static gboolean |
236 plugin_unload(GaimPlugin *plugin) | 244 plugin_unload(GaimPlugin *plugin) |
237 { | 245 { |
246 GList *cnvs; | |
238 void *conv_handle = gaim_conversations_get_handle(); | 247 void *conv_handle = gaim_conversations_get_handle(); |
239 | 248 |
240 gaim_signal_disconnect(conv_handle, "conversation-created", | 249 gaim_signal_disconnect(conv_handle, "conversation-created", |
241 plugin, GAIM_CALLBACK(timestamp_new_convo)); | 250 plugin, GAIM_CALLBACK(timestamp_new_convo)); |
242 gaim_signal_disconnect(conv_handle, "receiving-im-msg", | 251 gaim_signal_disconnect(conv_handle, "receiving-im-msg", |
243 plugin, GAIM_CALLBACK(timestamp_receiving_msg)); | 252 plugin, GAIM_CALLBACK(timestamp_receiving_msg)); |
244 gaim_signal_disconnect(conv_handle, "displaying-im-msg", | 253 gaim_signal_disconnect(conv_handle, "displaying-im-msg", |
245 plugin, GAIM_CALLBACK(timestamp_displaying_conv_msg)); | 254 plugin, GAIM_CALLBACK(timestamp_displaying_conv_msg)); |
246 | 255 |
247 destroy_timer_list(); | 256 destroy_timer_list(); |
257 | |
258 for (cnvs = gaim_get_conversations(); cnvs != NULL; cnvs = cnvs->next) { | |
259 GaimConversation *c = cnvs->data; | |
260 GaimGtkConversation *conv = GAIM_GTK_CONVERSATION(c); | |
261 gtk_imhtml_show_comments(GTK_IMHTML(conv->imhtml), TRUE); | |
262 } | |
263 | |
248 return TRUE; | 264 return TRUE; |
249 } | 265 } |
250 | 266 |
251 static GaimGtkPluginUiInfo ui_info = | 267 static GaimGtkPluginUiInfo ui_info = |
252 { | 268 { |