aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c42
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c119
-rw-r--r--src/bookmarks/ephy-bookmarks.c46
-rw-r--r--src/bookmarks/ephy-bookmarks.h4
-rw-r--r--src/bookmarks/ephy-new-bookmark.c2
-rw-r--r--src/bookmarks/ephy-topics-selector.c16
-rw-r--r--src/bookmarks/ephy-topics-selector.h3
7 files changed, 141 insertions, 91 deletions
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index 9da4dffa8..6654ea25a 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -200,10 +200,39 @@ bookmark_properties_response_cb (GtkDialog *dialog,
}
static void
+update_entry (EphyBookmarkProperties *props, GtkWidget *entry, guint prop)
+{
+ GValue value = { 0, };
+ char *text;
+
+ text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, text);
+ ephy_node_set_property (props->priv->bookmark,
+ prop,
+ &value);
+ g_value_unset (&value);
+ g_free (text);
+}
+
+static void
+title_entry_changed_cb (GtkWidget *entry, EphyBookmarkProperties *props)
+{
+ update_entry (props, entry, EPHY_NODE_BMK_PROP_TITLE);
+}
+
+static void
+location_entry_changed_cb (GtkWidget *entry, EphyBookmarkProperties *props)
+{
+ update_entry (props, entry, EPHY_NODE_BMK_PROP_LOCATION);
+}
+
+static void
build_ui (EphyBookmarkProperties *editor)
{
GtkWidget *table, *label, *entry, *topics_selector;
char *str;
+ const char *tmp;
g_signal_connect (G_OBJECT (editor),
"response",
@@ -229,6 +258,11 @@ build_ui (EphyBookmarkProperties *editor)
g_free (str);
gtk_widget_show (label);
entry = gtk_entry_new ();
+ tmp = ephy_node_get_property_string (editor->priv->bookmark,
+ EPHY_NODE_BMK_PROP_TITLE);
+ gtk_entry_set_text (GTK_ENTRY (entry), tmp);
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (title_entry_changed_cb), editor);
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
editor->priv->title_entry = entry;
gtk_widget_set_size_request (entry, 200, -1);
@@ -243,6 +277,11 @@ build_ui (EphyBookmarkProperties *editor)
g_free (str);
gtk_widget_show (label);
entry = gtk_entry_new ();
+ tmp = ephy_node_get_property_string (editor->priv->bookmark,
+ EPHY_NODE_BMK_PROP_LOCATION);
+ gtk_entry_set_text (GTK_ENTRY (entry), tmp);
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (location_entry_changed_cb), editor);
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
editor->priv->location_entry = entry;
gtk_widget_show (entry);
@@ -255,7 +294,8 @@ build_ui (EphyBookmarkProperties *editor)
gtk_label_set_markup (GTK_LABEL (label), str);
g_free (str);
gtk_widget_show (label);
- topics_selector = ephy_topics_selector_new (editor->priv->bookmarks);
+ topics_selector = ephy_topics_selector_new (editor->priv->bookmarks,
+ editor->priv->bookmark);
gtk_widget_show (topics_selector);
editor->priv->topics_selector = topics_selector;
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 1037ada63..bb27fa619 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -53,14 +53,20 @@ static void ephy_bookmarks_editor_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
-static void popup_cmd_open_bookmarks_in_tabs (EggAction *action,
- EphyBookmarksEditor *editor);
-static void popup_cmd_open_bookmarks_in_browser (EggAction *action,
- EphyBookmarksEditor *editor);
-static void popup_cmd_remove_bookmarks (EggAction *action,
- EphyBookmarksEditor *editor);
-static void popup_cmd_bookmark_properties (EggAction *action,
- EphyBookmarksEditor *editor);
+static void cmd_open_bookmarks_in_tabs (EggAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_open_bookmarks_in_browser (EggAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_remove_bookmarks (EggAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_bookmark_properties (EggAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_add_topic (EggAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_remove_topic (EggAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_rename_bookmark (EggAction *action,
+ EphyBookmarksEditor *editor);
struct EphyBookmarksEditorPrivate
{
@@ -69,6 +75,7 @@ struct EphyBookmarksEditorPrivate
EphyNodeView *key_view;
EphyNodeFilter *bookmarks_filter;
GtkWidget *search_entry;
+ GtkWidget *menu_dock;
EggMenuMerge *ui_merge;
EggActionGroup *action_group;
};
@@ -89,25 +96,53 @@ static GObjectClass *parent_class = NULL;
static EggActionGroupEntry ephy_bookmark_popup_entries [] = {
/* Toplevel */
+ { "File", N_("_File"), NULL, NULL, NULL, NULL, NULL },
{ "FakeToplevel", (""), NULL, NULL, NULL, NULL, NULL },
- { "OpenInWindow", N_("Open In _New Window"), GTK_STOCK_OPEN, NULL,
- NULL, G_CALLBACK (popup_cmd_open_bookmarks_in_browser), NULL },
+ { "NewTopic", N_("_New Topic"), GTK_STOCK_NEW, NULL,
+ NULL, G_CALLBACK (cmd_add_topic), NULL },
+
+ { "OpenInWindow", N_("_Open In New Window"), GTK_STOCK_OPEN, NULL,
+ NULL, G_CALLBACK (cmd_open_bookmarks_in_browser), NULL },
{ "OpenInTab", N_("Open In New _Tab"), NULL, NULL,
- NULL, G_CALLBACK (popup_cmd_open_bookmarks_in_tabs), NULL },
+ NULL, G_CALLBACK (cmd_open_bookmarks_in_tabs), NULL },
+
+ { "RenameBookmark", N_("_Rename Bookmark"), NULL, NULL,
+ NULL, G_CALLBACK (cmd_rename_bookmark), NULL },
+
+ { "RemoveBookmark", N_("_Delete Bookmark"), GTK_STOCK_DELETE, NULL,
+ NULL, G_CALLBACK (cmd_remove_bookmarks), NULL },
- { "Remove", N_("_Remove"), GTK_STOCK_REMOVE, NULL,
- NULL, G_CALLBACK (popup_cmd_remove_bookmarks), NULL },
+ { "RemoveTopic", N_("D_elete Topic"), NULL, NULL,
+ NULL, G_CALLBACK (cmd_remove_topic), NULL },
{ "Properties", N_("_Properties"), GTK_STOCK_PROPERTIES, NULL,
- NULL, G_CALLBACK (popup_cmd_bookmark_properties), NULL },
+ NULL, G_CALLBACK (cmd_bookmark_properties), NULL },
};
static guint ephy_bookmark_popup_n_entries = G_N_ELEMENTS (ephy_bookmark_popup_entries);
static void
-popup_cmd_open_bookmarks_in_tabs (EggAction *action,
- EphyBookmarksEditor *editor)
+cmd_add_topic (EggAction *action,
+ EphyBookmarksEditor *editor)
+{
+}
+
+static void
+cmd_remove_topic (EggAction *action,
+ EphyBookmarksEditor *editor)
+{
+}
+
+static void
+cmd_rename_bookmark (EggAction *action,
+ EphyBookmarksEditor *editor)
+{
+}
+
+static void
+cmd_open_bookmarks_in_tabs (EggAction *action,
+ EphyBookmarksEditor *editor)
{
EphyWindow *window;
GList *selection;
@@ -135,8 +170,8 @@ popup_cmd_open_bookmarks_in_tabs (EggAction *action,
}
static void
-popup_cmd_open_bookmarks_in_browser (EggAction *action,
- EphyBookmarksEditor *editor)
+cmd_open_bookmarks_in_browser (EggAction *action,
+ EphyBookmarksEditor *editor)
{
EphyWindow *window;
GList *selection;
@@ -164,15 +199,15 @@ popup_cmd_open_bookmarks_in_browser (EggAction *action,
}
static void
-popup_cmd_remove_bookmarks (EggAction *action,
- EphyBookmarksEditor *editor)
+cmd_remove_bookmarks (EggAction *action,
+ EphyBookmarksEditor *editor)
{
ephy_node_view_remove (editor->priv->bm_view);
}
static void
-popup_cmd_bookmark_properties (EggAction *action,
- EphyBookmarksEditor *editor)
+cmd_bookmark_properties (EggAction *action,
+ EphyBookmarksEditor *editor)
{
GtkWidget *dialog;
GList *selection;
@@ -355,28 +390,6 @@ ephy_bookmarks_editor_node_activated_cb (GtkWidget *view,
}
static void
-ephy_bookmarks_editor_go_to_location (EphyBookmarksEditor *editor)
-{
- GList *selection;
- const char *location;
- GtkWindow *window;
-
- selection = ephy_node_view_get_selection (editor->priv->bm_view);
- if (selection != NULL)
- {
- EphyNode *bm = EPHY_NODE (selection->data);
-
- location = ephy_node_get_property_string (bm,
- EPHY_NODE_BMK_PROP_LOCATION);
- g_return_if_fail (location != NULL);
- window = gtk_window_get_transient_for (GTK_WINDOW (editor));
- g_return_if_fail (IS_EPHY_WINDOW (window));
- ephy_window_load_url (EPHY_WINDOW (window), location);
- g_list_free (selection);
- }
-}
-
-static void
bookmarks_filter (EphyBookmarksEditor *editor,
EphyNode *keyword)
{
@@ -465,6 +478,14 @@ build_search_box (EphyBookmarksEditor *editor)
}
static void
+add_widget (EggMenuMerge *merge, GtkWidget *widget, EphyBookmarksEditor *editor)
+{
+ gtk_box_pack_start (GTK_BOX (editor->priv->menu_dock),
+ widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+}
+
+static void
ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
{
GtkWidget *hbox, *vbox;
@@ -482,7 +503,12 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
ephy_bookmark_popup_entries[i].user_data = editor;
}
+ editor->priv->menu_dock = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (editor->priv->menu_dock);
+ gtk_container_add (GTK_CONTAINER (editor), editor->priv->menu_dock);
+
ui_merge = egg_menu_merge_new ();
+ g_signal_connect (ui_merge, "add_widget", G_CALLBACK (add_widget), editor);
action_group = egg_action_group_new ("PopupActions");
egg_action_group_add_actions (action_group, ephy_bookmark_popup_entries,
ephy_bookmark_popup_n_entries);
@@ -491,17 +517,16 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
egg_menu_merge_add_ui_from_file (ui_merge,
ephy_file ("epiphany-bookmark-editor-ui.xml"),
NULL);
+ egg_menu_merge_ensure_update (ui_merge);
editor->priv->ui_merge = ui_merge;
editor->priv->action_group = action_group;
gtk_window_set_title (GTK_WINDOW (editor), _("Bookmarks"));
-
- gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
gtk_widget_set_size_request (GTK_WIDGET (editor), 500, 450);
hbox = gtk_hbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
- gtk_container_add (GTK_CONTAINER (editor), hbox);
+ gtk_container_add (GTK_CONTAINER (editor->priv->menu_dock), hbox);
gtk_widget_show (hbox);
g_assert (editor->priv->bookmarks);
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 81a06e738..7baaf7d8f 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -163,42 +163,6 @@ ephy_bookmarks_class_init (EphyBookmarksClass *klass)
object_class->finalize = ephy_bookmarks_finalize;
}
-static gboolean
-ephy_bookmarks_clean_empty_keywords (EphyBookmarks *eb)
-{
- GPtrArray *children;
- int i;
- GList *l = NULL, *tmp;
-
- children = ephy_node_get_children (eb->priv->keywords);
- ephy_node_thaw (eb->priv->keywords);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
-
- kid = g_ptr_array_index (children, i);
-
- if (ephy_node_get_n_children (kid) == 0)
- {
- l = g_list_append (l, kid);
- }
- }
-
- if (l == NULL) return FALSE;
-
- for (tmp = l; tmp != NULL; tmp = tmp->next)
- {
- EphyNode *node = EPHY_NODE (tmp->data);
- LOG ("Remove empty keyword: %s",
- ephy_node_get_property_string (node,
- EPHY_NODE_KEYWORD_PROP_NAME))
- g_object_unref (node);
- }
- g_list_free (l);
-
- return FALSE;
-}
-
static void
ephy_bookmarks_load (EphyBookmarks *eb)
{
@@ -439,7 +403,6 @@ bookmarks_removed_cb (EphyNode *node,
EphyBookmarks *eb)
{
ephy_bookmarks_emit_data_changed (eb);
- g_idle_add ((GSourceFunc)ephy_bookmarks_clean_empty_keywords, eb);
}
static void
@@ -854,6 +817,14 @@ ephy_bookmarks_find_keyword (EphyBookmarks *eb,
return node;
}
+gboolean
+ephy_bookmarks_has_keyword (EphyBookmarks *eb,
+ EphyNode *keyword,
+ EphyNode *bookmark)
+{
+ return ephy_node_has_child (keyword, bookmark);
+}
+
void
ephy_bookmarks_set_keyword (EphyBookmarks *eb,
EphyNode *keyword,
@@ -872,7 +843,6 @@ ephy_bookmarks_unset_keyword (EphyBookmarks *eb,
if (!ephy_node_has_child (keyword, bookmark)) return;
ephy_node_remove_child (keyword, bookmark);
- ephy_bookmarks_clean_empty_keywords (eb);
}
EphyNode *
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index 4811c5577..fa3232565 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -89,6 +89,10 @@ EphyNode *ephy_bookmarks_find_keyword (EphyBookmarks *eb,
const char *name,
gboolean partial_match);
+gboolean ephy_bookmarks_has_keyword (EphyBookmarks *eb,
+ EphyNode *keyword,
+ EphyNode *bookmark);
+
void ephy_bookmarks_set_keyword (EphyBookmarks *eb,
EphyNode *keyword,
EphyNode *bookmark);
diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c
index bd14eb974..7edf24d6c 100644
--- a/src/bookmarks/ephy-new-bookmark.c
+++ b/src/bookmarks/ephy-new-bookmark.c
@@ -213,7 +213,7 @@ build_editing_table (EphyNewBookmark *editor)
gtk_label_set_markup (GTK_LABEL (label), str);
g_free (str);
gtk_widget_show (label);
- topics_selector = ephy_topics_selector_new (editor->priv->bookmarks);
+ topics_selector = ephy_topics_selector_new (editor->priv->bookmarks, NULL);
gtk_widget_show (topics_selector);
editor->priv->topics_selector = topics_selector;
diff --git a/src/bookmarks/ephy-topics-selector.c b/src/bookmarks/ephy-topics-selector.c
index f0c64b59d..9ebccb97e 100644
--- a/src/bookmarks/ephy-topics-selector.c
+++ b/src/bookmarks/ephy-topics-selector.c
@@ -201,7 +201,7 @@ fill_model (EphyTopicsSelector *editor)
{
EphyNode *kid;
const char *name;
- gboolean has_keyword;
+ gboolean has_keyword = FALSE;
gboolean real_topic;
GtkTreeIter iter;
@@ -209,7 +209,14 @@ fill_model (EphyTopicsSelector *editor)
name = ephy_node_get_property_string
(kid, EPHY_NODE_KEYWORD_PROP_NAME);
- has_keyword = FALSE;
+
+ if (editor->priv->bookmark != NULL)
+ {
+ has_keyword = ephy_bookmarks_has_keyword
+ (editor->priv->bookmarks, kid,
+ editor->priv->bookmark);
+ }
+
real_topic = !ephy_node_get_property_boolean
(kid, EPHY_NODE_KEYWORD_PROP_ALL_PRIORITY);
@@ -242,6 +249,7 @@ topic_toggled (GtkCellRendererToggle *cell,
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
COL_HAS_TOPIC, has_topic, -1);
+ ephy_topics_selector_apply (selector);
}
void
@@ -328,7 +336,8 @@ ephy_topics_selector_init (EphyTopicsSelector *editor)
}
GtkWidget *
-ephy_topics_selector_new (EphyBookmarks *bookmarks)
+ephy_topics_selector_new (EphyBookmarks *bookmarks,
+ EphyNode *bookmark)
{
EphyTopicsSelector *editor;
@@ -337,6 +346,7 @@ ephy_topics_selector_new (EphyBookmarks *bookmarks)
editor = EPHY_TOPICS_SELECTOR (g_object_new
(EPHY_TYPE_TOPIC_SELECTOR,
"bookmarks", bookmarks,
+ "bookmark", bookmark,
"hadjustment", NULL,
"vadjustment", NULL,
"hscrollbar_policy", GTK_POLICY_AUTOMATIC,
diff --git a/src/bookmarks/ephy-topics-selector.h b/src/bookmarks/ephy-topics-selector.h
index 5af7a65af..8adfa7523 100644
--- a/src/bookmarks/ephy-topics-selector.h
+++ b/src/bookmarks/ephy-topics-selector.h
@@ -50,7 +50,8 @@ typedef struct
GType ephy_topics_selector_get_type (void);
-GtkWidget *ephy_topics_selector_new (EphyBookmarks *bookmarks);
+GtkWidget *ephy_topics_selector_new (EphyBookmarks *bookmarks,
+ EphyNode *bookmark);
void ephy_topics_selector_set_bookmark (EphyTopicsSelector *selector,
EphyNode *bookmark);