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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/gtk/browser_toolbar_gtk.h" 5 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
6 6
7 #include <X11/XF86keysym.h> 7 #include <X11/XF86keysym.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 wrench_menu_model_(this, browser), 90 wrench_menu_model_(this, browser),
91 browser_(browser), 91 browser_(browser),
92 window_(window), 92 window_(window),
93 profile_(NULL) { 93 profile_(NULL) {
94 browser_->command_updater()->AddCommandObserver(IDC_BACK, this); 94 browser_->command_updater()->AddCommandObserver(IDC_BACK, this);
95 browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this); 95 browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this);
96 browser_->command_updater()->AddCommandObserver(IDC_HOME, this); 96 browser_->command_updater()->AddCommandObserver(IDC_HOME, this);
97 browser_->command_updater()->AddCommandObserver(IDC_BOOKMARK_PAGE, this); 97 browser_->command_updater()->AddCommandObserver(IDC_BOOKMARK_PAGE, this);
98 98
99 registrar_.Add(this, 99 registrar_.Add(this,
100 NotificationType::BROWSER_THEME_CHANGED, 100 chrome::BROWSER_THEME_CHANGED,
101 NotificationService::AllSources()); 101 NotificationService::AllSources());
102 registrar_.Add(this, 102 registrar_.Add(this,
103 NotificationType::UPGRADE_RECOMMENDED, 103 chrome::UPGRADE_RECOMMENDED,
104 NotificationService::AllSources()); 104 NotificationService::AllSources());
105 } 105 }
106 106
107 BrowserToolbarGtk::~BrowserToolbarGtk() { 107 BrowserToolbarGtk::~BrowserToolbarGtk() {
108 browser_->command_updater()->RemoveCommandObserver(IDC_BACK, this); 108 browser_->command_updater()->RemoveCommandObserver(IDC_BACK, this);
109 browser_->command_updater()->RemoveCommandObserver(IDC_FORWARD, this); 109 browser_->command_updater()->RemoveCommandObserver(IDC_FORWARD, this);
110 browser_->command_updater()->RemoveCommandObserver(IDC_HOME, this); 110 browser_->command_updater()->RemoveCommandObserver(IDC_HOME, this);
111 browser_->command_updater()->RemoveCommandObserver(IDC_BOOKMARK_PAGE, this); 111 browser_->command_updater()->RemoveCommandObserver(IDC_BOOKMARK_PAGE, this);
112 112
113 offscreen_entry_.Destroy(); 113 offscreen_entry_.Destroy();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 // Put the wrench button in a box so that we can paint the update notification 216 // Put the wrench button in a box so that we can paint the update notification
217 // over it. 217 // over it.
218 GtkWidget* wrench_box = gtk_alignment_new(0, 0, 1, 1); 218 GtkWidget* wrench_box = gtk_alignment_new(0, 0, 1, 1);
219 g_signal_connect_after(wrench_box, "expose-event", 219 g_signal_connect_after(wrench_box, "expose-event",
220 G_CALLBACK(OnWrenchMenuButtonExposeThunk), this); 220 G_CALLBACK(OnWrenchMenuButtonExposeThunk), this);
221 gtk_container_add(GTK_CONTAINER(wrench_box), wrench_button); 221 gtk_container_add(GTK_CONTAINER(wrench_box), wrench_button);
222 gtk_box_pack_start(GTK_BOX(toolbar_), wrench_box, FALSE, FALSE, 4); 222 gtk_box_pack_start(GTK_BOX(toolbar_), wrench_box, FALSE, FALSE, 4);
223 223
224 wrench_menu_.reset(new MenuGtk(this, &wrench_menu_model_)); 224 wrench_menu_.reset(new MenuGtk(this, &wrench_menu_model_));
225 registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED, 225 registrar_.Add(this, chrome::ZOOM_LEVEL_CHANGED,
226 Source<HostZoomMap>(browser_->profile()->GetHostZoomMap())); 226 Source<HostZoomMap>(browser_->profile()->GetHostZoomMap()));
227 227
228 if (ShouldOnlyShowLocation()) { 228 if (ShouldOnlyShowLocation()) {
229 gtk_widget_show(event_box_); 229 gtk_widget_show(event_box_);
230 gtk_widget_show(alignment_); 230 gtk_widget_show(alignment_);
231 gtk_widget_show(toolbar_); 231 gtk_widget_show(toolbar_);
232 gtk_widget_show_all(location_hbox_); 232 gtk_widget_show_all(location_hbox_);
233 gtk_widget_hide(reload_->widget()); 233 gtk_widget_hide(reload_->widget());
234 } else { 234 } else {
235 gtk_widget_show_all(event_box_); 235 gtk_widget_show_all(event_box_);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (accelerator_gtk) 342 if (accelerator_gtk)
343 *accelerator = *accelerator_gtk; 343 *accelerator = *accelerator_gtk;
344 return !!accelerator_gtk; 344 return !!accelerator_gtk;
345 } 345 }
346 346
347 // NotificationObserver -------------------------------------------------------- 347 // NotificationObserver --------------------------------------------------------
348 348
349 void BrowserToolbarGtk::Observe(NotificationType type, 349 void BrowserToolbarGtk::Observe(NotificationType type,
350 const NotificationSource& source, 350 const NotificationSource& source,
351 const NotificationDetails& details) { 351 const NotificationDetails& details) {
352 if (type == NotificationType::PREF_CHANGED) { 352 if (type == chrome::PREF_CHANGED) {
353 NotifyPrefChanged(Details<std::string>(details).ptr()); 353 NotifyPrefChanged(Details<std::string>(details).ptr());
354 } else if (type == NotificationType::BROWSER_THEME_CHANGED) { 354 } else if (type == chrome::BROWSER_THEME_CHANGED) {
355 // Update the spacing around the menu buttons 355 // Update the spacing around the menu buttons
356 bool use_gtk = theme_service_->UsingNativeTheme(); 356 bool use_gtk = theme_service_->UsingNativeTheme();
357 int border = use_gtk ? 0 : 2; 357 int border = use_gtk ? 0 : 2;
358 gtk_container_set_border_width( 358 gtk_container_set_border_width(
359 GTK_CONTAINER(wrench_menu_button_->widget()), border); 359 GTK_CONTAINER(wrench_menu_button_->widget()), border);
360 360
361 // Force the height of the toolbar so we get the right amount of padding 361 // Force the height of the toolbar so we get the right amount of padding
362 // above and below the location bar. We always force the size of the widgets 362 // above and below the location bar. We always force the size of the widgets
363 // to either side of the location box, but we only force the location box 363 // to either side of the location box, but we only force the location box
364 // size in chrome-theme mode because that's the only time we try to control 364 // size in chrome-theme mode because that's the only time we try to control
(...skipping 12 matching lines...) Expand all
377 377
378 if (use_gtk) { 378 if (use_gtk) {
379 // We need to manually update the icon if we are in GTK mode. (Note that 379 // We need to manually update the icon if we are in GTK mode. (Note that
380 // we set the initial value in Init()). 380 // we set the initial value in Init()).
381 gtk_image_set_from_pixbuf( 381 gtk_image_set_from_pixbuf(
382 GTK_IMAGE(wrench_menu_image_), 382 GTK_IMAGE(wrench_menu_image_),
383 theme_service_->GetRTLEnabledPixbufNamed(IDR_TOOLS)); 383 theme_service_->GetRTLEnabledPixbufNamed(IDR_TOOLS));
384 } 384 }
385 385
386 UpdateRoundedness(); 386 UpdateRoundedness();
387 } else if (type == NotificationType::UPGRADE_RECOMMENDED) { 387 } else if (type == chrome::UPGRADE_RECOMMENDED) {
388 // Redraw the wrench menu to update the badge. 388 // Redraw the wrench menu to update the badge.
389 gtk_widget_queue_draw(wrench_menu_button_->widget()); 389 gtk_widget_queue_draw(wrench_menu_button_->widget());
390 } else if (type == NotificationType::ZOOM_LEVEL_CHANGED) { 390 } else if (type == chrome::ZOOM_LEVEL_CHANGED) {
391 // If our zoom level changed, we need to tell the menu to update its state, 391 // If our zoom level changed, we need to tell the menu to update its state,
392 // since the menu could still be open. 392 // since the menu could still be open.
393 wrench_menu_->UpdateMenu(); 393 wrench_menu_->UpdateMenu();
394 } else { 394 } else {
395 NOTREACHED(); 395 NOTREACHED();
396 } 396 }
397 } 397 }
398 398
399 // BrowserToolbarGtk, public --------------------------------------------------- 399 // BrowserToolbarGtk, public ---------------------------------------------------
400 400
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 int x_offset = base::i18n::IsRTL() ? 0 : 647 int x_offset = base::i18n::IsRTL() ? 0 :
648 sender->allocation.width - badge->width(); 648 sender->allocation.width - badge->width();
649 int y_offset = 0; 649 int y_offset = 0;
650 canvas.DrawBitmapInt( 650 canvas.DrawBitmapInt(
651 *badge, 651 *badge,
652 sender->allocation.x + x_offset, 652 sender->allocation.x + x_offset,
653 sender->allocation.y + y_offset); 653 sender->allocation.y + y_offset);
654 654
655 return FALSE; 655 return FALSE;
656 } 656 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698