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

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

Issue 7321011: Multi-Profiles: Add delete profile command (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove debug code 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
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"
11 #include "chrome/browser/ui/profile_menu_model.h" 11 #include "chrome/browser/ui/profile_menu_model.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "ui/base/text/text_elider.h" 13 #include "ui/base/text/text_elider.h"
14 14
15 // Maximum width for name string in pixels. 15 // Maximum width for name string in pixels.
16 const int kMaxTextWidth = 200; 16 const int kMaxTextWidth = 200;
17 17
18 ProfileMenuButton::ProfileMenuButton() { 18 ProfileMenuButton::ProfileMenuButton(Profile* profile) : profile_(profile) {
19 profile_menu_model_.reset(new ProfileMenuModel); 19 profile_menu_model_.reset(new ProfileMenuModel(profile_));
20 menu_.reset(new MenuGtk(NULL, profile_menu_model_.get())); 20 menu_.reset(new MenuGtk(NULL, profile_menu_model_.get()));
21 21
22 widget_.Own(gtk_button_new()); 22 widget_.Own(gtk_button_new());
23 23
24 g_signal_connect(widget_.get(), "button-press-event", 24 g_signal_connect(widget_.get(), "button-press-event",
25 G_CALLBACK(OnButtonPressedThunk), this); 25 G_CALLBACK(OnButtonPressedThunk), this);
26 gtk_widget_set_no_show_all(GTK_WIDGET(widget_.get()), TRUE); 26 gtk_widget_set_no_show_all(GTK_WIDGET(widget_.get()), TRUE);
27 } 27 }
28 28
29 ProfileMenuButton::~ProfileMenuButton() {} 29 ProfileMenuButton::~ProfileMenuButton() {}
30 30
31 void ProfileMenuButton::UpdateText(Profile* profile) { 31 void ProfileMenuButton::UpdateText() {
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 if (!text.empty())
39 gtk_widget_show(widget_.get()); 39 gtk_widget_show(widget_.get());
40 else 40 else
41 gtk_widget_hide(widget_.get()); 41 gtk_widget_hide(widget_.get());
42 } 42 }
43 43
44 gboolean ProfileMenuButton::OnButtonPressed(GtkWidget* widget, 44 gboolean ProfileMenuButton::OnButtonPressed(GtkWidget* widget,
45 GdkEventButton* event) { 45 GdkEventButton* event) {
46 if (event->button != 1) 46 if (event->button != 1)
47 return FALSE; 47 return FALSE;
48 48
49 menu_->PopupForWidget(widget_.get(), event->button, event->time); 49 menu_->PopupForWidget(widget_.get(), event->button, event->time);
50 return TRUE; 50 return TRUE;
51 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698