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

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

Issue 7327003: Multi-Profiles: Add customize profile menu item (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Multi-Profiles: Add customize profile menu item 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/profile_menu_button.h ('k') | chrome/browser/ui/profile_menu_model.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/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/browser.h"
10 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" 11 #include "chrome/browser/ui/gtk/gtk_chrome_button.h"
11 #include "chrome/browser/ui/profile_menu_model.h" 12 #include "chrome/browser/ui/profile_menu_model.h"
12 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
13 #include "ui/base/text/text_elider.h" 14 #include "ui/base/text/text_elider.h"
14 15
15 // Maximum width for name string in pixels. 16 // Maximum width for name string in pixels.
16 const int kMaxTextWidth = 200; 17 const int kMaxTextWidth = 200;
17 18
18 ProfileMenuButton::ProfileMenuButton(Profile* profile) : profile_(profile) { 19 ProfileMenuButton::ProfileMenuButton(Browser* browser) : browser_(browser) {
19 profile_menu_model_.reset(new ProfileMenuModel(profile_)); 20 profile_menu_model_.reset(new ProfileMenuModel(browser_));
20 menu_.reset(new MenuGtk(NULL, profile_menu_model_.get())); 21 menu_.reset(new MenuGtk(NULL, profile_menu_model_.get()));
21 22
22 widget_.Own(gtk_button_new()); 23 widget_.Own(gtk_button_new());
23 24
24 g_signal_connect(widget_.get(), "button-press-event", 25 g_signal_connect(widget_.get(), "button-press-event",
25 G_CALLBACK(OnButtonPressedThunk), this); 26 G_CALLBACK(OnButtonPressedThunk), this);
26 gtk_widget_set_no_show_all(GTK_WIDGET(widget_.get()), TRUE); 27 gtk_widget_set_no_show_all(GTK_WIDGET(widget_.get()), TRUE);
27 } 28 }
28 29
29 ProfileMenuButton::~ProfileMenuButton() {} 30 ProfileMenuButton::~ProfileMenuButton() {}
30 31
31 void ProfileMenuButton::UpdateText() { 32 void ProfileMenuButton::UpdateText() {
32 string16 text = UTF8ToUTF16( 33 string16 text = UTF8ToUTF16(browser_->profile()->GetPrefs()->GetString(
33 profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); 34 prefs::kGoogleServicesUsername));
34 string16 elided_text = ui::ElideText(text, gfx::Font(), kMaxTextWidth, false); 35 string16 elided_text = ui::ElideText(text, gfx::Font(), kMaxTextWidth, false);
35 gtk_button_set_label( 36 gtk_button_set_label(
36 GTK_BUTTON(widget_.get()), UTF16ToUTF8(elided_text).c_str()); 37 GTK_BUTTON(widget_.get()), UTF16ToUTF8(elided_text).c_str());
37 38
38 gtk_widget_set_visible(widget_.get(), !text.empty()); 39 gtk_widget_set_visible(widget_.get(), !text.empty());
39 } 40 }
40 41
41 gboolean ProfileMenuButton::OnButtonPressed(GtkWidget* widget, 42 gboolean ProfileMenuButton::OnButtonPressed(GtkWidget* widget,
42 GdkEventButton* event) { 43 GdkEventButton* event) {
43 if (event->button != 1) 44 if (event->button != 1)
44 return FALSE; 45 return FALSE;
45 46
46 menu_->PopupForWidget(widget_.get(), event->button, event->time); 47 menu_->PopupForWidget(widget_.get(), event->button, event->time);
47 return TRUE; 48 return TRUE;
48 } 49 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/profile_menu_button.h ('k') | chrome/browser/ui/profile_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698