aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-node-view.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-03-23 20:30:41 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-03-23 20:30:41 +0800
commitc325934e436073606e8ff5c725f1b068618d3797 (patch)
tree7eb87588f06c0de47747b69133b8038fc677a20e /src/bookmarks/ephy-node-view.c
parentf360f793d3c18a3d0e9870f05d0a9787066f7046 (diff)
downloadgsoc2013-epiphany-c325934e436073606e8ff5c725f1b068618d3797.tar
gsoc2013-epiphany-c325934e436073606e8ff5c725f1b068618d3797.tar.gz
gsoc2013-epiphany-c325934e436073606e8ff5c725f1b068618d3797.tar.bz2
gsoc2013-epiphany-c325934e436073606e8ff5c725f1b068618d3797.tar.lz
gsoc2013-epiphany-c325934e436073606e8ff5c725f1b068618d3797.tar.xz
gsoc2013-epiphany-c325934e436073606e8ff5c725f1b068618d3797.tar.zst
gsoc2013-epiphany-c325934e436073606e8ff5c725f1b068618d3797.zip
Complete implementation of the editor functionalities.
2003-03-23 Marco Pesenti Gritti <marco@it.gnome.org> * TODO: * data/ui/epiphany-bookmark-editor-ui.xml.in: * src/bookmarks/ephy-bookmarks-editor.c: (cmd_add_topic), (cmd_remove_topic), (cmd_close), (cmd_rename_topic), (cmd_rename_bookmark), (ephy_bookmarks_editor_construct): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_remove_keyword): * src/bookmarks/ephy-bookmarks.h: * src/bookmarks/ephy-node-view.c: (cell_renderer_edited), (ephy_node_view_add_column), (ephy_node_view_init), (ephy_node_view_edit): * src/bookmarks/ephy-node-view.h: Complete implementation of the editor functionalities. [Still work to do ... I updated the TODO with some of the higher priority things. If you want to work on any of them let me know ... (to avoid conflicts, I plan to keep working on this stuff in the next days).]
Diffstat (limited to 'src/bookmarks/ephy-node-view.c')
-rw-r--r--src/bookmarks/ephy-node-view.c96
1 files changed, 93 insertions, 3 deletions
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);
+}
+