pidgin/gtkstatusbox.c

changeset 26753
a8dca8faae69
parent 25903
7a2258038ceb
child 26820
76f90ca8f6f2
equal deleted inserted replaced
26752:27fe5aa7cbd0 26753:a8dca8faae69
65 # ifdef _WIN32 65 # ifdef _WIN32
66 # include "wspell.h" 66 # include "wspell.h"
67 # endif 67 # endif
68 #endif 68 #endif
69 69
70 #define TYPING_TIMEOUT 4000 70 /* Timeout for typing notifications in seconds */
71 #define TYPING_TIMEOUT 4
71 72
72 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); 73 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data);
73 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data); 74 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data);
74 static void remove_typing_cb(PidginStatusBox *box); 75 static void remove_typing_cb(PidginStatusBox *box);
75 static void update_size (PidginStatusBox *box); 76 static void update_size (PidginStatusBox *box);
1153 return FALSE; 1154 return FALSE;
1154 1155
1155 /* Reset the status if Escape was pressed */ 1156 /* Reset the status if Escape was pressed */
1156 if (event->keyval == GDK_Escape) 1157 if (event->keyval == GDK_Escape)
1157 { 1158 {
1158 g_source_remove(status_box->typing); 1159 purple_timeout_remove(status_box->typing);
1159 status_box->typing = 0; 1160 status_box->typing = 0;
1160 if (status_box->account != NULL) 1161 if (status_box->account != NULL)
1161 update_to_reflect_account_status(status_box, status_box->account, 1162 update_to_reflect_account_status(status_box, status_box->account,
1162 purple_account_get_active_status(status_box->account)); 1163 purple_account_get_active_status(status_box->account));
1163 else { 1164 else {
1166 } 1167 }
1167 return TRUE; 1168 return TRUE;
1168 } 1169 }
1169 1170
1170 pidgin_status_box_pulse_typing(status_box); 1171 pidgin_status_box_pulse_typing(status_box);
1171 g_source_remove(status_box->typing); 1172 purple_timeout_remove(status_box->typing);
1172 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); 1173 status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
1173 1174
1174 return FALSE; 1175 return FALSE;
1175 } 1176 }
1176 1177
1177 #if GTK_CHECK_VERSION(2,6,0) 1178 #if GTK_CHECK_VERSION(2,6,0)
2594 /* Nothing has changed, so we don't need to do anything */ 2595 /* Nothing has changed, so we don't need to do anything */
2595 status_menu_refresh_iter(status_box); 2596 status_menu_refresh_iter(status_box);
2596 return; 2597 return;
2597 } 2598 }
2598 2599
2599 g_source_remove(status_box->typing); 2600 purple_timeout_remove(status_box->typing);
2600 status_box->typing = 0; 2601 status_box->typing = 0;
2601 2602
2602 activate_currently_selected_status(status_box); 2603 activate_currently_selected_status(status_box);
2603 pidgin_status_box_refresh(status_box); 2604 pidgin_status_box_refresh(status_box);
2604 } 2605 }
2622 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, 2623 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter,
2623 TYPE_COLUMN, &type, 2624 TYPE_COLUMN, &type,
2624 DATA_COLUMN, &data, 2625 DATA_COLUMN, &data,
2625 -1); 2626 -1);
2626 if (status_box->typing != 0) 2627 if (status_box->typing != 0)
2627 g_source_remove(status_box->typing); 2628 purple_timeout_remove(status_box->typing);
2628 status_box->typing = 0; 2629 status_box->typing = 0;
2629 2630
2630 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) 2631 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box)))
2631 { 2632 {
2632 if (type == PIDGIN_STATUS_BOX_TYPE_POPULAR || type == PIDGIN_STATUS_BOX_TYPE_SAVED_POPULAR) 2633 if (type == PIDGIN_STATUS_BOX_TYPE_POPULAR || type == PIDGIN_STATUS_BOX_TYPE_SAVED_POPULAR)
2690 if (status_box->imhtml_visible) 2691 if (status_box->imhtml_visible)
2691 { 2692 {
2692 GtkTextIter start, end; 2693 GtkTextIter start, end;
2693 GtkTextBuffer *buffer; 2694 GtkTextBuffer *buffer;
2694 gtk_widget_show_all(status_box->vbox); 2695 gtk_widget_show_all(status_box->vbox);
2695 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); 2696 status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
2696 gtk_widget_grab_focus(status_box->imhtml); 2697 gtk_widget_grab_focus(status_box->imhtml);
2697 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); 2698 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml));
2698 gtk_text_buffer_get_bounds(buffer, &start, &end); 2699 gtk_text_buffer_get_bounds(buffer, &start, &end);
2699 gtk_text_buffer_move_mark(buffer, gtk_text_buffer_get_mark(buffer, "insert"), &end); 2700 gtk_text_buffer_move_mark(buffer, gtk_text_buffer_get_mark(buffer, "insert"), &end);
2700 gtk_text_buffer_move_mark(buffer, gtk_text_buffer_get_mark(buffer, "selection_bound"), &start); 2701 gtk_text_buffer_move_mark(buffer, gtk_text_buffer_get_mark(buffer, "selection_bound"), &start);
2739 PidginStatusBox *status_box = (PidginStatusBox*)data; 2740 PidginStatusBox *status_box = (PidginStatusBox*)data;
2740 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) 2741 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box)))
2741 { 2742 {
2742 if (status_box->typing != 0) { 2743 if (status_box->typing != 0) {
2743 pidgin_status_box_pulse_typing(status_box); 2744 pidgin_status_box_pulse_typing(status_box);
2744 g_source_remove(status_box->typing); 2745 purple_timeout_remove(status_box->typing);
2745 } 2746 }
2746 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); 2747 status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
2747 } 2748 }
2748 pidgin_status_box_refresh(status_box); 2749 pidgin_status_box_refresh(status_box);
2749 } 2750 }
2750 2751
2751 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data) 2752 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data)

mercurial