OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 GTK_WIDGET_UNSET_FLAGS(wrench_button, GTK_CAN_FOCUS); | 220 GTK_WIDGET_UNSET_FLAGS(wrench_button, GTK_CAN_FOCUS); |
221 | 221 |
222 // Put the wrench button in a box so that we can paint the update notification | 222 // Put the wrench button in a box so that we can paint the update notification |
223 // over it. | 223 // over it. |
224 GtkWidget* wrench_box = gtk_alignment_new(0, 0, 1, 1); | 224 GtkWidget* wrench_box = gtk_alignment_new(0, 0, 1, 1); |
225 g_signal_connect_after(wrench_box, "expose-event", | 225 g_signal_connect_after(wrench_box, "expose-event", |
226 G_CALLBACK(OnWrenchMenuButtonExposeThunk), this); | 226 G_CALLBACK(OnWrenchMenuButtonExposeThunk), this); |
227 gtk_container_add(GTK_CONTAINER(wrench_box), wrench_button); | 227 gtk_container_add(GTK_CONTAINER(wrench_box), wrench_button); |
228 gtk_box_pack_start(GTK_BOX(toolbar_), wrench_box, FALSE, FALSE, 4); | 228 gtk_box_pack_start(GTK_BOX(toolbar_), wrench_box, FALSE, FALSE, 4); |
229 | 229 |
230 wrench_menu_.reset(new MenuGtk(this, &wrench_menu_model_)); | 230 wrench_menu_.reset(new MenuGtk(this, wrench_menu_model_.menu_model())); |
231 g_signal_connect(wrench_menu_->widget(), "show", | 231 g_signal_connect(wrench_menu_->widget(), "show", |
232 G_CALLBACK(OnWrenchMenuShowThunk), this); | 232 G_CALLBACK(OnWrenchMenuShowThunk), this); |
233 | 233 |
234 if (ShouldOnlyShowLocation()) { | 234 if (ShouldOnlyShowLocation()) { |
235 gtk_widget_show(event_box_); | 235 gtk_widget_show(event_box_); |
236 gtk_widget_show(alignment_); | 236 gtk_widget_show(alignment_); |
237 gtk_widget_show(toolbar_); | 237 gtk_widget_show(toolbar_); |
238 gtk_widget_show_all(location_hbox_); | 238 gtk_widget_show_all(location_hbox_); |
239 gtk_widget_hide(reload_->widget()); | 239 gtk_widget_hide(reload_->widget()); |
240 } else { | 240 } else { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 // event is not sent when clicking a button brings up the menu. | 326 // event is not sent when clicking a button brings up the menu. |
327 gtk_chrome_button_set_hover_state( | 327 gtk_chrome_button_set_hover_state( |
328 GTK_CHROME_BUTTON(wrench_menu_button_->widget()), 0.0); | 328 GTK_CHROME_BUTTON(wrench_menu_button_->widget()), 0.0); |
329 wrench_menu_button_->UnsetPaintOverride(); | 329 wrench_menu_button_->UnsetPaintOverride(); |
330 } | 330 } |
331 | 331 |
332 GtkIconSet* BrowserToolbarGtk::GetIconSetForId(int idr) { | 332 GtkIconSet* BrowserToolbarGtk::GetIconSetForId(int idr) { |
333 return theme_provider_->GetIconSetForId(idr); | 333 return theme_provider_->GetIconSetForId(idr); |
334 } | 334 } |
335 | 335 |
336 // menus::SimpleMenuModel::Delegate | 336 // menus::AcceleratorProvider |
337 | |
338 bool BrowserToolbarGtk::IsCommandIdEnabled(int id) const { | |
339 return browser_->command_updater()->IsCommandEnabled(id); | |
340 } | |
341 | |
342 bool BrowserToolbarGtk::IsCommandIdChecked(int id) const { | |
343 if (!profile_) | |
344 return false; | |
345 | |
346 EncodingMenuController controller; | |
347 if (id == IDC_SHOW_BOOKMARK_BAR) { | |
348 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | |
349 } else if (controller.DoesCommandBelongToEncodingMenu(id)) { | |
350 TabContents* tab_contents = browser_->GetSelectedTabContents(); | |
351 if (tab_contents) { | |
352 return controller.IsItemChecked(profile_, tab_contents->encoding(), | |
353 id); | |
354 } | |
355 } | |
356 | |
357 return false; | |
358 } | |
359 | |
360 void BrowserToolbarGtk::ExecuteCommand(int id) { | |
361 browser_->ExecuteCommand(id); | |
362 } | |
363 | 337 |
364 bool BrowserToolbarGtk::GetAcceleratorForCommandId( | 338 bool BrowserToolbarGtk::GetAcceleratorForCommandId( |
365 int id, | 339 int id, |
366 menus::Accelerator* accelerator) { | 340 menus::Accelerator* accelerator) { |
367 const menus::AcceleratorGtk* accelerator_gtk = | 341 const menus::AcceleratorGtk* accelerator_gtk = |
368 Singleton<AcceleratorsGtk>()->GetPrimaryAcceleratorForCommand(id); | 342 Singleton<AcceleratorsGtk>()->GetPrimaryAcceleratorForCommand(id); |
369 if (accelerator_gtk) | 343 if (accelerator_gtk) |
370 *accelerator = *accelerator_gtk; | 344 *accelerator = *accelerator_gtk; |
371 return !!accelerator_gtk; | 345 return !!accelerator_gtk; |
372 } | 346 } |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 687 |
714 return FALSE; | 688 return FALSE; |
715 } | 689 } |
716 | 690 |
717 bool BrowserToolbarGtk::UpgradeAnimationIsFaded() { | 691 bool BrowserToolbarGtk::UpgradeAnimationIsFaded() { |
718 return upgrade_reminder_animation_.cycles_remaining() > 0 && | 692 return upgrade_reminder_animation_.cycles_remaining() > 0 && |
719 // This funky looking math makes the badge throb for 2 seconds once | 693 // This funky looking math makes the badge throb for 2 seconds once |
720 // every 8 seconds. | 694 // every 8 seconds. |
721 ((upgrade_reminder_animation_.cycles_remaining() - 1) / 2) % 4 == 0; | 695 ((upgrade_reminder_animation_.cycles_remaining() - 1) / 2) % 4 == 0; |
722 } | 696 } |
OLD | NEW |