aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c45
-rw-r--r--src/bookmarks/ephy-bookmarks.c6
-rw-r--r--src/bookmarks/ephy-bookmarks.h3
-rw-r--r--src/bookmarks/ephy-node-view.c96
-rw-r--r--src/bookmarks/ephy-node-view.h5
5 files changed, 149 insertions, 6 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 7383b2477..8a0a94f0f 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -67,6 +67,10 @@ static void cmd_remove_topic (EggAction *action,
EphyBookmarksEditor *editor);
static void cmd_rename_bookmark (EggAction *action,
EphyBookmarksEditor *editor);
+static void cmd_rename_topic (EggAction *action,
+ EphyBookmarksEditor *editor);
+static void cmd_close (EggAction *action,
+ EphyBookmarksEditor *editor);
struct EphyBookmarksEditorPrivate
{
@@ -98,6 +102,7 @@ static GObjectClass *parent_class = NULL;
static EggActionGroupEntry ephy_bookmark_popup_entries [] = {
/* Toplevel */
{ "File", N_("_File"), NULL, NULL, NULL, NULL, NULL },
+ { "Edit", N_("_Edit"), NULL, NULL, NULL, NULL, NULL },
{ "FakeToplevel", (""), NULL, NULL, NULL, NULL, NULL },
{ "NewTopic", N_("_New Topic"), GTK_STOCK_NEW, NULL,
@@ -112,6 +117,9 @@ static EggActionGroupEntry ephy_bookmark_popup_entries [] = {
{ "RenameBookmark", N_("_Rename Bookmark"), NULL, NULL,
NULL, G_CALLBACK (cmd_rename_bookmark), NULL },
+ { "RenameTopic", N_("R_ename Topic"), NULL, NULL,
+ NULL, G_CALLBACK (cmd_rename_topic), NULL },
+
{ "RemoveBookmark", N_("_Delete Bookmark"), GTK_STOCK_DELETE, NULL,
NULL, G_CALLBACK (cmd_remove_bookmarks), NULL },
@@ -120,6 +128,9 @@ static EggActionGroupEntry ephy_bookmark_popup_entries [] = {
{ "Properties", N_("_Properties"), GTK_STOCK_PROPERTIES, NULL,
NULL, G_CALLBACK (cmd_bookmark_properties), NULL },
+
+ { "Close", N_("_Close"), GTK_STOCK_CLOSE, NULL,
+ NULL, G_CALLBACK (cmd_close), NULL },
};
static guint ephy_bookmark_popup_n_entries = G_N_ELEMENTS (ephy_bookmark_popup_entries);
@@ -127,18 +138,48 @@ static void
cmd_add_topic (EggAction *action,
EphyBookmarksEditor *editor)
{
+ EphyNode *node;
+
+ node = ephy_bookmarks_add_keyword (editor->priv->bookmarks,
+ _("Type a topic"));
+ ephy_node_view_select_node (editor->priv->key_view, node);
+ ephy_node_view_edit (editor->priv->key_view);
}
static void
cmd_remove_topic (EggAction *action,
EphyBookmarksEditor *editor)
{
+ GList *selection;
+
+ selection = ephy_node_view_get_selection (editor->priv->key_view);
+ if (selection)
+ {
+ EphyNode *node = EPHY_NODE (selection->data);
+ ephy_bookmarks_remove_keyword (editor->priv->bookmarks, node);
+ g_list_free (selection);
+ }
+}
+
+static void
+cmd_close (EggAction *action,
+ EphyBookmarksEditor *editor)
+{
+ gtk_widget_hide (GTK_WIDGET (editor));
+}
+
+static void
+cmd_rename_topic (EggAction *action,
+ EphyBookmarksEditor *editor)
+{
+ ephy_node_view_edit (editor->priv->key_view);
}
static void
cmd_rename_bookmark (EggAction *action,
EphyBookmarksEditor *editor)
{
+ ephy_node_view_edit (editor->priv->bm_view);
}
static GtkWidget *
@@ -571,7 +612,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
ephy_node_view_enable_drag_source (key_view);
ephy_node_view_set_browse_mode (key_view);
ephy_node_view_add_column (key_view, _("Topics"),
- EPHY_TREE_MODEL_NODE_COL_KEYWORD, TRUE);
+ EPHY_TREE_MODEL_NODE_COL_KEYWORD, TRUE, TRUE);
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (key_view), FALSE, TRUE, 0);
gtk_widget_set_size_request (GTK_WIDGET (key_view), 130, -1);
gtk_widget_show (GTK_WIDGET (key_view));
@@ -599,7 +640,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
ephy_node_view_enable_drag_source (bm_view);
ephy_node_view_add_icon_column (bm_view, EPHY_TREE_MODEL_NODE_COL_ICON);
ephy_node_view_add_column (bm_view, _("Bookmarks"),
- EPHY_TREE_MODEL_NODE_COL_BOOKMARK, TRUE);
+ EPHY_TREE_MODEL_NODE_COL_BOOKMARK, TRUE, TRUE);
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (bm_view), TRUE, TRUE, 0);
gtk_widget_show (GTK_WIDGET (bm_view));
editor->priv->bm_view = bm_view;
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 7baaf7d8f..cb6a7edc2 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -770,6 +770,12 @@ ephy_bookmarks_add_keyword (EphyBookmarks *eb,
return key;
}
+void ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
+ EphyNode *keyword)
+{
+ ephy_node_remove_child (eb->priv->keywords, keyword);
+}
+
EphyNode *
ephy_bookmarks_find_keyword (EphyBookmarks *eb,
const char *name,
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index fa3232565..f8db9b961 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -89,6 +89,9 @@ EphyNode *ephy_bookmarks_find_keyword (EphyBookmarks *eb,
const char *name,
gboolean partial_match);
+void ephy_bookmarks_remove_keyword (EphyBookmarks *eb,
+ EphyNode *keyword);
+
gboolean ephy_bookmarks_has_keyword (EphyBookmarks *eb,
EphyNode *keyword,
EphyNode *bookmark);
diff --git a/src/bookmarks/ephy-node-view.c b/src/bookmarks/ephy-node-view.c
index 2c97e4f33..e91f7f912 100644
--- a/src/bookmarks/ephy-node-view.c
+++ b/src/bookmarks/ephy-node-view.c
@@ -25,6 +25,7 @@
#include <libgnome/gnome-i18n.h>
#include "eggtreemodelfilter.h"
+#include "ephy-bookmarks.h"
#include "ephy-tree-model-node.h"
#include "ephy-node-view.h"
#include "ephy-tree-model-sort.h"
@@ -51,6 +52,9 @@ struct EphyNodeViewPrivate
EphyTreeModelNode *nodemodel;
GtkTreeModel *filtermodel;
GtkTreeModel *sortmodel;
+ GtkCellRenderer *editable_renderer;
+ GtkTreeViewColumn *editable_column;
+ EphyTreeModelNodeColumn editable_node_column;
EphyNodeFilter *filter;
@@ -493,18 +497,75 @@ set_sort_column_id (EphyNodeView *view)
return FALSE;
}
-
+
+static void
+cell_renderer_edited (GtkCellRendererText *cell,
+ const char *path_str,
+ const char *new_text,
+ EphyNodeView *view)
+{
+ GValue value = { 0, };
+ GtkTreePath *path;
+ GtkTreeIter iter, iter2;
+ EphyNode *node;
+
+ g_object_set (G_OBJECT (view->priv->editable_renderer),
+ "editable", FALSE,
+ NULL);
+
+ path = gtk_tree_path_new_from_string (path_str);
+ gtk_tree_model_get_iter (view->priv->sortmodel, &iter, path);
+ gtk_tree_model_sort_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_SORT (view->priv->sortmodel), &iter2, &iter);
+ egg_tree_model_filter_convert_iter_to_child_iter
+ (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2);
+ node = ephy_tree_model_node_node_from_iter (view->priv->nodemodel, &iter);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, new_text);
+
+ switch (view->priv->editable_node_column)
+ {
+ case EPHY_TREE_MODEL_NODE_COL_BOOKMARK:
+ ephy_node_set_property (node,
+ EPHY_NODE_BMK_PROP_TITLE,
+ &value);
+ break;
+ case EPHY_TREE_MODEL_NODE_COL_KEYWORD:
+ ephy_node_set_property (node,
+ EPHY_NODE_KEYWORD_PROP_NAME,
+ &value);
+ break;
+ default:
+ break;
+ }
+
+ g_value_unset (&value);
+}
+
void
ephy_node_view_add_column (EphyNodeView *view,
const char *title,
EphyTreeModelNodeColumn column,
- gboolean sortable)
+ gboolean sortable,
+ gboolean editable)
{
GtkTreeViewColumn *gcolumn;
GtkCellRenderer *renderer;
+ g_return_if_fail (!editable || view->priv->editable_renderer == NULL);
+
gcolumn = (GtkTreeViewColumn *) gtk_tree_view_column_new ();
renderer = gtk_cell_renderer_text_new ();
+
+ if (editable)
+ {
+ view->priv->editable_renderer = renderer;
+ view->priv->editable_column = gcolumn;
+ view->priv->editable_node_column = column;
+ g_signal_connect (renderer, "edited", G_CALLBACK (cell_renderer_edited), view);
+ }
+
gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE);
gtk_tree_view_column_set_attributes (gcolumn, renderer,
"text", column,
@@ -545,6 +606,7 @@ static void
ephy_node_view_init (EphyNodeView *view)
{
view->priv = g_new0 (EphyNodeViewPrivate, 1);
+ view->priv->editable_renderer = NULL;
}
static void
@@ -655,10 +717,38 @@ ephy_node_view_enable_drag_source (EphyNodeView *view)
ephy_dnd_enable_model_drag_source (GTK_WIDGET (view->priv->treeview));
}
-void
+void
ephy_node_view_set_hinted (EphyNodeView *view, gboolean hinted)
{
g_return_if_fail (view != NULL);
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view->priv->treeview), hinted);
}
+
+void
+ephy_node_view_edit (EphyNodeView *view)
+{
+ GtkTreeSelection *selection;
+ GList *rows;
+ GtkTreeModel *model;
+
+ g_return_if_fail (view->priv->editable_renderer != NULL);
+
+ selection = gtk_tree_view_get_selection
+ (GTK_TREE_VIEW (view->priv->treeview));
+ rows = gtk_tree_selection_get_selected_rows (selection, &model);
+ if (rows == NULL) return;
+
+ g_object_set (G_OBJECT (view->priv->editable_renderer),
+ "editable", TRUE,
+ NULL);
+
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view->priv->treeview),
+ (GtkTreePath *)rows->data,
+ view->priv->editable_column,
+ TRUE);
+
+ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (rows);
+}
+
diff --git a/src/bookmarks/ephy-node-view.h b/src/bookmarks/ephy-node-view.h
index 89a84f72c..9055b914e 100644
--- a/src/bookmarks/ephy-node-view.h
+++ b/src/bookmarks/ephy-node-view.h
@@ -64,7 +64,8 @@ void ephy_node_view_enable_dnd (EphyNodeView *view);
void ephy_node_view_add_column (EphyNodeView *view,
const char *title,
EphyTreeModelNodeColumn column,
- gboolean sortable);
+ gboolean sortable,
+ gboolean editable);
void ephy_node_view_add_icon_column (EphyNodeView *view,
EphyTreeModelNodeColumn column);
@@ -83,6 +84,8 @@ void ephy_node_view_enable_drag_source (EphyNodeView *view);
void ephy_node_view_set_hinted (EphyNodeView *view,
gboolean hinted);
+void ephy_node_view_edit (EphyNodeView *view);
+
G_END_DECLS
#endif /* EPHY_NODE_VIEW_H */