/dev/qulogic/ckeditor: eacf87d0062d: Make editable-ness a constr...
Elliott Sales de Andrade
qulogic at pidgin.im
Mon Aug 5 19:00:09 EDT 2013
Changeset: eacf87d0062dbe3bdb359aee3cc3cb7ae123f82b
Author: Elliott Sales de Andrade <qulogic at pidgin.im>
Date: 2013-08-04 16:32 -0400
Branch: default
URL: https://hg.pidgin.im/dev/qulogic/ckeditor/rev/eacf87d0062d
Description:
Make editable-ness a construct-only property of the GtkWebView.
There's just too much that goes into the editor component to allow
blindly changing between editor and not. If you want to temporarily
make it read-only, you can use the original WebView's editable
setting, but the GtkWebView's editable remains a IM-entry-like thing.
diffstat:
pidgin/gtkstatusbox.c | 4 +-
pidgin/gtkutils.c | 3 +-
pidgin/gtkwebview.c | 57 ++++++++++++++++++-------------------------
pidgin/gtkwebview.h | 21 ++-------------
pidgin/plugins/xmppconsole.c | 6 ++--
5 files changed, 33 insertions(+), 58 deletions(-)
diffs (210 lines):
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -1836,8 +1836,8 @@ pidgin_status_box_init (PidginStatusBox
g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
status_box->vbox = gtk_vbox_new(0, FALSE);
- status_box->sw = pidgin_create_webview(FALSE, &status_box->webview, NULL);
- gtk_webview_set_editable(GTK_WEBVIEW(status_box->webview), TRUE);
+ status_box->sw = pidgin_create_webview(TRUE, &status_box->webview, NULL);
+ gtk_webview_hide_toolbar(GTK_WEBVIEW(status_box->webview));
#if 0
g_signal_connect(G_OBJECT(status_box->toggle_button), "button-press-event",
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -241,8 +241,7 @@ pidgin_create_webview(gboolean editable,
gtk_widget_show(sep);
}
- webview = gtk_webview_new();
- gtk_webview_set_editable(GTK_WEBVIEW(webview), editable);
+ webview = gtk_webview_new(editable);
if (editable && purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck"))
pidgin_webview_set_spellcheck(GTK_WEBVIEW(webview), TRUE);
gtk_widget_show(webview);
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -1354,11 +1354,16 @@ editable_input_cb(GtkWebView *webview, g
*****************************************************************************/
GtkWidget *
-gtk_webview_new(void)
+gtk_webview_new(gboolean editable)
{
- WebKitWebView *webview = WEBKIT_WEB_VIEW(g_object_new(gtk_webview_get_type(), NULL));
- WebKitWebSettings *settings = webkit_web_view_get_settings(webview);
-
+ GtkWidget *result;
+ WebKitWebView *webview;
+ WebKitWebSettings *settings;
+
+ result = g_object_new(gtk_webview_get_type(), NULL);
+ webview = WEBKIT_WEB_VIEW(result);
+ settings = webkit_web_view_get_settings(webview);
+
g_object_set(G_OBJECT(settings), "default-encoding", "utf-8", NULL);
#ifdef _WIN32
/* XXX: win32 WebKitGTK replaces backslash with yen sign for
@@ -1369,8 +1374,15 @@ gtk_webview_new(void)
g_object_set(G_OBJECT(settings), "default-font-family", "Verdana", NULL);
#endif
webkit_web_view_set_settings(webview, settings);
-
- return GTK_WIDGET(webview);
+
+ if (editable) {
+ webkit_web_view_set_editable(WEBKIT_WEB_VIEW(webview), editable);
+
+ g_signal_connect(G_OBJECT(webview), "user-changed-contents",
+ G_CALLBACK(editable_input_cb), NULL);
+ }
+
+ return result;
}
static void
@@ -1407,6 +1419,8 @@ gtk_webview_class_init(GtkWebViewClass *
g_type_class_add_private(klass, sizeof(GtkWebViewPriv));
+ /* Signals */
+
signals[BUTTONS_UPDATE] = g_signal_new("allowed-formats-updated",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
@@ -1446,11 +1460,15 @@ gtk_webview_class_init(GtkWebViewClass *
G_TYPE_NONE, 1, WEBKIT_TYPE_DOM_RANGE,
NULL);
+ /* Class Methods */
+
klass->toggle_format = webview_toggle_format;
klass->clear_format = webview_clear_formatting;
gobject_class->finalize = gtk_webview_finalize;
+ /* Key Bindings */
+
binding_set = gtk_binding_set_by_class(parent_class);
gtk_binding_entry_add_signal(binding_set, GDK_KEY_b, GDK_CONTROL_MASK,
"format-toggled", 1, G_TYPE_INT,
@@ -1710,27 +1728,6 @@ gtk_webview_page_down(GtkWebView *webvie
}
void
-gtk_webview_set_editable(GtkWebView *webview, gboolean editable)
-{
- GtkWebViewPriv *priv;
- g_return_if_fail(webview != NULL);
-
- priv = GTK_WEBVIEW_GET_PRIVATE(webview);
- webkit_web_view_set_editable(WEBKIT_WEB_VIEW(webview), editable);
-
- if (editable) {
- g_signal_connect(G_OBJECT(webview), "user-changed-contents",
- G_CALLBACK(editable_input_cb), NULL);
- } else {
- g_signal_handlers_disconnect_by_func(G_OBJECT(webview),
- G_CALLBACK(editable_input_cb),
- NULL);
- }
-
- priv->format_functions = GTK_WEBVIEW_ALL;
-}
-
-void
gtk_webview_setup_entry(GtkWebView *webview, PurpleConnectionFlags flags)
{
GtkWebViewButtons buttons;
@@ -2046,12 +2043,6 @@ gtk_webview_get_current_fontsize(GtkWebV
return size;
}
-gboolean
-gtk_webview_get_editable(GtkWebView *webview)
-{
- return webkit_web_view_get_editable(WEBKIT_WEB_VIEW(webview));
-}
-
void
gtk_webview_clear_formatting(GtkWebView *webview)
{
diff --git a/pidgin/gtkwebview.h b/pidgin/gtkwebview.h
--- a/pidgin/gtkwebview.h
+++ b/pidgin/gtkwebview.h
@@ -118,9 +118,11 @@ GType gtk_webview_get_type(void);
/**
* Create a new GtkWebView object
*
+ * @param editable Whether this GtkWebView will be user-editable
+ *
* @return A GtkWidget corresponding to the GtkWebView object
*/
-GtkWidget *gtk_webview_new(void);
+GtkWidget *gtk_webview_new(gboolean editable);
/**
* A very basic routine to append html, which can be considered
@@ -222,14 +224,6 @@ void gtk_webview_page_up(GtkWebView *web
void gtk_webview_page_down(GtkWebView *webview);
/**
- * Enables or disables editing in a GtkWebView.
- *
- * @param webview The GtkWebView
- * @param editable @c TRUE to make the widget editable, or @c FALSE otherwise.
- */
-void gtk_webview_set_editable(GtkWebView *webview, gboolean editable);
-
-/**
* Setup formatting for a GtkWebView depending on the flags specified.
*
* @param webview The GtkWebView.
@@ -359,15 +353,6 @@ char *gtk_webview_get_current_backcolor(
gint gtk_webview_get_current_fontsize(GtkWebView *webview);
/**
- * Checks whether a GtkWebView is marked as editable.
- *
- * @param webview The GtkWebView
- *
- * @return @c TRUE if the IM/HTML is editable, or @c FALSE otherwise.
- */
-gboolean gtk_webview_get_editable(GtkWebView *webview);
-
-/**
* Gets the content of the head element of a GtkWebView as HTML.
*
* @param webview The GtkWebView
diff --git a/pidgin/plugins/xmppconsole.c b/pidgin/plugins/xmppconsole.c
--- a/pidgin/plugins/xmppconsole.c
+++ b/pidgin/plugins/xmppconsole.c
@@ -796,7 +796,7 @@ create_console(PurplePluginAction *actio
gtk_box_pack_start(GTK_BOX(console->hbox), console->dropdown, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL);
- console->webview = gtk_webview_new();
+ console->webview = gtk_webview_new(FALSE);
gtk_webview_load_html_string(GTK_WEBVIEW(console->webview), EMPTY_HTML);
if (console->count == 0) {
char *tmp = g_strdup_printf("<div class=info>%s</div>",
@@ -826,13 +826,13 @@ create_console(PurplePluginAction *actio
gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
- console->entry = gtk_webview_new();
+ console->entry = gtk_webview_new(TRUE);
+ gtk_webview_hide_toolbar(GTK_WEBVIEW(console->entry));
gtk_webview_set_whole_buffer_formatting_only(GTK_WEBVIEW(console->entry), TRUE);
g_signal_connect(G_OBJECT(console->entry),"key-press-event", G_CALLBACK(message_send_cb), console);
console->sw = pidgin_make_scrollable(console->entry, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_ETCHED_IN, -1, -1);
gtk_box_pack_start(GTK_BOX(vbox), console->sw, FALSE, FALSE, 0);
- gtk_webview_set_editable(GTK_WEBVIEW(console->entry), TRUE);
g_signal_connect(G_OBJECT(console->entry), "changed", G_CALLBACK(entry_changed_cb), NULL);
entry_changed_cb(console->entry, NULL);
More information about the Commits
mailing list