diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 20:10:31 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 20:10:31 +0000 |
commit | e116a526fce847f7d19a0576d30b3e8de812d923 (patch) | |
tree | 37b3c5b865128a09bd761c58079183060c411643 /chrome | |
parent | e296bed56a43c1aac9204e86976fcfc91c8e9631 (diff) | |
download | chromium_src-e116a526fce847f7d19a0576d30b3e8de812d923.zip chromium_src-e116a526fce847f7d19a0576d30b3e8de812d923.tar.gz chromium_src-e116a526fce847f7d19a0576d30b3e8de812d923.tar.bz2 |
On linux, add a context menu item in the tab strip for disabling
window decorations.
This is mostly just an experiment. The window currently looks bad
because of no rounded corners. It's also not possible to resize in
this state and if you have too many tabs, you can't move.
Review URL: http://codereview.chromium.org/114075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17655 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/generated_resources.grd | 4 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 1 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 27 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 10 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.cc | 26 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.h | 1 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
8 files changed, 60 insertions, 14 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index e18a890..730b748 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -3846,6 +3846,10 @@ each locale. --> Don't ask again </message> + <message name="IDS_SHOW_WINDOW_DECORATIONS" desc="The menu entry text in the tab strip context menu. This toggles the system title bar and window borders (window decorations) on linux."> + Use system title bar and borders + </message> + <message name="IDS_RGBA_CSS_FORMAT_STRING" translateable="false" desc="The format string to use when converting colors to CSS rgba()."> rgba($1, $2, $3, $4) </message> diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index fe99bdd..64eb536 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1200,6 +1200,7 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kDeleteFormData, true); prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod, 0); prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true); + prefs->RegisterBooleanPref(prefs::kUseCustomChromeFrame, false); } // static diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 0e6d1a6..5153e16 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -284,9 +284,9 @@ std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; // readability. BrowserWindowGtk::BrowserWindowGtk(Browser* browser) : browser_(browser), - // TODO(port): make this a pref. - custom_frame_(false), full_screen_(false) { + use_custom_frame_.Init(prefs::kUseCustomChromeFrame, + browser_->profile()->GetPrefs(), this); window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); SetWindowIcon(); SetGeometryHints(); @@ -354,8 +354,7 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser) // Note that calling this the first time is necessary to get the // proper control layout. - // TODO(port): make this a pref. - SetCustomFrame(false); + UpdateCustomFrame(); GtkWidget* event_box = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(event_box), render_area_vbox_); @@ -387,7 +386,7 @@ void BrowserWindowGtk::HandleAccelerator(guint keyval, gboolean BrowserWindowGtk::OnContentAreaExpose(GtkWidget* widget, GdkEventExpose* e, BrowserWindowGtk* window) { - if (window->custom_frame_) { + if (window->use_custom_frame_.GetValue()) { NOTIMPLEMENTED() << " needs custom drawing for the custom frame."; return FALSE; } @@ -640,6 +639,13 @@ void BrowserWindowGtk::Observe(NotificationType type, const NotificationDetails& details) { if (type == NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED) { MaybeShowBookmarkBar(browser_->GetSelectedTabContents()); + } else if (type == NotificationType::PREF_CHANGED) { + std::wstring* pref_name = Details<std::wstring>(details).ptr(); + if (*pref_name == prefs::kUseCustomChromeFrame) { + UpdateCustomFrame(); + } else { + NOTREACHED() << "Got a pref change notification we didn't register for!"; + } } else { NOTREACHED() << "Got a notification we didn't register for!"; } @@ -827,11 +833,12 @@ void BrowserWindowGtk::ConnectAccelerators() { } } -void BrowserWindowGtk::SetCustomFrame(bool custom_frame) { - custom_frame_ = custom_frame; - if (custom_frame_) { - gtk_container_set_border_width(GTK_CONTAINER(window_vbox_), 2); - // TODO(port): all the crazy blue title bar, etc. +void BrowserWindowGtk::UpdateCustomFrame() { + gtk_window_set_decorated(window_, + !use_custom_frame_.GetValue()); + if (use_custom_frame_.GetValue()) { + // TODO(port): The taller title bar and custom window border. + gtk_container_set_border_width(GTK_CONTAINER(window_vbox_), 0); NOTIMPLEMENTED(); } else { gtk_container_set_border_width(GTK_CONTAINER(window_vbox_), 0); diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index 4e5f067ad..8cb6a3e 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -15,6 +15,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/common/notification_registrar.h" +#include "chrome/common/pref_member.h" #include "chrome/common/x11_util.h" class BookmarkBarGtk; @@ -157,7 +158,7 @@ class BrowserWindowGtk : public BrowserWindow, // Change whether we're showing the custom blue frame. // Must be called once at startup. // Triggers relayout of the content. - void SetCustomFrame(bool custom_frame); + void UpdateCustomFrame(); // Save the window position in the prefs. void SaveWindowPosition(); @@ -199,9 +200,6 @@ class BrowserWindowGtk : public BrowserWindow, gfx::Rect bounds_; GdkWindowState state_; - // Whether we're drawing the custom Chrome frame (including title bar). - bool custom_frame_; - // Whether we are full screen. Since IsFullscreen() gets called before // OnStateChanged(), we can't rely on |state_| & GDK_WINDOW_STATE_FULLSCREEN. bool full_screen_; @@ -229,6 +227,10 @@ class BrowserWindowGtk : public BrowserWindow, // The timer used to update frames for the Loading Animation. base::RepeatingTimer<BrowserWindowGtk> loading_animation_timer_; + // Whether we're showing the custom chrome frame or the window manager + // decorations. + BooleanPrefMember use_custom_frame_; + // A map which translates an X Window ID into its respective GtkWindow. static std::map<XID, GtkWindow*> xid_map_; diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 57891f7..d145296 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -16,6 +16,8 @@ #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/pref_names.h" +#include "chrome/common/pref_service.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -36,6 +38,9 @@ const int kHorizontalMoveThreshold = 16; // pixels // which results in overlapping tabs. const int kTabHOffset = -16; +// A linux specific menu item for toggling window decorations. +const int kShowWindowDecorationsCommand = 200; + inline int Round(double x) { return static_cast<int>(x + 0.5); } @@ -1175,6 +1180,12 @@ void TabStripGtk::ShowContextMenu() { context_menu_->AppendMenuItemWithLabel( TabStripModel::CommandTaskManager, l10n_util::GetStringUTF8(IDS_TASK_MANAGER)); + + context_menu_->AppendSeparator(); + + context_menu_->AppendCheckMenuItemWithLabel( + kShowWindowDecorationsCommand, + l10n_util::GetStringUTF8(IDS_SHOW_WINDOW_DECORATIONS)); } context_menu_->PopupAsContext(gtk_get_current_event_time()); @@ -1183,6 +1194,7 @@ void TabStripGtk::ShowContextMenu() { bool TabStripGtk::IsCommandEnabled(int command_id) const { switch (command_id) { case TabStripModel::CommandNewTab: + case kShowWindowDecorationsCommand: return true; case TabStripModel::CommandRestoreTab: @@ -1198,6 +1210,12 @@ bool TabStripGtk::IsCommandEnabled(int command_id) const { return false; } +bool TabStripGtk::IsItemChecked(int command_id) const { + DCHECK(command_id == kShowWindowDecorationsCommand); + PrefService* prefs = model_->profile()->GetPrefs(); + return !prefs->GetBoolean(prefs::kUseCustomChromeFrame); +} + void TabStripGtk::ExecuteCommand(int command_id) { switch (command_id) { case TabStripModel::CommandNewTab: @@ -1213,6 +1231,14 @@ void TabStripGtk::ExecuteCommand(int command_id) { NOTIMPLEMENTED(); break; + case kShowWindowDecorationsCommand: + { + PrefService* prefs = model_->profile()->GetPrefs(); + prefs->SetBoolean(prefs::kUseCustomChromeFrame, + !prefs->GetBoolean(prefs::kUseCustomChromeFrame)); + break; + } + default: NOTREACHED(); } diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h index cf0fff3..cf90088 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.h +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h @@ -193,6 +193,7 @@ class TabStripGtk : public TabStripModelObserver, void ShowContextMenu(); // MenuGtk::Delegate implementation: virtual bool IsCommandEnabled(int command_id) const; + virtual bool IsItemChecked(int command_id) const; virtual void ExecuteCommand(int command_id); // -- Animations ------------------------------------------------------------- diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 63bab2b..e46bb9c 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -262,6 +262,10 @@ const wchar_t kCurrentThemeDisplayProperties[] = // on start-up. const wchar_t kCheckDefaultBrowser[] = L"browser.check_default_browser"; +// Boolean that is false if we should show window manager decorations. If +// true, we draw a custom chrome frame (thicker title bar and blue border). +const wchar_t kUseCustomChromeFrame[] = L"browser.custom_chrome_frame"; + // *************** LOCAL STATE *************** // These are attached to the machine/installation diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index a592f41..8b17f9d 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -96,6 +96,7 @@ extern const wchar_t kCurrentThemeColors[]; extern const wchar_t kCurrentThemeTints[]; extern const wchar_t kCurrentThemeDisplayProperties[]; extern const wchar_t kCheckDefaultBrowser[]; +extern const wchar_t kUseCustomChromeFrame[]; // Local state extern const wchar_t kAvailableProfiles[]; |