OLD | NEW |
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/content_setting_bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 // Store the gtk menu to the map. | 251 // Store the gtk menu to the map. |
252 gtk_menu->menu_model.reset(new ContentSettingMediaMenuModel( | 252 gtk_menu->menu_model.reset(new ContentSettingMediaMenuModel( |
253 gtk_menu->type, | 253 gtk_menu->type, |
254 content_setting_bubble_model_.get(), | 254 content_setting_bubble_model_.get(), |
255 base::Bind(&ContentSettingBubbleGtk::UpdateMenuLabel, | 255 base::Bind(&ContentSettingBubbleGtk::UpdateMenuLabel, |
256 base::Unretained(this)))); | 256 base::Unretained(this)))); |
257 gtk_menu->menu.reset(new MenuGtk(NULL, gtk_menu->menu_model.get())); | 257 gtk_menu->menu.reset(new MenuGtk(NULL, gtk_menu->menu_model.get())); |
258 media_menus_[button] = gtk_menu; | 258 media_menus_[button] = gtk_menu; |
259 | 259 |
| 260 if (!gtk_menu->menu_model->GetItemCount()) { |
| 261 // Show a "None available" title and grey out the menu when there is no |
| 262 // available device. |
| 263 UpdateMenuLabel( |
| 264 gtk_menu->type, |
| 265 l10n_util::GetStringUTF8(IDS_MEDIA_MENU_NO_DEVICE_TITLE)); |
| 266 gtk_widget_set_sensitive(button, FALSE); |
| 267 } |
| 268 |
260 // Use the longest width of the menus as the width of the menu buttons. | 269 // Use the longest width of the menus as the width of the menu buttons. |
261 GtkRequisition menu_req; | 270 GtkRequisition menu_req; |
262 gtk_widget_size_request(gtk_menu->menu->widget(), &menu_req); | 271 gtk_widget_size_request(gtk_menu->menu->widget(), &menu_req); |
263 menu_width = std::max(menu_width, menu_req.width); | 272 menu_width = std::max(menu_width, menu_req.width); |
264 | 273 |
265 g_signal_connect(button, "clicked", G_CALLBACK(OnMenuButtonClickedThunk), | 274 g_signal_connect(button, "clicked", G_CALLBACK(OnMenuButtonClickedThunk), |
266 this); | 275 this); |
267 gtk_table_attach(GTK_TABLE(table), button, 1, 2, row, row + 1, | 276 gtk_table_attach(GTK_TABLE(table), button, 1, 2, row, row + 1, |
268 GTK_FILL, GTK_FILL, ui::kControlSpacing * 2, | 277 GTK_FILL, GTK_FILL, ui::kControlSpacing * 2, |
269 ui::kControlSpacing / 2); | 278 ui::kControlSpacing / 2); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 GtkMediaMenuMap::iterator i(media_menus_.find(button)); | 415 GtkMediaMenuMap::iterator i(media_menus_.find(button)); |
407 DCHECK(i != media_menus_.end()); | 416 DCHECK(i != media_menus_.end()); |
408 i->second->menu->PopupForWidget(button, 1, gtk_get_current_event_time()); | 417 i->second->menu->PopupForWidget(button, 1, gtk_get_current_event_time()); |
409 } | 418 } |
410 | 419 |
411 ContentSettingBubbleGtk::MediaMenuGtk::MediaMenuGtk( | 420 ContentSettingBubbleGtk::MediaMenuGtk::MediaMenuGtk( |
412 content::MediaStreamType type) | 421 content::MediaStreamType type) |
413 : type(type) {} | 422 : type(type) {} |
414 | 423 |
415 ContentSettingBubbleGtk::MediaMenuGtk::~MediaMenuGtk() {} | 424 ContentSettingBubbleGtk::MediaMenuGtk::~MediaMenuGtk() {} |
OLD | NEW |