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

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

Issue 4691001: Make GConf dependency optional. (Closed)
Patch Set: Created 10 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
« no previous file with comments | « chrome/browser/gtk/browser_titlebar.h ('k') | chrome/browser/gtk/gconf_titlebar_listener.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/gtk/browser_titlebar.h" 5 #include "chrome/browser/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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "app/l10n_util.h" 13 #include "app/l10n_util.h"
14 #include "app/resource_bundle.h" 14 #include "app/resource_bundle.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/singleton.h" 16 #include "base/singleton.h"
17 #include "base/string_piece.h" 17 #include "base/string_piece.h"
18 #include "base/string_tokenizer.h" 18 #include "base/string_tokenizer.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "chrome/app/chrome_dll_resource.h" 20 #include "chrome/app/chrome_dll_resource.h"
21 #include "chrome/browser/browser.h" 21 #include "chrome/browser/browser.h"
22 #include "chrome/browser/encoding_menu_controller.h" 22 #include "chrome/browser/encoding_menu_controller.h"
23 #include "chrome/browser/gtk/accelerators_gtk.h" 23 #include "chrome/browser/gtk/accelerators_gtk.h"
24 #include "chrome/browser/gtk/browser_window_gtk.h" 24 #include "chrome/browser/gtk/browser_window_gtk.h"
25 #include "chrome/browser/gtk/custom_button.h" 25 #include "chrome/browser/gtk/custom_button.h"
26 #if defined(USE_GCONF)
26 #include "chrome/browser/gtk/gconf_titlebar_listener.h" 27 #include "chrome/browser/gtk/gconf_titlebar_listener.h"
28 #endif
27 #include "chrome/browser/gtk/gtk_theme_provider.h" 29 #include "chrome/browser/gtk/gtk_theme_provider.h"
28 #include "chrome/browser/gtk/gtk_util.h" 30 #include "chrome/browser/gtk/gtk_util.h"
29 #include "chrome/browser/gtk/menu_gtk.h" 31 #include "chrome/browser/gtk/menu_gtk.h"
30 #include "chrome/browser/gtk/nine_box.h" 32 #include "chrome/browser/gtk/nine_box.h"
31 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" 33 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
32 #include "chrome/browser/prefs/pref_service.h" 34 #include "chrome/browser/prefs/pref_service.h"
33 #include "chrome/browser/profile.h" 35 #include "chrome/browser/profile.h"
34 #include "chrome/browser/tab_contents/tab_contents.h" 36 #include "chrome/browser/tab_contents/tab_contents.h"
35 #include "chrome/browser/wrench_menu_model.h" 37 #include "chrome/browser/wrench_menu_model.h"
36 #include "chrome/common/notification_service.h" 38 #include "chrome/common/notification_service.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, 188 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU,
187 encoding_menu_model_.get()); 189 encoding_menu_model_.get());
188 190
189 AddSeparator(); 191 AddSeparator();
190 AddItemWithStringId(IDC_CLOSE_WINDOW, IDS_CLOSE); 192 AddItemWithStringId(IDC_CLOSE_WINDOW, IDS_CLOSE);
191 } 193 }
192 194
193 //////////////////////////////////////////////////////////////////////////////// 195 ////////////////////////////////////////////////////////////////////////////////
194 // BrowserTitlebar 196 // BrowserTitlebar
195 197
198 // static
199 const char BrowserTitlebar::kDefaultButtonString[] = ":minimize,maximize,close";
200
196 BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window, 201 BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window,
197 GtkWindow* window) 202 GtkWindow* window)
198 : browser_window_(browser_window), 203 : browser_window_(browser_window),
199 window_(window), 204 window_(window),
200 titlebar_left_buttons_vbox_(NULL), 205 titlebar_left_buttons_vbox_(NULL),
201 titlebar_right_buttons_vbox_(NULL), 206 titlebar_right_buttons_vbox_(NULL),
202 titlebar_left_buttons_hbox_(NULL), 207 titlebar_left_buttons_hbox_(NULL),
203 titlebar_right_buttons_hbox_(NULL), 208 titlebar_right_buttons_hbox_(NULL),
204 titlebar_left_spy_frame_(NULL), 209 titlebar_left_spy_frame_(NULL),
205 titlebar_right_spy_frame_(NULL), 210 titlebar_right_spy_frame_(NULL),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 gtk_widget_set_no_show_all(titlebar_right_spy_frame_, TRUE); 297 gtk_widget_set_no_show_all(titlebar_right_spy_frame_, TRUE);
293 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_right_spy_frame_), 0, 298 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_right_spy_frame_), 0,
294 kOTRBottomSpacing, kOTRSideSpacing, kOTRSideSpacing); 299 kOTRBottomSpacing, kOTRSideSpacing, kOTRSideSpacing);
295 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_spy_frame_, 300 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_spy_frame_,
296 FALSE, FALSE, 0); 301 FALSE, FALSE, 0);
297 } 302 }
298 titlebar_right_buttons_vbox_ = gtk_vbox_new(FALSE, 0); 303 titlebar_right_buttons_vbox_ = gtk_vbox_new(FALSE, 0);
299 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_buttons_vbox_, 304 gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_buttons_vbox_,
300 FALSE, FALSE, 0); 305 FALSE, FALSE, 0);
301 306
307 #if defined(USE_GCONF)
302 // Either read the gconf database and register for updates (on GNOME), or use 308 // Either read the gconf database and register for updates (on GNOME), or use
303 // the default value (anywhere else). 309 // the default value (anywhere else).
304 Singleton<GConfTitlebarListener>()->SetTitlebarButtons(this); 310 Singleton<GConfTitlebarListener>()->SetTitlebarButtons(this);
311 #else
312 BuildButtons(kDefaultButtonString);
313 #endif
305 314
306 // We use an alignment to control the titlebar height. 315 // We use an alignment to control the titlebar height.
307 titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 316 titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
308 if (browser_window_->browser()->type() == Browser::TYPE_NORMAL) { 317 if (browser_window_->browser()->type() == Browser::TYPE_NORMAL) {
309 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_alignment_, TRUE, 318 gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_alignment_, TRUE,
310 TRUE, 0); 319 TRUE, 0);
311 320
312 // Put the tab strip in the titlebar. 321 // Put the tab strip in the titlebar.
313 gtk_container_add(GTK_CONTAINER(titlebar_alignment_), 322 gtk_container_add(GTK_CONTAINER(titlebar_alignment_),
314 browser_window_->tabstrip()->widget()); 323 browser_window_->tabstrip()->widget());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 UpdateTitleAndIcon(); 365 UpdateTitleAndIcon();
357 } 366 }
358 367
359 gtk_widget_show_all(container_); 368 gtk_widget_show_all(container_);
360 369
361 ActiveWindowWatcherX::AddObserver(this); 370 ActiveWindowWatcherX::AddObserver(this);
362 } 371 }
363 372
364 BrowserTitlebar::~BrowserTitlebar() { 373 BrowserTitlebar::~BrowserTitlebar() {
365 ActiveWindowWatcherX::RemoveObserver(this); 374 ActiveWindowWatcherX::RemoveObserver(this);
375 #if defined(USE_GCONF)
366 Singleton<GConfTitlebarListener>()->RemoveObserver(this); 376 Singleton<GConfTitlebarListener>()->RemoveObserver(this);
377 #endif
367 } 378 }
368 379
369 void BrowserTitlebar::BuildButtons(const std::string& button_string) { 380 void BrowserTitlebar::BuildButtons(const std::string& button_string) {
370 // Clear out all previous data. 381 // Clear out all previous data.
371 close_button_.reset(); 382 close_button_.reset();
372 restore_button_.reset(); 383 restore_button_.reset();
373 maximize_button_.reset(); 384 maximize_button_.reset();
374 minimize_button_.reset(); 385 minimize_button_.reset();
375 gtk_util::RemoveAllChildren(titlebar_left_buttons_vbox_); 386 gtk_util::RemoveAllChildren(titlebar_left_buttons_vbox_);
376 gtk_util::RemoveAllChildren(titlebar_right_buttons_vbox_); 387 gtk_util::RemoveAllChildren(titlebar_right_buttons_vbox_);
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 menus::SimpleMenuModel::Delegate* delegate) 937 menus::SimpleMenuModel::Delegate* delegate)
927 : SimpleMenuModel(delegate) { 938 : SimpleMenuModel(delegate) {
928 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); 939 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB);
929 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); 940 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB);
930 AddSeparator(); 941 AddSeparator();
931 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); 942 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER);
932 AddSeparator(); 943 AddSeparator();
933 AddCheckItemWithStringId(kShowWindowDecorationsCommand, 944 AddCheckItemWithStringId(kShowWindowDecorationsCommand,
934 IDS_SHOW_WINDOW_DECORATIONS_MENU); 945 IDS_SHOW_WINDOW_DECORATIONS_MENU);
935 } 946 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_titlebar.h ('k') | chrome/browser/gtk/gconf_titlebar_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698