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

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

Issue 160422: Remember/restore the bookmark manager pane position. (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 | « chrome/browser/gtk/bookmark_manager_gtk.h ('k') | no next file » | 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_manager_gtk.h" 5 #include "chrome/browser/gtk/bookmark_manager_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 GtkUtil::SetWindowIcon(GTK_WINDOW(window_)); 324 GtkUtil::SetWindowIcon(GTK_WINDOW(window_));
325 325
326 model_->AddObserver(this); 326 model_->AddObserver(this);
327 if (model_->IsLoaded()) 327 if (model_->IsLoaded())
328 Loaded(model_); 328 Loaded(model_);
329 329
330 gtk_widget_show_all(window_); 330 gtk_widget_show_all(window_);
331 } 331 }
332 332
333 BookmarkManagerGtk::~BookmarkManagerGtk() { 333 BookmarkManagerGtk::~BookmarkManagerGtk() {
334 g_browser_process->local_state()->SetInteger(
335 prefs::kBookmarkManagerSplitLocation,
336 gtk_paned_get_position(GTK_PANED(paned_)));
334 SaveColumnConfiguration(); 337 SaveColumnConfiguration();
335 model_->RemoveObserver(this); 338 model_->RemoveObserver(this);
336 } 339 }
337 340
338 void BookmarkManagerGtk::InitWidgets() { 341 void BookmarkManagerGtk::InitWidgets() {
339 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); 342 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
340 gtk_window_set_title(GTK_WINDOW(window_), 343 gtk_window_set_title(GTK_WINDOW(window_),
341 l10n_util::GetStringUTF8(IDS_BOOKMARK_MANAGER_TITLE).c_str()); 344 l10n_util::GetStringUTF8(IDS_BOOKMARK_MANAGER_TITLE).c_str());
342 g_signal_connect( 345 g_signal_connect(
343 window_, "configure-event", G_CALLBACK(OnWindowConfiguredThunk), this); 346 window_, "configure-event", G_CALLBACK(OnWindowConfiguredThunk), this);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 G_CALLBACK(OnSearchTextChangedThunk), this); 399 G_CALLBACK(OnSearchTextChangedThunk), this);
397 400
398 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); 401 GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
399 gtk_box_pack_start(GTK_BOX(hbox), menu_bar, FALSE, FALSE, 0); 402 gtk_box_pack_start(GTK_BOX(hbox), menu_bar, FALSE, FALSE, 0);
400 gtk_box_pack_end(GTK_BOX(hbox), search_entry_, FALSE, FALSE, 0); 403 gtk_box_pack_end(GTK_BOX(hbox), search_entry_, FALSE, FALSE, 0);
401 gtk_box_pack_end(GTK_BOX(hbox), search_label, FALSE, FALSE, kSearchPadding); 404 gtk_box_pack_end(GTK_BOX(hbox), search_label, FALSE, FALSE, kSearchPadding);
402 405
403 GtkWidget* left_pane = MakeLeftPane(); 406 GtkWidget* left_pane = MakeLeftPane();
404 GtkWidget* right_pane = MakeRightPane(); 407 GtkWidget* right_pane = MakeRightPane();
405 408
406 GtkWidget* paned = gtk_hpaned_new(); 409 paned_ = gtk_hpaned_new();
410 gtk_paned_pack1(GTK_PANED(paned_), left_pane, FALSE, FALSE);
411 gtk_paned_pack2(GTK_PANED(paned_), right_pane, TRUE, FALSE);
412
407 // Set the initial position of the pane divider. 413 // Set the initial position of the pane divider.
408 gtk_paned_set_position(GTK_PANED(paned), width / 3); 414 int split_x = g_browser_process->local_state()->GetInteger(
409 gtk_paned_pack1(GTK_PANED(paned), left_pane, FALSE, FALSE); 415 prefs::kBookmarkManagerSplitLocation);
410 gtk_paned_pack2(GTK_PANED(paned), right_pane, TRUE, FALSE); 416 if (split_x == -1) {
417 split_x = width / 3;
418 } else {
419 int min_split_size = width / 8;
420 // Make sure the user can see both the tree/table.
421 split_x = std::min(width - min_split_size,
422 std::max(min_split_size, split_x));
423 }
424 gtk_paned_set_position(GTK_PANED(paned_), split_x);
411 425
412 GtkWidget* vbox = gtk_vbox_new(FALSE, 0); 426 GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
413 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 427 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
414 gtk_box_pack_start(GTK_BOX(vbox), paned, TRUE, TRUE, 0); 428 gtk_box_pack_start(GTK_BOX(vbox), paned_, TRUE, TRUE, 0);
415 gtk_container_add(GTK_CONTAINER(window_), vbox); 429 gtk_container_add(GTK_CONTAINER(window_), vbox);
416 430
417 ResetOrganizeMenu(true); 431 ResetOrganizeMenu(true);
418 } 432 }
419 433
420 GtkWidget* BookmarkManagerGtk::MakeLeftPane() { 434 GtkWidget* BookmarkManagerGtk::MakeLeftPane() {
421 left_store_ = bookmark_utils::MakeFolderTreeStore(); 435 left_store_ = bookmark_utils::MakeFolderTreeStore();
422 436
423 GtkTreeViewColumn* icon_column = gtk_tree_view_column_new_with_attributes( 437 GtkTreeViewColumn* icon_column = gtk_tree_view_column_new_with_attributes(
424 "", gtk_cell_renderer_pixbuf_new(), "pixbuf", bookmark_utils::FOLDER_ICON, 438 "", gtk_cell_renderer_pixbuf_new(), "pixbuf", bookmark_utils::FOLDER_ICON,
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) { 1405 } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) {
1392 if (g_browser_process->io_thread()) { 1406 if (g_browser_process->io_thread()) {
1393 bookmark_html_writer::WriteBookmarks( 1407 bookmark_html_writer::WriteBookmarks(
1394 g_browser_process->io_thread()->message_loop(), model_, 1408 g_browser_process->io_thread()->message_loop(), model_,
1395 path.ToWStringHack()); 1409 path.ToWStringHack());
1396 } 1410 }
1397 } else { 1411 } else {
1398 NOTREACHED(); 1412 NOTREACHED();
1399 } 1413 }
1400 } 1414 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/bookmark_manager_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698