| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // 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 |
| 36 // 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 |
| 37 // click Cancel and discard their modifications. |selected_id| is the | 37 // click Cancel and discard their modifications. |selected_id| is the |
| 38 // node->id() of the BookmarkNode that should selected on | 38 // node->id() of the BookmarkNode that should selected on |
| 39 // 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 |
| 40 // node->representation of the node associated with |selected_id| in |store|. | 40 // node->representation of the node associated with |selected_id| in |store|. |
| 41 // |recursive| indicates whether to recurse into sub-directories (if false, | 41 // |recursive| indicates whether to recurse into sub-directories (if false, |
| 42 // 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 |
| 43 // to include bookmarks in the tree, or to only show folders. | 43 // to include bookmarks in the tree, or to only show folders. |
| 44 // If |node_to_ignore| is non-null, a node in the tree store is not created for | |
| 45 // it. | |
| 46 void AddToTreeStore(BookmarkModel* model, int64 selected_id, | 44 void AddToTreeStore(BookmarkModel* model, int64 selected_id, |
| 47 const BookmarkNode* node_to_ignore, GtkTreeStore* store, | 45 GtkTreeStore* store, GtkTreeIter* selected_iter); |
| 48 GtkTreeIter* selected_iter); | |
| 49 | 46 |
| 50 // 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|. |
| 51 // If |parent| is NULL, add it at the top level. | 48 // If |parent| is NULL, add it at the top level. |
| 52 void AddToTreeStoreAt(const BookmarkNode* node, int64 selected_id, | 49 void AddToTreeStoreAt(const BookmarkNode* node, int64 selected_id, |
| 53 const BookmarkNode* node_to_ignore, GtkTreeStore* store, | 50 GtkTreeStore* store, GtkTreeIter* selected_iter, |
| 54 GtkTreeIter* selected_iter, GtkTreeIter* parent); | 51 GtkTreeIter* parent); |
| 55 | 52 |
| 56 // 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 |
| 57 // returned widget has a floating reference. | 54 // returned widget has a floating reference. |
| 58 GtkWidget* MakeTreeViewForStore(GtkTreeStore* store); | 55 GtkWidget* MakeTreeViewForStore(GtkTreeStore* store); |
| 59 | 56 |
| 60 // A helper method for getting pointer back to the GtkCellRendererText used for | 57 // A helper method for getting pointer back to the GtkCellRendererText used for |
| 61 // the folder names. | 58 // the folder names. |
| 62 GtkCellRenderer* GetCellRendererText(GtkTreeView* tree_view); | 59 GtkCellRenderer* GetCellRendererText(GtkTreeView* tree_view); |
| 63 | 60 |
| 64 // Commits changes to a GtkTreeStore built from BuildTreeStoreFrom() back | 61 // Commits changes to a GtkTreeStore built from BuildTreeStoreFrom() back |
| 65 // into the BookmarkModel it was generated from. Returns the BookmarkNode that | 62 // into the BookmarkModel it was generated from. Returns the BookmarkNode that |
| 66 // represented by |selected|. | 63 // represented by |selected|. |
| 67 const BookmarkNode* CommitTreeStoreDifferencesBetween( | 64 const BookmarkNode* CommitTreeStoreDifferencesBetween( |
| 68 BookmarkModel* model, GtkTreeStore* tree_store, | 65 BookmarkModel* model, GtkTreeStore* tree_store, |
| 69 GtkTreeIter* selected); | 66 GtkTreeIter* selected); |
| 70 | 67 |
| 71 // Returns the id field of the row pointed to by |iter|. | 68 // Returns the id field of the row pointed to by |iter|. |
| 72 int64 GetIdFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter); | 69 int64 GetIdFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter); |
| 73 | 70 |
| 74 // Returns the title field of the row pointed to by |iter|. | 71 // Returns the title field of the row pointed to by |iter|. |
| 75 std::wstring GetTitleFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter); | 72 std::wstring GetTitleFromTreeIter(GtkTreeModel* model, GtkTreeIter* iter); |
| 76 | 73 |
| 77 } // namespace bookmark_utils | 74 } // namespace bookmark_utils |
| 78 | 75 |
| 79 #endif // CHROME_BROWSER_GTK_BOOKMARK_TREE_MODEL_H_ | 76 #endif // CHROME_BROWSER_GTK_BOOKMARK_TREE_MODEL_H_ |
| OLD | NEW |