pidgin/gtkstatusbox.c

branch
soc.2013.gobjectification.plugins
changeset 37102
63a5361c11a1
parent 37075
cf3f735b09b7
parent 35500
ae6432ea326f
child 37109
94d1a2589d5a
equal deleted inserted replaced
37101:8ba9a23354ff 37102:63a5361c11a1
58 #include "gtk3compat.h" 58 #include "gtk3compat.h"
59 59
60 /* Timeout for typing notifications in seconds */ 60 /* Timeout for typing notifications in seconds */
61 #define TYPING_TIMEOUT 4 61 #define TYPING_TIMEOUT 4
62 62
63 static void webview_changed_cb(GtkWebView *webview, void *data); 63 static void webview_changed_cb(PidginWebView *webview, void *data);
64 static void webview_format_changed_cb(GtkWebView *webview, GtkWebViewButtons buttons, void *data); 64 static void webview_format_changed_cb(PidginWebView *webview, PidginWebViewButtons buttons, void *data);
65 static void remove_typing_cb(PidginStatusBox *box); 65 static void remove_typing_cb(PidginStatusBox *box);
66 static void update_size (PidginStatusBox *box); 66 static void update_size (PidginStatusBox *box);
67 static gint get_statusbox_index(PidginStatusBox *box, PurpleSavedStatus *saved_status); 67 static gint get_statusbox_index(PidginStatusBox *box, PurpleSavedStatus *saved_status);
68 static PurpleAccount* check_active_accounts_for_identical_statuses(void); 68 static PurpleAccount* check_active_accounts_for_identical_statuses(void);
69 69
262 break; 262 break;
263 } 263 }
264 264
265 #if 0 265 #if 0
266 /* TODO WebKit: Doesn't do this? */ 266 /* TODO WebKit: Doesn't do this? */
267 gtk_webview_set_populate_primary_clipboard( 267 pidgin_webview_set_populate_primary_clipboard(
268 GTK_WEBVIEW(status_box->webview), TRUE); 268 PIDGIN_WEBVIEW(status_box->webview), TRUE);
269 #endif 269 #endif
270 270
271 if (status_no != -1) { 271 if (status_no != -1) {
272 GtkTreePath *path; 272 GtkTreePath *path;
273 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); 273 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE);
286 } 286 }
287 else 287 else
288 { 288 {
289 gtk_widget_show_all(status_box->vbox); 289 gtk_widget_show_all(status_box->vbox);
290 status_box->webview_visible = TRUE; 290 status_box->webview_visible = TRUE;
291 gtk_webview_load_html_string(GTK_WEBVIEW(status_box->webview), message); 291 pidgin_webview_load_html_string(PIDGIN_WEBVIEW(status_box->webview), message);
292 } 292 }
293 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); 293 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE);
294 pidgin_status_box_refresh(status_box); 294 pidgin_status_box_refresh(status_box);
295 } 295 }
296 } 296 }
877 * Suppress the "changed" signal because the status 877 * Suppress the "changed" signal because the status
878 * was changed programmatically. 878 * was changed programmatically.
879 */ 879 */
880 gtk_widget_set_sensitive(GTK_WIDGET(status_box->webview), FALSE); 880 gtk_widget_set_sensitive(GTK_WIDGET(status_box->webview), FALSE);
881 881
882 gtk_webview_load_html_string(GTK_WEBVIEW(status_box->webview), ""); 882 pidgin_webview_load_html_string(PIDGIN_WEBVIEW(status_box->webview), "");
883 gtk_webview_clear_formatting(GTK_WEBVIEW(status_box->webview)); 883 pidgin_webview_clear_formatting(PIDGIN_WEBVIEW(status_box->webview));
884 884
885 if (!purple_savedstatus_is_transient(saved_status) || !message || !*message) 885 if (!purple_savedstatus_is_transient(saved_status) || !message || !*message)
886 { 886 {
887 status_box->webview_visible = FALSE; 887 status_box->webview_visible = FALSE;
888 gtk_widget_hide(status_box->vbox); 888 gtk_widget_hide(status_box->vbox);
890 else 890 else
891 { 891 {
892 status_box->webview_visible = TRUE; 892 status_box->webview_visible = TRUE;
893 gtk_widget_show_all(status_box->vbox); 893 gtk_widget_show_all(status_box->vbox);
894 894
895 gtk_webview_load_html_string(GTK_WEBVIEW(status_box->webview), message); 895 pidgin_webview_load_html_string(PIDGIN_WEBVIEW(status_box->webview), message);
896 } 896 }
897 897
898 gtk_widget_set_sensitive(GTK_WIDGET(status_box->webview), TRUE); 898 gtk_widget_set_sensitive(GTK_WIDGET(status_box->webview), TRUE);
899 update_size(status_box); 899 update_size(status_box);
900 } 900 }
1071 gtk_tree_view_set_model(GTK_TREE_VIEW(status_box->tree_view), GTK_TREE_MODEL(status_box->dropdown_store)); 1071 gtk_tree_view_set_model(GTK_TREE_VIEW(status_box->tree_view), GTK_TREE_MODEL(status_box->dropdown_store));
1072 gtk_tree_view_set_search_column(GTK_TREE_VIEW(status_box->tree_view), TEXT_COLUMN); 1072 gtk_tree_view_set_search_column(GTK_TREE_VIEW(status_box->tree_view), TEXT_COLUMN);
1073 } 1073 }
1074 1074
1075 static gboolean 1075 static gboolean
1076 combo_box_scroll_event_cb(GtkWidget *w, GdkEventScroll *event, GtkWebView *webview) 1076 combo_box_scroll_event_cb(GtkWidget *w, GdkEventScroll *event, PidginWebView *webview)
1077 { 1077 {
1078 pidgin_status_box_popup(PIDGIN_STATUS_BOX(w), (GdkEvent *)event); 1078 pidgin_status_box_popup(PIDGIN_STATUS_BOX(w), (GdkEvent *)event);
1079 return TRUE; 1079 return TRUE;
1080 } 1080 }
1081 1081
1082 static gboolean 1082 static gboolean
1083 webview_scroll_event_cb(GtkWidget *w, GdkEventScroll *event, GtkWebView *webview) 1083 webview_scroll_event_cb(GtkWidget *w, GdkEventScroll *event, PidginWebView *webview)
1084 { 1084 {
1085 if (event->direction == GDK_SCROLL_UP) 1085 if (event->direction == GDK_SCROLL_UP)
1086 gtk_webview_page_up(webview); 1086 pidgin_webview_page_up(webview);
1087 else if (event->direction == GDK_SCROLL_DOWN) 1087 else if (event->direction == GDK_SCROLL_DOWN)
1088 gtk_webview_page_down(webview); 1088 pidgin_webview_page_down(webview);
1089 return TRUE; 1089 return TRUE;
1090 } 1090 }
1091 1091
1092 static gboolean 1092 static gboolean
1093 webview_remove_focus(GtkWidget *w, GdkEventKey *event, PidginStatusBox *status_box) 1093 webview_remove_focus(GtkWidget *w, GdkEventKey *event, PidginStatusBox *status_box)
1113 { 1113 {
1114 purple_timeout_remove(status_box->typing); 1114 purple_timeout_remove(status_box->typing);
1115 status_box->typing = 0; 1115 status_box->typing = 0;
1116 #if 0 1116 #if 0
1117 /* TODO WebKit: Doesn't do this? */ 1117 /* TODO WebKit: Doesn't do this? */
1118 gtk_webview_set_populate_primary_clipboard( 1118 pidgin_webview_set_populate_primary_clipboard(
1119 GTK_WEBVIEW(status_box->webview), TRUE); 1119 PIDGIN_WEBVIEW(status_box->webview), TRUE);
1120 #endif 1120 #endif
1121 if (status_box->account != NULL) 1121 if (status_box->account != NULL)
1122 update_to_reflect_account_status(status_box, status_box->account, 1122 update_to_reflect_account_status(status_box, status_box->account,
1123 purple_account_get_active_status(status_box->account)); 1123 purple_account_get_active_status(status_box->account));
1124 else { 1124 else {
1216 spellcheck_prefs_cb(const char *name, PurplePrefType type, 1216 spellcheck_prefs_cb(const char *name, PurplePrefType type,
1217 gconstpointer value, gpointer data) 1217 gconstpointer value, gpointer data)
1218 { 1218 {
1219 PidginStatusBox *status_box = (PidginStatusBox *)data; 1219 PidginStatusBox *status_box = (PidginStatusBox *)data;
1220 1220
1221 pidgin_webview_set_spellcheck(GTK_WEBVIEW(status_box->webview), 1221 pidgin_webview_set_spellcheck(PIDGIN_WEBVIEW(status_box->webview),
1222 (gboolean)GPOINTER_TO_INT(value)); 1222 (gboolean)GPOINTER_TO_INT(value));
1223 } 1223 }
1224 1224
1225 #if 0 1225 #if 0
1226 static gboolean button_released_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *box) 1226 static gboolean button_released_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *box)
1676 } 1676 }
1677 return FALSE; 1677 return FALSE;
1678 } 1678 }
1679 1679
1680 static void 1680 static void
1681 webview_cursor_moved_cb(gpointer data, GtkWebView *webview) 1681 webview_cursor_moved_cb(gpointer data, PidginWebView *webview)
1682 { 1682 {
1683 /* Restart the typing timeout if arrow keys are pressed while editing the message */ 1683 /* Restart the typing timeout if arrow keys are pressed while editing the message */
1684 PidginStatusBox *status_box = data; 1684 PidginStatusBox *status_box = data;
1685 if (status_box->typing == 0) 1685 if (status_box->typing == 0)
1686 return; 1686 return;
1831 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, "pixbuf", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); 1831 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, "pixbuf", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL);
1832 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); 1832 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
1833 1833
1834 status_box->vbox = gtk_vbox_new(0, FALSE); 1834 status_box->vbox = gtk_vbox_new(0, FALSE);
1835 status_box->sw = pidgin_create_webview(TRUE, &status_box->webview, NULL); 1835 status_box->sw = pidgin_create_webview(TRUE, &status_box->webview, NULL);
1836 gtk_webview_hide_toolbar(GTK_WEBVIEW(status_box->webview)); 1836 pidgin_webview_hide_toolbar(PIDGIN_WEBVIEW(status_box->webview));
1837 1837
1838 #if 0 1838 #if 0
1839 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-press-event", 1839 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-press-event",
1840 G_CALLBACK(button_pressed_cb), status_box); 1840 G_CALLBACK(button_pressed_cb), status_box);
1841 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-release-event", 1841 g_signal_connect(G_OBJECT(status_box->toggle_button), "button-release-event",
1853 G_CALLBACK(webview_cursor_moved_cb), status_box); 1853 G_CALLBACK(webview_cursor_moved_cb), status_box);
1854 g_signal_connect(G_OBJECT(status_box->webview), "key-press-event", 1854 g_signal_connect(G_OBJECT(status_box->webview), "key-press-event",
1855 G_CALLBACK(webview_remove_focus), status_box); 1855 G_CALLBACK(webview_remove_focus), status_box);
1856 1856
1857 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck")) 1857 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck"))
1858 pidgin_webview_set_spellcheck(GTK_WEBVIEW(status_box->webview), TRUE); 1858 pidgin_webview_set_spellcheck(PIDGIN_WEBVIEW(status_box->webview), TRUE);
1859 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); 1859 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box));
1860 gtk_widget_show_all(status_box->vbox); 1860 gtk_widget_show_all(status_box->vbox);
1861 1861
1862 gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box)); 1862 gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box));
1863 1863
2633 return; 2633 return;
2634 } 2634 }
2635 2635
2636 #if 0 2636 #if 0
2637 /* TODO WebKit: Doesn't do this? */ 2637 /* TODO WebKit: Doesn't do this? */
2638 gtk_webview_set_populate_primary_clipboard( 2638 pidgin_webview_set_populate_primary_clipboard(
2639 GTK_WEBVIEW(status_box->webview), TRUE); 2639 PIDGIN_WEBVIEW(status_box->webview), TRUE);
2640 #endif 2640 #endif
2641 2641
2642 purple_timeout_remove(status_box->typing); 2642 purple_timeout_remove(status_box->typing);
2643 status_box->typing = 0; 2643 status_box->typing = 0;
2644 2644
2740 gtk_widget_show_all(status_box->vbox); 2740 gtk_widget_show_all(status_box->vbox);
2741 status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); 2741 status_box->typing = purple_timeout_add_seconds(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box);
2742 gtk_widget_grab_focus(status_box->webview); 2742 gtk_widget_grab_focus(status_box->webview);
2743 #if 0 2743 #if 0
2744 /* TODO WebKit: Doesn't do this? */ 2744 /* TODO WebKit: Doesn't do this? */
2745 gtk_webview_set_populate_primary_clipboard( 2745 pidgin_webview_set_populate_primary_clipboard(
2746 GTK_WEBVIEW(status_box->webview), FALSE); 2746 PIDGIN_WEBVIEW(status_box->webview), FALSE);
2747 #endif 2747 #endif
2748 2748
2749 webkit_web_view_select_all(WEBKIT_WEB_VIEW(status_box->webview)); 2749 webkit_web_view_select_all(WEBKIT_WEB_VIEW(status_box->webview));
2750 } 2750 }
2751 else 2751 else
2782 2782
2783 return index; 2783 return index;
2784 } 2784 }
2785 2785
2786 static void 2786 static void
2787 webview_changed_cb(GtkWebView *webview, void *data) 2787 webview_changed_cb(PidginWebView *webview, void *data)
2788 { 2788 {
2789 PidginStatusBox *status_box = (PidginStatusBox*)data; 2789 PidginStatusBox *status_box = (PidginStatusBox*)data;
2790 if (gtk_widget_get_sensitive(GTK_WIDGET(status_box))) 2790 if (gtk_widget_get_sensitive(GTK_WIDGET(status_box)))
2791 { 2791 {
2792 if (status_box->typing != 0) { 2792 if (status_box->typing != 0) {
2797 } 2797 }
2798 pidgin_status_box_refresh(status_box); 2798 pidgin_status_box_refresh(status_box);
2799 } 2799 }
2800 2800
2801 static void 2801 static void
2802 webview_format_changed_cb(GtkWebView *webview, GtkWebViewButtons buttons, void *data) 2802 webview_format_changed_cb(PidginWebView *webview, PidginWebViewButtons buttons, void *data)
2803 { 2803 {
2804 webview_changed_cb(NULL, data); 2804 webview_changed_cb(NULL, data);
2805 } 2805 }
2806 2806
2807 char *pidgin_status_box_get_message(PidginStatusBox *status_box) 2807 char *pidgin_status_box_get_message(PidginStatusBox *status_box)
2808 { 2808 {
2809 if (status_box->webview_visible) 2809 if (status_box->webview_visible)
2810 return g_strstrip(gtk_webview_get_body_text(GTK_WEBVIEW(status_box->webview))); 2810 return g_strstrip(pidgin_webview_get_body_text(PIDGIN_WEBVIEW(status_box->webview)));
2811 else 2811 else
2812 return NULL; 2812 return NULL;
2813 } 2813 }

mercurial