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

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

Issue 551214: GTK: Make page and app menus shortcut control flow match windows more closely... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 10 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/browser_toolbar_gtk.h ('k') | chrome/browser/gtk/browser_window_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/browser_toolbar_gtk.h" 5 #include "chrome/browser/gtk/browser_toolbar_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <X11/XF86keysym.h> 9 #include <X11/XF86keysym.h>
10 10
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 app_menu_.reset(new MenuGtk(this, &app_menu_model_)); 224 app_menu_.reset(new MenuGtk(this, &app_menu_model_));
225 gtk_box_pack_start(GTK_BOX(menus_hbox_), chrome_menu, FALSE, FALSE, 0); 225 gtk_box_pack_start(GTK_BOX(menus_hbox_), chrome_menu, FALSE, FALSE, 0);
226 226
227 gtk_box_pack_start(GTK_BOX(toolbar_), menus_hbox_, FALSE, FALSE, 0); 227 gtk_box_pack_start(GTK_BOX(toolbar_), menus_hbox_, FALSE, FALSE, 0);
228 228
229 // Page and app menu accelerators. 229 // Page and app menu accelerators.
230 GtkAccelGroup* accel_group = gtk_accel_group_new(); 230 GtkAccelGroup* accel_group = gtk_accel_group_new();
231 gtk_window_add_accel_group(top_level_window, accel_group); 231 gtk_window_add_accel_group(top_level_window, accel_group);
232 // Drop the initial ref on |accel_group| so |window_| will own it. 232 // Drop the initial ref on |accel_group| so |window_| will own it.
233 g_object_unref(accel_group); 233 g_object_unref(accel_group);
mattm 2010/01/30 01:11:04 should accel_group be removed too?
234 // I would use "popup-menu" here, but GTK complains. I would use "activate",
235 // but the docs say never to connect to that signal.
236 gtk_widget_add_accelerator(page_menu, "clicked", accel_group,
237 GDK_e, GDK_MOD1_MASK,
238 static_cast<GtkAccelFlags>(0));
239 gtk_widget_add_accelerator(chrome_menu, "clicked", accel_group,
240 GDK_f, GDK_MOD1_MASK,
241 static_cast<GtkAccelFlags>(0));
242 234
243 if (ShouldOnlyShowLocation()) { 235 if (ShouldOnlyShowLocation()) {
244 gtk_widget_show(event_box_); 236 gtk_widget_show(event_box_);
245 gtk_widget_show(alignment_); 237 gtk_widget_show(alignment_);
246 gtk_widget_show(toolbar_); 238 gtk_widget_show(toolbar_);
247 gtk_widget_show_all(location_hbox); 239 gtk_widget_show_all(location_hbox);
248 gtk_widget_hide(star_->widget()); 240 gtk_widget_hide(star_->widget());
249 gtk_widget_hide(go_->widget()); 241 gtk_widget_hide(go_->widget());
250 } else { 242 } else {
251 gtk_widget_show_all(event_box_); 243 gtk_widget_show_all(event_box_);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 285 }
294 286
295 void BrowserToolbarGtk::UpdateForBookmarkBarVisibility( 287 void BrowserToolbarGtk::UpdateForBookmarkBarVisibility(
296 bool show_bottom_padding) { 288 bool show_bottom_padding) {
297 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 289 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_),
298 ShouldOnlyShowLocation() ? 0 : kTopPadding, 290 ShouldOnlyShowLocation() ? 0 : kTopPadding,
299 !show_bottom_padding || ShouldOnlyShowLocation() ? 0 : kTopPadding, 291 !show_bottom_padding || ShouldOnlyShowLocation() ? 0 : kTopPadding,
300 kLeftRightPadding, kLeftRightPadding); 292 kLeftRightPadding, kLeftRightPadding);
301 } 293 }
302 294
295 void BrowserToolbarGtk::ShowPageMenu() {
296 PopupForButton(page_menu_button_.get());
297 }
298
299 void BrowserToolbarGtk::ShowAppMenu() {
300 PopupForButton(app_menu_button_.get());
301 }
302
303 // CommandUpdater::CommandObserver --------------------------------------------- 303 // CommandUpdater::CommandObserver ---------------------------------------------
304 304
305 void BrowserToolbarGtk::EnabledStateChangedForCommand(int id, bool enabled) { 305 void BrowserToolbarGtk::EnabledStateChangedForCommand(int id, bool enabled) {
306 GtkWidget* widget = NULL; 306 GtkWidget* widget = NULL;
307 switch (id) { 307 switch (id) {
308 case IDC_BACK: 308 case IDC_BACK:
309 widget = back_->widget(); 309 widget = back_->widget();
310 break; 310 break;
311 case IDC_FORWARD: 311 case IDC_FORWARD:
312 widget = forward_->widget(); 312 widget = forward_->widget();
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 505
506 GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton( 506 GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton(
507 const std::string& localized_tooltip, 507 const std::string& localized_tooltip,
508 OwnedWidgetGtk* owner) { 508 OwnedWidgetGtk* owner) {
509 GtkWidget* button = theme_provider_->BuildChromeButton(); 509 GtkWidget* button = theme_provider_->BuildChromeButton();
510 owner->Own(button); 510 owner->Own(button);
511 511
512 gtk_widget_set_tooltip_text(button, localized_tooltip.c_str()); 512 gtk_widget_set_tooltip_text(button, localized_tooltip.c_str());
513 g_signal_connect(button, "button-press-event", 513 g_signal_connect(button, "button-press-event",
514 G_CALLBACK(OnMenuButtonPressEvent), this); 514 G_CALLBACK(OnMenuButtonPressEvent), this);
515 g_signal_connect(button, "clicked",
516 G_CALLBACK(OnMenuClicked), this);
517 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); 515 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
518 516
519 return button; 517 return button;
520 } 518 }
521 519
522 void BrowserToolbarGtk::SetUpDragForHomeButton() { 520 void BrowserToolbarGtk::SetUpDragForHomeButton() {
523 gtk_drag_dest_set(home_->widget(), GTK_DEST_DEFAULT_ALL, 521 gtk_drag_dest_set(home_->widget(), GTK_DEST_DEFAULT_ALL,
524 NULL, 0, GDK_ACTION_COPY); 522 NULL, 0, GDK_ACTION_COPY);
525 static const int targets[] = { GtkDndUtil::TEXT_PLAIN, 523 static const int targets[] = { GtkDndUtil::TEXT_PLAIN,
526 GtkDndUtil::TEXT_URI_LIST, -1 }; 524 GtkDndUtil::TEXT_URI_LIST, -1 };
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 GTK_STATE_ACTIVE); 653 GTK_STATE_ACTIVE);
656 MenuGtk* menu = button == toolbar->page_menu_button_.get() ? 654 MenuGtk* menu = button == toolbar->page_menu_button_.get() ?
657 toolbar->page_menu_.get() : toolbar->app_menu_.get(); 655 toolbar->page_menu_.get() : toolbar->app_menu_.get();
658 menu->Popup(button, reinterpret_cast<GdkEvent*>(event)); 656 menu->Popup(button, reinterpret_cast<GdkEvent*>(event));
659 toolbar->menu_bar_helper_.MenuStartedShowing(button, menu->widget()); 657 toolbar->menu_bar_helper_.MenuStartedShowing(button, menu->widget());
660 658
661 return TRUE; 659 return TRUE;
662 } 660 }
663 661
664 // static 662 // static
665 gboolean BrowserToolbarGtk::OnMenuClicked(GtkWidget* button,
666 BrowserToolbarGtk* toolbar) {
667 toolbar->PopupForButton(button);
668
669 return TRUE;
670 }
671
672 // static
673 void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, 663 void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget,
674 GdkDragContext* drag_context, gint x, gint y, 664 GdkDragContext* drag_context, gint x, gint y,
675 GtkSelectionData* data, guint info, guint time, 665 GtkSelectionData* data, guint info, guint time,
676 BrowserToolbarGtk* toolbar) { 666 BrowserToolbarGtk* toolbar) {
677 if (info != GtkDndUtil::TEXT_PLAIN) { 667 if (info != GtkDndUtil::TEXT_PLAIN) {
678 NOTIMPLEMENTED() << "Only support plain text drops for now, sorry!"; 668 NOTIMPLEMENTED() << "Only support plain text drops for now, sorry!";
679 return; 669 return;
680 } 670 }
681 671
682 GURL url(reinterpret_cast<char*>(data->data)); 672 GURL url(reinterpret_cast<char*>(data->data));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 menu->PopupAsFromKeyEvent(button); 723 menu->PopupAsFromKeyEvent(button);
734 menu_bar_helper_.MenuStartedShowing(button, menu->widget()); 724 menu_bar_helper_.MenuStartedShowing(button, menu->widget());
735 } 725 }
736 726
737 void BrowserToolbarGtk::PopupForButtonNextTo(GtkWidget* button, 727 void BrowserToolbarGtk::PopupForButtonNextTo(GtkWidget* button,
738 GtkMenuDirectionType dir) { 728 GtkMenuDirectionType dir) {
739 GtkWidget* other_button = button == page_menu_button_.get() ? 729 GtkWidget* other_button = button == page_menu_button_.get() ?
740 app_menu_button_.get() : page_menu_button_.get(); 730 app_menu_button_.get() : page_menu_button_.get();
741 PopupForButton(other_button); 731 PopupForButton(other_button);
742 } 732 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_toolbar_gtk.h ('k') | chrome/browser/gtk/browser_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698