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

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc

Issue 10561003: Implementaion for showing recently closed tabs list on right clicking new tab button. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 6 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
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/tabs/tab_strip_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/autocomplete/autocomplete.h" 16 #include "chrome/browser/autocomplete/autocomplete.h"
17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
18 #include "chrome/browser/autocomplete/autocomplete_match.h" 18 #include "chrome/browser/autocomplete/autocomplete_match.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/themes/theme_service.h" 20 #include "chrome/browser/themes/theme_service.h"
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_navigator.h" 22 #include "chrome/browser/ui/browser_navigator.h"
23 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 23 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
24 #include "chrome/browser/ui/gtk/custom_button.h" 24 #include "chrome/browser/ui/gtk/custom_button.h"
25 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 25 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
26 #include "chrome/browser/ui/gtk/gtk_util.h" 26 #include "chrome/browser/ui/gtk/gtk_util.h"
27 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h" 27 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h"
28 #include "chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.h" 28 #include "chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.h"
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
30 #include "chrome/browser/ui/tabs/recently_closed_tabs_menu_model.h"
30 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
31 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
32 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
33 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
34 #include "grit/theme_resources.h" 35 #include "grit/theme_resources.h"
35 #include "grit/theme_resources_standard.h" 36 #include "grit/theme_resources_standard.h"
36 #include "grit/ui_resources.h" 37 #include "grit/ui_resources.h"
37 #include "ui/base/animation/animation_delegate.h" 38 #include "ui/base/animation/animation_delegate.h"
38 #include "ui/base/animation/slide_animation.h" 39 #include "ui/base/animation/slide_animation.h"
39 #include "ui/base/dragdrop/gtk_dnd_util.h" 40 #include "ui/base/dragdrop/gtk_dnd_util.h"
(...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 info == ui::NETSCAPE_URL || 2164 info == ui::NETSCAPE_URL ||
2164 info == ui::TEXT_PLAIN) { 2165 info == ui::TEXT_PLAIN) {
2165 success = CompleteDrop(gtk_selection_data_get_data(data), 2166 success = CompleteDrop(gtk_selection_data_get_data(data),
2166 info == ui::TEXT_PLAIN); 2167 info == ui::TEXT_PLAIN);
2167 } 2168 }
2168 2169
2169 gtk_drag_finish(context, success, FALSE, time); 2170 gtk_drag_finish(context, success, FALSE, time);
2170 return TRUE; 2171 return TRUE;
2171 } 2172 }
2172 2173
2174 void TabStripGtk::ShowRecentlyClosedTabsMenu(GtkWidget* widget,
2175 int button, guint32 event_time) {
2176 Browser* browser = window_->browser();
2177 DCHECK(browser);
2178 menu_model_.reset(new RecentlyClosedTabsMenuModel(browser));
2179 menu_.reset(new MenuGtk(this, menu_model_.get()));
2180 menu_->PopupForWidget(widget, button, event_time);
2181 }
2182
2183 gboolean TabStripGtk::OnButtonPress(GtkWidget* widget,
2184 GdkEventButton* event) {
2185 if (event->button == 3)
2186 ShowRecentlyClosedTabsMenu(widget, event->button, event->time);
2187 return FALSE;
2188 }
2189
2173 void TabStripGtk::OnNewTabClicked(GtkWidget* widget) { 2190 void TabStripGtk::OnNewTabClicked(GtkWidget* widget) {
2174 GdkEvent* event = gtk_get_current_event(); 2191 GdkEvent* event = gtk_get_current_event();
2175 DCHECK_EQ(event->type, GDK_BUTTON_RELEASE); 2192 DCHECK_EQ(event->type, GDK_BUTTON_RELEASE);
2176 int mouse_button = event->button.button; 2193 int mouse_button = event->button.button;
2177 gdk_event_free(event); 2194 gdk_event_free(event);
2178 2195
2179 switch (mouse_button) { 2196 switch (mouse_button) {
2180 case 1: 2197 case 1:
2181 model_->delegate()->AddBlankTab(true); 2198 model_->delegate()->AddBlankTab(true);
2182 break; 2199 break;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 cairo_destroy(cr); 2255 cairo_destroy(cr);
2239 } 2256 }
2240 2257
2241 CustomDrawButton* TabStripGtk::MakeNewTabButton() { 2258 CustomDrawButton* TabStripGtk::MakeNewTabButton() {
2242 CustomDrawButton* button = new CustomDrawButton(IDR_NEWTAB_BUTTON, 2259 CustomDrawButton* button = new CustomDrawButton(IDR_NEWTAB_BUTTON,
2243 IDR_NEWTAB_BUTTON_P, IDR_NEWTAB_BUTTON_H, 0); 2260 IDR_NEWTAB_BUTTON_P, IDR_NEWTAB_BUTTON_H, 0);
2244 2261
2245 gtk_widget_set_tooltip_text(button->widget(), 2262 gtk_widget_set_tooltip_text(button->widget(),
2246 l10n_util::GetStringUTF8(IDS_TOOLTIP_NEW_TAB).c_str()); 2263 l10n_util::GetStringUTF8(IDS_TOOLTIP_NEW_TAB).c_str());
2247 2264
2265 g_signal_connect(button->widget(), "button-press-event",
2266 G_CALLBACK(OnButtonPressThunk), this);
2267
2248 // Let the middle mouse button initiate clicks as well. 2268 // Let the middle mouse button initiate clicks as well.
2249 gtk_util::SetButtonTriggersNavigation(button->widget()); 2269 gtk_util::SetButtonTriggersNavigation(button->widget());
2250 g_signal_connect(button->widget(), "clicked", 2270 g_signal_connect(button->widget(), "clicked",
2251 G_CALLBACK(OnNewTabClickedThunk), this); 2271 G_CALLBACK(OnNewTabClickedThunk), this);
2252 gtk_widget_set_can_focus(button->widget(), FALSE); 2272 gtk_widget_set_can_focus(button->widget(), FALSE);
2253 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); 2273 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0);
2254 2274
2255 return button; 2275 return button;
2256 } 2276 }
2257 2277
2258 void TabStripGtk::SetNewTabButtonBackground() { 2278 void TabStripGtk::SetNewTabButtonBackground() {
2259 SkColor color = theme_service_->GetColor( 2279 SkColor color = theme_service_->GetColor(
2260 ThemeService::COLOR_BUTTON_BACKGROUND); 2280 ThemeService::COLOR_BUTTON_BACKGROUND);
2261 SkBitmap* background = theme_service_->GetBitmapNamed( 2281 SkBitmap* background = theme_service_->GetBitmapNamed(
2262 IDR_THEME_WINDOW_CONTROL_BACKGROUND); 2282 IDR_THEME_WINDOW_CONTROL_BACKGROUND);
2263 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); 2283 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK);
2264 newtab_button_->SetBackground(color, background, mask); 2284 newtab_button_->SetBackground(color, background, mask);
2265 } 2285 }
2286
2287 bool TabStripGtk::AlwaysShowIconForCmd(int command_id) const {
2288 return true;
2289 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_strip_gtk.h ('k') | chrome/browser/ui/tabs/recently_closed_tabs_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698