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

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

Issue 11338028: Add support for XFWM titlebar buttons. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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) 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/browser_titlebar.h" 5 #include "chrome/browser/ui/gtk/browser_titlebar.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_info_cache.h" 25 #include "chrome/browser/profiles/profile_info_cache.h"
26 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_commands.h" 28 #include "chrome/browser/ui/browser_commands.h"
29 #include "chrome/browser/ui/browser_tabstrip.h" 29 #include "chrome/browser/ui/browser_tabstrip.h"
30 #include "chrome/browser/ui/gtk/accelerators_gtk.h" 30 #include "chrome/browser/ui/gtk/accelerators_gtk.h"
31 #include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h" 31 #include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h"
32 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 32 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
33 #include "chrome/browser/ui/gtk/custom_button.h" 33 #include "chrome/browser/ui/gtk/custom_button.h"
34 #if defined(USE_GCONF)
35 #include "chrome/browser/ui/gtk/gconf_titlebar_listener.h"
36 #endif
37 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 34 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
38 #include "chrome/browser/ui/gtk/gtk_util.h" 35 #include "chrome/browser/ui/gtk/gtk_util.h"
39 #include "chrome/browser/ui/gtk/menu_gtk.h" 36 #include "chrome/browser/ui/gtk/menu_gtk.h"
40 #include "chrome/browser/ui/gtk/nine_box.h" 37 #include "chrome/browser/ui/gtk/nine_box.h"
41 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" 38 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
39 #include "chrome/browser/ui/gtk/titlebar_listener.h"
42 #include "chrome/browser/ui/gtk/unity_service.h" 40 #include "chrome/browser/ui/gtk/unity_service.h"
43 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 41 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
44 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 42 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
45 #include "chrome/common/chrome_notification_types.h" 43 #include "chrome/common/chrome_notification_types.h"
46 #include "chrome/common/chrome_switches.h" 44 #include "chrome/common/chrome_switches.h"
47 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
48 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
49 #include "content/public/browser/web_contents.h" 47 #include "content/public/browser/web_contents.h"
50 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
51 #include "grit/theme_resources.h" 49 #include "grit/theme_resources.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_buttons_vbox_, 309 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_buttons_vbox_,
312 FALSE, FALSE, 0); 310 FALSE, FALSE, 0);
313 311
314 // Create the Avatar button and listen for notifications. It must always be 312 // Create the Avatar button and listen for notifications. It must always be
315 // created because a new profile can be added at any time. 313 // created because a new profile can be added at any time.
316 avatar_button_.reset(new AvatarMenuButtonGtk(browser_window_->browser())); 314 avatar_button_.reset(new AvatarMenuButtonGtk(browser_window_->browser()));
317 315
318 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 316 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
319 content::NotificationService::AllSources()); 317 content::NotificationService::AllSources());
320 318
321 #if defined(USE_GCONF) 319 TitlebarListener::GetInstance()->SetTitlebarButtons(this);
322 // Either read the gconf database and register for updates (on GNOME), or use
323 // the default value (anywhere else).
324 GConfTitlebarListener::GetInstance()->SetTitlebarButtons(this);
325 #else
326 BuildButtons(kDefaultButtonString);
327 #endif
328 320
329 UpdateAvatar(); 321 UpdateAvatar();
330 322
331 // We use an alignment to control the titlebar height. 323 // We use an alignment to control the titlebar height.
332 titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 324 titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
333 if (browser_window_->browser()->is_type_tabbed()) { 325 if (browser_window_->browser()->is_type_tabbed()) {
334 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_alignment_, TRUE, 326 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_alignment_, TRUE,
335 TRUE, 0); 327 TRUE, 0);
336 328
337 // Put the tab strip in the titlebar. 329 // Put the tab strip in the titlebar.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 content::Source<ThemeService>(theme_service_)); 372 content::Source<ThemeService>(theme_service_));
381 theme_service_->InitThemesFor(this); 373 theme_service_->InitThemesFor(this);
382 374
383 gtk_widget_show_all(container_); 375 gtk_widget_show_all(container_);
384 376
385 ui::ActiveWindowWatcherX::AddObserver(this); 377 ui::ActiveWindowWatcherX::AddObserver(this);
386 } 378 }
387 379
388 BrowserTitlebar::~BrowserTitlebar() { 380 BrowserTitlebar::~BrowserTitlebar() {
389 ui::ActiveWindowWatcherX::RemoveObserver(this); 381 ui::ActiveWindowWatcherX::RemoveObserver(this);
390 #if defined(USE_GCONF) 382 TitlebarListener::GetInstance()->RemoveObserver(this);
391 GConfTitlebarListener::GetInstance()->RemoveObserver(this);
392 #endif
393 } 383 }
394 384
395 void BrowserTitlebar::BuildButtons(const std::string& button_string) { 385 void BrowserTitlebar::BuildButtons(const std::string& button_string) {
396 // Clear out all previous data. 386 // Clear out all previous data.
397 close_button_.reset(); 387 close_button_.reset();
398 restore_button_.reset(); 388 restore_button_.reset();
399 maximize_button_.reset(); 389 maximize_button_.reset();
400 minimize_button_.reset(); 390 minimize_button_.reset();
401 gtk_util::RemoveAllChildren(titlebar_left_buttons_vbox_); 391 gtk_util::RemoveAllChildren(titlebar_left_buttons_vbox_);
402 gtk_util::RemoveAllChildren(titlebar_right_buttons_vbox_); 392 gtk_util::RemoveAllChildren(titlebar_right_buttons_vbox_);
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 ui::SimpleMenuModel::Delegate* delegate) 1025 ui::SimpleMenuModel::Delegate* delegate)
1036 : SimpleMenuModel(delegate) { 1026 : SimpleMenuModel(delegate) {
1037 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); 1027 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB);
1038 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); 1028 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB);
1039 AddSeparator(ui::NORMAL_SEPARATOR); 1029 AddSeparator(ui::NORMAL_SEPARATOR);
1040 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); 1030 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER);
1041 AddSeparator(ui::NORMAL_SEPARATOR); 1031 AddSeparator(ui::NORMAL_SEPARATOR);
1042 AddCheckItemWithStringId(kShowWindowDecorationsCommand, 1032 AddCheckItemWithStringId(kShowWindowDecorationsCommand,
1043 IDS_SHOW_WINDOW_DECORATIONS_MENU); 1033 IDS_SHOW_WINDOW_DECORATIONS_MENU);
1044 } 1034 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698