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

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

Issue 7310016: GTK: Now that we depend on gtk 2.18+, replace this pattern: (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/location_bar_view_gtk.cc ('k') | chrome/browser/ui/gtk/tabs/tab_gtk.cc » ('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/profile_menu_button.h" 5 #include "chrome/browser/ui/gtk/profile_menu_button.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_chrome_button.h" 10 #include "chrome/browser/ui/gtk/gtk_chrome_button.h"
(...skipping 17 matching lines...) Expand all
28 28
29 ProfileMenuButton::~ProfileMenuButton() {} 29 ProfileMenuButton::~ProfileMenuButton() {}
30 30
31 void ProfileMenuButton::UpdateText(Profile* profile) { 31 void ProfileMenuButton::UpdateText(Profile* profile) {
32 string16 text = UTF8ToUTF16( 32 string16 text = UTF8ToUTF16(
33 profile->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); 33 profile->GetPrefs()->GetString(prefs::kGoogleServicesUsername));
34 string16 elided_text = ui::ElideText(text, gfx::Font(), kMaxTextWidth, false); 34 string16 elided_text = ui::ElideText(text, gfx::Font(), kMaxTextWidth, false);
35 gtk_button_set_label( 35 gtk_button_set_label(
36 GTK_BUTTON(widget_.get()), UTF16ToUTF8(elided_text).c_str()); 36 GTK_BUTTON(widget_.get()), UTF16ToUTF8(elided_text).c_str());
37 37
38 if (!text.empty()) 38 gtk_widget_set_visible(widget_.get(), !text.empty());
39 gtk_widget_show(widget_.get());
40 else
41 gtk_widget_hide(widget_.get());
42 } 39 }
43 40
44 gboolean ProfileMenuButton::OnButtonPressed(GtkWidget* widget, 41 gboolean ProfileMenuButton::OnButtonPressed(GtkWidget* widget,
45 GdkEventButton* event) { 42 GdkEventButton* event) {
46 if (event->button != 1) 43 if (event->button != 1)
47 return FALSE; 44 return FALSE;
48 45
49 menu_->PopupForWidget(widget_.get(), event->button, event->time); 46 menu_->PopupForWidget(widget_.get(), event->button, event->time);
50 return TRUE; 47 return TRUE;
51 } 48 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.cc ('k') | chrome/browser/ui/gtk/tabs/tab_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698