diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-04-17 20:59:52 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-17 20:59:52 +0800 |
commit | 609b92cfa632385313d1d2421b516bdb41fdbf00 (patch) | |
tree | 09fc963d624f5723fc75551eb125b3d7d825f795 /src/bookmarks | |
parent | 9e94d5208ee7d936c6d3595435b9364fec5850dd (diff) | |
download | gsoc2013-epiphany-609b92cfa632385313d1d2421b516bdb41fdbf00.tar gsoc2013-epiphany-609b92cfa632385313d1d2421b516bdb41fdbf00.tar.gz gsoc2013-epiphany-609b92cfa632385313d1d2421b516bdb41fdbf00.tar.bz2 gsoc2013-epiphany-609b92cfa632385313d1d2421b516bdb41fdbf00.tar.lz gsoc2013-epiphany-609b92cfa632385313d1d2421b516bdb41fdbf00.tar.xz gsoc2013-epiphany-609b92cfa632385313d1d2421b516bdb41fdbf00.tar.zst gsoc2013-epiphany-609b92cfa632385313d1d2421b516bdb41fdbf00.zip |
New abstracted implementations. Nicer and will be useful for history
2003-04-17 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/widgets/Makefile.am:
* lib/widgets/ephy-node-view.c:
* lib/widgets/ephy-node-view.h:
* lib/widgets/ephy-tree-model-node.c:
* lib/widgets/ephy-tree-model-node.h:
New abstracted implementations.
Nicer and will be useful for
history dialog interface rehash to make
it more consistent with bookmarks (this
was the hard part of the work).
* src/bookmarks/Makefile.am:
* src/bookmarks/ephy-bookmarks-editor.c:
Use them.
* src/history-dialog.c:
Temp hack to keep the thing building until
I actually rewrite history dialog.
2
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/Makefile.am | 6 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 52 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 13 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.h | 7 | ||||
-rw-r--r-- | src/bookmarks/ephy-node-view.c | 1039 | ||||
-rw-r--r-- | src/bookmarks/ephy-node-view.h | 101 | ||||
-rw-r--r-- | src/bookmarks/ephy-topics-selector.c | 5 | ||||
-rw-r--r-- | src/bookmarks/ephy-tree-model-node.c | 752 | ||||
-rw-r--r-- | src/bookmarks/ephy-tree-model-node.h | 83 |
9 files changed, 51 insertions, 2007 deletions
diff --git a/src/bookmarks/Makefile.am b/src/bookmarks/Makefile.am index 563329335..8da75c248 100644 --- a/src/bookmarks/Makefile.am +++ b/src/bookmarks/Makefile.am @@ -32,11 +32,7 @@ libephybookmarks_la_SOURCES = \ ephy-keywords-entry.h \ ephy-new-bookmark.c \ ephy-new-bookmark.h \ - ephy-node-view.c \ - ephy-node-view.h \ ephy-topic-action.c \ ephy-topic-action.h \ ephy-topics-selector.c \ - ephy-topics-selector.h \ - ephy-tree-model-node.c \ - ephy-tree-model-node.h + ephy-topics-selector.h diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index b9782120f..25fd53357 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -44,6 +44,7 @@ #include "popup-commands.h" #include "ephy-state.h" #include "window-commands.h" +#include "ephy-debug.h" static GtkTargetEntry topic_drag_dest_types [] = { @@ -118,6 +119,7 @@ struct EphyBookmarksEditorPrivate GtkWidget *window; EggMenuMerge *ui_merge; EggActionGroup *action_group; + int priority_col; }; enum @@ -532,12 +534,12 @@ ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor) if (key_focus && selected) { EphyNode *node = EPHY_NODE (selected->data); - EphyBookmarksKeywordPriority priority;; + EphyNodeViewPriority priority;; priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY); - if (priority == -1) priority = EPHY_BOOKMARKS_KEYWORD_NORMAL_PRIORITY; - key_normal = (priority == EPHY_BOOKMARKS_KEYWORD_NORMAL_PRIORITY); + if (priority == -1) priority = EPHY_NODE_VIEW_NORMAL_PRIORITY; + key_normal = (priority == EPHY_NODE_VIEW_NORMAL_PRIORITY); g_list_free (selected); } @@ -828,6 +830,28 @@ menu_activate_cb (EphyNodeView *view, } static void +provide_favicon (EphyNode *node, GValue *value, gpointer user_data) +{ + EphyFaviconCache *cache; + const char *icon_location; + GdkPixbuf *pixbuf = NULL; + + cache = ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell)); + icon_location = ephy_node_get_property_string + (node, EPHY_NODE_BMK_PROP_ICON); + + LOG ("Get favicon for %s", icon_location ? icon_location : "None") + + if (icon_location) + { + pixbuf = ephy_favicon_cache_get (cache, icon_location); + } + + g_value_init (value, GDK_TYPE_PIXBUF); + g_value_set_object (value, pixbuf); +} + +static void ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) { GtkTreeSelection *selection; @@ -913,12 +937,15 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) n_topic_drag_types, -1); ephy_node_view_enable_drag_dest (EPHY_NODE_VIEW (key_view), - topic_drag_dest_types, - n_topic_drag_dest_types); + topic_drag_dest_types, + n_topic_drag_dest_types); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (key_view)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); ephy_node_view_add_column (EPHY_NODE_VIEW (key_view), _("Topics"), - EPHY_TREE_MODEL_NODE_COL_KEYWORD, TRUE, TRUE); + G_TYPE_STRING, + EPHY_NODE_KEYWORD_PROP_NAME, + EPHY_NODE_KEYWORD_PROP_PRIORITY, + TRUE, TRUE); gtk_container_add (GTK_CONTAINER (scrolled_window), key_view); gtk_widget_set_size_request (key_view, 130, -1); gtk_widget_show (key_view); @@ -932,13 +959,13 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) G_CALLBACK (keyword_node_selected_cb), editor); g_signal_connect (G_OBJECT (key_view), - "show_popup", - G_CALLBACK (keyword_node_show_popup_cb), - editor); - g_signal_connect (G_OBJECT (key_view), "node_dropped", G_CALLBACK (node_dropped_cb), editor); + g_signal_connect (G_OBJECT (key_view), + "show_popup", + G_CALLBACK (keyword_node_show_popup_cb), + editor); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), @@ -969,9 +996,10 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) bmk_drag_types, n_bmk_drag_types, EPHY_NODE_BMK_PROP_LOCATION); - ephy_node_view_add_icon_column (EPHY_NODE_VIEW (bm_view), EPHY_TREE_MODEL_NODE_COL_ICON); + ephy_node_view_add_icon_column (EPHY_NODE_VIEW (bm_view), provide_favicon); ephy_node_view_add_column (EPHY_NODE_VIEW (bm_view), _("Title"), - EPHY_TREE_MODEL_NODE_COL_BOOKMARK, TRUE, TRUE); + G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE, + -1, TRUE, TRUE); gtk_container_add (GTK_CONTAINER (scrolled_window), bm_view); gtk_widget_show (bm_view); editor->priv->bm_view = bm_view; diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 1962ae3be..955a7ef35 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -22,6 +22,7 @@ #include "ephy-history.h" #include "ephy-debug.h" #include "ephy-tree-model-node.h" +#include "ephy-node-view.h" #include <string.h> #include <libgnome/gnome-i18n.h> @@ -506,10 +507,10 @@ ephy_bookmarks_init (EphyBookmarks *eb) eb->priv->keywords = ephy_node_new_with_id (KEYWORDS_NODE_ID); ephy_node_ref (eb->priv->keywords); g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_BOOKMARKS_KEYWORD_ALL_PRIORITY); + g_value_set_int (&value, EPHY_NODE_VIEW_ALL_PRIORITY); ephy_node_set_property (eb->priv->bookmarks, - EPHY_NODE_KEYWORD_PROP_PRIORITY, - &value); + EPHY_NODE_KEYWORD_PROP_PRIORITY, + &value); g_value_unset (&value); g_signal_connect_object (G_OBJECT (eb->priv->keywords), "child_removed", @@ -530,7 +531,7 @@ ephy_bookmarks_init (EphyBookmarks *eb) &value); g_value_unset (&value); g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_BOOKMARKS_KEYWORD_SPECIAL_PRIORITY); + g_value_set_int (&value, EPHY_NODE_VIEW_SPECIAL_PRIORITY); ephy_node_set_property (eb->priv->favorites, EPHY_NODE_KEYWORD_PROP_PRIORITY, &value); @@ -547,7 +548,7 @@ ephy_bookmarks_init (EphyBookmarks *eb) &value); g_value_unset (&value); g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_BOOKMARKS_KEYWORD_SPECIAL_PRIORITY); + g_value_set_int (&value, EPHY_NODE_VIEW_SPECIAL_PRIORITY); ephy_node_set_property (eb->priv->notcategorized, EPHY_NODE_KEYWORD_PROP_PRIORITY, &value); @@ -856,7 +857,7 @@ ephy_bookmarks_add_keyword (EphyBookmarks *eb, g_value_unset (&value); g_value_init (&value, G_TYPE_INT); - g_value_set_int (&value, EPHY_BOOKMARKS_KEYWORD_NORMAL_PRIORITY); + g_value_set_int (&value, EPHY_NODE_VIEW_NORMAL_PRIORITY); ephy_node_set_property (key, EPHY_NODE_KEYWORD_PROP_PRIORITY, &value); g_value_unset (&value); diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h index 174c3c930..0ab70af8e 100644 --- a/src/bookmarks/ephy-bookmarks.h +++ b/src/bookmarks/ephy-bookmarks.h @@ -47,13 +47,6 @@ enum EPHY_NODE_KEYWORD_PROP_PRIORITY = 8 }; -typedef enum -{ - EPHY_BOOKMARKS_KEYWORD_ALL_PRIORITY, - EPHY_BOOKMARKS_KEYWORD_SPECIAL_PRIORITY, - EPHY_BOOKMARKS_KEYWORD_NORMAL_PRIORITY -} EphyBookmarksKeywordPriority; - struct EphyBookmarks { GObject parent; diff --git a/src/bookmarks/ephy-node-view.c b/src/bookmarks/ephy-node-view.c deleted file mode 100644 index cb96f72b1..000000000 --- a/src/bookmarks/ephy-node-view.c +++ /dev/null @@ -1,1039 +0,0 @@ -/* - * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include <gtk/gtktreeselection.h> -#include <gtk/gtktreeviewcolumn.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkcellrendererpixbuf.h> -#include <gtk/gtkwindow.h> -#include <gdk/gdkkeysyms.h> -#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" -#include "eggtreemultidnd.h" -#include "ephy-dnd.h" -#include "ephy-marshal.h" -#include "string.h" - -static void ephy_node_view_class_init (EphyNodeViewClass *klass); -static void ephy_node_view_init (EphyNodeView *view); -static void ephy_node_view_finalize (GObject *object); -static void ephy_node_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void ephy_node_view_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -struct EphyNodeViewPrivate -{ - EphyNode *root; - - EphyTreeModelNode *nodemodel; - GtkTreeModel *filtermodel; - GtkTreeModel *sortmodel; - GtkCellRenderer *editable_renderer; - GtkTreeViewColumn *editable_column; - EphyTreeModelNodeColumn editable_node_column; - - EphyNodeFilter *filter; - - EphyTreeModelNodeColumn default_sort_column_id; - - GtkTargetList *drag_targets; - - EphyNode *selected_node; - - gboolean editing; -}; - -enum -{ - NODE_ACTIVATED, - NODE_SELECTED, - NODE_DROPPED, - SHOW_POPUP, - LAST_SIGNAL -}; - -enum -{ - PROP_0, - PROP_ROOT, - PROP_FILTER -}; - -static EphyNodeView *target_view; - -static GObjectClass *parent_class = NULL; - -static guint ephy_node_view_signals[LAST_SIGNAL] = { 0 }; - -GType -ephy_node_view_get_type (void) -{ - static GType ephy_node_view_type = 0; - - if (ephy_node_view_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (EphyNodeViewClass), - NULL, - NULL, - (GClassInitFunc) ephy_node_view_class_init, - NULL, - NULL, - sizeof (EphyNodeView), - 0, - (GInstanceInitFunc) ephy_node_view_init - }; - - ephy_node_view_type = g_type_register_static (GTK_TYPE_TREE_VIEW, - "EphyNodeView", - &our_info, 0); - } - - return ephy_node_view_type; -} - -static void -ephy_node_view_class_init (EphyNodeViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = ephy_node_view_finalize; - - object_class->set_property = ephy_node_view_set_property; - object_class->get_property = ephy_node_view_get_property; - - g_object_class_install_property (object_class, - PROP_ROOT, - g_param_spec_object ("root", - "Root node", - "Root node", - EPHY_TYPE_NODE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, - PROP_FILTER, - g_param_spec_object ("filter", - "Filter object", - "Filter object", - EPHY_TYPE_NODE_FILTER, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - ephy_node_view_signals[NODE_ACTIVATED] = - g_signal_new ("node_activated", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyNodeViewClass, node_activated), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - EPHY_TYPE_NODE); - ephy_node_view_signals[NODE_SELECTED] = - g_signal_new ("node_selected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyNodeViewClass, node_selected), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - EPHY_TYPE_NODE); - ephy_node_view_signals[NODE_DROPPED] = - g_signal_new ("node_dropped", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyNodeViewClass, node_dropped), - NULL, NULL, - ephy_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - EPHY_TYPE_NODE, - G_TYPE_POINTER); - ephy_node_view_signals[SHOW_POPUP] = - g_signal_new ("show_popup", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyNodeViewClass, show_popup), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); -} - -static void -ephy_node_view_finalize (GObject *object) -{ - EphyNodeView *view; - - g_return_if_fail (object != NULL); - g_return_if_fail (EPHY_IS_NODE_VIEW (object)); - - view = EPHY_NODE_VIEW (object); - - g_return_if_fail (view->priv != NULL); - - g_object_unref (G_OBJECT (view->priv->sortmodel)); - g_object_unref (G_OBJECT (view->priv->filtermodel)); - g_object_unref (G_OBJECT (view->priv->nodemodel)); - - g_free (view->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -filter_changed_cb (EphyNodeFilter *filter, - EphyNodeView *view) -{ - GtkWidget *window; - - g_return_if_fail (EPHY_IS_NODE_VIEW (view)); - - window = gtk_widget_get_toplevel (GTK_WIDGET (view)); - - if (window != NULL && window->window != NULL) - { - /* nice busy cursor */ - GdkCursor *cursor; - - cursor = gdk_cursor_new (GDK_WATCH); - gdk_window_set_cursor (window->window, cursor); - gdk_cursor_unref (cursor); - - gdk_flush (); - - gdk_window_set_cursor (window->window, NULL); - - /* no flush: this will cause the cursor to be reset - * only when the UI is free again */ - } -} - -static void -ephy_node_view_selection_changed_cb (GtkTreeSelection *selection, - EphyNodeView *view) -{ - GList *list; - EphyNode *node = NULL; - - view->priv->selected_node = NULL; - - list = ephy_node_view_get_selection (view); - if (list) - { - node = EPHY_NODE (list->data); - } - g_list_free (list); - - g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_SELECTED], 0, node); -} - -static void -ephy_node_view_row_activated_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *column, - EphyNodeView *view) -{ - GtkTreeIter iter, iter2; - EphyNode *node; - - 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_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_ACTIVATED], 0, node); -} - -static EphyNode * -get_node_from_path (EphyNodeView *view, GtkTreePath *path) -{ - EphyNode *node; - GtkTreeIter iter, iter2; - - 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); - - return node; -} - -static gboolean -ephy_node_view_key_press_cb (GtkTreeView *treeview, - GdkEventKey *event, - EphyNodeView *view) -{ - if ((event->state & GDK_SHIFT_MASK) && - (event->keyval == GDK_F10)) - { - g_signal_emit (G_OBJECT (view), ephy_node_view_signals[SHOW_POPUP], 0); - - return TRUE; - } - - return FALSE; -} - -static gboolean -ephy_node_view_button_press_cb (GtkTreeView *treeview, - GdkEventButton *event, - EphyNodeView *view) -{ - GtkTreePath *path; - GtkTreeSelection *selection; - gboolean result = FALSE; - - if (event->button == 3) - { - if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview), - event->x, - event->y, - &path, - NULL, NULL, NULL)) - { - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); - if (gtk_tree_selection_path_is_selected (selection, path)) - { - /* We handle the event (so the view won't be - * changed by the user click) because the user - * clicked on an already selected element */ - result = TRUE; - } - else - { - view->priv->selected_node = get_node_from_path (view, path); - } - - target_view = view; - g_signal_emit (G_OBJECT (view), ephy_node_view_signals[SHOW_POPUP], 0); - target_view = NULL; - } - } - - return result; -} - -static void -ephy_node_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EphyNodeView *view = EPHY_NODE_VIEW (object); - - switch (prop_id) - { - case PROP_ROOT: - view->priv->root = g_value_get_object (value); - break; - case PROP_FILTER: - view->priv->filter = g_value_get_object (value); - - if (view->priv->filter != NULL) - { - g_signal_connect_object (G_OBJECT (view->priv->filter), - "changed", - G_CALLBACK (filter_changed_cb), - G_OBJECT (view), - 0); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -ephy_node_view_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EphyNodeView *view = EPHY_NODE_VIEW (object); - - switch (prop_id) - { - case PROP_ROOT: - g_value_set_object (value, view->priv->root); - break; - case PROP_FILTER: - g_value_set_object (value, view->priv->filter); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -node_from_sort_iter_cb (EphyTreeModelSort *model, - GtkTreeIter *iter, - void **node, - EphyNodeView *view) -{ - GtkTreeIter filter_iter, node_iter; - - gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model), - &filter_iter, iter); - egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), - &node_iter, &filter_iter); - *node = ephy_tree_model_node_node_from_iter - (EPHY_TREE_MODEL_NODE (view->priv->nodemodel), &node_iter); -} - -static void -ephy_node_view_construct (EphyNodeView *view) -{ - GtkTreeSelection *selection; - - - view->priv->nodemodel = ephy_tree_model_node_new (view->priv->root, - view->priv->filter); - view->priv->filtermodel = egg_tree_model_filter_new (GTK_TREE_MODEL (view->priv->nodemodel), - NULL); - egg_tree_model_filter_set_visible_column (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), - EPHY_TREE_MODEL_NODE_COL_VISIBLE); - view->priv->sortmodel = ephy_tree_model_sort_new (view->priv->filtermodel); - g_signal_connect_object (G_OBJECT (view->priv->sortmodel), - "node_from_iter", - G_CALLBACK (node_from_sort_iter_cb), - view, - 0); - gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->priv->sortmodel)); - g_signal_connect_object (G_OBJECT (view), - "button_press_event", - G_CALLBACK (ephy_node_view_button_press_cb), - view, - 0); - g_signal_connect_object (G_OBJECT (view), - "key_press_event", - G_CALLBACK (ephy_node_view_key_press_cb), - view, - 0); - g_signal_connect_object (G_OBJECT (view), - "row_activated", - G_CALLBACK (ephy_node_view_row_activated_cb), - view, - 0); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); - g_signal_connect_object (G_OBJECT (selection), - "changed", - G_CALLBACK (ephy_node_view_selection_changed_cb), - view, - 0); -} - -GtkWidget * -ephy_node_view_new (EphyNode *root, - EphyNodeFilter *filter) -{ - EphyNodeView *view; - - view = EPHY_NODE_VIEW (g_object_new (EPHY_TYPE_NODE_VIEW, - "filter", filter, - "root", root, - NULL)); - - ephy_node_view_construct (view); - - g_return_val_if_fail (view->priv != NULL, NULL); - - return GTK_WIDGET (view); -} - -static int -ephy_node_view_sort_func (GtkTreeModel *model, - GtkTreeIter *a, - GtkTreeIter *b, - gpointer user_data) -{ - GList *order; - GList *l; - int retval = 0; - - g_return_val_if_fail (model != NULL, 0); - g_return_val_if_fail (user_data != NULL, 0); - - order = (GList *) user_data; - - for (l = order; l != NULL && retval == 0; l = g_list_next (l)) - { - EphyTreeModelNodeColumn column = GPOINTER_TO_INT (l->data); - GType type = gtk_tree_model_get_column_type (model, column); - GValue a_value = {0, }; - GValue b_value = {0, }; - gchar *stra, *strb; - - gtk_tree_model_get_value (model, a, column, &a_value); - gtk_tree_model_get_value (model, b, column, &b_value); - - switch (G_TYPE_FUNDAMENTAL (type)) - { - case G_TYPE_STRING: - stra = g_utf8_casefold (g_value_get_string (&a_value), -1); - strb = g_utf8_casefold (g_value_get_string (&b_value), -1); - g_return_val_if_fail (stra != NULL || strb != NULL, 0); - - if (column == EPHY_TREE_MODEL_NODE_COL_BOOKMARK || - column == EPHY_TREE_MODEL_NODE_COL_KEYWORD) - retval = g_utf8_collate (stra, strb); - g_free (stra); - g_free (strb); - break; - case G_TYPE_INT: - if (g_value_get_int (&a_value) < g_value_get_int (&b_value)) - retval = -1; - else if (g_value_get_int (&a_value) == g_value_get_int (&b_value)) - retval = 0; - else - retval = 1; - break; - case G_TYPE_BOOLEAN: - if (g_value_get_boolean (&a_value) < g_value_get_boolean (&b_value)) - retval = -1; - else if (g_value_get_boolean (&a_value) == g_value_get_boolean (&b_value)) - retval = 0; - else - retval = 1; - break; - default: - g_warning ("Attempting to sort on invalid type %s\n", g_type_name (type)); - break; - } - - g_value_unset (&a_value); - g_value_unset (&b_value); - } - - return retval; - -} - -static gboolean -set_sort_column_id (EphyNodeView *view) -{ - EphyTreeModelNodeColumn priority = EPHY_TREE_MODEL_NODE_COL_PRIORITY; - GList *sort_order = NULL; - sort_order = g_list_append (sort_order, GINT_TO_POINTER (priority)); - sort_order = g_list_append (sort_order, GINT_TO_POINTER (view->priv->default_sort_column_id)); - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (view->priv->sortmodel), - GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, - GTK_SORT_ASCENDING); - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (view->priv->sortmodel), - ephy_node_view_sort_func, - sort_order, - (GtkDestroyNotify) g_list_free); - - 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; - - view->priv->editing = FALSE; - - 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); -} - -GtkTreeViewColumn * -ephy_node_view_add_column (EphyNodeView *view, - const char *title, - EphyTreeModelNodeColumn column, - gboolean sortable, - gboolean editable) -{ - GtkTreeViewColumn *gcolumn; - GtkCellRenderer *renderer; - - g_return_val_if_fail (!editable || view->priv->editable_renderer == NULL, 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, - "weight", EPHY_TREE_MODEL_NODE_COL_TITLE_WEIGHT, - NULL); - gtk_tree_view_column_set_sizing (gcolumn, - GTK_TREE_VIEW_COLUMN_AUTOSIZE); - gtk_tree_view_column_set_title (gcolumn, title); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), - gcolumn); - if (sortable) - { - view->priv->default_sort_column_id = column; - g_idle_add ((GSourceFunc) set_sort_column_id, view); - } - - return gcolumn; -} - -void -ephy_node_view_add_icon_column (EphyNodeView *view, - EphyTreeModelNodeColumn column) -{ - GtkTreeViewColumn *gcolumn; - GtkCellRenderer *renderer; - - gcolumn = (GtkTreeViewColumn *) gtk_tree_view_column_new (); - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (gcolumn, renderer, TRUE); - gtk_tree_view_column_set_attributes (gcolumn, renderer, - "pixbuf", column, - NULL); - gtk_tree_view_column_set_sizing (gcolumn, - GTK_TREE_VIEW_COLUMN_GROW_ONLY); - gtk_tree_view_append_column (GTK_TREE_VIEW (view), - gcolumn); -} - -static void -ephy_node_view_init (EphyNodeView *view) -{ - view->priv = g_new0 (EphyNodeViewPrivate, 1); - view->priv->editable_renderer = NULL; - view->priv->editing = TRUE; - view->priv->selected_node = NULL; -} - -static void -get_selection (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - void **data) -{ - GtkTreeModelSort *sortmodel = GTK_TREE_MODEL_SORT (model); - EggTreeModelFilter *filtermodel = EGG_TREE_MODEL_FILTER (sortmodel->child_model); - EphyTreeModelNode *nodemodel = EPHY_TREE_MODEL_NODE (filtermodel->child_model); - GList **list = (GList **) data; - GtkTreeIter *iter2 = gtk_tree_iter_copy (iter); - GtkTreeIter iter3; - GtkTreeIter iter4; - EphyNode *node; - - gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model), - &iter3, iter2); - egg_tree_model_filter_convert_iter_to_child_iter (filtermodel, &iter4, &iter3); - - node = ephy_tree_model_node_node_from_iter (nodemodel, &iter4); - - gtk_tree_iter_free (iter2); - - *list = g_list_prepend (*list, node); -} - -GList * -ephy_node_view_get_selection (EphyNodeView *view) -{ - GList *list = NULL; - GtkTreeSelection *selection; - - if (view->priv->selected_node) - { - list = g_list_append (list, view->priv->selected_node); - } - else - { - selection = gtk_tree_view_get_selection - (GTK_TREE_VIEW (view)); - - gtk_tree_selection_selected_foreach - (selection, - (GtkTreeSelectionForeachFunc) get_selection, - (void **) &list); - } - - return list; -} - -void -ephy_node_view_remove (EphyNodeView *view) -{ - GList *list; - EphyNode *node; - GtkTreeIter iter, iter2; - GtkTreePath *path; - - /* Before removing we try to select the next node in the view. If that is - * not available we try with the previous one, and if that is absent too, - * we do not select anything (which equals to select the topic "All") - */ - - list = ephy_node_view_get_selection (view); - g_return_if_fail (list != NULL); - node = EPHY_NODE ((g_list_last (list))->data); - ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->priv->nodemodel), - node, &iter); - egg_tree_model_filter_convert_child_iter_to_iter (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), - &iter2, &iter); - gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->priv->sortmodel), - &iter, &iter2); - iter2 = iter; - - if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->priv->sortmodel), &iter)) - { - path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->priv->sortmodel), &iter); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE); - gtk_tree_path_free (path); - } - else - { - path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->priv->sortmodel), &iter2); - if (gtk_tree_path_prev (path)) - { - gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE); - } - gtk_tree_path_free (path); - } - - for (; list != NULL; list = list->next) - { - ephy_node_unref (EPHY_NODE (list->data)); - } - - g_list_free (list); -} - -void -ephy_node_view_select_node (EphyNodeView *view, - EphyNode *node) -{ - GtkTreeIter iter, iter2; - GValue val = { 0, }; - gboolean visible; - GtkTreeSelection *selection; - GtkTreePath *path; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); - - g_return_if_fail (node != NULL); - - ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->priv->nodemodel), - node, &iter); - gtk_tree_model_get_value (GTK_TREE_MODEL (view->priv->nodemodel), &iter, - EPHY_TREE_MODEL_NODE_COL_VISIBLE, &val); - visible = g_value_get_boolean (&val); - g_value_unset (&val); - if (visible == FALSE) return; - - egg_tree_model_filter_convert_child_iter_to_iter (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), - &iter2, &iter); - gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->priv->sortmodel), - &iter, &iter2); - - path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->priv->sortmodel), &iter); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), - path, NULL, FALSE); - gtk_tree_path_free (path); -} - -static gboolean -drag_motion_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EphyNodeView *view) -{ - EphyNode *node; - GtkTreePath *path = NULL; - GtkTreeViewDropPosition pos; - gboolean res; - EphyBookmarksKeywordPriority priority; - - g_signal_stop_emission_by_name (widget, "drag_motion"); - - res = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos); - if (!res) return TRUE; - - node = get_node_from_path (view, path); - - priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY); - - if (priority != EPHY_BOOKMARKS_KEYWORD_ALL_PRIORITY && - priority != EPHY_BOOKMARKS_KEYWORD_SPECIAL_PRIORITY) - - { - gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (widget), path, - GTK_TREE_VIEW_DROP_INTO_OR_AFTER); - gdk_drag_status (context, context->suggested_action, time); - } - else - { - gdk_drag_status (context, 0, time); - } - - return TRUE; -} - -static gboolean -drag_drop_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EphyNodeView *view) -{ - GdkAtom target; - - g_signal_stop_emission_by_name (widget, "drag_drop"); - - target = gtk_drag_dest_find_target (widget, context, - view->priv->drag_targets); - - if (target != GDK_NONE) - { - gtk_drag_get_data (widget, context, target, time); - } - - return TRUE; -} - -static gboolean -drag_data_received_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection_data, - guint info, - guint time, - EphyNodeView *view) -{ - GtkTreePath *path = NULL; - GtkTreeViewDropPosition pos; - - g_signal_stop_emission_by_name (widget, "drag_data_received"); - - if (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - { - EphyNode *node; - GList *src_nodes; - - node = get_node_from_path (view, path); - - src_nodes = ephy_dnd_node_list_extract_nodes - (selection_data->data); - - g_signal_emit (G_OBJECT (view), - ephy_node_view_signals[NODE_DROPPED], 0, - node, src_nodes); - - g_list_free (src_nodes); - - } - - return TRUE; -} - -void -ephy_node_view_enable_drag_dest (EphyNodeView *view, - GtkTargetEntry *types, - int n_types) -{ - GtkWidget *treeview; - - g_return_if_fail (view != NULL); - - treeview = GTK_WIDGET (view); - - gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (treeview), - types, n_types, - GDK_ACTION_COPY); - view->priv->drag_targets = gtk_target_list_new (types, n_types); - - g_signal_connect (treeview, "drag_data_received", - G_CALLBACK (drag_data_received_cb), view); - g_signal_connect (treeview, "drag_drop", - G_CALLBACK (drag_drop_cb), view); - g_signal_connect (treeview, "drag_motion", - G_CALLBACK (drag_motion_cb), view); -} - -void -ephy_node_view_enable_drag_source (EphyNodeView *view, - GtkTargetEntry *types, - int n_types, - guint prop_id) -{ - GtkWidget *treeview; - - g_return_if_fail (view != NULL); - - treeview = GTK_WIDGET (view); - - egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (treeview)); - - gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview), - GDK_BUTTON1_MASK, - types, n_types, - GDK_ACTION_COPY); - - ephy_tree_model_sort_set_drag_property (EPHY_TREE_MODEL_SORT (view->priv->sortmodel), - prop_id); -} - -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)); - 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), - (GtkTreePath *)rows->data, - view->priv->editable_column, - TRUE); - - view->priv->editing = TRUE; - - g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); - g_list_free (rows); -} - -gboolean -ephy_node_view_is_editing (EphyNodeView *view) -{ - return view->priv->editing; -} - -gboolean -ephy_node_view_is_target (EphyNodeView *view) -{ - if (target_view == view) - { - return TRUE; - } - else if (target_view != NULL) - { - return FALSE; - } - else - { - return gtk_widget_is_focus (GTK_WIDGET (view)); - } -} - -gboolean -ephy_node_view_has_selection (EphyNodeView *view, gboolean *multiple) -{ - GtkTreeSelection *selection; - int rows; - - if (view->priv->selected_node) - { - rows = 1; - } - else - { - selection = gtk_tree_view_get_selection - (GTK_TREE_VIEW (view)); - - rows = gtk_tree_selection_count_selected_rows (selection); - } - - if (multiple) - { - *multiple = rows > 1; - } - - return rows > 0; -} diff --git a/src/bookmarks/ephy-node-view.h b/src/bookmarks/ephy-node-view.h deleted file mode 100644 index 43006449e..000000000 --- a/src/bookmarks/ephy-node-view.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - */ - -#ifndef __EPHY_NODE_VIEW_H -#define __EPHY_NODE_VIEW_H - -#include <gtk/gtktreeview.h> -#include <gtk/gtkdnd.h> - -#include "ephy-tree-model-node.h" -#include "ephy-node-filter.h" - -G_BEGIN_DECLS - -#define EPHY_TYPE_NODE_VIEW (ephy_node_view_get_type ()) -#define EPHY_NODE_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_NODE_VIEW, EphyNodeView)) -#define EPHY_NODE_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_NODE_VIEW, EphyNodeViewClass)) -#define EPHY_IS_NODE_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_NODE_VIEW)) -#define EPHY_IS_NODE_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_NODE_VIEW)) -#define EPHY_NODE_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_NODE_VIEW, EphyNodeViewClass)) - -typedef struct EphyNodeViewPrivate EphyNodeViewPrivate; - -typedef struct -{ - GtkTreeView parent; - - EphyNodeViewPrivate *priv; -} EphyNodeView; - -typedef struct -{ - GtkTreeViewClass parent; - - void (*node_activated) (EphyNodeView *view, EphyNode *node); - void (*node_selected) (EphyNodeView *view, EphyNode *node); - void (*node_dropped) (EphyNodeView *view, EphyNode *node, GList *nodes); - void (*show_popup) (EphyNodeView *view); -} EphyNodeViewClass; - -GType ephy_node_view_get_type (void); - -GtkWidget *ephy_node_view_new (EphyNode *root, - EphyNodeFilter *filter); - -void ephy_node_view_enable_dnd (EphyNodeView *view); - -GtkTreeViewColumn *ephy_node_view_add_column (EphyNodeView *view, - const char *title, - EphyTreeModelNodeColumn column, - gboolean sortable, - gboolean editable); - -void ephy_node_view_add_icon_column (EphyNodeView *view, - EphyTreeModelNodeColumn column); - -void ephy_node_view_remove (EphyNodeView *view); - -gboolean ephy_node_view_has_selection (EphyNodeView *view, - gboolean *multiple); - -GList *ephy_node_view_get_selection (EphyNodeView *view); - -void ephy_node_view_select_node (EphyNodeView *view, - EphyNode *node); - -void ephy_node_view_enable_drag_source (EphyNodeView *view, - GtkTargetEntry *types, - int n_types, - guint prop_id); - -void ephy_node_view_enable_drag_dest (EphyNodeView *view, - GtkTargetEntry *types, - int n_types); - -void ephy_node_view_edit (EphyNodeView *view); - -gboolean ephy_node_view_is_editing (EphyNodeView *view); - -gboolean ephy_node_view_is_target (EphyNodeView *view); - -G_END_DECLS - -#endif /* EPHY_NODE_VIEW_H */ diff --git a/src/bookmarks/ephy-topics-selector.c b/src/bookmarks/ephy-topics-selector.c index cf1439617..d97a9449f 100644 --- a/src/bookmarks/ephy-topics-selector.c +++ b/src/bookmarks/ephy-topics-selector.c @@ -19,6 +19,7 @@ #include "ephy-topics-selector.h" #include "ephy-debug.h" +#include "ephy-node-view.h" #include <gtk/gtkliststore.h> #include <gtk/gtkcellrenderertoggle.h> @@ -223,9 +224,9 @@ fill_model (EphyTopicsSelector *editor) priority = ephy_node_get_property_int (kid, EPHY_NODE_KEYWORD_PROP_PRIORITY); - if (priority == -1) priority = EPHY_BOOKMARKS_KEYWORD_NORMAL_PRIORITY; + if (priority == -1) priority = EPHY_NODE_VIEW_NORMAL_PRIORITY; - if (priority == EPHY_BOOKMARKS_KEYWORD_NORMAL_PRIORITY) + if (priority == EPHY_NODE_VIEW_NORMAL_PRIORITY) { gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, diff --git a/src/bookmarks/ephy-tree-model-node.c b/src/bookmarks/ephy-tree-model-node.c deleted file mode 100644 index bca22c379..000000000 --- a/src/bookmarks/ephy-tree-model-node.c +++ /dev/null @@ -1,752 +0,0 @@ -/* - * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - */ - -#include <config.h> -#include <gtk/gtktreeview.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <libgnome/gnome-i18n.h> -#include <time.h> -#include <string.h> - -#include "ephy-node-filter.h" -#include "ephy-bookmarks.h" -#include "ephy-tree-model-node.h" -#include "ephy-stock-icons.h" -#include "ephy-node.h" -#include "ephy-shell.h" -#include "ephy-debug.h" - -static void ephy_tree_model_node_class_init (EphyTreeModelNodeClass *klass); -static void ephy_tree_model_node_init (EphyTreeModelNode *model); -static void ephy_tree_model_node_finalize (GObject *object); -static void ephy_tree_model_node_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void ephy_tree_model_node_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static guint ephy_tree_model_node_get_flags (GtkTreeModel *tree_model); -static int ephy_tree_model_node_get_n_columns (GtkTreeModel *tree_model); -static GType ephy_tree_model_node_get_column_type (GtkTreeModel *tree_model, - int index); -static gboolean ephy_tree_model_node_get_iter (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreePath *path); -static GtkTreePath *ephy_tree_model_node_get_path (GtkTreeModel *tree_model, - GtkTreeIter *iter); -static void ephy_tree_model_node_get_value (GtkTreeModel *tree_model, - GtkTreeIter *iter, - int column, - GValue *value); -static gboolean ephy_tree_model_node_iter_next (GtkTreeModel *tree_model, - GtkTreeIter *iter); -static gboolean ephy_tree_model_node_iter_children (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent); -static gboolean ephy_tree_model_node_iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter); -static int ephy_tree_model_node_iter_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter); -static gboolean ephy_tree_model_node_iter_nth_child (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent, - int n); -static gboolean ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child); -static void ephy_tree_model_node_tree_model_init (GtkTreeModelIface *iface); -static void root_child_removed_cb (EphyNode *node, - EphyNode *child, - EphyTreeModelNode *model); -static void root_child_added_cb (EphyNode *node, - EphyNode *child, - EphyTreeModelNode *model); -static void root_child_changed_cb (EphyNode *node, - EphyNode *child, - EphyTreeModelNode *model); -static inline void ephy_tree_model_node_update_node (EphyTreeModelNode *model, - EphyNode *node, - int idx); -static void root_destroyed_cb (EphyNode *node, - EphyTreeModelNode *model); -static inline GtkTreePath *get_path_real (EphyTreeModelNode *model, - EphyNode *node); - -struct EphyTreeModelNodePrivate -{ - EphyNode *root; - - EphyNodeFilter *filter; -}; - -enum -{ - PROP_0, - PROP_ROOT, - PROP_FILTER -}; - -static GObjectClass *parent_class = NULL; - -GType -ephy_tree_model_node_get_type (void) -{ - static GType ephy_tree_model_node_type = 0; - - if (ephy_tree_model_node_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (EphyTreeModelNodeClass), - NULL, - NULL, - (GClassInitFunc) ephy_tree_model_node_class_init, - NULL, - NULL, - sizeof (EphyTreeModelNode), - 0, - (GInstanceInitFunc) ephy_tree_model_node_init - }; - - static const GInterfaceInfo tree_model_info = - { - (GInterfaceInitFunc) ephy_tree_model_node_tree_model_init, - NULL, - NULL - }; - - ephy_tree_model_node_type = g_type_register_static (G_TYPE_OBJECT, - "EphyTreeModelNode", - &our_info, 0); - - g_type_add_interface_static (ephy_tree_model_node_type, - GTK_TYPE_TREE_MODEL, - &tree_model_info); - } - - return ephy_tree_model_node_type; -} - -static void -ephy_tree_model_node_class_init (EphyTreeModelNodeClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = ephy_tree_model_node_finalize; - - object_class->set_property = ephy_tree_model_node_set_property; - object_class->get_property = ephy_tree_model_node_get_property; - - g_object_class_install_property (object_class, - PROP_ROOT, - g_param_spec_object ("root", - "Root node", - "Root node", - EPHY_TYPE_NODE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, - PROP_FILTER, - g_param_spec_object ("filter", - "Filter object", - "Filter object", - EPHY_TYPE_NODE_FILTER, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); -} - -static void -ephy_tree_model_node_init (EphyTreeModelNode *model) -{ - GtkWidget *dummy; - - do - { - model->stamp = g_random_int (); - } - while (model->stamp == 0); - - model->priv = g_new0 (EphyTreeModelNodePrivate, 1); - - dummy = gtk_tree_view_new (); - - gtk_widget_destroy (dummy); -} - -static void -ephy_tree_model_node_finalize (GObject *object) -{ - EphyTreeModelNode *model; - - g_return_if_fail (object != NULL); - g_return_if_fail (EPHY_IS_TREE_MODEL_NODE (object)); - - model = EPHY_TREE_MODEL_NODE (object); - - g_return_if_fail (model->priv != NULL); - - g_free (model->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -filter_changed_cb (EphyNodeFilter *filter, - EphyTreeModelNode *model) -{ - GPtrArray *kids; - int i; - - kids = ephy_node_get_children (model->priv->root); - - for (i = 0; i < kids->len; i++) - { - ephy_tree_model_node_update_node (model, - g_ptr_array_index (kids, i), - i); - } - - ephy_node_thaw (model->priv->root); -} - -static void -ephy_tree_model_node_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object); - - switch (prop_id) - { - case PROP_ROOT: - model->priv->root = g_value_get_object (value); - - g_signal_connect_object (G_OBJECT (model->priv->root), - "child_added", - G_CALLBACK (root_child_added_cb), - G_OBJECT (model), - 0); - g_signal_connect_object (G_OBJECT (model->priv->root), - "child_removed", - G_CALLBACK (root_child_removed_cb), - G_OBJECT (model), - 0); - g_signal_connect_object (G_OBJECT (model->priv->root), - "child_changed", - G_CALLBACK (root_child_changed_cb), - G_OBJECT (model), - 0); - g_signal_connect_object (G_OBJECT (model->priv->root), - "destroyed", - G_CALLBACK (root_destroyed_cb), - G_OBJECT (model), - 0); - - break; - case PROP_FILTER: - model->priv->filter = g_value_get_object (value); - - if (model->priv->filter != NULL) - { - g_signal_connect_object (G_OBJECT (model->priv->filter), - "changed", - G_CALLBACK (filter_changed_cb), - G_OBJECT (model), - 0); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -ephy_tree_model_node_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (object); - - switch (prop_id) - { - case PROP_ROOT: - g_value_set_object (value, model->priv->root); - break; - case PROP_FILTER: - g_value_set_object (value, model->priv->filter); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -EphyTreeModelNode * -ephy_tree_model_node_new (EphyNode *root, - EphyNodeFilter *filter) -{ - EphyTreeModelNode *model; - - model = EPHY_TREE_MODEL_NODE (g_object_new (EPHY_TYPE_TREE_MODEL_NODE, - "filter", filter, - "root", root, - NULL)); - - g_return_val_if_fail (model->priv != NULL, NULL); - - return model; -} - -static void -ephy_tree_model_node_tree_model_init (GtkTreeModelIface *iface) -{ - iface->get_flags = ephy_tree_model_node_get_flags; - iface->get_n_columns = ephy_tree_model_node_get_n_columns; - iface->get_column_type = ephy_tree_model_node_get_column_type; - iface->get_iter = ephy_tree_model_node_get_iter; - iface->get_path = ephy_tree_model_node_get_path; - iface->get_value = ephy_tree_model_node_get_value; - iface->iter_next = ephy_tree_model_node_iter_next; - iface->iter_children = ephy_tree_model_node_iter_children; - iface->iter_has_child = ephy_tree_model_node_iter_has_child; - iface->iter_n_children = ephy_tree_model_node_iter_n_children; - iface->iter_nth_child = ephy_tree_model_node_iter_nth_child; - iface->iter_parent = ephy_tree_model_node_iter_parent; -} - -static guint -ephy_tree_model_node_get_flags (GtkTreeModel *tree_model) -{ - return 0; -} - -static int -ephy_tree_model_node_get_n_columns (GtkTreeModel *tree_model) -{ - return EPHY_TREE_MODEL_NODE_NUM_COLUMNS; -} - -static GType -ephy_tree_model_node_get_column_type (GtkTreeModel *tree_model, - int index) -{ - g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), G_TYPE_INVALID); - g_return_val_if_fail ((index < EPHY_TREE_MODEL_NODE_NUM_COLUMNS) && (index >= 0), G_TYPE_INVALID); - - switch (index) - { - case EPHY_TREE_MODEL_NODE_COL_BOOKMARK: - case EPHY_TREE_MODEL_NODE_COL_KEYWORD: - return G_TYPE_STRING; - case EPHY_TREE_MODEL_NODE_COL_TITLE_WEIGHT: - case EPHY_TREE_MODEL_NODE_COL_PRIORITY: - return G_TYPE_INT; - case EPHY_TREE_MODEL_NODE_COL_VISIBLE: - return G_TYPE_BOOLEAN; - case EPHY_TREE_MODEL_NODE_COL_ICON: - return GDK_TYPE_PIXBUF; - default: - g_assert_not_reached (); - return G_TYPE_INVALID; - } -} - -static gboolean -ephy_tree_model_node_get_iter (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreePath *path) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model); - int i; - - g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (model), FALSE); - g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE); - - if (model->priv->root == NULL) - return FALSE; - - i = gtk_tree_path_get_indices (path)[0]; - - iter->stamp = model->stamp; - iter->user_data = ephy_node_get_nth_child (model->priv->root, i); - - if (iter->user_data == NULL) - { - iter->stamp = 0; - return FALSE; - } - - return TRUE; -} - -static inline GtkTreePath * -get_path_real (EphyTreeModelNode *model, - EphyNode *node) -{ - GtkTreePath *retval; - - retval = gtk_tree_path_new (); - gtk_tree_path_append_index (retval, ephy_node_get_child_index (model->priv->root, node)); - - return retval; -} - -static GtkTreePath * -ephy_tree_model_node_get_path (GtkTreeModel *tree_model, - GtkTreeIter *iter) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model); - EphyNode *node; - - g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), NULL); - g_return_val_if_fail (iter != NULL, NULL); - g_return_val_if_fail (iter->user_data != NULL, NULL); - g_return_val_if_fail (iter->stamp == model->stamp, NULL); - - if (model->priv->root == NULL) - return NULL; - - node = EPHY_NODE (iter->user_data); - - if (node == model->priv->root) - return gtk_tree_path_new (); - - return get_path_real (model, node); -} - -static void -get_icon_pixbuf (EphyNode *node, GValue *value) -{ - EphyFaviconCache *cache; - const char *icon_location; - GdkPixbuf *pixbuf = NULL; - - cache = ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell)); - icon_location = ephy_node_get_property_string - (node, EPHY_NODE_BMK_PROP_ICON); - - LOG ("Get favicon for %s", icon_location ? icon_location : "None") - - if (icon_location) - { - pixbuf = ephy_favicon_cache_get (cache, icon_location); - } - - g_value_init (value, GDK_TYPE_PIXBUF); - g_value_set_object (value, pixbuf); -} - -static void -ephy_tree_model_node_get_value (GtkTreeModel *tree_model, - GtkTreeIter *iter, - int column, - GValue *value) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model); - EphyNode *node; - int priority; - - g_return_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model)); - g_return_if_fail (iter != NULL); - g_return_if_fail (iter->stamp == model->stamp); - g_return_if_fail (EPHY_IS_NODE (iter->user_data)); - g_return_if_fail (column < EPHY_TREE_MODEL_NODE_NUM_COLUMNS); - - if (model->priv->root == NULL) - return; - - node = EPHY_NODE (iter->user_data); - - switch (column) - { - case EPHY_TREE_MODEL_NODE_COL_BOOKMARK: - ephy_node_get_property (node, - EPHY_NODE_BMK_PROP_TITLE, - value); - break; - case EPHY_TREE_MODEL_NODE_COL_KEYWORD: - ephy_node_get_property (node, - EPHY_NODE_KEYWORD_PROP_NAME, - value); - break; - case EPHY_TREE_MODEL_NODE_COL_ICON: - get_icon_pixbuf (node, value); - break; - - case EPHY_TREE_MODEL_NODE_COL_VISIBLE: - g_value_init (value, G_TYPE_BOOLEAN); - - if (model->priv->filter != NULL) - { - g_value_set_boolean (value, - ephy_node_filter_evaluate (model->priv->filter, node)); - } - else - { - g_value_set_boolean (value, TRUE); - } - break; - case EPHY_TREE_MODEL_NODE_COL_TITLE_WEIGHT: - g_value_init (value, G_TYPE_INT); - priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY); - if (priority == EPHY_BOOKMARKS_KEYWORD_ALL_PRIORITY || - priority == EPHY_BOOKMARKS_KEYWORD_SPECIAL_PRIORITY) - g_value_set_int (value, PANGO_WEIGHT_BOLD); - else - g_value_set_int (value, PANGO_WEIGHT_NORMAL); - break; - case EPHY_TREE_MODEL_NODE_COL_PRIORITY: - g_value_init (value, G_TYPE_INT); - priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY); - if (priority == EPHY_BOOKMARKS_KEYWORD_ALL_PRIORITY || - priority == EPHY_BOOKMARKS_KEYWORD_SPECIAL_PRIORITY) - g_value_set_int (value, priority); - else - g_value_set_int (value, EPHY_BOOKMARKS_KEYWORD_NORMAL_PRIORITY); - break; - default: - g_assert_not_reached (); - break; - } -} - -static gboolean -ephy_tree_model_node_iter_next (GtkTreeModel *tree_model, - GtkTreeIter *iter) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model); - EphyNode *node; - - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (iter->user_data != NULL, FALSE); - g_return_val_if_fail (iter->stamp == EPHY_TREE_MODEL_NODE (tree_model)->stamp, FALSE); - - if (model->priv->root == NULL) - return FALSE; - - node = EPHY_NODE (iter->user_data); - - if (node == model->priv->root) - return FALSE; - - iter->user_data = ephy_node_get_next_child (model->priv->root, node); - - return (iter->user_data != NULL); -} - -static gboolean -ephy_tree_model_node_iter_children (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model); - - if (model->priv->root == NULL) - return FALSE; - - if (parent != NULL) - return FALSE; - - iter->stamp = model->stamp; - iter->user_data = model->priv->root; - - return TRUE; -} - -static gboolean -ephy_tree_model_node_iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter) -{ - return FALSE; -} - -static int -ephy_tree_model_node_iter_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model); - - g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), -1); - - if (model->priv->root == NULL) - return 0; - - if (iter == NULL) - return ephy_node_get_n_children (model->priv->root); - - g_return_val_if_fail (model->stamp == iter->stamp, -1); - - return 0; -} - -static gboolean -ephy_tree_model_node_iter_nth_child (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent, - int n) -{ - EphyTreeModelNode *model = EPHY_TREE_MODEL_NODE (tree_model); - EphyNode *node; - - g_return_val_if_fail (EPHY_IS_TREE_MODEL_NODE (tree_model), FALSE); - - if (model->priv->root == NULL) - return FALSE; - - if (parent != NULL) - return FALSE; - - node = ephy_node_get_nth_child (model->priv->root, n); - - if (node != NULL) - { - iter->stamp = model->stamp; - iter->user_data = node; - return TRUE; - } - else - return FALSE; -} - -static gboolean -ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child) -{ - return FALSE; -} - -EphyNode * -ephy_tree_model_node_node_from_iter (EphyTreeModelNode *model, - GtkTreeIter *iter) -{ - return EPHY_NODE (iter->user_data); -} - -void -ephy_tree_model_node_iter_from_node (EphyTreeModelNode *model, - EphyNode *node, - GtkTreeIter *iter) -{ - iter->stamp = model->stamp; - iter->user_data = node; -} - -static void -root_child_removed_cb (EphyNode *node, - EphyNode *child, - EphyTreeModelNode *model) -{ - GtkTreePath *path; - - path = get_path_real (model, child); - gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path); - gtk_tree_path_free (path); -} - -static void -root_child_added_cb (EphyNode *node, - EphyNode *child, - EphyTreeModelNode *model) -{ - GtkTreePath *path; - GtkTreeIter iter; - - ephy_tree_model_node_iter_from_node (model, child, &iter); - - path = get_path_real (model, child); - gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter); - gtk_tree_path_free (path); -} - -static inline void -ephy_tree_model_node_update_node (EphyTreeModelNode *model, - EphyNode *node, - int idx) -{ - GtkTreePath *path; - GtkTreeIter iter; - - ephy_tree_model_node_iter_from_node (model, node, &iter); - - if (idx >= 0) - { - path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, idx); - } - else - { - path = get_path_real (model, node); - } - - LOG ("Updating row") - - gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter); - gtk_tree_path_free (path); -} - -static void -root_child_changed_cb (EphyNode *node, - EphyNode *child, - EphyTreeModelNode *model) -{ - ephy_tree_model_node_update_node (model, child, -1); -} - -static void -root_destroyed_cb (EphyNode *node, - EphyTreeModelNode *model) -{ - model->priv->root = NULL; - - /* no need to do other stuff since we should have had a bunch of child_removed - * signals already */ -} - -GType -ephy_tree_model_node_column_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) - { - static const GEnumValue values[] = - { - { EPHY_TREE_MODEL_NODE_COL_BOOKMARK, "EPHY_TREE_MODEL_NODE_COL_BOOKMARK", "bookmark" }, - { EPHY_TREE_MODEL_NODE_COL_KEYWORD, "EPHY_TREE_MODEL_NODE_COL_KEYWORD", "keyword" }, - { EPHY_TREE_MODEL_NODE_COL_ICON, "EPHY_TREE_MODEL_NODE_COL_ICON", "icon" }, - { EPHY_TREE_MODEL_NODE_COL_VISIBLE, "EPHY_TREE_MODEL_NODE_COL_VISIBLE", "visible" }, - { EPHY_TREE_MODEL_NODE_COL_TITLE_WEIGHT, "EPHY_TREE_MODEL_NODE_COL_TITLE_WEIGHT", "title weight" }, - { EPHY_TREE_MODEL_NODE_COL_PRIORITY, "EPHY_TREE_MODEL_NODE_COL_PRIORITY", "priority" }, - - { 0, 0, 0 } - }; - - etype = g_enum_register_static ("EphyTreeModelNodeColumn", values); - } - - return etype; -} - diff --git a/src/bookmarks/ephy-tree-model-node.h b/src/bookmarks/ephy-tree-model-node.h deleted file mode 100644 index afc862f58..000000000 --- a/src/bookmarks/ephy-tree-model-node.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - */ - -#ifndef __EPHY_TREE_MODEL_NODE_H -#define __EPHY_TREE_MODEL_NODE_H - -#include <gtk/gtktreemodel.h> - -#include "ephy-node.h" -#include "ephy-node-filter.h" - -G_BEGIN_DECLS - -#define EPHY_TYPE_TREE_MODEL_NODE (ephy_tree_model_node_get_type ()) -#define EPHY_TREE_MODEL_NODE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_TREE_MODEL_NODE, EphyTreeModelNode)) -#define EPHY_TREE_MODEL_NODE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_TREE_MODEL_NODE, EphyTreeModelNodeClass)) -#define EPHY_IS_TREE_MODEL_NODE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_TREE_MODEL_NODE)) -#define EPHY_IS_TREE_MODEL_NODE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_TREE_MODEL_NODE)) -#define EPHY_TREE_MODEL_NODE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_TREE_MODEL_NODE, EphyTreeModelNodeClass)) - -typedef enum -{ - EPHY_TREE_MODEL_NODE_COL_BOOKMARK, - EPHY_TREE_MODEL_NODE_COL_KEYWORD, - EPHY_TREE_MODEL_NODE_COL_VISIBLE, - EPHY_TREE_MODEL_NODE_COL_ICON, - EPHY_TREE_MODEL_NODE_COL_TITLE_WEIGHT, - EPHY_TREE_MODEL_NODE_COL_PRIORITY, - EPHY_TREE_MODEL_NODE_NUM_COLUMNS -} EphyTreeModelNodeColumn; - -GType ephy_tree_model_node_column_get_type (void); - -#define EPHY_TYPE_TREE_MODEL_NODE_COLUMN (ephy_tree_model_node_column_get_type ()) - -typedef struct EphyTreeModelNodePrivate EphyTreeModelNodePrivate; - -typedef struct -{ - GObject parent; - - EphyTreeModelNodePrivate *priv; - - int stamp; -} EphyTreeModelNode; - -typedef struct -{ - GObjectClass parent; -} EphyTreeModelNodeClass; - -GType ephy_tree_model_node_get_type (void); - -EphyTreeModelNode *ephy_tree_model_node_new (EphyNode *root, - EphyNodeFilter *filter); - -EphyNode *ephy_tree_model_node_node_from_iter (EphyTreeModelNode *model, - GtkTreeIter *iter); - -void ephy_tree_model_node_iter_from_node (EphyTreeModelNode *model, - EphyNode *node, - GtkTreeIter *iter); - -G_END_DECLS - -#endif /* EPHY_TREE_MODEL_NODE_H */ |