/pidgin/main: e5258008e4d7: Convert pounce dialog to a GtkWebView.
Elliott Sales de Andrade
qulogic at pidgin.im
Thu Jul 26 17:59:18 EDT 2012
Changeset: e5258008e4d7492f007ace4c0c39951b2f4044b1
Author: Elliott Sales de Andrade <qulogic at pidgin.im>
Date: 2012-07-26 00:43 -0400
Branch: default
URL: http://hg.pidgin.im/pidgin/main/rev/e5258008e4d7
Description:
Convert pounce dialog to a GtkWebView.
diffstat:
pidgin/gtkpounce.c | 41 ++++++++++++++++++++++++++++-------------
1 files changed, 28 insertions(+), 13 deletions(-)
diffs (136 lines):
diff --git a/pidgin/gtkpounce.c b/pidgin/gtkpounce.c
--- a/pidgin/gtkpounce.c
+++ b/pidgin/gtkpounce.c
@@ -38,11 +38,11 @@
#include "gtkblist.h"
#include "gtkdialogs.h"
-#include "gtkimhtml.h"
#include "gtkpounce.h"
#include "gtknotify.h"
#include "pidginstock.h"
#include "gtkutils.h"
+#include "gtkwebview.h"
/**
* These are used for the GtkTreeView when you're scrolling through
@@ -304,7 +304,7 @@ save_pounce_cb(GtkWidget *w, PidginPounc
events |= PURPLE_POUNCE_MESSAGE_RECEIVED;
/* Data fields */
- message = gtk_imhtml_get_markup(GTK_IMHTML(dialog->send_msg_entry));
+ message = gtk_webview_get_body_html(GTK_WEBVIEW(dialog->send_msg_entry));
command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry));
sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry));
reason = gtk_entry_get_text(GTK_ENTRY(dialog->popup_entry));
@@ -378,6 +378,19 @@ save_pounce_cb(GtkWidget *w, PidginPounc
delete_win_cb(NULL, NULL, dialog);
}
+static gboolean
+entry_key_press_cb(GtkWidget *widget, GdkEventKey *event,
+ PidginPounceDialog *dialog)
+{
+ if ((event->keyval == GDK_KEY_Return)
+ || (event->keyval == GDK_KEY_KP_Enter)) {
+ save_pounce_cb(widget, dialog);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
pounce_choose_cb(GtkWidget *item, PurpleAccount *account,
PidginPounceDialog *dialog)
@@ -477,7 +490,7 @@ static void
reset_send_msg_entry(PidginPounceDialog *dialog, GtkWidget *dontcare)
{
PurpleAccount *account = pidgin_account_option_menu_get_selected(dialog->account_menu);
- gtk_imhtml_setup_entry(GTK_IMHTML(dialog->send_msg_entry),
+ gtk_webview_setup_entry(GTK_WEBVIEW(dialog->send_msg_entry),
(account && purple_account_get_connection(account)) ? purple_connection_get_flags(purple_account_get_connection(account)) : PURPLE_CONNECTION_HTML);
}
@@ -496,7 +509,7 @@ pidgin_pounce_editor_show(PurpleAccount
GtkSizeGroup *sg;
GPtrArray *sound_widgets;
GPtrArray *exec_widgets;
- GtkWidget *send_msg_imhtml;
+ GtkWidget *send_msg_webview;
g_return_if_fail((cur_pounce != NULL) ||
(account != NULL) ||
@@ -683,7 +696,7 @@ pidgin_pounce_editor_show(PurpleAccount
dialog->play_sound
= gtk_check_button_new_with_mnemonic(_("P_lay a sound"));
- send_msg_imhtml = pidgin_create_imhtml(TRUE, &dialog->send_msg_entry, NULL, NULL);
+ send_msg_webview = pidgin_create_webview(TRUE, &dialog->send_msg_entry, NULL, NULL);
reset_send_msg_entry(dialog, NULL);
dialog->exec_cmd_entry = gtk_entry_new();
dialog->popup_entry = gtk_entry_new();
@@ -695,7 +708,7 @@ pidgin_pounce_editor_show(PurpleAccount
dialog->play_sound_test = gtk_button_new_with_mnemonic(_("Pre_view"));
dialog->play_sound_reset = gtk_button_new_with_mnemonic(_("Reset"));
- gtk_widget_set_sensitive(send_msg_imhtml, FALSE);
+ gtk_widget_set_sensitive(send_msg_webview, FALSE);
gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE);
gtk_widget_set_sensitive(dialog->popup_entry, FALSE);
gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE);
@@ -730,7 +743,7 @@ pidgin_pounce_editor_show(PurpleAccount
GTK_FILL, 0, 0, 0);
gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 5, 2, 3,
GTK_FILL, 0, 0, 0);
- gtk_table_attach(GTK_TABLE(table), send_msg_imhtml, 0, 5, 3, 4,
+ gtk_table_attach(GTK_TABLE(table), send_msg_webview, 0, 5, 3, 4,
GTK_FILL, 0, 0, 0);
gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 4, 5,
GTK_FILL, 0, 0, 0);
@@ -755,7 +768,7 @@ pidgin_pounce_editor_show(PurpleAccount
gtk_widget_show(dialog->popup);
gtk_widget_show(dialog->popup_entry);
gtk_widget_show(dialog->send_msg);
- gtk_widget_show(send_msg_imhtml);
+ gtk_widget_show(send_msg_webview);
gtk_widget_show(dialog->exec_cmd);
gtk_widget_show(dialog->exec_cmd_entry);
gtk_widget_show(dialog->exec_cmd_browse);
@@ -771,7 +784,7 @@ pidgin_pounce_editor_show(PurpleAccount
g_signal_connect(G_OBJECT(dialog->send_msg), "clicked",
G_CALLBACK(pidgin_toggle_sensitive),
- send_msg_imhtml);
+ send_msg_webview);
g_signal_connect(G_OBJECT(dialog->popup), "clicked",
G_CALLBACK(pidgin_toggle_sensitive),
@@ -811,13 +824,13 @@ pidgin_pounce_editor_show(PurpleAccount
g_object_set_data_full(G_OBJECT(dialog->window), "sound-widgets",
sound_widgets, (GDestroyNotify)g_ptr_array_free);
- g_signal_connect_swapped(G_OBJECT(dialog->send_msg_entry), "format_function_clear",
+ g_signal_connect_swapped(G_OBJECT(dialog->send_msg_entry), "format-cleared",
G_CALLBACK(reset_send_msg_entry), dialog);
g_signal_connect_swapped(G_OBJECT(dialog->account_menu), "changed",
G_CALLBACK(reset_send_msg_entry), dialog);
- g_signal_connect(G_OBJECT(dialog->send_msg_entry), "message_send",
- G_CALLBACK(save_pounce_cb), dialog);
+ g_signal_connect(G_OBJECT(dialog->send_msg_entry), "key-press-event",
+ G_CALLBACK(entry_key_press_cb), dialog);
g_signal_connect(G_OBJECT(dialog->popup_entry), "activate",
G_CALLBACK(save_pounce_cb), dialog);
g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate",
@@ -930,7 +943,9 @@ pidgin_pounce_editor_show(PurpleAccount
"send-message",
"message")) != NULL)
{
- gtk_imhtml_append_text(GTK_IMHTML(dialog->send_msg_entry), value, 0);
+ char *tmp = g_markup_escape_text(value, -1);
+ gtk_webview_append_html(GTK_WEBVIEW(dialog->send_msg_entry), value);
+ g_free(tmp);
}
if ((value = purple_pounce_action_get_attribute(cur_pounce,
More information about the Commits
mailing list