Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: chrome/browser/gtk/bookmark_editor_gtk.cc

Issue 160603: GTK: Make folder tree views expand columns properly, also refactor the code i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/gtk/bookmark_manager_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/gtk/bookmark_editor_gtk.h" 5 #include "chrome/browser/gtk/bookmark_editor_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 NULL); 150 NULL);
151 151
152 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); 152 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
153 153
154 if (show_tree_) { 154 if (show_tree_) {
155 GtkTreeIter selected_iter; 155 GtkTreeIter selected_iter;
156 int64 selected_id = parent_ ? parent_->id() : 0; 156 int64 selected_id = parent_ ? parent_->id() : 0;
157 tree_store_ = bookmark_utils::MakeFolderTreeStore(); 157 tree_store_ = bookmark_utils::MakeFolderTreeStore();
158 bookmark_utils::AddToTreeStore(bb_model_, selected_id, 158 bookmark_utils::AddToTreeStore(bb_model_, selected_id,
159 tree_store_, &selected_iter); 159 tree_store_, &selected_iter);
160 160 tree_view_ = bookmark_utils::MakeTreeViewForStore(tree_store_);
161 GtkTreeViewColumn* icon_column =
162 gtk_tree_view_column_new_with_attributes(
163 "FolderIcon", gtk_cell_renderer_pixbuf_new(), "pixbuf",
164 bookmark_utils::FOLDER_ICON, NULL);
165 GtkTreeViewColumn* name_column =
166 gtk_tree_view_column_new_with_attributes(
167 "FolderName", gtk_cell_renderer_text_new(), "text",
168 bookmark_utils::FOLDER_NAME, NULL);
169
170 tree_view_ = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tree_store_));
171 // Let |tree_view| own the store.
172 g_object_unref(tree_store_);
173 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view_), FALSE);
174 gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view_), icon_column);
175 gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view_), name_column);
176 gtk_widget_set_size_request(tree_view_, kTreeWidth, kTreeHeight); 161 gtk_widget_set_size_request(tree_view_, kTreeWidth, kTreeHeight);
177
178 tree_selection_ = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view_)); 162 tree_selection_ = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view_));
179 163
180 GtkTreePath* path = NULL; 164 GtkTreePath* path = NULL;
181 if (selected_id) { 165 if (selected_id) {
182 path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree_store_), 166 path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree_store_),
183 &selected_iter); 167 &selected_iter);
184 } else { 168 } else {
185 // We don't have a selected parent (Probably because we're making a new 169 // We don't have a selected parent (Probably because we're making a new
186 // bookmark). Select the first item in the list. 170 // bookmark). Select the first item in the list.
187 path = gtk_tree_path_new_from_string("0"); 171 path = gtk_tree_path_new_from_string("0");
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 376
393 GtkTreeIter new_item_iter; 377 GtkTreeIter new_item_iter;
394 dialog->AddNewGroup(&iter, &new_item_iter); 378 dialog->AddNewGroup(&iter, &new_item_iter);
395 379
396 GtkTreePath* path = gtk_tree_model_get_path( 380 GtkTreePath* path = gtk_tree_model_get_path(
397 GTK_TREE_MODEL(dialog->tree_store_), &new_item_iter); 381 GTK_TREE_MODEL(dialog->tree_store_), &new_item_iter);
398 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(dialog->tree_view_), path); 382 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(dialog->tree_view_), path);
399 gtk_tree_selection_select_path(dialog->tree_selection_, path); 383 gtk_tree_selection_select_path(dialog->tree_selection_, path);
400 gtk_tree_path_free(path); 384 gtk_tree_path_free(path);
401 } 385 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gtk/bookmark_manager_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698