diff options
author | Xan Lopez <xan@src.gnome.org> | 2007-12-22 10:14:19 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2007-12-22 10:14:19 +0800 |
commit | 9bcf221c42b75b4fcedbbbbc5b7e9ec040d70efd (patch) | |
tree | 55d36728c85a5ffad9bb0539d7e368e21df7cee0 /embed | |
parent | 6adb4570e797dcafcd865fd67e489766294a2f8b (diff) | |
download | gsoc2013-epiphany-9bcf221c42b75b4fcedbbbbc5b7e9ec040d70efd.tar gsoc2013-epiphany-9bcf221c42b75b4fcedbbbbc5b7e9ec040d70efd.tar.gz gsoc2013-epiphany-9bcf221c42b75b4fcedbbbbc5b7e9ec040d70efd.tar.bz2 gsoc2013-epiphany-9bcf221c42b75b4fcedbbbbc5b7e9ec040d70efd.tar.lz gsoc2013-epiphany-9bcf221c42b75b4fcedbbbbc5b7e9ec040d70efd.tar.xz gsoc2013-epiphany-9bcf221c42b75b4fcedbbbbc5b7e9ec040d70efd.tar.zst gsoc2013-epiphany-9bcf221c42b75b4fcedbbbbc5b7e9ec040d70efd.zip |
Implement clipboard operations for WebKit.
svn path=/trunk/; revision=7795
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-command-manager.c | 87 | ||||
-rw-r--r-- | embed/webkit/webkit-embed.c | 17 |
2 files changed, 65 insertions, 39 deletions
diff --git a/embed/ephy-command-manager.c b/embed/ephy-command-manager.c index df72eca4c..4100a4ec9 100644 --- a/embed/ephy-command-manager.c +++ b/embed/ephy-command-manager.c @@ -28,33 +28,33 @@ ephy_command_manager_base_init (gpointer g_class); GType ephy_command_manager_get_type (void) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - const GTypeInfo our_info = - { - sizeof (EphyCommandManagerIface), - ephy_command_manager_base_init, - NULL, - }; - - type = g_type_register_static (G_TYPE_INTERFACE, - "EphyCommandManager", - &our_info, - (GTypeFlags)0); - } - - return type; + static GType type = 0; + + if (G_UNLIKELY (type == 0)) + { + const GTypeInfo our_info = + { + sizeof (EphyCommandManagerIface), + ephy_command_manager_base_init, + NULL, + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "EphyCommandManager", + &our_info, + (GTypeFlags)0); + } + + return type; } static void ephy_command_manager_base_init (gpointer g_class) { - static gboolean initialized = FALSE; + static gboolean initialized = FALSE; - if (!initialized) - { + if (!initialized) + { /** * EphyCommandManager::command-changed: * @manager: @@ -64,18 +64,18 @@ ephy_command_manager_base_init (gpointer g_class) * available to unavailable, or vice-versa. The new availability can be tested * with ephy_command_manager_can_do_command(). **/ - g_signal_new ("command_changed", - EPHY_TYPE_COMMAND_MANAGER, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyCommandManagerIface, command_changed), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING); - - initialized = TRUE; - } + g_signal_new ("command_changed", + EPHY_TYPE_COMMAND_MANAGER, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyCommandManagerIface, command_changed), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING); + + initialized = TRUE; + } } /** @@ -87,10 +87,14 @@ ephy_command_manager_base_init (gpointer g_class) **/ void ephy_command_manager_do_command (EphyCommandManager *manager, - const char *command) + const char *command) { - EphyCommandManagerIface *iface = EPHY_COMMAND_MANAGER_GET_IFACE (manager); - iface->do_command (manager, command); + EphyCommandManagerIface *iface; + + g_return_if_fail (command != NULL); + + iface = EPHY_COMMAND_MANAGER_GET_IFACE (manager); + iface->do_command (manager, command); } /** @@ -104,8 +108,13 @@ ephy_command_manager_do_command (EphyCommandManager *manager, **/ gboolean ephy_command_manager_can_do_command (EphyCommandManager *manager, - const char *command) + const char *command) { - EphyCommandManagerIface *iface = EPHY_COMMAND_MANAGER_GET_IFACE (manager); - return iface->can_do_command (manager, command); + EphyCommandManagerIface *iface; + + g_return_val_if_fail (command != NULL, FALSE); + + iface = EPHY_COMMAND_MANAGER_GET_IFACE (manager); + + return iface->can_do_command (manager, command); } diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c index 25c985abd..bf09d7150 100644 --- a/embed/webkit/webkit-embed.c +++ b/embed/webkit/webkit-embed.c @@ -63,12 +63,29 @@ static void impl_manager_do_command (EphyCommandManager *manager, const char *command) { + WebKitWebView *web_view = WEBKIT_EMBED (manager)->priv->web_view; + + if (! strcmp (command, "cmd_copy")) + return webkit_web_view_copy_clipboard (web_view); + else if (! strcmp (command, "cmd_cut")) + return webkit_web_view_cut_clipboard (web_view); + else if (! strcmp (command, "cmd_paste")) + return webkit_web_view_paste_clipboard (web_view); } static gboolean impl_manager_can_do_command (EphyCommandManager *manager, const char *command) { + WebKitWebView *web_view = WEBKIT_EMBED (manager)->priv->web_view; + + if (! strcmp (command, "cmd_copy")) + return webkit_web_view_can_copy_clipboard (web_view); + else if (! strcmp (command, "cmd_cut")) + return webkit_web_view_can_cut_clipboard (web_view); + else if (! strcmp (command, "cmd_paste")) + return webkit_web_view_can_paste_clipboard (web_view); + return FALSE; } |