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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_titlebar_gtk.cc

Issue 10209037: Add key modifier to minimize/restore button click to minimize/restore-all panels for GTK (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_titlebar_gtk.h ('k') | no next file » | 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) 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/panels/panel_browser_titlebar_gtk.h" 5 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h"
6 6
7 #include "chrome/browser/ui/gtk/custom_button.h" 7 #include "chrome/browser/ui/gtk/custom_button.h"
8 #include "chrome/browser/ui/panels/panel.h" 8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" 9 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 11 matching lines...) Expand all
22 22
23 PanelBrowserTitlebarGtk::PanelBrowserTitlebarGtk( 23 PanelBrowserTitlebarGtk::PanelBrowserTitlebarGtk(
24 PanelBrowserWindowGtk* browser_window, GtkWindow* window) 24 PanelBrowserWindowGtk* browser_window, GtkWindow* window)
25 : BrowserTitlebar(browser_window, window), 25 : BrowserTitlebar(browser_window, window),
26 browser_window_(browser_window) { 26 browser_window_(browser_window) {
27 } 27 }
28 28
29 PanelBrowserTitlebarGtk::~PanelBrowserTitlebarGtk() { 29 PanelBrowserTitlebarGtk::~PanelBrowserTitlebarGtk() {
30 } 30 }
31 31
32 void PanelBrowserTitlebarGtk::Init() {
jennb 2012/04/27 23:38:39 Don't need to override Init() in titlebar. You can
33 BrowserTitlebar::Init();
34
35 // Need to watch for minimize/unminimize button release event so that we can
36 // find out if the user is pressing down the modifier key simultaneously.
37 if (minimize_button() && unminimize_button_.get()) {
jennb 2012/04/27 23:43:15 Or, since we connect signals in the PanelBrowserWi
38 g_signal_connect(minimize_button()->widget(), "button-release-event",
39 G_CALLBACK(OnMinimizeButtonReleaseEventThunk), this);
40 g_signal_connect(unminimize_button_->widget(), "button-release-event",
41 G_CALLBACK(OnUnminimizeButtonReleaseEventThunk), this);
42 }
43 }
44
32 bool PanelBrowserTitlebarGtk::BuildButton(const std::string& button_token, 45 bool PanelBrowserTitlebarGtk::BuildButton(const std::string& button_token,
33 bool left_side) { 46 bool left_side) {
34 // Panel only shows close and minimize/restore buttons. 47 // Panel only shows close and minimize/restore buttons.
35 if (button_token != "close" && button_token != "minimize") 48 if (button_token != "close" && button_token != "minimize")
36 return false; 49 return false;
37 50
38 // Create unminimze button in order to show it to expand the minimized panel. 51 // Create unminimze button in order to show it to expand the minimized panel.
39 if (button_token == "minimize") 52 if (button_token == "minimize")
40 unminimize_button_.reset(CreateTitlebarButton("unminimize", left_side)); 53 unminimize_button_.reset(CreateTitlebarButton("unminimize", left_side));
41 54
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return; 91 return;
79 92
80 Panel* panel = browser_window_->panel(); 93 Panel* panel = browser_window_->panel();
81 gtk_widget_set_visible(minimize_button()->widget(), panel->CanMinimize()); 94 gtk_widget_set_visible(minimize_button()->widget(), panel->CanMinimize());
82 gtk_widget_set_visible(unminimize_button_->widget(), panel->CanRestore()); 95 gtk_widget_set_visible(unminimize_button_->widget(), panel->CanRestore());
83 } 96 }
84 97
85 void PanelBrowserTitlebarGtk::HandleButtonClick(GtkWidget* button) { 98 void PanelBrowserTitlebarGtk::HandleButtonClick(GtkWidget* button) {
86 if (close_button() && close_button()->widget() == button) 99 if (close_button() && close_button()->widget() == button)
87 browser_window_->panel()->Close(); 100 browser_window_->panel()->Close();
88 else if (minimize_button() && minimize_button()->widget() == button) 101 // Minimize/unminimize buttons are handled in mouse-release-event so that we
89 browser_window_->panel()->Minimize(); 102 // can find out if the user is pressing down the modifier key simultaneously.
90 else if (unminimize_button_.get() && unminimize_button_->widget() == button)
91 browser_window_->panel()->Restore();
92 } 103 }
93 104
94 void PanelBrowserTitlebarGtk::ShowFaviconMenu(GdkEventButton* event) { 105 void PanelBrowserTitlebarGtk::ShowFaviconMenu(GdkEventButton* event) {
95 // Favicon menu is not supported in panels. 106 // Favicon menu is not supported in panels.
96 } 107 }
108
109 gboolean PanelBrowserTitlebarGtk::OnMinimizeButtonReleaseEvent(
110 GtkWidget* widget, GdkEventButton* event) {
111 if (event->button != 1)
112 return TRUE;
113
114 browser_window_->panel()->OnMinimizeButtonClicked(
115 (event->state & GDK_CONTROL_MASK) ?
116 panel::APPLY_TO_ALL : panel::NO_MODIFIER);
117 return TRUE;
118 }
119
120 gboolean PanelBrowserTitlebarGtk::OnUnminimizeButtonReleaseEvent(
121 GtkWidget* widget, GdkEventButton* event) {
122 if (event->button != 1)
123 return TRUE;
124
125 browser_window_->panel()->OnRestoreButtonClicked(
126 (event->state & GDK_CONTROL_MASK) ?
127 panel::APPLY_TO_ALL : panel::NO_MODIFIER);
128 return TRUE;
129 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_titlebar_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698