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 #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/gtk_dnd_util.h" | 10 #include "app/gtk_dnd_util.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 gtk_widget_show_all(window_); | 316 gtk_widget_show_all(window_); |
317 } | 317 } |
318 | 318 |
319 BookmarkManagerGtk::~BookmarkManagerGtk() { | 319 BookmarkManagerGtk::~BookmarkManagerGtk() { |
320 g_browser_process->local_state()->SetInteger( | 320 g_browser_process->local_state()->SetInteger( |
321 prefs::kBookmarkManagerSplitLocation, | 321 prefs::kBookmarkManagerSplitLocation, |
322 gtk_paned_get_position(GTK_PANED(paned_))); | 322 gtk_paned_get_position(GTK_PANED(paned_))); |
323 SaveColumnConfiguration(); | 323 SaveColumnConfiguration(); |
324 model_->RemoveObserver(this); | 324 model_->RemoveObserver(this); |
| 325 |
| 326 gtk_accel_group_disconnect_key(accel_group_, GDK_w, GDK_CONTROL_MASK); |
| 327 gtk_window_remove_accel_group(GTK_WINDOW(window_), accel_group_); |
| 328 g_object_unref(accel_group_); |
325 } | 329 } |
326 | 330 |
327 void BookmarkManagerGtk::InitWidgets() { | 331 void BookmarkManagerGtk::InitWidgets() { |
328 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 332 window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
329 gtk_window_set_title(GTK_WINDOW(window_), | 333 gtk_window_set_title(GTK_WINDOW(window_), |
330 l10n_util::GetStringUTF8(IDS_BOOKMARK_MANAGER_TITLE).c_str()); | 334 l10n_util::GetStringUTF8(IDS_BOOKMARK_MANAGER_TITLE).c_str()); |
331 g_signal_connect( | 335 g_signal_connect( |
332 window_, "configure-event", G_CALLBACK(OnWindowConfiguredThunk), this); | 336 window_, "configure-event", G_CALLBACK(OnWindowConfiguredThunk), this); |
333 g_signal_connect( | 337 g_signal_connect( |
334 window_, "destroy", G_CALLBACK(OnWindowDestroyedThunk), this); | 338 window_, "destroy", G_CALLBACK(OnWindowDestroyedThunk), this); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } | 413 } |
410 gtk_paned_set_position(GTK_PANED(paned_), split_x); | 414 gtk_paned_set_position(GTK_PANED(paned_), split_x); |
411 | 415 |
412 GtkWidget* vbox = gtk_vbox_new(FALSE, 0); | 416 GtkWidget* vbox = gtk_vbox_new(FALSE, 0); |
413 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 417 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
414 gtk_box_pack_start(GTK_BOX(vbox), paned_, TRUE, TRUE, 0); | 418 gtk_box_pack_start(GTK_BOX(vbox), paned_, TRUE, TRUE, 0); |
415 gtk_container_add(GTK_CONTAINER(window_), vbox); | 419 gtk_container_add(GTK_CONTAINER(window_), vbox); |
416 } | 420 } |
417 | 421 |
418 void BookmarkManagerGtk::ConnectAccelerators() { | 422 void BookmarkManagerGtk::ConnectAccelerators() { |
419 GtkAccelGroup* accel_group = gtk_accel_group_new(); | 423 accel_group_ = gtk_accel_group_new(); |
420 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group); | 424 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group_); |
421 | 425 |
422 // Drop the initial ref on |accel_group| so |window_| will own it. | 426 gtk_accel_group_connect(accel_group_, |
423 g_object_unref(accel_group); | |
424 | |
425 gtk_accel_group_connect(accel_group, | |
426 GDK_w, GDK_CONTROL_MASK, GtkAccelFlags(0), | 427 GDK_w, GDK_CONTROL_MASK, GtkAccelFlags(0), |
427 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), | 428 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), |
428 this, NULL)); | 429 this, NULL)); |
429 } | 430 } |
430 | 431 |
431 GtkWidget* BookmarkManagerGtk::MakeLeftPane() { | 432 GtkWidget* BookmarkManagerGtk::MakeLeftPane() { |
432 left_store_ = bookmark_utils::MakeFolderTreeStore(); | 433 left_store_ = bookmark_utils::MakeFolderTreeStore(); |
433 left_tree_view_ = bookmark_utils::MakeTreeViewForStore(left_store_); | 434 left_tree_view_ = bookmark_utils::MakeTreeViewForStore(left_store_); |
434 | 435 |
435 // When a row is collapsed that contained the selected node, we want to select | 436 // When a row is collapsed that contained the selected node, we want to select |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 modifier & gtk_accelerator_get_default_mod_mask()); | 1416 modifier & gtk_accelerator_get_default_mod_mask()); |
1416 // The only accelerator we have registered is ctrl+w, so any other value is a | 1417 // The only accelerator we have registered is ctrl+w, so any other value is a |
1417 // non-fatal error. | 1418 // non-fatal error. |
1418 DCHECK_EQ(keyval, static_cast<guint>(GDK_w)); | 1419 DCHECK_EQ(keyval, static_cast<guint>(GDK_w)); |
1419 DCHECK_EQ(modifier, GDK_CONTROL_MASK); | 1420 DCHECK_EQ(modifier, GDK_CONTROL_MASK); |
1420 | 1421 |
1421 gtk_widget_destroy(bookmark_manager->window_); | 1422 gtk_widget_destroy(bookmark_manager->window_); |
1422 | 1423 |
1423 return TRUE; | 1424 return TRUE; |
1424 } | 1425 } |
OLD | NEW |