gtkhtml r8799 - in branches/mbarnes-composer: . components/editor
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkhtml r8799 - in branches/mbarnes-composer: . components/editor
- Date: Mon, 31 Mar 2008 20:00:50 +0100 (BST)
Author: mbarnes
Date: Mon Mar 31 20:00:49 2008
New Revision: 8799
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=8799&view=rev
Log:
Forward GtkHTML events as GObject signals.
Disable the Bonobo editor by default.
Modified:
branches/mbarnes-composer/components/editor/gtkhtml-editor-marshal.list
branches/mbarnes-composer/components/editor/gtkhtml-editor.c
branches/mbarnes-composer/components/editor/gtkhtml-editor.h
branches/mbarnes-composer/configure.in
Modified: branches/mbarnes-composer/components/editor/gtkhtml-editor-marshal.list
==============================================================================
--- branches/mbarnes-composer/components/editor/gtkhtml-editor-marshal.list (original)
+++ branches/mbarnes-composer/components/editor/gtkhtml-editor-marshal.list Mon Mar 31 20:00:49 2008
@@ -1 +1,2 @@
VOID:STRING,POINTER
+STRING:STRING
Modified: branches/mbarnes-composer/components/editor/gtkhtml-editor.c
==============================================================================
--- branches/mbarnes-composer/components/editor/gtkhtml-editor.c (original)
+++ branches/mbarnes-composer/components/editor/gtkhtml-editor.c Mon Mar 31 20:00:49 2008
@@ -35,7 +35,12 @@
};
enum {
- URL_REQUESTED,
+ COMMAND_AFTER,
+ COMMAND_BEFORE,
+ IMAGE_URI,
+ LINK_CLICKED,
+ OBJECT_DELETED,
+ URI_REQUESTED,
LAST_SIGNAL
};
@@ -174,7 +179,7 @@
/* We can only handle local URLs here. */
if (g_ascii_strncasecmp (url, "file:/", 6) != 0) {
- g_signal_emit (editor, signals[URL_REQUESTED], 0, url, stream);
+ g_signal_emit (editor, signals[URI_REQUESTED], 0, url, stream);
return;
}
@@ -318,26 +323,58 @@
gpointer user_data)
{
GtkhtmlEditor *editor = user_data;
- GValue *value = NULL;
+ GValue *return_value = NULL;
+ gchar *return_string = NULL;
+ const gchar *string = NULL;
+ guint signal_id;
+
+ /* GtkHTML event arguments are either NULL or a single string. */
+ if (G_VALUE_HOLDS (args, G_TYPE_STRING))
+ string = g_value_get_string (args);
switch (event) {
case GTK_HTML_EDITOR_EVENT_COMMAND_BEFORE:
+ /* Signal argument is the command name. */
+ signal_id = signals[COMMAND_BEFORE];
+ g_return_val_if_fail (string != NULL, NULL);
+ g_signal_emit (editor, signal_id, 0, string);
break;
case GTK_HTML_EDITOR_EVENT_COMMAND_AFTER:
+ /* Signal argument is the command name. */
+ signal_id = signals[COMMAND_AFTER];
+ g_return_val_if_fail (string != NULL, NULL);
+ g_signal_emit (editor, signal_id, 0, string);
break;
case GTK_HTML_EDITOR_EVENT_IMAGE_URL:
+ /* Signal argument is the image URL. */
+ /* XXX Returns a string. */
+ signal_id = signals[IMAGE_URI];
+ g_return_val_if_fail (string != NULL, NULL);
+ g_signal_emit (
+ editor, signal_id, 0, string, &return_string);
+ return_value = g_new0 (GValue, 1);
+ g_value_init (return_value, G_TYPE_STRING);
+ g_value_take_string (return_value, return_string);
break;
case GTK_HTML_EDITOR_EVENT_DELETE:
+ /* No signal arguments. */
+ signal_id = signals[OBJECT_DELETED];
+ g_return_val_if_fail (string == NULL, NULL);
+ g_signal_emit (editor, signal_id, 0);
break;
case GTK_HTML_EDITOR_EVENT_LINK_CLICKED:
+ /* Signal argument is the link URL. */
+ signal_id = signals[LINK_CLICKED];
+ g_return_val_if_fail (string != NULL, NULL);
+ g_signal_emit (editor, signal_id, 0, string);
break;
}
- return value;
+ return return_value;
}
static GtkWidget *
@@ -720,14 +757,63 @@
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE));
- signals[URL_REQUESTED] = g_signal_new (
- "url-requested",
+ signals[COMMAND_AFTER] = g_signal_new (
+ "command-after",
G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
+ G_STRUCT_OFFSET (GtkhtmlEditorClass, command_after),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ signals[COMMAND_BEFORE] = g_signal_new (
+ "command-before",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkhtmlEditorClass, command_before),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ signals[IMAGE_URI] = g_signal_new (
+ "image-uri",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkhtmlEditorClass, image_uri),
+ NULL, NULL,
+ gtkhtml_editor_marshal_STRING__STRING,
+ G_TYPE_STRING, 1,
+ G_TYPE_STRING);
+
+ signals[LINK_CLICKED] = g_signal_new (
+ "link-clicked",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkhtmlEditorClass, link_clicked),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ signals[OBJECT_DELETED] = g_signal_new (
+ "object-deleted",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkhtmlEditorClass, object_deleted),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[URI_REQUESTED] = g_signal_new (
+ "uri-requested",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkhtmlEditorClass, uri_requested),
+ NULL, NULL,
gtkhtml_editor_marshal_VOID__STRING_POINTER,
- G_TYPE_NONE,
- 2,
+ G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_POINTER);
}
Modified: branches/mbarnes-composer/components/editor/gtkhtml-editor.h
==============================================================================
--- branches/mbarnes-composer/components/editor/gtkhtml-editor.h (original)
+++ branches/mbarnes-composer/components/editor/gtkhtml-editor.h Mon Mar 31 20:00:49 2008
@@ -70,6 +70,19 @@
void (*copy_clipboard) (GtkhtmlEditor *editor);
void (*paste_clipboard) (GtkhtmlEditor *editor);
void (*select_all) (GtkhtmlEditor *editor);
+
+ /* GtkHTML events */
+ void (*command_before) (GtkhtmlEditor *editor,
+ const gchar *command);
+ void (*command_after) (GtkhtmlEditor *editor,
+ const gchar *command);
+ gchar * (*image_uri) (GtkhtmlEditor *editor,
+ const gchar *uri);
+ void (*link_clicked) (GtkhtmlEditor *editor,
+ const gchar *uri);
+ void (*object_deleted) (GtkhtmlEditor *editor);
+ void (*uri_requested) (GtkhtmlEditor *editor,
+ const gchar *uri);
};
GType gtkhtml_editor_get_type (void);
Modified: branches/mbarnes-composer/configure.in
==============================================================================
--- branches/mbarnes-composer/configure.in (original)
+++ branches/mbarnes-composer/configure.in Mon Mar 31 20:00:49 2008
@@ -94,8 +94,8 @@
# Bonobo editor module
AC_ARG_WITH(bonobo-editor,
AC_HELP_STRING([--with-bonobo-editor],
- [build the older Bonobo-based editor [default=yes]]),
- bonobo_editor="$withval", bonobo_editor="yes")
+ [build the older Bonobo-based editor [default=no]]),
+ bonobo_editor="$withval", bonobo_editor="no")
if test "x$bonobo_editor" = "xyes"; then
EDITOR_MODULES="${GTKHTML_MODULES} libbonobo-2.0 >= libbonobo_minimum_version libbonoboui-2.0 >= libbonoboui_minimum_version"
PKG_CHECK_MODULES(EDITOR, $EDITOR_MODULES)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]