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

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

Issue 115792: Control spacing of toolbar elements with pixels rather than " " GtkLabels.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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') | no next file » | 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 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/common/pref_service.h" 30 #include "chrome/common/pref_service.h"
31 #include "grit/chromium_strings.h" 31 #include "grit/chromium_strings.h"
32 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
33 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
34 34
35 namespace { 35 namespace {
36 36
37 // Height of the toolbar in pixels. 37 // Height of the toolbar in pixels.
38 const int kToolbarHeight = 37; 38 const int kToolbarHeight = 37;
39 39
40 // Interior spacing between toolbar buttons (for those that have any spacing).
41 const int kButtonSpacing = 6;
42
40 // The amount of space between the bottom of the star and the top of the 43 // The amount of space between the bottom of the star and the top of the
41 // Omnibox results popup window. We want a two pixel space between the bottom 44 // Omnibox results popup window. We want a two pixel space between the bottom
42 // and the results, but have some extra space below the buttons already. 45 // and the results, but have some extra space below the buttons already.
43 const int kPopupTopMargin = 0; 46 const int kPopupTopMargin = 0;
44 47
45 // Space between the edge of the star/go button and the popup frame. We want 48 // Space between the edge of the star/go button and the popup frame. We want
46 // to leave 1 pixel on both side here so that the borders line up. 49 // to leave 1 pixel on both side here so that the borders line up.
47 const int kPopupLeftRightMargin = 1; 50 const int kPopupLeftRightMargin = 1;
48 51
49 } // namespace 52 } // namespace
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 back_.reset(new BackForwardButtonGtk(browser_, false)); 106 back_.reset(new BackForwardButtonGtk(browser_, false));
104 gtk_box_pack_start(GTK_BOX(toolbar_), back_->widget(), FALSE, FALSE, 0); 107 gtk_box_pack_start(GTK_BOX(toolbar_), back_->widget(), FALSE, FALSE, 0);
105 AddAcceleratorToButton(back_->widget(), GDK_Left, GDK_MOD1_MASK); 108 AddAcceleratorToButton(back_->widget(), GDK_Left, GDK_MOD1_MASK);
106 AddAcceleratorToButton(back_->widget(), GDK_BackSpace, 0); 109 AddAcceleratorToButton(back_->widget(), GDK_BackSpace, 0);
107 110
108 forward_.reset(new BackForwardButtonGtk(browser_, true)); 111 forward_.reset(new BackForwardButtonGtk(browser_, true));
109 gtk_box_pack_start(GTK_BOX(toolbar_), forward_->widget(), FALSE, FALSE, 0); 112 gtk_box_pack_start(GTK_BOX(toolbar_), forward_->widget(), FALSE, FALSE, 0);
110 AddAcceleratorToButton(forward_->widget(), GDK_Right, GDK_MOD1_MASK); 113 AddAcceleratorToButton(forward_->widget(), GDK_Right, GDK_MOD1_MASK);
111 AddAcceleratorToButton(forward_->widget(), GDK_BackSpace, GDK_SHIFT_MASK); 114 AddAcceleratorToButton(forward_->widget(), GDK_BackSpace, GDK_SHIFT_MASK);
112 115
113 // TODO(estade): These blank labels will change size when the user changes
114 // system font size. We should hard code their size in pixels.
115 gtk_box_pack_start(GTK_BOX(toolbar_), gtk_label_new(" "), FALSE, FALSE, 0);
116
117 reload_.reset(BuildToolbarButton(IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0, 116 reload_.reset(BuildToolbarButton(IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0,
118 l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD))); 117 l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD), kButtonSpacing));
119 AddAcceleratorToButton(reload_->widget(), 118 AddAcceleratorToButton(reload_->widget(),
120 GDK_r, GDK_CONTROL_MASK); 119 GDK_r, GDK_CONTROL_MASK);
121 // Any modifier except alt can be combined with f5 (this matches windows 120 // Any modifier except alt can be combined with f5 (this matches windows
122 // chromium). 121 // chromium).
123 AddAcceleratorToButton(reload_->widget(), 122 AddAcceleratorToButton(reload_->widget(),
124 GDK_F5, GDK_MODIFIER_MASK & ~GDK_MOD1_MASK); 123 GDK_F5, GDK_MODIFIER_MASK & ~GDK_MOD1_MASK);
125 124
126 // TODO(port): we need to dynamically react to changes in show_home_button_ 125 // TODO(port): we need to dynamically react to changes in show_home_button_
127 // and hide/show home appropriately. But we don't have a UI for it yet. 126 // and hide/show home appropriately. But we don't have a UI for it yet.
128 if (*show_home_button_) 127 if (*show_home_button_)
129 home_.reset(MakeHomeButton()); 128 home_.reset(MakeHomeButton());
130 129
131 gtk_box_pack_start(GTK_BOX(toolbar_), gtk_label_new(" "), FALSE, FALSE, 0);
132
133 star_.reset(BuildStarButton(l10n_util::GetStringUTF8(IDS_TOOLTIP_STAR))); 130 star_.reset(BuildStarButton(l10n_util::GetStringUTF8(IDS_TOOLTIP_STAR)));
134 131
135 location_bar_->Init(); 132 location_bar_->Init();
136 gtk_box_pack_start(GTK_BOX(toolbar_), location_bar_->widget(), TRUE, TRUE, 0); 133 gtk_box_pack_start(GTK_BOX(toolbar_), location_bar_->widget(), TRUE, TRUE, 0);
137 134
138 go_.reset(new GoButtonGtk(location_bar_.get(), browser_)); 135 go_.reset(new GoButtonGtk(location_bar_.get(), browser_));
139 gtk_box_pack_start(GTK_BOX(toolbar_), go_->widget(), FALSE, FALSE, 0); 136 gtk_box_pack_start(GTK_BOX(toolbar_), go_->widget(), FALSE, FALSE, 0);
140 137
141 gtk_box_pack_start(GTK_BOX(toolbar_), gtk_label_new(" "), FALSE, FALSE, 0); 138 GtkWidget* spacing = gtk_label_new("");
139 gtk_widget_set_size_request(spacing, kButtonSpacing, -1);
140 gtk_box_pack_start(GTK_BOX(toolbar_), spacing, FALSE, FALSE, 0);
142 141
143 BuildToolbarMenuButton(IDR_MENU_PAGE, 142 BuildToolbarMenuButton(IDR_MENU_PAGE,
144 l10n_util::GetStringUTF8(IDS_PAGEMENU_TOOLTIP), 143 l10n_util::GetStringUTF8(IDS_PAGEMENU_TOOLTIP),
145 &page_menu_button_); 144 &page_menu_button_);
146 page_menu_.reset(new MenuGtk(this, GetStandardPageMenu(), accel_group_)); 145 page_menu_.reset(new MenuGtk(this, GetStandardPageMenu(), accel_group_));
147 146
148 BuildToolbarMenuButton(IDR_MENU_CHROME, 147 BuildToolbarMenuButton(IDR_MENU_CHROME,
149 l10n_util::GetStringFUTF8(IDS_APPMENU_TOOLTIP, 148 l10n_util::GetStringFUTF8(IDS_APPMENU_TOOLTIP,
150 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))), 149 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))),
151 &app_menu_button_); 150 &app_menu_button_);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 star_y += star->allocation.y + star->allocation.height; // Bottom edge. 269 star_y += star->allocation.y + star->allocation.height; // Bottom edge.
271 270
272 return gfx::Rect(star_x + kPopupLeftRightMargin, star_y + kPopupTopMargin, 271 return gfx::Rect(star_x + kPopupLeftRightMargin, star_y + kPopupTopMargin,
273 go_x - star_x - (2 * kPopupLeftRightMargin), 0); 272 go_x - star_x - (2 * kPopupLeftRightMargin), 0);
274 } 273 }
275 274
276 // BrowserToolbarGtk, private -------------------------------------------------- 275 // BrowserToolbarGtk, private --------------------------------------------------
277 276
278 CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton( 277 CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
279 int normal_id, int active_id, int highlight_id, int depressed_id, 278 int normal_id, int active_id, int highlight_id, int depressed_id,
280 const std::string& localized_tooltip) { 279 const std::string& localized_tooltip, int spacing) {
281 CustomDrawButton* button = new CustomDrawButton(normal_id, active_id, 280 CustomDrawButton* button = new CustomDrawButton(normal_id, active_id,
282 highlight_id, depressed_id); 281 highlight_id, depressed_id);
283 282
284 gtk_widget_set_tooltip_text(button->widget(), 283 gtk_widget_set_tooltip_text(button->widget(),
285 localized_tooltip.c_str()); 284 localized_tooltip.c_str());
286 g_signal_connect(button->widget(), "clicked", 285 g_signal_connect(button->widget(), "clicked",
287 G_CALLBACK(OnButtonClick), this); 286 G_CALLBACK(OnButtonClick), this);
288 287
289 gtk_box_pack_start(GTK_BOX(toolbar_), button->widget(), FALSE, FALSE, 0); 288 gtk_box_pack_start(GTK_BOX(toolbar_), button->widget(), FALSE, FALSE,
289 spacing);
290 return button; 290 return button;
291 } 291 }
292 292
293 ToolbarStarToggleGtk* BrowserToolbarGtk::BuildStarButton( 293 ToolbarStarToggleGtk* BrowserToolbarGtk::BuildStarButton(
294 const std::string& localized_tooltip) { 294 const std::string& localized_tooltip) {
295 ToolbarStarToggleGtk* button = new ToolbarStarToggleGtk; 295 ToolbarStarToggleGtk* button = new ToolbarStarToggleGtk;
296 296
297 gtk_widget_set_tooltip_text(button->widget(), 297 gtk_widget_set_tooltip_text(button->widget(),
298 localized_tooltip.c_str()); 298 localized_tooltip.c_str());
299 g_signal_connect(button->widget(), "clicked", 299 g_signal_connect(button->widget(), "clicked",
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 GtkWidget* widget, 377 GtkWidget* widget,
378 unsigned int accelerator, 378 unsigned int accelerator,
379 unsigned int accelerator_mod) { 379 unsigned int accelerator_mod) {
380 gtk_widget_add_accelerator( 380 gtk_widget_add_accelerator(
381 widget, "clicked", accel_group_, accelerator, 381 widget, "clicked", accel_group_, accelerator,
382 GdkModifierType(accelerator_mod), GtkAccelFlags(0)); 382 GdkModifierType(accelerator_mod), GtkAccelFlags(0));
383 } 383 }
384 384
385 CustomDrawButton* BrowserToolbarGtk::MakeHomeButton() { 385 CustomDrawButton* BrowserToolbarGtk::MakeHomeButton() {
386 return BuildToolbarButton(IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, 386 return BuildToolbarButton(IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0,
387 l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME)); 387 l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME), 0);
388 } 388 }
389 389
390 void BrowserToolbarGtk::InitNineBox() { 390 void BrowserToolbarGtk::InitNineBox() {
391 // TODO(estade): use |profile_|? 391 // TODO(estade): use |profile_|?
392 background_ninebox_.reset(new NineBox( 392 background_ninebox_.reset(new NineBox(
393 browser_->profile()->GetThemeProvider(), 393 browser_->profile()->GetThemeProvider(),
394 0, IDR_THEME_TOOLBAR, 0, 0, 0, 0, 0, 0, 0)); 394 0, IDR_THEME_TOOLBAR, 0, 0, 0, 0, 0, 0, 0));
395 } 395 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_toolbar_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698