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