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

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

Issue 10918275: [gtk] website settings bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: slightly simpler drawing Created 8 years, 3 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/website_settings/website_settings_popup_gtk.cc ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/zoom_bubble_gtk.h" 5 #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
12 #include "chrome/browser/ui/zoom/zoom_controller.h" 12 #include "chrome/browser/ui/zoom/zoom_controller.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "ui/base/gtk/gtk_hig_constants.h" 17 #include "ui/base/gtk/gtk_hig_constants.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
20 20
21 namespace { 21 namespace {
22 22
23 // Pointer to singleton object (NULL if no bubble is open). 23 // Pointer to singleton object (NULL if no bubble is open).
24 ZoomBubbleGtk* g_bubble = NULL; 24 ZoomBubbleGtk* g_bubble = NULL;
25 25
26 // Padding on each side of the percentage label and the left and right sides of
27 // the "Set to default" button.
28 const int kSidePadding = 5;
29
30 // Number of milliseconds the bubble should stay open for if it will auto-close. 26 // Number of milliseconds the bubble should stay open for if it will auto-close.
31 const int kBubbleCloseDelay = 1500; 27 const int kBubbleCloseDelay = 1500;
32 28
33 // Need to manually set anchor width and height to ensure that the bubble shows 29 // Need to manually set anchor width and height to ensure that the bubble shows
34 // in the correct spot the first time it is displayed when no icon is present. 30 // in the correct spot the first time it is displayed when no icon is present.
35 const int kBubbleAnchorWidth = 20; 31 const int kBubbleAnchorWidth = 20;
36 const int kBubbleAnchorHeight = 25; 32 const int kBubbleAnchorHeight = 25;
37 33
38 } // namespace 34 } // namespace
39 35
(...skipping 29 matching lines...) Expand all
69 TabContents* tab_contents, 65 TabContents* tab_contents,
70 bool auto_close) 66 bool auto_close)
71 : auto_close_(auto_close), 67 : auto_close_(auto_close),
72 mouse_inside_(false), 68 mouse_inside_(false),
73 tab_contents_(tab_contents) { 69 tab_contents_(tab_contents) {
74 GtkThemeService* theme_service = 70 GtkThemeService* theme_service =
75 GtkThemeService::GetFrom(Profile::FromBrowserContext( 71 GtkThemeService::GetFrom(Profile::FromBrowserContext(
76 tab_contents->web_contents()->GetBrowserContext())); 72 tab_contents->web_contents()->GetBrowserContext()));
77 73
78 event_box_ = gtk_event_box_new(); 74 event_box_ = gtk_event_box_new();
75 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), FALSE);
79 GtkWidget* container = gtk_vbox_new(FALSE, 0); 76 GtkWidget* container = gtk_vbox_new(FALSE, 0);
80 gtk_container_add(GTK_CONTAINER(event_box_), container); 77 gtk_container_add(GTK_CONTAINER(event_box_), container);
81 78
82 int zoom_percent = tab_contents->zoom_controller()->zoom_percent(); 79 int zoom_percent = tab_contents->zoom_controller()->zoom_percent();
83 std::string percentage_text = UTF16ToUTF8(l10n_util::GetStringFUTF16Int( 80 std::string percentage_text = UTF16ToUTF8(l10n_util::GetStringFUTF16Int(
84 IDS_TOOLTIP_ZOOM, zoom_percent)); 81 IDS_TOOLTIP_ZOOM, zoom_percent));
85 label_ = theme_service->BuildLabel(percentage_text, ui::kGdkBlack); 82 label_ = theme_service->BuildLabel(percentage_text, ui::kGdkBlack);
86 gtk_widget_modify_font(label_, pango_font_description_from_string("13")); 83 gtk_widget_modify_font(label_, pango_font_description_from_string("13"));
87 gtk_misc_set_padding(GTK_MISC(label_), kSidePadding, kSidePadding); 84 gtk_misc_set_padding(GTK_MISC(label_),
88 85 ui::kControlSpacing, ui::kControlSpacing);
89 gtk_box_pack_start(GTK_BOX(container), label_, FALSE, FALSE, 0); 86 gtk_box_pack_start(GTK_BOX(container), label_, FALSE, FALSE, 0);
90 87
91 GtkWidget* separator = gtk_hseparator_new(); 88 GtkWidget* separator = gtk_hseparator_new();
92 gtk_box_pack_start(GTK_BOX(container), separator, FALSE, FALSE, 0); 89 gtk_box_pack_start(GTK_BOX(container), separator, FALSE, FALSE, 0);
93 90
94 GtkWidget* set_default_button = theme_service->BuildChromeButton(); 91 GtkWidget* set_default_button = theme_service->BuildChromeButton();
95 gtk_button_set_label(GTK_BUTTON(set_default_button), 92 gtk_button_set_label(GTK_BUTTON(set_default_button),
96 l10n_util::GetStringUTF8(IDS_ZOOM_SET_DEFAULT).c_str()); 93 l10n_util::GetStringUTF8(IDS_ZOOM_SET_DEFAULT).c_str());
97 94
98 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 95 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
99 gtk_alignment_set_padding( 96 gtk_alignment_set_padding(
100 GTK_ALIGNMENT(alignment), 0, 0, kSidePadding, kSidePadding); 97 GTK_ALIGNMENT(alignment), 0, 0, ui::kControlSpacing, ui::kControlSpacing);
101 gtk_container_add(GTK_CONTAINER(alignment), set_default_button); 98 gtk_container_add(GTK_CONTAINER(alignment), set_default_button);
102 99
103 gtk_box_pack_start(GTK_BOX(container), alignment, FALSE, FALSE, 0); 100 gtk_box_pack_start(GTK_BOX(container), alignment, FALSE, FALSE, 0);
104 g_signal_connect(set_default_button, "clicked", 101 g_signal_connect(set_default_button, "clicked",
105 G_CALLBACK(&OnSetDefaultLinkClickThunk), this); 102 G_CALLBACK(&OnSetDefaultLinkClickThunk), this);
106 103
107 gtk_container_set_focus_child(GTK_CONTAINER(container), NULL); 104 gtk_container_set_focus_child(GTK_CONTAINER(container), NULL);
108 105
109 gfx::Rect rect(kBubbleAnchorWidth, kBubbleAnchorHeight); 106 gfx::Rect rect(kBubbleAnchorWidth, kBubbleAnchorHeight);
110 BubbleGtk::ArrowLocationGtk arrow_location = 107 BubbleGtk::ArrowLocationGtk arrow_location =
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 StopTimerIfNecessary(); 197 StopTimerIfNecessary();
201 return FALSE; 198 return FALSE;
202 } 199 }
203 200
204 gboolean ZoomBubbleGtk::OnMouseLeave(GtkWidget* widget, 201 gboolean ZoomBubbleGtk::OnMouseLeave(GtkWidget* widget,
205 GdkEventCrossing* event) { 202 GdkEventCrossing* event) {
206 mouse_inside_ = false; 203 mouse_inside_ = false;
207 StartTimerIfNecessary(); 204 StartTimerIfNecessary();
208 return FALSE; 205 return FALSE;
209 } 206 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698