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 | 9 |
10 class BookmarkModel; | 10 class BookmarkModel; |
11 class BookmarkNode; | 11 class BookmarkNode; |
12 | 12 |
13 typedef struct _GtkTreeIter GtkTreeIter; | 13 typedef struct _GtkTreeIter GtkTreeIter; |
14 typedef struct _GtkTreeModel GtkTreeModel; | 14 typedef struct _GtkTreeModel GtkTreeModel; |
15 typedef struct _GtkTreeStore GtkTreeStore; | 15 typedef struct _GtkTreeStore GtkTreeStore; |
| 16 typedef struct _GdkPixbuf GdkPixbuf; |
16 | 17 |
17 namespace bookmark_utils { | 18 namespace bookmark_utils { |
18 | 19 |
19 // Copies the tree of folders from the BookmarkModel into a GtkTreeStore. We | 20 enum FolderTreeStoreColumns { |
| 21 FOLDER_ICON, |
| 22 FOLDER_NAME, |
| 23 ITEM_ID, |
| 24 FOLDER_STORE_NUM_COLUMNS |
| 25 }; |
| 26 |
| 27 // Make a tree store that has two columns: name and id. |
| 28 GtkTreeStore* MakeFolderTreeStore(); |
| 29 |
| 30 // Copies the tree of folders rooted at |node| into a GtkTreeStore. We |
20 // want the user to be able to modify the tree of folders, but to be able to | 31 // want the user to be able to modify the tree of folders, but to be able to |
21 // click Cancel and discard their modifications. |selected_id| is the | 32 // click Cancel and discard their modifications. |selected_id| is the |
22 // node->id() of the BookmarkNode that should selected on | 33 // node->id() of the BookmarkNode that should selected on |
23 // node->screen. |selected_iter| is an out value that points to the | 34 // node->screen. |selected_iter| is an out value that points to the |
24 // node->representation of the node associated with |selected_id| in |store|. | 35 // node->representation of the node associated with |selected_id| in |store|. |
25 void BuildTreeStoreFrom(BookmarkModel* model, int selected_id, | 36 // |recursive| indicates whether to recurse into sub-directories (if false, |
26 GtkTreeStore** store, GtkTreeIter* selected_iter); | 37 // the tree store will effectively be a list). |only_folders| indicates whether |
| 38 // to include bookmarks in the tree, or to only show folders. |
| 39 void AddToTreeStore(BookmarkModel* model, int selected_id, |
| 40 GtkTreeStore* store, GtkTreeIter* selected_iter); |
27 | 41 |
28 // Commits changes to a GtkTreeStore built from BuildTreeStoreFrom() back | 42 // Commits changes to a GtkTreeStore built from BuildTreeStoreFrom() back |
29 // into the BookmarkModel it was generated from. Returns the BookmarkNode that | 43 // into the BookmarkModel it was generated from. Returns the BookmarkNode that |
30 // represented by |selected|. | 44 // represented by |selected|. |
31 BookmarkNode* CommitTreeStoreDifferencesBetween( | 45 BookmarkNode* CommitTreeStoreDifferencesBetween( |
32 BookmarkModel* model, GtkTreeStore* tree_store, | 46 BookmarkModel* model, GtkTreeStore* tree_store, |
33 GtkTreeIter* selected); | 47 GtkTreeIter* selected); |
34 | 48 |
35 // Returns the id field of the row pointed to by |iter|. | 49 // Returns the id field of the row pointed to by |iter|. |
36 int GetIdFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter); | 50 int GetIdFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter); |
37 | 51 |
38 // Returns the title field of the row pointed to by |iter|. | 52 // Returns the title field of the row pointed to by |iter|. |
39 std::wstring GetTitleFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter); | 53 std::wstring GetTitleFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter); |
40 | 54 |
| 55 // Get a pointer to the folder icon. The returned pointer should not be freed. |
| 56 GdkPixbuf* GetFolderIcon(); |
| 57 |
| 58 // As above. |
| 59 GdkPixbuf* GetDefaultFavicon(); |
| 60 |
41 } // namespace bookmark_utils | 61 } // namespace bookmark_utils |
42 | 62 |
43 #endif // CHROME_BROWSER_GTK_BOOKMARK_TREE_MODEL_H_ | 63 #endif // CHROME_BROWSER_GTK_BOOKMARK_TREE_MODEL_H_ |
OLD | NEW |