aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Harvey <peter.a.harvey@gmail.com>2006-02-09 18:29:24 +0800
committerPeter Anthony Harvey <paharvey@src.gnome.org>2006-02-09 18:29:24 +0800
commit16b0cbaf01e356007d3257ece00d407aa13138f7 (patch)
tree236bad3be94268f3adccf9b7e78b3ef3faf41d32
parent05c6fc746dbf135d87b214d0f741bf533eb16b5b (diff)
downloadgsoc2013-epiphany-16b0cbaf01e356007d3257ece00d407aa13138f7.tar
gsoc2013-epiphany-16b0cbaf01e356007d3257ece00d407aa13138f7.tar.gz
gsoc2013-epiphany-16b0cbaf01e356007d3257ece00d407aa13138f7.tar.bz2
gsoc2013-epiphany-16b0cbaf01e356007d3257ece00d407aa13138f7.tar.lz
gsoc2013-epiphany-16b0cbaf01e356007d3257ece00d407aa13138f7.tar.xz
gsoc2013-epiphany-16b0cbaf01e356007d3257ece00d407aa13138f7.tar.zst
gsoc2013-epiphany-16b0cbaf01e356007d3257ece00d407aa13138f7.zip
data/ui/epiphany-bookmark-editor-ui.xml
2006-02-09 Peter Harvey <peter.a.harvey@gmail.com> * data/ui/epiphany-bookmark-editor-ui.xml * src/bookmarks/ephy-bookmarks-editor.c Restore the 'Show on Toolbar' functionality, implemented very differently now.
-rw-r--r--ChangeLog8
-rw-r--r--data/ui/epiphany-bookmark-editor-ui.xml70
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c121
3 files changed, 166 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 405f65072..336672a34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-02-09 Peter Harvey <peter.a.harvey@gmail.com>
+
+ * data/ui/epiphany-bookmark-editor-ui.xml
+ * src/bookmarks/ephy-bookmarks-editor.c
+
+ Restore the 'Show on Toolbar' functionality, implemented very
+ differently now.
+
2006-02-08 Jean-François Rameau <jframeau@cvs.gnome.org>
* embed/mozilla/EphyBrowser.cpp: (HandleEvent):
diff --git a/data/ui/epiphany-bookmark-editor-ui.xml b/data/ui/epiphany-bookmark-editor-ui.xml
index 79bb82e49..b62b5b9c9 100644
--- a/data/ui/epiphany-bookmark-editor-ui.xml
+++ b/data/ui/epiphany-bookmark-editor-ui.xml
@@ -2,56 +2,60 @@
<menubar>
<menu name="FileMenu" action="File">
- <menuitem name="FileNewTopic" action="NewTopic"/>
- <separator name="FileSep1"/>
- <menuitem name="FileOpenInWindow" action="OpenInWindow"/>
- <menuitem name="FileOpenInTab" action="OpenInTab"/>
- <separator name="FileSep2"/>
- <menuitem name="FileRename" action="Rename"/>
- <menuitem name="FileDelete" action="Delete"/>
- <separator name="FileSep3"/>
- <menuitem name="FileProperties" action="Properties"/>
- <separator name="FileSep4"/>
- <menuitem name="FileImport" action="Import"/>
- <menuitem name="FileExport" action="Export"/>
- <separator name="FileSep5"/>
- <menuitem name="FileClose" action="Close"/>
+ <menuitem action="NewTopic"/>
+ <separator/>
+ <menuitem action="OpenInWindow"/>
+ <menuitem action="OpenInTab"/>
+ <separator/>
+ <menuitem action="Rename"/>
+ <menuitem action="Delete"/>
+ <separator/>
+ <menuitem action="ShowOnToolbar"/>
+ <menuitem action="Properties"/>
+ <separator/>
+ <menuitem action="Import"/>
+ <menuitem action="Export"/>
+ <separator/>
+ <menuitem action="Close"/>
</menu>
<menu name="EditMenu" action="Edit">
- <menuitem name="EditCut" action="Cut"/>
- <menuitem name="EditCopy" action="Copy"/>
- <menuitem name="EditPaste" action="Paste"/>
- <menuitem name="EditSelectAll" action="SelectAll"/>
+ <menuitem action="Cut"/>
+ <menuitem action="Copy"/>
+ <menuitem action="Paste"/>
+ <menuitem action="SelectAll"/>
</menu>
<menu name="ViewMenu" action="View">
- <menuitem name="ViewTitleMenu" action="ViewTitle"/>
- <menuitem name="ViewTitleAddressMenu" action="ViewTitleAddress"/>
+ <menuitem action="ViewTitle"/>
+ <menuitem action="ViewTitleAddress"/>
</menu>
<menu name="HelpMenu" action="Help">
- <menuitem name="HelpContents" action="HelpContents"/>
- <menuitem name="HelpAbout" action="HelpAbout"/>
+ <menuitem action="HelpContents"/>
+ <menuitem action="HelpAbout"/>
</menu>
</menubar>
<popup name="EphyBookmarkEditorPopup" action="PopupAction">
- <menuitem name="OpenInWindowBMK" action="OpenInWindow"/>
- <menuitem name="OpenInTabBMK" action="OpenInTab"/>
- <separator name="BookmarksPopupSep1"/>
- <menuitem name="CopyBMK" action="Copy"/>
- <separator name="BookmarksPopupSep2"/>
- <menuitem name="RenameBMK" action="Rename"/>
- <menuitem name="DeleteBMK" action="Delete"/>
- <separator name="BookmarksPopupSep3"/>
- <menuitem name="BMKProperties" action="Properties"/>
+ <menuitem action="OpenInWindow"/>
+ <menuitem action="OpenInTab"/>
+ <separator/>
+ <menuitem action="Copy"/>
+ <separator/>
+ <menuitem action="Rename"/>
+ <menuitem action="Delete"/>
+ <separator/>
+ <menuitem action="ShowOnToolbar"/>
+ <menuitem action="Properties"/>
</popup>
<popup name="EphyBookmarkKeywordPopup" action="PopupAction">
- <menuitem name="RenameTPC" action="Rename"/>
- <menuitem name="DeleteTPC" action="Delete"/>
+ <menuitem action="Rename"/>
+ <menuitem action="Delete"/>
+ <separator/>
+ <menuitem action="ShowOnToolbar"/>
</popup>
</ui>
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index e3cb8fa1c..c031a4cd0 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -49,6 +49,8 @@
#include "ephy-bookmarks-import.h"
#include "ephy-bookmarks-export.h"
#include "ephy-bookmarks-ui.h"
+#include "ephy-bookmark-action.h"
+#include "ephy-topic-action.h"
#include "ephy-node-common.h"
#include "ephy-node-view.h"
#include "ephy-window.h"
@@ -114,6 +116,8 @@ static void cmd_open_bookmarks_in_tabs (GtkAction *action,
EphyBookmarksEditor *editor);
static void cmd_open_bookmarks_in_browser (GtkAction *action,
EphyBookmarksEditor *editor);
+static void cmd_toolbar (GtkAction *action,
+ EphyBookmarksEditor *editor);
static void cmd_delete (GtkAction *action,
EphyBookmarksEditor *editor);
static void cmd_bookmark_properties (GtkAction *action,
@@ -229,6 +233,12 @@ static const GtkActionEntry ephy_bookmark_popup_entries [] = {
G_CALLBACK (window_cmd_help_about) },
};
+static const GtkToggleActionEntry ephy_bookmark_toggle_entries [] = {
+ { "ShowOnToolbar", NULL, N_("_Show on Toolbar"), NULL,
+ N_("Show the selected bookmark on a toolbar"),
+ G_CALLBACK (cmd_toolbar), FALSE },
+};
+
enum
{
VIEW_TITLE,
@@ -417,6 +427,91 @@ delete_topic_dialog_construct (GtkWindow *parent,
}
static void
+cmd_toolbar (GtkAction *action,
+ EphyBookmarksEditor *editor)
+{
+ EggToolbarsModel *model;
+ EphyNode *node;
+ gboolean show;
+ const char *tname;
+ char *name;
+ gint flags, tpos;
+ GList *selection;
+ GList *l;
+
+ model = EGG_TOOLBARS_MODEL (ephy_shell_get_toolbars_model (ephy_shell_get_default (), FALSE));
+
+ for (tpos = 0; tpos < egg_toolbars_model_n_toolbars (model); tpos++)
+ {
+ tname = egg_toolbars_model_toolbar_nth (model, tpos);
+ if (tname != NULL && strcmp (tname, "Bookmarks") == 0)
+ break;
+ }
+
+ if (tpos == egg_toolbars_model_n_toolbars (model))
+ {
+ tpos = egg_toolbars_model_add_toolbar (model, -1, "Bookmarks");
+ }
+
+ if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->bm_view)))
+ {
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->bm_view));
+
+ node = selection->data;
+ name = ephy_bookmark_action_name (node);
+ flags = egg_toolbars_model_get_name_flags (model, name);
+ show = ((flags & EGG_TB_MODEL_NAME_USED) == 0);
+ g_free (name);
+
+ for (l = selection; l; l = l->next)
+ {
+ node = l->data;
+ name = ephy_bookmark_action_name (node);
+ flags = egg_toolbars_model_get_name_flags (model, name);
+ if(show && ((flags & EGG_TB_MODEL_NAME_USED) == 0))
+ {
+ egg_toolbars_model_add_item (model, tpos, -1, name);
+ }
+ else if(!show && ((flags & EGG_TB_MODEL_NAME_USED) != 0))
+ {
+ egg_toolbars_model_delete_item (model, name);
+ }
+ g_free (name);
+ }
+
+ g_list_free (selection);
+ }
+ else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->key_view)))
+ {
+ selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view));
+
+ node = selection->data;
+ name = ephy_topic_action_name (node);
+ flags = egg_toolbars_model_get_name_flags (model, name);
+ show = ((flags & EGG_TB_MODEL_NAME_USED) == 0);
+ g_free (name);
+
+ for (l = selection; l; l = l->next)
+ {
+ node = l->data;
+ name = ephy_topic_action_name (node);
+ flags = egg_toolbars_model_get_name_flags (model, name);
+ if(show && ((flags & EGG_TB_MODEL_NAME_USED) == 0))
+ {
+ egg_toolbars_model_add_item (model, tpos, -1, name);
+ }
+ else if(!show && ((flags & EGG_TB_MODEL_NAME_USED) != 0))
+ {
+ egg_toolbars_model_delete_item (model, name);
+ }
+ g_free (name);
+ }
+
+ g_list_free (selection);
+ }
+}
+
+static void
cmd_delete (GtkAction *action,
EphyBookmarksEditor *editor)
{
@@ -1146,15 +1241,22 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
gboolean key_normal = FALSE;
gboolean cut, copy, paste, select_all;
gboolean mutable = TRUE;
+ gboolean showtoolbar = FALSE;
+ gboolean ontoolbar = FALSE;
+ EggToolbarsModel *model;
GtkActionGroup *action_group;
GtkAction *action;
GList *selected;
GtkWidget *focus_widget;
int num_bmk_selected;
+ char *name;
LOG ("Update menu sensitivity");
+ model = EGG_TOOLBARS_MODEL (ephy_shell_get_toolbars_model
+ (ephy_shell_get_default(), FALSE));
+
bmk_focus = ephy_node_view_is_target
(EPHY_NODE_VIEW (editor->priv->bm_view));
key_focus = ephy_node_view_is_target
@@ -1200,6 +1302,11 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
if (priority == -1) priority = EPHY_NODE_NORMAL_PRIORITY;
key_normal = (priority == EPHY_NODE_NORMAL_PRIORITY);
+ name = ephy_topic_action_name (node);
+ ontoolbar = ((egg_toolbars_model_get_name_flags (model, name)
+ & EGG_TB_MODEL_NAME_USED) != 0);
+ g_free (name);
+
g_list_free (selected);
}
@@ -1213,6 +1320,11 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
id = ephy_node_get_id (node);
mutable = !ephy_node_get_property_boolean (node, EPHY_NODE_BMK_PROP_IMMUTABLE);
+
+ name = ephy_bookmark_action_name (node);
+ ontoolbar = ((egg_toolbars_model_get_name_flags (model, name)
+ & EGG_TB_MODEL_NAME_USED) != 0);
+ g_free (name);
g_list_free (selected);
}
@@ -1240,6 +1352,8 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
delete = (bmk_focus && bmk_selection && mutable) ||
(key_selection && key_focus && key_normal);
properties = bmk_focus && single_bmk_selected && mutable;
+ showtoolbar = (bmk_focus && bmk_selection) ||
+ (key_focus && key_selection);
action_group = editor->priv->action_group;
action = gtk_action_group_get_action (action_group, "OpenInWindow");
@@ -1263,6 +1377,11 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor)
gtk_action_set_sensitive (action, paste);
action = gtk_action_group_get_action (action_group, "SelectAll");
g_object_set (action, "sensitive", select_all, NULL);
+ action = gtk_action_group_get_action (action_group, "ShowOnToolbar");
+ gtk_action_set_sensitive (action, showtoolbar);
+ g_signal_handlers_block_by_func (action, cmd_toolbar, editor);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), ontoolbar);
+ g_signal_handlers_unblock_by_func (action, cmd_toolbar, editor);
}
static gboolean
@@ -1609,6 +1728,8 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
gtk_action_group_set_translation_domain (action_group, NULL);
gtk_action_group_add_actions (action_group, ephy_bookmark_popup_entries,
G_N_ELEMENTS (ephy_bookmark_popup_entries), editor);
+ gtk_action_group_add_toggle_actions (action_group, ephy_bookmark_toggle_entries,
+ G_N_ELEMENTS (ephy_bookmark_toggle_entries), editor);
details_value = get_details_value (editor);
gtk_action_group_add_radio_actions (action_group,