diff options
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/bookmark_editor_gtk.cc | 18 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_manager_gtk.cc | 14 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_tree_model.cc | 20 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_tree_model.h | 5 |
4 files changed, 27 insertions, 30 deletions
diff --git a/chrome/browser/gtk/bookmark_editor_gtk.cc b/chrome/browser/gtk/bookmark_editor_gtk.cc index 8b449a4..c5824ec 100644 --- a/chrome/browser/gtk/bookmark_editor_gtk.cc +++ b/chrome/browser/gtk/bookmark_editor_gtk.cc @@ -157,24 +157,8 @@ void BookmarkEditorGtk::Init(GtkWindow* parent_window) { tree_store_ = bookmark_utils::MakeFolderTreeStore(); bookmark_utils::AddToTreeStore(bb_model_, selected_id, tree_store_, &selected_iter); - - GtkTreeViewColumn* icon_column = - gtk_tree_view_column_new_with_attributes( - "FolderIcon", gtk_cell_renderer_pixbuf_new(), "pixbuf", - bookmark_utils::FOLDER_ICON, NULL); - GtkTreeViewColumn* name_column = - gtk_tree_view_column_new_with_attributes( - "FolderName", gtk_cell_renderer_text_new(), "text", - bookmark_utils::FOLDER_NAME, NULL); - - tree_view_ = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tree_store_)); - // Let |tree_view| own the store. - g_object_unref(tree_store_); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view_), FALSE); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view_), icon_column); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view_), name_column); + tree_view_ = bookmark_utils::MakeTreeViewForStore(tree_store_); gtk_widget_set_size_request(tree_view_, kTreeWidth, kTreeHeight); - tree_selection_ = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view_)); GtkTreePath* path = NULL; diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc index 2092367..bfca0e1 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.cc +++ b/chrome/browser/gtk/bookmark_manager_gtk.cc @@ -433,20 +433,8 @@ void BookmarkManagerGtk::InitWidgets() { GtkWidget* BookmarkManagerGtk::MakeLeftPane() { left_store_ = bookmark_utils::MakeFolderTreeStore(); + left_tree_view_ = bookmark_utils::MakeTreeViewForStore(left_store_); - GtkTreeViewColumn* icon_column = gtk_tree_view_column_new_with_attributes( - "", gtk_cell_renderer_pixbuf_new(), "pixbuf", bookmark_utils::FOLDER_ICON, - NULL); - GtkTreeViewColumn* name_column = gtk_tree_view_column_new_with_attributes( - "", gtk_cell_renderer_text_new(), "text", bookmark_utils::FOLDER_NAME, - NULL); - - left_tree_view_ = gtk_tree_view_new_with_model(GTK_TREE_MODEL(left_store_)); - // Let |tree_view| own the store. - g_object_unref(left_store_); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(left_tree_view_), FALSE); - gtk_tree_view_append_column(GTK_TREE_VIEW(left_tree_view_), icon_column); - gtk_tree_view_append_column(GTK_TREE_VIEW(left_tree_view_), name_column); // When a row is collapsed that contained the selected node, we want to select // it. g_signal_connect(left_tree_view_, "row-collapsed", diff --git a/chrome/browser/gtk/bookmark_tree_model.cc b/chrome/browser/gtk/bookmark_tree_model.cc index 34eedb0..f78baf1 100644 --- a/chrome/browser/gtk/bookmark_tree_model.cc +++ b/chrome/browser/gtk/bookmark_tree_model.cc @@ -86,6 +86,26 @@ void AddToTreeStore(BookmarkModel* model, int64 selected_id, } } +GtkWidget* MakeTreeViewForStore(GtkTreeStore* store) { + GtkTreeViewColumn* column = gtk_tree_view_column_new(); + GtkCellRenderer* image_renderer = gtk_cell_renderer_pixbuf_new(); + gtk_tree_view_column_pack_start(column, image_renderer, FALSE); + gtk_tree_view_column_add_attribute(column, image_renderer, + "pixbuf", FOLDER_ICON); + GtkCellRenderer* text_renderer = gtk_cell_renderer_text_new(); + g_object_set(text_renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); + gtk_tree_view_column_pack_start(column, text_renderer, TRUE); + gtk_tree_view_column_add_attribute(column, text_renderer, + "text", FOLDER_NAME); + + GtkWidget* tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); + // Let |tree_view| own the store. + g_object_unref(store); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), FALSE); + gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column); + return tree_view; +} + void AddToTreeStoreAt(const BookmarkNode* node, int64 selected_id, GtkTreeStore* store, GtkTreeIter* selected_iter, GtkTreeIter* parent) { diff --git a/chrome/browser/gtk/bookmark_tree_model.h b/chrome/browser/gtk/bookmark_tree_model.h index 96e9fd5..6656b61 100644 --- a/chrome/browser/gtk/bookmark_tree_model.h +++ b/chrome/browser/gtk/bookmark_tree_model.h @@ -15,6 +15,7 @@ typedef struct _GtkTreeIter GtkTreeIter; typedef struct _GtkTreeModel GtkTreeModel; typedef struct _GtkTreeStore GtkTreeStore; typedef struct _GdkPixbuf GdkPixbuf; +typedef struct _GtkWidget GtkWidget; namespace bookmark_utils { @@ -46,6 +47,10 @@ void AddToTreeStoreAt(const BookmarkNode* node, int64 selected_id, GtkTreeStore* store, GtkTreeIter* selected_iter, GtkTreeIter* parent); +// Makes a tree view for the store. This will take ownership of |store| and the +// returned widget has a floating reference. +GtkWidget* MakeTreeViewForStore(GtkTreeStore* store); + // Commits changes to a GtkTreeStore built from BuildTreeStoreFrom() back // into the BookmarkModel it was generated from. Returns the BookmarkNode that // represented by |selected|. |