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

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
« no previous file with comments | « chrome/browser/ui/gtk/browser_toolbar_gtk.h ('k') | chrome/browser/ui/gtk/browser_window_gtk.h » ('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) 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 18 matching lines...) Expand all
29 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" 29 #include "chrome/browser/ui/gtk/gtk_chrome_button.h"
30 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 30 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
31 #include "chrome/browser/ui/gtk/gtk_util.h" 31 #include "chrome/browser/ui/gtk/gtk_util.h"
32 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" 32 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
33 #include "chrome/browser/ui/gtk/reload_button_gtk.h" 33 #include "chrome/browser/ui/gtk/reload_button_gtk.h"
34 #include "chrome/browser/ui/gtk/rounded_window.h" 34 #include "chrome/browser/ui/gtk/rounded_window.h"
35 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" 35 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
36 #include "chrome/browser/ui/gtk/view_id_util.h" 36 #include "chrome/browser/ui/gtk/view_id_util.h"
37 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 37 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
38 #include "chrome/browser/upgrade_detector.h" 38 #include "chrome/browser/upgrade_detector.h"
39 #include "chrome/common/chrome_notification_types.h"
39 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
40 #include "chrome/common/url_constants.h" 41 #include "chrome/common/url_constants.h"
41 #include "content/browser/tab_contents/tab_contents.h" 42 #include "content/browser/tab_contents/tab_contents.h"
42 #include "content/browser/user_metrics.h" 43 #include "content/browser/user_metrics.h"
43 #include "content/common/notification_details.h" 44 #include "content/common/notification_details.h"
44 #include "content/common/notification_service.h" 45 #include "content/common/notification_service.h"
45 #include "content/common/notification_type.h"
46 #include "grit/chromium_strings.h" 46 #include "grit/chromium_strings.h"
47 #include "grit/generated_resources.h" 47 #include "grit/generated_resources.h"
48 #include "grit/theme_resources.h" 48 #include "grit/theme_resources.h"
49 #include "grit/theme_resources_standard.h" 49 #include "grit/theme_resources_standard.h"
50 #include "ui/base/dragdrop/gtk_dnd_util.h" 50 #include "ui/base/dragdrop/gtk_dnd_util.h"
51 #include "ui/base/l10n/l10n_util.h" 51 #include "ui/base/l10n/l10n_util.h"
52 #include "ui/base/models/accelerator_gtk.h" 52 #include "ui/base/models/accelerator_gtk.h"
53 #include "ui/gfx/canvas_skia_paint.h" 53 #include "ui/gfx/canvas_skia_paint.h"
54 #include "ui/gfx/gtk_util.h" 54 #include "ui/gfx/gtk_util.h"
55 #include "ui/gfx/skbitmap_operations.h" 55 #include "ui/gfx/skbitmap_operations.h"
(...skipping 34 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::NOTIFICATION_BROWSER_THEME_CHANGED,
101 NotificationService::AllSources()); 101 NotificationService::AllSources());
102 registrar_.Add(this, 102 registrar_.Add(this,
103 NotificationType::UPGRADE_RECOMMENDED, 103 chrome::NOTIFICATION_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, content::NOTIFICATION_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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 ui::Accelerator* accelerator) { 339 ui::Accelerator* accelerator) {
340 const ui::AcceleratorGtk* accelerator_gtk = 340 const ui::AcceleratorGtk* accelerator_gtk =
341 AcceleratorsGtk::GetInstance()->GetPrimaryAcceleratorForCommand(id); 341 AcceleratorsGtk::GetInstance()->GetPrimaryAcceleratorForCommand(id);
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(int 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::NOTIFICATION_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::NOTIFICATION_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::NOTIFICATION_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 == content::NOTIFICATION_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
« no previous file with comments | « chrome/browser/ui/gtk/browser_toolbar_gtk.h ('k') | chrome/browser/ui/gtk/browser_window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698