Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / bookmarks / bookmark_tree_model.h
blob7e8de0b586381e7df76b77cf7a597e3bd105aaea
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_TREE_MODEL_H_
6 #define CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_TREE_MODEL_H_
8 #include "base/basictypes.h"
9 #include "base/strings/string16.h"
11 class BookmarkModel;
12 class BookmarkNode;
14 typedef struct _GtkCellRenderer GtkCellRenderer;
15 typedef struct _GtkTreeIter GtkTreeIter;
16 typedef struct _GtkTreeModel GtkTreeModel;
17 typedef struct _GtkTreeStore GtkTreeStore;
18 typedef struct _GtkTreeView GtkTreeView;
19 typedef struct _GdkPixbuf GdkPixbuf;
20 typedef struct _GtkWidget GtkWidget;
22 enum FolderTreeStoreColumns {
23 FOLDER_ICON,
24 FOLDER_NAME,
25 ITEM_ID,
26 IS_EDITABLE,
27 FOLDER_STORE_NUM_COLUMNS
30 // Make a tree store that has two columns: name and id.
31 GtkTreeStore* MakeFolderTreeStore();
33 // Copies the folders in the model's root node into a GtkTreeStore. We
34 // want the user to be able to modify the tree of folders, but to be able to
35 // click Cancel and discard their modifications. |selected_id| is the
36 // node->id() of the BookmarkNode that should selected on
37 // node->screen. |selected_iter| is an out value that points to the
38 // node->representation of the node associated with |selected_id| in |store|.
39 // |recursive| indicates whether to recurse into sub-directories (if false,
40 // the tree store will effectively be a list). |only_folders| indicates whether
41 // to include bookmarks in the tree, or to only show folders.
42 void AddToTreeStore(BookmarkModel* model, int64 selected_id,
43 GtkTreeStore* store, GtkTreeIter* selected_iter);
45 // As above, but inserts just the tree rooted at |node| as a child of |parent|.
46 // If |parent| is NULL, add it at the top level.
47 void AddToTreeStoreAt(const BookmarkNode* node, int64 selected_id,
48 GtkTreeStore* store, GtkTreeIter* selected_iter,
49 GtkTreeIter* parent);
51 // Makes a tree view for the store. This will take ownership of |store| and the
52 // returned widget has a floating reference.
53 GtkWidget* MakeTreeViewForStore(GtkTreeStore* store);
55 // A helper method for getting pointer back to the GtkCellRendererText used for
56 // the folder names.
57 GtkCellRenderer* GetCellRendererText(GtkTreeView* tree_view);
59 // Commits changes to a GtkTreeStore built from BuildTreeStoreFrom() back
60 // into the BookmarkModel it was generated from. Returns the BookmarkNode that
61 // represented by |selected|.
62 const BookmarkNode* CommitTreeStoreDifferencesBetween(
63 BookmarkModel* model, GtkTreeStore* tree_store,
64 GtkTreeIter* selected);
66 // Returns the id field of the row pointed to by |iter|.
67 int64 GetIdFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter);
69 // Returns the title field in utf8 of the row pointed to by |iter|.
70 base::string16 GetTitleFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter);
72 #endif // CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_TREE_MODEL_H_