aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-10-25 23:15:35 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-10-25 23:15:35 +0800
commit38956a20d942387e3d5b839c4b962713bd60cdf0 (patch)
tree6ac41837526e3b5aab171741e0803ff87492a2ea /embed/mozilla
parent20602830fa6d28dd28cab60de0698ec523b1c6b9 (diff)
downloadgsoc2013-epiphany-38956a20d942387e3d5b839c4b962713bd60cdf0.tar
gsoc2013-epiphany-38956a20d942387e3d5b839c4b962713bd60cdf0.tar.gz
gsoc2013-epiphany-38956a20d942387e3d5b839c4b962713bd60cdf0.tar.bz2
gsoc2013-epiphany-38956a20d942387e3d5b839c4b962713bd60cdf0.tar.lz
gsoc2013-epiphany-38956a20d942387e3d5b839c4b962713bd60cdf0.tar.xz
gsoc2013-epiphany-38956a20d942387e3d5b839c4b962713bd60cdf0.tar.zst
gsoc2013-epiphany-38956a20d942387e3d5b839c4b962713bd60cdf0.zip
Interface for commands. Useful for undo. (cmd_undo works).
2003-10-25 Marco Pesenti Gritti <marco@gnome.org> * embed/Makefile.am: * embed/ephy-command-manager.c: (ephy_command_manager_get_type), (ephy_command_manager_base_init), (ephy_command_manager_do_command), (ephy_command_manager_can_do_command), (ephy_command_manager_observe_command): * embed/ephy-command-manager.h: Interface for commands. Useful for undo. (cmd_undo works). * embed/ephy-embed.c: * embed/ephy-embed.h: Remove all clipboard calls. * embed/mozilla/EphyWrapper.cpp: * embed/mozilla/EphyWrapper.h: * embed/mozilla/Makefile.am: * embed/mozilla/mozilla-embed.cpp: Implement part of the commands interface. No regressions. * src/window-commands.c: (window_cmd_edit_cut), (window_cmd_edit_copy), (window_cmd_edit_paste), (window_cmd_edit_select_all): Implement clipboard using commands.
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/EphyWrapper.cpp53
-rw-r--r--embed/mozilla/EphyWrapper.h16
-rw-r--r--embed/mozilla/Makefile.am1
-rw-r--r--embed/mozilla/mozilla-embed.cpp179
4 files changed, 67 insertions, 182 deletions
diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp
index 5cb399201..bea527fe2 100644
--- a/embed/mozilla/EphyWrapper.cpp
+++ b/embed/mozilla/EphyWrapper.cpp
@@ -30,6 +30,7 @@
#include <gtkmozembed_internal.h>
#include <unistd.h>
+#include "nsICommandManager.h"
#include "nsIContentViewer.h"
#include "nsIGlobalHistory.h"
#include "nsIDocShellHistory.h"
@@ -51,7 +52,6 @@
#include "nsCWebBrowserPersist.h"
#include "nsNetUtil.h"
#include "nsIChromeEventHandler.h"
-#include "nsIClipboardCommands.h"
#include "nsIDOMDocumentStyle.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
@@ -712,48 +712,6 @@ nsresult EphyWrapper::ForceEncoding (const char *encoding)
return result;
}
-nsresult EphyWrapper::CanCutSelection(PRBool *result)
-{
- nsCOMPtr<nsIClipboardCommands> clipboard (do_GetInterface(mWebBrowser));
- return clipboard->CanCutSelection (result);
-}
-
-nsresult EphyWrapper::CanCopySelection(PRBool *result)
-{
- nsCOMPtr<nsIClipboardCommands> clipboard (do_GetInterface(mWebBrowser));
- return clipboard->CanCopySelection (result);
-}
-
-nsresult EphyWrapper::CanPaste(PRBool *result)
-{
- nsCOMPtr<nsIClipboardCommands> clipboard (do_GetInterface(mWebBrowser));
- return clipboard->CanPaste (result);
-}
-
-nsresult EphyWrapper::CutSelection(void)
-{
- nsCOMPtr<nsIClipboardCommands> clipboard (do_GetInterface(mWebBrowser));
- return clipboard->CutSelection ();
-}
-
-nsresult EphyWrapper::CopySelection(void)
-{
- nsCOMPtr<nsIClipboardCommands> clipboard (do_GetInterface(mWebBrowser));
- return clipboard->CopySelection ();
-}
-
-nsresult EphyWrapper::Paste(void)
-{
- nsCOMPtr<nsIClipboardCommands> clipboard (do_GetInterface(mWebBrowser));
- return clipboard->Paste ();
-}
-
-nsresult EphyWrapper::SelectAll (void)
-{
- nsCOMPtr<nsIClipboardCommands> clipboard (do_GetInterface(mWebBrowser));
- return clipboard->SelectAll ();
-}
-
nsresult EphyWrapper::PushTargetDocument (nsIDOMDocument *domDoc)
{
mTargetDocument = domDoc;
@@ -894,3 +852,12 @@ nsresult EphyWrapper::GetEncodingInfo (EphyEncodingInfo **infoptr)
return NS_OK;
}
+
+nsresult EphyWrapper::DoCommand (const char *command)
+{
+ nsCOMPtr<nsICommandManager> cmdManager;
+ cmdManager = do_GetInterface (mWebBrowser);
+ if (!cmdManager) return NS_ERROR_FAILURE;
+
+ return cmdManager->DoCommand (command, nsnull, nsnull);
+}
diff --git a/embed/mozilla/EphyWrapper.h b/embed/mozilla/EphyWrapper.h
index 64cf99026..3867d053d 100644
--- a/embed/mozilla/EphyWrapper.h
+++ b/embed/mozilla/EphyWrapper.h
@@ -48,6 +48,8 @@ public:
nsresult Init (GtkMozEmbed *mozembed);
nsresult Destroy (void);
+ nsresult DoCommand (const char *command);
+
nsresult SetZoom (float aTextZoom, PRBool reflow);
nsresult GetZoom (float *aTextZoom);
@@ -81,22 +83,8 @@ public:
nsresult GetEncodingInfo (EphyEncodingInfo **infoptr);
- nsresult CanCutSelection(PRBool *result);
-
- nsresult CanCopySelection(PRBool *result);
-
- nsresult CanPaste(PRBool *result);
-
- nsresult CutSelection(void);
-
- nsresult CopySelection(void);
-
- nsresult Paste(void);
-
nsresult GetMainDOMDocument (nsIDOMDocument **aDOMDocument);
- nsresult SelectAll (void);
-
nsresult PushTargetDocument (nsIDOMDocument *domDoc);
nsresult PopTargetDocument ();
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index b31e1c6e2..9f80eb1c1 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -10,6 +10,7 @@ INCLUDES = \
-I$(MOZILLA_INCLUDE_ROOT)/chrome \
-I$(MOZILLA_INCLUDE_ROOT)/content \
-I$(MOZILLA_INCLUDE_ROOT)/cookie \
+ -I$(MOZILLA_INCLUDE_ROOT)/commandhandler \
-I$(MOZILLA_INCLUDE_ROOT)/docshell \
-I$(MOZILLA_INCLUDE_ROOT)/dom \
-I$(MOZILLA_INCLUDE_ROOT)/exthandler \
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index e00738e4f..defa2fc12 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -18,8 +18,7 @@
* $Id$
*/
-#include "gtkmozembed.h"
-#include "gtkmozembed_internal.h"
+#include "ephy-command-manager.h"
#include "ephy-string.h"
#include "ephy-embed.h"
#include "ephy-debug.h"
@@ -29,6 +28,8 @@
#include "EventContext.h"
#include "ephy-debug.h"
+#include <gtkmozembed.h>
+#include <gtkmozembed_internal.h>
#include <nsIWindowWatcher.h>
#include <nsIURI.h>
#include <nsIURL.h>
@@ -108,20 +109,6 @@ impl_zoom_set (EphyEmbed *embed,
static gresult
impl_zoom_get (EphyEmbed *embed,
float *zoom);
-static gresult
-impl_selection_can_cut (EphyEmbed *embed);
-static gresult
-impl_selection_can_copy (EphyEmbed *embed);
-static gresult
-impl_can_paste (EphyEmbed *embed);
-static gresult
-impl_select_all (EphyEmbed *embed);
-static gresult
-impl_selection_cut (EphyEmbed *embed);
-static gresult
-impl_selection_copy (EphyEmbed *embed);
-static gresult
-impl_paste (EphyEmbed *embed);
static gresult
impl_shistory_count (EphyEmbed *embed,
int *count);
@@ -256,6 +243,43 @@ static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
static GObjectClass *parent_class = NULL;
+static gresult
+impl_manager_do_command (EphyCommandManager *manager,
+ const char *command)
+{
+ nsresult result = NS_OK;
+ EphyWrapper *wrapper;
+
+ wrapper = MOZILLA_EMBED(manager)->priv->wrapper;
+ g_return_val_if_fail (wrapper != NULL, G_FAILED);
+
+ result = wrapper->DoCommand (command);
+
+ return result ? G_OK : G_FAILED;
+}
+
+static gresult
+impl_manager_can_do_command (EphyCommandManager *manager,
+ const char *command)
+{
+ return G_NOT_IMPLEMENTED;
+}
+
+static gresult
+impl_manager_observe_command (EphyCommandManager *manager,
+ const char *command)
+{
+ return G_NOT_IMPLEMENTED;
+}
+
+static void
+ephy_command_manager_init (EphyCommandManagerClass *manager_class)
+{
+ manager_class->do_command = impl_manager_do_command;
+ manager_class->can_do_command = impl_manager_can_do_command;
+ manager_class->observe_command = impl_manager_observe_command;
+}
+
GType
mozilla_embed_get_type (void)
{
@@ -278,11 +302,18 @@ mozilla_embed_get_type (void)
static const GInterfaceInfo embed_info =
{
- (GInterfaceInitFunc) ephy_embed_init, /* interface_init */
- NULL, /* interface_finalize */
- NULL /* interface_data */
+ (GInterfaceInitFunc) ephy_embed_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo ephy_command_manager_info =
+ {
+ (GInterfaceInitFunc) ephy_command_manager_init,
+ NULL,
+ NULL
};
-
+
mozilla_embed_type = g_type_register_static (GTK_TYPE_MOZ_EMBED,
"MozillaEmbed",
&our_info,
@@ -290,6 +321,9 @@ mozilla_embed_get_type (void)
g_type_add_interface_static (mozilla_embed_type,
EPHY_TYPE_EMBED,
&embed_info);
+ g_type_add_interface_static (mozilla_embed_type,
+ EPHY_TYPE_COMMAND_MANAGER,
+ &ephy_command_manager_info);
}
return mozilla_embed_type;
@@ -364,12 +398,6 @@ ephy_embed_init (EphyEmbedClass *embed_class)
embed_class->copy_page = impl_copy_page;
embed_class->zoom_set = impl_zoom_set;
embed_class->zoom_get = impl_zoom_get;
- embed_class->selection_can_cut = impl_selection_can_cut;
- embed_class->selection_can_copy = impl_selection_can_copy;
- embed_class->can_paste = impl_can_paste;
- embed_class->selection_cut = impl_selection_cut;
- embed_class->selection_copy = impl_selection_copy;
- embed_class->paste = impl_paste;
embed_class->shistory_count = impl_shistory_count;
embed_class->shistory_get_nth = impl_shistory_get_nth;
embed_class->shistory_get_pos = impl_shistory_get_pos;
@@ -381,7 +409,6 @@ ephy_embed_init (EphyEmbedClass *embed_class)
embed_class->find_set_properties = impl_find_set_properties;
embed_class->set_encoding = impl_set_encoding;
embed_class->get_encoding_info = impl_get_encoding_info;
- embed_class->select_all = impl_select_all;
embed_class->print = impl_print;
embed_class->print_preview_close = impl_print_preview_close;
embed_class->print_preview_num_pages = impl_print_preview_num_pages;
@@ -860,104 +887,6 @@ impl_zoom_get (EphyEmbed *embed,
}
}
-static gresult
-impl_selection_can_cut (EphyEmbed *embed)
-{
- gboolean result;
- EphyWrapper *wrapper;
-
- wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
-
- wrapper->CanCutSelection (&result);
-
- return result ? G_OK : G_FAILED;
-}
-
-static gresult
-impl_selection_can_copy (EphyEmbed *embed)
-{
- gboolean result;
- EphyWrapper *wrapper;
-
- wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
-
- wrapper->CanCopySelection (&result);
-
- return result ? G_OK : G_FAILED;
-}
-
-static gresult
-impl_can_paste (EphyEmbed *embed)
-{
- gboolean result;
- EphyWrapper *wrapper;
-
- wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
-
- wrapper->CanPaste (&result);
-
- return result ? G_OK : G_FAILED;
-}
-
-static gresult
-impl_select_all (EphyEmbed *embed)
-{
- nsresult result;
- EphyWrapper *wrapper;
-
- wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
-
- result = wrapper->SelectAll ();
-
- return result ? G_OK : G_FAILED;
-}
-
-static gresult
-impl_selection_cut (EphyEmbed *embed)
-{
- nsresult rv;
- EphyWrapper *wrapper;
-
- wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
-
- rv = wrapper->CutSelection ();
-
- return NS_SUCCEEDED(rv) ? G_OK : G_FAILED;
-}
-
-static gresult
-impl_selection_copy (EphyEmbed *embed)
-{
- nsresult rv;
- EphyWrapper *wrapper;
-
- wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
-
- rv = wrapper->CopySelection ();
-
- return NS_SUCCEEDED(rv) ? G_OK : G_FAILED;
-}
-
-static gresult
-impl_paste (EphyEmbed *embed)
-{
- nsresult rv;
- EphyWrapper *wrapper;
-
- wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
- g_return_val_if_fail (wrapper != NULL, G_FAILED);
-
- rv = wrapper->Paste ();
-
- return NS_SUCCEEDED(rv) ? G_OK : G_FAILED;
-}
-
static gresult
impl_shistory_count (EphyEmbed *embed,
int *count)