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

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

Issue 10494004: Implements a zoom icon in the Omnibox for Views. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
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/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 // 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.
27 const int kBubbleCloseDelay = 400; 27 const int kBubbleCloseDelay = 400;
28 28
29 // 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
30 // 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.
31 const int kBubbleAnchorWidth = 20; 31 const int kBubbleAnchorWidth = 20;
32 const int kBubbleAnchorHeight = 25; 32 const int kBubbleAnchorHeight = 25;
33 } 33 }
34 34
35 // static 35 // static
36 void ZoomBubbleGtk::Show(GtkWidget* anchor, 36 void ZoomBubbleGtk::Show(GtkWidget* anchor, Profile* profile,
37 Profile* profile, 37 int zoomPercent, bool autoclose) {
Ben Goodger (Google) 2012/06/04 15:16:49 leave
Kyle Horimoto 2012/06/05 05:03:59 This was changed in my other CL and must have gott
38 int zoom_percent,
39 bool autoclose) {
40 if (g_bubble) 38 if (g_bubble)
41 ZoomBubbleGtk::Close(); 39 ZoomBubbleGtk::Close();
42 g_bubble = new ZoomBubbleGtk(anchor, profile, zoom_percent, autoclose); 40 g_bubble = new ZoomBubbleGtk(anchor, profile, zoomPercent, autoclose);
Ben Goodger (Google) 2012/06/04 15:16:49 leave this parameter name the way it was
Kyle Horimoto 2012/06/05 05:03:59 Same.
43 } 41 }
44 42
45 // static 43 // static
46 void ZoomBubbleGtk::Close() { 44 void ZoomBubbleGtk::Close() {
47 if (g_bubble) 45 if (g_bubble)
48 g_bubble->CloseBubble(); 46 g_bubble->CloseBubble();
49 } 47 }
50 48
51 void ZoomBubbleGtk::BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) { 49 void ZoomBubbleGtk::BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) {
52 } 50 }
53 51
54 void ZoomBubbleGtk::Observe(int type, 52 void ZoomBubbleGtk::Observe(int type,
55 const content::NotificationSource& source, 53 const content::NotificationSource& source,
56 const content::NotificationDetails& details) { 54 const content::NotificationDetails& details) {
57 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); 55 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED);
58 56
59 if (theme_service_->UsingNativeTheme()) 57 if (theme_service_->UsingNativeTheme())
60 gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, NULL); 58 gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, NULL);
61 else 59 else
62 gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, &ui::kGdkBlack); 60 gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, &ui::kGdkBlack);
63 } 61 }
64 62
65 ZoomBubbleGtk::ZoomBubbleGtk(GtkWidget* anchor, 63 ZoomBubbleGtk::ZoomBubbleGtk(GtkWidget* anchor,
66 Profile* profile, 64 Profile* profile,
67 int zoom_percent, 65 int zoomPercent,
68 bool autoclose) 66 bool autoclose)
69 : theme_service_(GtkThemeService::GetFrom(profile)), 67 : theme_service_(GtkThemeService::GetFrom(profile)),
70 factory_(this) { 68 factory_(this) {
71 string16 labelText = l10n_util::GetStringFUTF16Int( 69 string16 labelText = l10n_util::GetStringFUTF16Int(
72 IDS_ZOOM_PERCENT, zoom_percent); 70 IDS_ZOOM_PERCENT, zoomPercent);
73 label_ = gtk_label_new(UTF16ToUTF8(labelText).c_str()); 71 label_ = gtk_label_new(UTF16ToUTF8(labelText).c_str());
74 72
75 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 73 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
76 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 74 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0,
77 kContentBorder, kContentBorder); 75 kContentBorder, kContentBorder);
78 gtk_container_add(GTK_CONTAINER(alignment), label_); 76 gtk_container_add(GTK_CONTAINER(alignment), label_);
79 77
80 GtkWidget* content = gtk_event_box_new(); 78 GtkWidget* content = gtk_event_box_new();
81 gtk_event_box_set_visible_window(GTK_EVENT_BOX(content), TRUE); 79 gtk_event_box_set_visible_window(GTK_EVENT_BOX(content), TRUE);
82 gtk_container_add(GTK_CONTAINER(content), alignment); 80 gtk_container_add(GTK_CONTAINER(content), alignment);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 120 }
123 121
124 void ZoomBubbleGtk::CloseBubble() { 122 void ZoomBubbleGtk::CloseBubble() {
125 bubble_->Close(); 123 bubble_->Close();
126 } 124 }
127 125
128 void ZoomBubbleGtk::OnDestroy(GtkWidget* widget) { 126 void ZoomBubbleGtk::OnDestroy(GtkWidget* widget) {
129 // Listen to the destroy signal and delete this instance when it is caught. 127 // Listen to the destroy signal and delete this instance when it is caught.
130 delete this; 128 delete this;
131 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698