aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Bordoley <bordoley@msu.edu>2003-04-20 01:20:45 +0800
committerDave Bordoley <Bordoley@src.gnome.org>2003-04-20 01:20:45 +0800
commitb2c6abf1424cde68177727eabb25f9789cfdc33c (patch)
treeebe680da5b9c1130b87caf2ae72d7635c01534c4
parent18bb6d0b335066b06f5e95d5ab27ac5a490e90b7 (diff)
downloadgsoc2013-epiphany-b2c6abf1424cde68177727eabb25f9789cfdc33c.tar
gsoc2013-epiphany-b2c6abf1424cde68177727eabb25f9789cfdc33c.tar.gz
gsoc2013-epiphany-b2c6abf1424cde68177727eabb25f9789cfdc33c.tar.bz2
gsoc2013-epiphany-b2c6abf1424cde68177727eabb25f9789cfdc33c.tar.lz
gsoc2013-epiphany-b2c6abf1424cde68177727eabb25f9789cfdc33c.tar.xz
gsoc2013-epiphany-b2c6abf1424cde68177727eabb25f9789cfdc33c.tar.zst
gsoc2013-epiphany-b2c6abf1424cde68177727eabb25f9789cfdc33c.zip
Add copy to the bookmark context menu.
2003-04-19 David Bordoley <bordoley@msu.edu> * data/ui/epiphany-bookmark-editor-ui.xml.in: Add copy to the bookmark context menu. * data/ui/epiphany-history-window-ui.xml.in: Add an edit menu. Add copy to history item context menu. * src/ephy-history-window.c: (cmd_cut), (cmd_copy), (cmd_paste), (cmd_select_all), (ephy_history_window_update_menu), (ephy_history_window_construct): Add edit menu actions. Update the edit menu when activated. Support copying the location of a history item and change the label to "Copy Location". * src/bookmarks/ephy-bookmarks-editor.c: (cmd_copy), (ephy_bookmarks_editor_update_menu): Support copying the location of a bookmark and change the label to "Copy Location".
-rw-r--r--ChangeLog24
-rw-r--r--data/ui/epiphany-bookmark-editor-ui.xml.in4
-rw-r--r--data/ui/epiphany-history-window-ui.xml.in14
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c51
-rw-r--r--src/ephy-history-window.c145
5 files changed, 221 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index a6e4cb3af..059c7c498 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2003-04-19 David Bordoley <bordoley@msu.edu>
+
+ * data/ui/epiphany-bookmark-editor-ui.xml.in:
+
+ Add copy to the bookmark context menu.
+
+ * data/ui/epiphany-history-window-ui.xml.in:
+
+ Add an edit menu. Add copy to history item context menu.
+
+ * src/ephy-history-window.c: (cmd_cut), (cmd_copy),
+ (cmd_paste), (cmd_select_all), (ephy_history_window_update_menu),
+ (ephy_history_window_construct):
+
+ Add edit menu actions. Update the edit menu when activated.
+ Support copying the location of a history item and change
+ the label to "Copy Location".
+
+ * src/bookmarks/ephy-bookmarks-editor.c: (cmd_copy),
+ (ephy_bookmarks_editor_update_menu):
+
+ Support copying the location of a bookmark and change
+ the label to "Copy Location".
+
2003-04-19 Marco Pesenti Gritti <marco@it.gnome.org>
* src/ephy-window.c: (menu_activate_cb), (setup_window):
diff --git a/data/ui/epiphany-bookmark-editor-ui.xml.in b/data/ui/epiphany-bookmark-editor-ui.xml.in
index 668385f61..f0b299a39 100644
--- a/data/ui/epiphany-bookmark-editor-ui.xml.in
+++ b/data/ui/epiphany-bookmark-editor-ui.xml.in
@@ -34,9 +34,11 @@
<menuitem name="OpenInWindowBMK" verb="OpenInWindow"/>
<menuitem name="OpenInTabBMK" verb="OpenInTab"/>
<separator name="BookmarksPopupSep1"/>
+ <menuitem name="CopyBMK" verb="Copy"/>
+ <separator name="BookmarksPopupSep2"/>
<menuitem name="RenameBMK" verb="Rename"/>
<menuitem name="DeleteBMK" verb="Delete"/>
- <separator name="BookmarksPopupSep2"/>
+ <separator name="BookmarksPopupSep3"/>
<menuitem name="BMKProperties" verb="Properties"/>
</popup>
diff --git a/data/ui/epiphany-history-window-ui.xml.in b/data/ui/epiphany-history-window-ui.xml.in
index a4a10885d..404a5940f 100644
--- a/data/ui/epiphany-history-window-ui.xml.in
+++ b/data/ui/epiphany-history-window-ui.xml.in
@@ -4,12 +4,19 @@
<submenu name="FileMenu" verb="File">
<menuitem name="FileOpenInWindow" verb="OpenInWindow"/>
<menuitem name="FileOpenInTab" verb="OpenInTab"/>
- <separator name="FileSep2"/>
- <menuitem name="FileClear" verb="Clear"/>
- <separator name="FileSep3"/>
+ <separator name="FileSep1"/>
<menuitem name="FileClose" verb="Close"/>
</submenu>
+<submenu name="EditMenu" verb="Edit">
+ <menuitem name="EditCut" verb="Cut"/>
+ <menuitem name="EditCopy" verb="Copy"/>
+ <menuitem name="EditPaste" verb="Paste"/>
+ <menuitem name="EditSelectAll" verb="SelectAll"/>
+ <separator name="EditSep1"/>
+ <menuitem name="EditClear" verb="Clear"/>
+</submenu>
+
<submenu name="HelpMenu" verb="Help">
<menuitem name="HelpContents" verb="HelpContents"/>
<menuitem name="HelpAbout" verb="HelpAbout"/>
@@ -22,6 +29,7 @@
<popup name="EphyHistoryWindowPopup" verb="FakeToplevel">
<menuitem name="OpenInWindowBMK" verb="OpenInWindow"/>
<menuitem name="OpenInTabBMK" verb="OpenInTab"/>
+ <menuitem name="CopyBMK" verb="Copy"/>
</popup>
</popups>
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index d8887eaa7..8c49eb991 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -333,6 +333,23 @@ cmd_copy (EggAction *action,
{
gtk_editable_copy_clipboard (GTK_EDITABLE (widget));
}
+
+ else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->bm_view)))
+ {
+ GList *selection;
+
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->bm_view));
+
+ if (g_list_length (selection) == 1)
+ {
+ const char *tmp;
+ EphyNode *node = EPHY_NODE (selection->data);
+ tmp = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), tmp, -1);
+ }
+
+ g_free (selection);
+ }
}
static void
@@ -487,7 +504,7 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
{
gboolean open_in_window, open_in_tab,
rename, delete, properties;
- const gchar *open_in_window_label, *open_in_tab_label;
+ const gchar *open_in_window_label, *open_in_tab_label, *copy_label;
gboolean bmk_focus, key_focus;
gboolean key_selection, bmk_selection;
gboolean key_normal = FALSE;
@@ -502,34 +519,36 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
(EPHY_NODE_VIEW (editor->priv->bm_view));
key_focus = ephy_node_view_is_target
(EPHY_NODE_VIEW (editor->priv->key_view));
-
focus_widget = gtk_window_get_focus (GTK_WINDOW (editor));
+ bmk_selection = ephy_node_view_has_selection
+ (EPHY_NODE_VIEW (editor->priv->bm_view),
+ &bmk_multiple_selection);
+ key_selection = ephy_node_view_has_selection
+ (EPHY_NODE_VIEW (editor->priv->key_view), NULL);
if (GTK_IS_EDITABLE (focus_widget))
{
gboolean has_selection;
+ gboolean clipboard_contains_text;
has_selection = gtk_editable_get_selection_bounds
(GTK_EDITABLE (focus_widget), NULL, NULL);
+ clipboard_contains_text = gtk_clipboard_wait_is_text_available
+ (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD));
- select_all = paste = TRUE;
cut = has_selection;
copy = has_selection;
+ paste = clipboard_contains_text;
+ select_all = TRUE;
}
else
{
- select_all = bmk_focus;
cut = FALSE;
- copy = FALSE;
+ copy = (bmk_focus && !bmk_multiple_selection && bmk_selection);
paste = FALSE;
+ select_all = bmk_focus;
}
- bmk_selection = ephy_node_view_has_selection
- (EPHY_NODE_VIEW (editor->priv->bm_view),
- &bmk_multiple_selection);
- key_selection = ephy_node_view_has_selection
- (EPHY_NODE_VIEW (editor->priv->key_view), NULL);
-
selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view));
if (key_focus && selected)
{
@@ -554,6 +573,15 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
open_in_tab_label = _("Open in New _Tab");
}
+ if (bmk_focus)
+ {
+ copy_label = _("_Copy Location");
+ }
+ else
+ {
+ copy_label = _("_Copy");
+ }
+
open_in_window = (bmk_focus && bmk_selection);
open_in_tab = (bmk_focus && bmk_selection);
rename = (bmk_focus && bmk_selection && !bmk_multiple_selection) ||
@@ -579,6 +607,7 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
g_object_set (action, "sensitive", cut, NULL);
action = egg_action_group_get_action (action_group, "Copy");
g_object_set (action, "sensitive", copy, NULL);
+ g_object_set (action, "label", copy_label, NULL);
action = egg_action_group_get_action (action_group, "Paste");
g_object_set (action, "sensitive", paste, NULL);
action = egg_action_group_get_action (action_group, "SelectAll");
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 2c2cd8ec8..0f8952252 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -72,6 +72,14 @@ static void cmd_clear (EggAction *action,
EphyHistoryWindow *editor);
static void cmd_close (EggAction *action,
EphyHistoryWindow *editor);
+static void cmd_cut (EggAction *action,
+ EphyHistoryWindow *editor);
+static void cmd_copy (EggAction *action,
+ EphyHistoryWindow *editor);
+static void cmd_paste (EggAction *action,
+ EphyHistoryWindow *editor);
+static void cmd_select_all (EggAction *action,
+ EphyHistoryWindow *editor);
static void cmd_help_contents (EggAction *action,
EphyHistoryWindow *editor);
@@ -99,6 +107,7 @@ static GObjectClass *parent_class = NULL;
static EggActionGroupEntry ephy_history_ui_entries [] = {
/* Toplevel */
{ "File", N_("_File"), NULL, NULL, NULL, NULL, NULL },
+ { "Edit", N_("_Edit"), NULL, NULL, NULL, NULL, NULL },
{ "Help", N_("_Help"), NULL, NULL, NULL, NULL, NULL },
{ "FakeToplevel", (""), NULL, NULL, NULL, NULL, NULL },
@@ -108,12 +117,24 @@ static EggActionGroupEntry ephy_history_ui_entries [] = {
{ "OpenInTab", N_("Open in New _Tab"), NULL, "<shift><control>O",
NULL, G_CALLBACK (cmd_open_bookmarks_in_tabs), NULL },
- { "Clear", N_("Clea_r"), GTK_STOCK_CLEAR, NULL,
+ { "Clear", N_("C_lear History"), GTK_STOCK_CLEAR, NULL,
NULL, G_CALLBACK (cmd_clear), NULL },
{ "Close", N_("_Close"), GTK_STOCK_CLOSE, "<control>W",
NULL, G_CALLBACK (cmd_close), NULL },
+ { "Cut", N_("Cu_t"), GTK_STOCK_CUT, "<control>X",
+ NULL, G_CALLBACK (cmd_cut), NULL },
+
+ { "Copy", N_("_Copy"), GTK_STOCK_COPY, "<control>C",
+ NULL, G_CALLBACK (cmd_copy), NULL },
+
+ { "Paste", N_("_Paste"), GTK_STOCK_PASTE, "<control>V",
+ NULL, G_CALLBACK (cmd_paste), NULL },
+
+ { "SelectAll", N_("Select _All"), NULL, "<control>A",
+ NULL, G_CALLBACK (cmd_select_all), NULL },
+
{ "HelpContents", N_("_Contents"), GTK_STOCK_HELP, "F1",
NULL, G_CALLBACK (cmd_help_contents), NULL },
@@ -203,6 +224,79 @@ cmd_open_bookmarks_in_browser (EggAction *action,
}
static void
+cmd_cut (EggAction *action,
+ EphyHistoryWindow *editor)
+{
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
+
+ if (GTK_IS_EDITABLE (widget))
+ {
+ gtk_editable_cut_clipboard (GTK_EDITABLE (widget));
+ }
+}
+
+static void
+cmd_copy (EggAction *action,
+ EphyHistoryWindow *editor)
+{
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
+
+ if (GTK_IS_EDITABLE (widget))
+ {
+ gtk_editable_copy_clipboard (GTK_EDITABLE (widget));
+ }
+
+ else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->pages_view)))
+ {
+ GList *selection;
+
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->pages_view));
+
+ if (g_list_length (selection) == 1)
+ {
+ const char *tmp;
+ EphyNode *node = EPHY_NODE (selection->data);
+ tmp = ephy_node_get_property_string (node, EPHY_NODE_PAGE_PROP_LOCATION);
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), tmp, -1);
+ }
+
+ g_free (selection);
+ }
+}
+
+static void
+cmd_paste (EggAction *action,
+ EphyHistoryWindow *editor)
+{
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
+
+ if (GTK_IS_EDITABLE (widget))
+ {
+ gtk_editable_paste_clipboard (GTK_EDITABLE (widget));
+ }
+}
+
+static void
+cmd_select_all (EggAction *action,
+ EphyHistoryWindow *editor)
+{
+ GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (editor));
+ GtkWidget *pages_view = editor->priv->pages_view;
+
+ if (GTK_IS_EDITABLE (widget))
+ {
+ gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
+ }
+ else if (ephy_node_view_is_target (EPHY_NODE_VIEW (pages_view)))
+ {
+ GtkTreeSelection *sel;
+
+ sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (pages_view));
+ gtk_tree_selection_select_all (sel);
+ }
+}
+
+static void
cmd_help_contents (EggAction *action,
EphyHistoryWindow *editor)
{
@@ -320,17 +414,43 @@ static void
ephy_history_window_update_menu (EphyHistoryWindow *editor)
{
gboolean open_in_window, open_in_tab;
+ gboolean cut, copy, paste, select_all;
gboolean pages_focus, pages_selection;
gboolean pages_multiple_selection;
EggActionGroup *action_group;
EggAction *action;
- char *open_in_window_label, *open_in_tab_label;
+ char *open_in_window_label, *open_in_tab_label, *copy_label;
+ GtkWidget *focus_widget;
pages_focus = ephy_node_view_is_target
(EPHY_NODE_VIEW (editor->priv->pages_view));
pages_selection = ephy_node_view_has_selection
(EPHY_NODE_VIEW (editor->priv->pages_view),
&pages_multiple_selection);
+ focus_widget = gtk_window_get_focus (GTK_WINDOW (editor));
+
+ if (GTK_IS_EDITABLE (focus_widget))
+ {
+ gboolean has_selection;
+ gboolean clipboard_contains_text;
+
+ has_selection = gtk_editable_get_selection_bounds
+ (GTK_EDITABLE (focus_widget), NULL, NULL);
+ clipboard_contains_text = gtk_clipboard_wait_is_text_available
+ (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD));
+
+ cut = has_selection;
+ copy = has_selection;
+ paste = clipboard_contains_text;
+ select_all = TRUE;
+ }
+ else
+ {
+ cut = FALSE;
+ copy = (pages_focus && !pages_multiple_selection && pages_selection);
+ paste = FALSE;
+ select_all = pages_focus;
+ }
if (pages_multiple_selection)
{
@@ -343,6 +463,16 @@ ephy_history_window_update_menu (EphyHistoryWindow *editor)
open_in_tab_label = _("Open in New _Tab");
}
+ if (pages_focus)
+ {
+ copy_label = _("_Copy Location");
+ }
+ else
+ {
+ copy_label = _("_Copy");
+ }
+
+
open_in_window = (pages_focus && pages_selection);
open_in_tab = (pages_focus && pages_selection);
@@ -353,6 +483,15 @@ ephy_history_window_update_menu (EphyHistoryWindow *editor)
action = egg_action_group_get_action (action_group, "OpenInTab");
g_object_set (action, "sensitive", open_in_tab, NULL);
g_object_set (action, "label", open_in_tab_label, NULL);
+ action = egg_action_group_get_action (action_group, "Cut");
+ g_object_set (action, "sensitive", cut, NULL);
+ action = egg_action_group_get_action (action_group, "Copy");
+ g_object_set (action, "sensitive", copy, NULL);
+ g_object_set (action, "label", copy_label, NULL);
+ action = egg_action_group_get_action (action_group, "Paste");
+ g_object_set (action, "sensitive", paste, NULL);
+ action = egg_action_group_get_action (action_group, "SelectAll");
+ g_object_set (action, "sensitive", select_all, NULL);
}
static void
@@ -582,6 +721,8 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
/* Update menu sensitivity before showing them */
menu = egg_menu_merge_get_widget (ui_merge, "/menu/FileMenu");
g_signal_connect (menu, "activate", G_CALLBACK (menu_activate_cb), editor);
+ menu = egg_menu_merge_get_widget (ui_merge, "/menu/EditMenu");
+ g_signal_connect (menu, "activate", G_CALLBACK (menu_activate_cb), editor);
hpaned = gtk_hpaned_new ();
gtk_container_set_border_width (GTK_CONTAINER (hpaned), 6);