Tue, 06 Nov 2018 03:10:02 +0000
Merged in default (pull request #406)
Move GtkPrefs to talkatu
Approved-by: Elliott Sales de Andrade
Approved-by: Eion Robb
| pidgin/gtkprefs.c | file | annotate | diff | comparison | revisions | |
| pidgin/resources/Prefs/prefs.ui | file | annotate | diff | comparison | revisions |
--- a/pidgin/gtkprefs.c Fri Nov 02 01:37:22 2018 +0000 +++ b/pidgin/gtkprefs.c Tue Nov 06 03:10:02 2018 +0000 @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ +#include <talkatu.h> + #include "internal.h" #include "glibcompat.h" #include "pidgin.h" @@ -51,7 +53,6 @@ #include "gtksound.h" #include "gtkstatus-icon-theme.h" #include "gtkutils.h" -#include "gtkwebview.h" #include "pidgindebug.h" #include "pidginstock.h" #ifdef USE_VV @@ -161,8 +162,8 @@ GtkWidget *resize_custom_smileys; GtkWidget *custom_smileys_size; GtkWidget *minimum_entry_lines; - GtkWidget *sample_box; - GtkWidget *sample_webview; + GtkTextBuffer *format_buffer; + GtkWidget *format_view; /* Win32 specific frame */ GtkWidget *font_frame; GtkWidget *use_theme_font; @@ -1876,78 +1877,24 @@ } static void -formatting_toggle_cb(PidginWebView *webview, PidginWebViewButtons buttons, void *data) +formatting_toggle_cb(TalkatuActionGroup *ag, GAction *action, const gchar *name, gpointer data) { - gboolean bold, italic, uline, strike; - - pidgin_webview_get_current_format(webview, &bold, &italic, &uline, &strike); - - if (buttons & PIDGIN_WEBVIEW_BOLD) + gboolean activated = talkatu_action_group_get_action_activated(ag, name); + if(g_ascii_strcasecmp(TALKATU_ACTION_FORMAT_BOLD, name) != 0) { purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", - bold); - if (buttons & PIDGIN_WEBVIEW_ITALIC) + activated); + } else if(g_ascii_strcasecmp(TALKATU_ACTION_FORMAT_ITALIC, name) != 0) { purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", - italic); - if (buttons & PIDGIN_WEBVIEW_UNDERLINE) + activated); + } else if(g_ascii_strcasecmp(TALKATU_ACTION_FORMAT_UNDERLINE, name) != 0) { purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", - uline); - if (buttons & PIDGIN_WEBVIEW_STRIKE) + activated); + } else if(g_ascii_strcasecmp(TALKATU_ACTION_FORMAT_STRIKETHROUGH, name) != 0) { purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike", - strike); - - if (buttons & PIDGIN_WEBVIEW_GROW || buttons & PIDGIN_WEBVIEW_SHRINK) - purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/font_size", - pidgin_webview_get_current_fontsize(webview)); - if (buttons & PIDGIN_WEBVIEW_FACE) { - char *face = pidgin_webview_get_current_fontface(webview); - - if (face) - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", face); - else - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", ""); - - g_free(face); - } - - if (buttons & PIDGIN_WEBVIEW_FORECOLOR) { - char *color = pidgin_webview_get_current_forecolor(webview); - - if (color) - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", color); - else - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", ""); - - g_free(color); - } - - if (buttons & PIDGIN_WEBVIEW_BACKCOLOR) { - char *color = pidgin_webview_get_current_backcolor(webview); - - if (color) - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", color); - else - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", ""); - - g_free(color); + activated); } } -static void -formatting_clear_cb(PidginWebView *webview, void *data) -{ - purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); - purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); - purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); - purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike", FALSE); - - purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/font_size", 3); - - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", ""); - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", ""); - purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", ""); -} - - #define CONVERSATION_CLOSE_ACCEL_PATH "<Actions>/ConversationActions/Close" /* Filled in in keyboard_shortcuts(). */ @@ -2100,7 +2047,7 @@ desc = pango_font_description_from_string(font); } - gtk_widget_modify_font(win->conversations.sample_webview, desc); + gtk_widget_override_font(win->conversations.format_view, desc); if (desc) pango_font_description_free(desc); @@ -2119,8 +2066,7 @@ static void bind_conv_page(PidginPrefsWindow *win) { - GtkWidget *webview; - GtkWidget *frame; + GSimpleActionGroup *ag = NULL; win->conversations.notification_chat.type = PURPLE_PREF_INT; win->conversations.notification_chat.key = PIDGIN_PREFS_ROOT "/conversations/notification_chat"; @@ -2195,38 +2141,9 @@ } #endif - frame = pidgin_create_webview(TRUE, &webview, NULL); - gtk_widget_show(frame); - gtk_widget_set_name(webview, "pidgin_prefs_font_webview"); - gtk_widget_set_size_request(frame, 450, -1); - pidgin_webview_set_whole_buffer_formatting_only(PIDGIN_WEBVIEW(webview), TRUE); - pidgin_webview_set_format_functions(PIDGIN_WEBVIEW(webview), - PIDGIN_WEBVIEW_BOLD | - PIDGIN_WEBVIEW_ITALIC | - PIDGIN_WEBVIEW_UNDERLINE | - PIDGIN_WEBVIEW_STRIKE | - PIDGIN_WEBVIEW_GROW | - PIDGIN_WEBVIEW_SHRINK | - PIDGIN_WEBVIEW_FACE | - PIDGIN_WEBVIEW_FORECOLOR | - PIDGIN_WEBVIEW_BACKCOLOR); - - pidgin_webview_append_html(PIDGIN_WEBVIEW(webview), - _("This is how your outgoing message text will " - "appear when you use protocols that support " - "formatting.")); - - gtk_box_pack_start(GTK_BOX(win->conversations.sample_box), frame, TRUE, TRUE, 0); - - pidgin_webview_setup_entry(PIDGIN_WEBVIEW(webview), - PURPLE_CONNECTION_FLAG_HTML | - PURPLE_CONNECTION_FLAG_FORMATTING_WBFO); - - g_signal_connect_after(G_OBJECT(webview), "format-toggled", + ag = talkatu_buffer_get_action_group(TALKATU_BUFFER(win->conversations.format_buffer)); + g_signal_connect_after(G_OBJECT(ag), "action-activated", G_CALLBACK(formatting_toggle_cb), NULL); - g_signal_connect_after(G_OBJECT(webview), "format-cleared", - G_CALLBACK(formatting_clear_cb), NULL); - win->conversations.sample_webview = webview; } static void @@ -4101,7 +4018,10 @@ conversations.minimum_entry_lines); gtk_widget_class_bind_template_child( widget_class, PidginPrefsWindow, - conversations.sample_box); + conversations.format_buffer); + gtk_widget_class_bind_template_child( + widget_class, PidginPrefsWindow, + conversations.format_view); #ifdef WIN32 gtk_widget_class_bind_template_child( widget_class, PidginPrefsWindow,
--- a/pidgin/resources/Prefs/prefs.ui Fri Nov 02 01:37:22 2018 +0000 +++ b/pidgin/resources/Prefs/prefs.ui Tue Nov 06 03:10:02 2018 +0000 @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- Generated with glade 3.22.1 --> <interface> + <requires lib="Talkatu" version="0.0"/> <requires lib="gtk+" version="3.10"/> <object class="GtkListStore" id="away.auto_reply.store"> <columns> @@ -90,6 +91,12 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="TalkatuTagTable" id="conversations.format_tag_table"/> + <object class="TalkatuWholeBuffer" id="conversations.format_buffer"> + <property name="tag_table">conversations.format_tag_table</property> + <property name="text" translatable="yes">This is how your outgoing message text will appear when you use protocols that support formatting.</property> + <property name="style">whole</property> + </object> <object class="GtkAdjustment" id="conversations.minimum_entry_lines.adjustment"> <property name="lower">1</property> <property name="upper">8</property> @@ -1409,7 +1416,38 @@ <property name="can_focus">False</property> <property name="orientation">vertical</property> <child> - <placeholder/> + <object class="TalkatuEditor"> + <property name="orientation">vertical</property> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child internal-child="toolbar"> + <object class="TalkatuToolbar"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + </object> + <packing> + <property name="fill">False</property> + </packing> + </child> + <child internal-child="view"> + <object class="TalkatuView" id="conversations.format_view"> + <property name="width_request">450</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="wrap_mode">word</property> + <property name="buffer">conversations.format_buffer</property> + </object> + <packing> + <property name="fill">False</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> </child> </object> </child>