aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-11-04 16:56:33 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-11-04 16:56:33 +0800
commit78c2e1a47c7fc6074a80c8b91dbdc1f57e3ba817 (patch)
tree80cdea46a31b32a1786dcda11a21106bb63a5231
parent2e01fbd1c41969e80dd599958b811867dc935a59 (diff)
downloadgsoc2013-epiphany-78c2e1a47c7fc6074a80c8b91dbdc1f57e3ba817.tar
gsoc2013-epiphany-78c2e1a47c7fc6074a80c8b91dbdc1f57e3ba817.tar.gz
gsoc2013-epiphany-78c2e1a47c7fc6074a80c8b91dbdc1f57e3ba817.tar.bz2
gsoc2013-epiphany-78c2e1a47c7fc6074a80c8b91dbdc1f57e3ba817.tar.lz
gsoc2013-epiphany-78c2e1a47c7fc6074a80c8b91dbdc1f57e3ba817.tar.xz
gsoc2013-epiphany-78c2e1a47c7fc6074a80c8b91dbdc1f57e3ba817.tar.zst
gsoc2013-epiphany-78c2e1a47c7fc6074a80c8b91dbdc1f57e3ba817.zip
Show only paste in the context menu, it's the only one that works in
2003-11-04 Marco Pesenti Gritti <marco@gnome.org> * data/ui/epiphany-ui.xml: Show only paste in the context menu, it's the only one that works in mozilla. * embed/ephy-command-manager.c: (ephy_command_manager_get_command_state): * embed/ephy-command-manager.h: Rename the state api. * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: * embed/mozilla/mozilla-embed.cpp: Implement state api. * src/ephy-window.c: (window_cmd_edit), (show_embed_popup): Update clipboard menus on activate.
-rw-r--r--ChangeLog23
-rw-r--r--data/ui/epiphany-ui.xml2
-rw-r--r--embed/ephy-command-manager.c15
-rw-r--r--embed/ephy-command-manager.h19
-rw-r--r--embed/mozilla/EphyBrowser.cpp12
-rw-r--r--embed/mozilla/EphyBrowser.h1
-rw-r--r--embed/mozilla/mozilla-embed.cpp20
-rw-r--r--src/ephy-window.c77
8 files changed, 117 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 72f7e0581..890c46b91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2003-11-04 Marco Pesenti Gritti <marco@gnome.org>
+
+ * data/ui/epiphany-ui.xml:
+
+ Show only paste in the context menu, it's the only
+ one that works in mozilla.
+
+ * embed/ephy-command-manager.c:
+ (ephy_command_manager_get_command_state):
+ * embed/ephy-command-manager.h:
+
+ Rename the state api.
+
+ * embed/mozilla/EphyBrowser.cpp:
+ * embed/mozilla/EphyBrowser.h:
+ * embed/mozilla/mozilla-embed.cpp:
+
+ Implement state api.
+
+ * src/ephy-window.c: (window_cmd_edit), (show_embed_popup):
+
+ Update clipboard menus on activate.
+
2003-11-03 Christian Persch <chpe@cvs.gnome.org>
* lib/ephy-marshal.list:
diff --git a/data/ui/epiphany-ui.xml b/data/ui/epiphany-ui.xml
index f331c7e71..5c6b2cf0d 100644
--- a/data/ui/epiphany-ui.xml
+++ b/data/ui/epiphany-ui.xml
@@ -85,8 +85,6 @@
</menubar>
<popup name="EphyInputPopup" action="PopupAction">
- <menuitem name="EditCutIP" action="EditCut"/>
- <menuitem name="EditCopyIP" action="EditCopy"/>
<menuitem name="EditPasteIP" action="EditPaste"/>
</popup>
<popup name="EphyTextPopup" action="PopupAction">
diff --git a/embed/ephy-command-manager.c b/embed/ephy-command-manager.c
index ab4ccdace..08654fee5 100644
--- a/embed/ephy-command-manager.c
+++ b/embed/ephy-command-manager.c
@@ -88,17 +88,10 @@ ephy_command_manager_do_command (EphyCommandManager *manager,
}
gresult
-ephy_command_manager_can_do_command (EphyCommandManager *manager,
- const char *command)
+ephy_command_manager_get_command_state (EphyCommandManager *manager,
+ const char *command,
+ gboolean *enabled)
{
EphyCommandManagerClass *klass = EPHY_COMMAND_MANAGER_GET_CLASS (manager);
- return klass->can_do_command (manager, command);
-}
-
-gresult
-ephy_command_manager_observe_command (EphyCommandManager *manager,
- const char *command)
-{
- EphyCommandManagerClass *klass = EPHY_COMMAND_MANAGER_GET_CLASS (manager);
- return klass->observe_command (manager, command);
+ return klass->get_command_state (manager, command, enabled);
}
diff --git a/embed/ephy-command-manager.h b/embed/ephy-command-manager.h
index 043d2c90d..14d7a4ca6 100644
--- a/embed/ephy-command-manager.h
+++ b/embed/ephy-command-manager.h
@@ -40,12 +40,11 @@ struct EphyCommandManagerClass
{
GTypeInterface base_iface;
- gresult (* do_command) (EphyCommandManager *manager,
- const char *command);
- gresult (* can_do_command) (EphyCommandManager *manager,
- const char *command);
- gresult (* observe_command) (EphyCommandManager *manager,
- const char *command);
+ gresult (* do_command) (EphyCommandManager *manager,
+ const char *command);
+ gresult (* get_command_state) (EphyCommandManager *manager,
+ const char *command,
+ gboolean *enabled);
/* Signals */
@@ -58,11 +57,9 @@ GType ephy_command_manager_get_type (void);
gresult ephy_command_manager_do_command (EphyCommandManager *manager,
const char *command);
-gresult ephy_command_manager_can_do_command (EphyCommandManager *manager,
- const char *command);
-
-gresult ephy_command_manager_observe_command (EphyCommandManager *manager,
- const char *command);
+gresult ephy_command_manager_get_command_state (EphyCommandManager *manager,
+ const char *command,
+ gboolean *enabled);
G_END_DECLS
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 8d1b3cdd0..732de1c42 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -722,3 +722,15 @@ nsresult EphyBrowser::DoCommand (const char *command)
return cmdManager->DoCommand (command, nsnull, nsnull);
}
+
+nsresult EphyBrowser::GetCommandState (const char *command, PRBool *enabled)
+{
+ nsCOMPtr<nsICommandManager> cmdManager;
+
+ g_return_val_if_fail (mWebBrowser, NS_ERROR_FAILURE);
+
+ cmdManager = do_GetInterface (mWebBrowser);
+ if (!cmdManager) return NS_ERROR_FAILURE;
+
+ return cmdManager->IsCommandEnabled (command, nsnull, enabled);
+}
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index 00d49cce2..a57736092 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -50,6 +50,7 @@ public:
nsresult Destroy (void);
nsresult DoCommand (const char *command);
+ nsresult GetCommandState (const char *command, PRBool *enabled);
nsresult SetZoom (float aTextZoom, PRBool reflow);
nsresult GetZoom (float *aTextZoom);
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 62af22e82..2d11e32ad 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -243,25 +243,23 @@ impl_manager_do_command (EphyCommandManager *manager,
}
static gresult
-impl_manager_can_do_command (EphyCommandManager *manager,
- const char *command)
+impl_manager_get_command_state (EphyCommandManager *manager,
+ const char *command,
+ gboolean *enabled)
{
- return G_NOT_IMPLEMENTED;
-}
+ nsresult result;
+ MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(manager)->priv;
-static gresult
-impl_manager_observe_command (EphyCommandManager *manager,
- const char *command)
-{
- return G_NOT_IMPLEMENTED;
+ result = mpriv->browser->GetCommandState (command, enabled);
+
+ return result ? G_OK : G_FAILED;
}
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;
+ manager_class->get_command_state = impl_manager_get_command_state;
}
GType
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 4ec9a3a92..03b1d70d2 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -23,6 +23,7 @@
#endif
#include "ephy-window.h"
+#include "ephy-command-manager.h"
#include "ephy-bookmarks-menu.h"
#include "ephy-favorites-menu.h"
#include "ephy-state.h"
@@ -56,11 +57,27 @@
#include <gtk/gtkuimanager.h>
#include <gtk/gtktoggleaction.h>
+static void
+ephy_window_class_init (EphyWindowClass *klass);
+static void
+ephy_window_init (EphyWindow *gs);
+static void
+ephy_window_finalize (GObject *object);
+static void
+ephy_window_show (GtkWidget *widget);
+static void
+ephy_window_notebook_switch_page_cb (GtkNotebook *notebook,
+ GtkNotebookPage *page,
+ guint page_num,
+ EphyWindow *window);
+static void
+window_cmd_edit (GtkAction *action, EphyWindow *window);
+
static GtkActionEntry ephy_menu_entries [] = {
/* Toplevel */
{ "File", NULL, N_("_File") },
- { "Edit", NULL, N_("_Edit") },
+ { "Edit", NULL, N_("_Edit"), NULL, NULL, G_CALLBACK (window_cmd_edit) },
{ "View", NULL, N_("_View") },
{ "Bookmarks", NULL, N_("_Bookmarks") },
{ "Go", NULL, N_("_Go") },
@@ -292,20 +309,6 @@ struct EphyWindowPrivate
guint num_tabs;
};
-static void
-ephy_window_class_init (EphyWindowClass *klass);
-static void
-ephy_window_init (EphyWindow *gs);
-static void
-ephy_window_finalize (GObject *object);
-static void
-ephy_window_show (GtkWidget *widget);
-static void
-ephy_window_notebook_switch_page_cb (GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- EphyWindow *window);
-
enum
{
PROP_0,
@@ -341,6 +344,46 @@ ephy_window_get_type (void)
return ephy_window_type;
}
+void
+window_cmd_edit (GtkAction *action,
+ EphyWindow *window)
+{
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
+ GtkActionGroup *action_group;
+ gboolean can_copy, can_cut;
+
+ if (GTK_IS_EDITABLE (widget))
+ {
+ gboolean has_selection;
+
+ has_selection = gtk_editable_get_selection_bounds
+ (GTK_EDITABLE (widget), NULL, NULL);
+
+ can_copy = has_selection;
+ can_cut = has_selection;
+ }
+ else
+ {
+ EphyEmbed *embed;
+
+ embed = ephy_window_get_active_embed (window);
+ g_return_if_fail (embed != NULL);
+
+ ephy_command_manager_get_command_state
+ (EPHY_COMMAND_MANAGER (embed), "cmd_copy", &can_copy);
+ ephy_command_manager_get_command_state
+ (EPHY_COMMAND_MANAGER (embed), "cmd_cut", &can_cut);
+ }
+
+ action_group = window->priv->action_group;
+
+ action = gtk_action_group_get_action (action_group, "EditCopy");
+ g_object_set (action, "sensitive", can_copy, NULL);
+
+ action = gtk_action_group_get_action (action_group, "EditCut");
+ g_object_set (action, "sensitive", can_cut, NULL);
+}
+
static void
remove_from_session (EphyWindow *window)
{
@@ -1000,10 +1043,10 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
{
popup = "/EphyImagePopup";
}
- /* else if (context & EMBED_CONTEXT_INPUT)
+ else if (context & EMBED_CONTEXT_INPUT)
{
popup = "/EphyInputPopup";
- } */
+ }
else
{
popup = framed ? "/EphyFramedDocumentPopup" :