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

Side by Side Diff: content/shell/shell_gtk.cc

Issue 10855070: Add shortcut to create new window for GTK content shell. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix nits Created 8 years, 4 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
« no previous file with comments | « content/shell/shell.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 "content/shell/shell.h" 5 #include "content/shell/shell.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 "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/string_piece.h" 12 #include "base/string_piece.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
15 #include "content/public/browser/native_web_keyboard_event.h" 15 #include "content/public/browser/native_web_keyboard_event.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_view.h" 17 #include "content/public/browser/web_contents_view.h"
18 #include "content/public/common/renderer_preferences.h" 18 #include "content/public/common/renderer_preferences.h"
19 #include "content/shell/shell_browser_context.h"
20 #include "content/shell/shell_content_browser_client.h"
19 #include "content/shell/shell_switches.h" 21 #include "content/shell/shell_switches.h"
20 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
21 23
22 namespace content { 24 namespace content {
23 25
24 void Shell::PlatformInitialize() { 26 void Shell::PlatformInitialize() {
25 } 27 }
26 28
27 base::StringPiece Shell::PlatformResourceProvider(int key) { 29 base::StringPiece Shell::PlatformResourceProvider(int key) {
28 NOTIMPLEMENTED(); 30 NOTIMPLEMENTED();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 GtkAccelGroup* accel_group = gtk_accel_group_new(); 77 GtkAccelGroup* accel_group = gtk_accel_group_new();
76 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group); 78 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group);
77 79
78 // Set global window handling accelerators: 80 // Set global window handling accelerators:
79 gtk_accel_group_connect( 81 gtk_accel_group_connect(
80 accel_group, GDK_w, GDK_CONTROL_MASK, 82 accel_group, GDK_w, GDK_CONTROL_MASK,
81 GTK_ACCEL_VISIBLE, 83 GTK_ACCEL_VISIBLE,
82 g_cclosure_new(G_CALLBACK(OnCloseWindowKeyPressedThunk), 84 g_cclosure_new(G_CALLBACK(OnCloseWindowKeyPressedThunk),
83 this, NULL)); 85 this, NULL));
84 86
87 gtk_accel_group_connect(
88 accel_group, GDK_n, GDK_CONTROL_MASK,
89 GTK_ACCEL_VISIBLE,
90 g_cclosure_new(G_CALLBACK(OnNewWindowKeyPressedThunk),
91 this, NULL));
92
85 GtkWidget* toolbar = gtk_toolbar_new(); 93 GtkWidget* toolbar = gtk_toolbar_new();
86 // Turn off the labels on the toolbar buttons. 94 // Turn off the labels on the toolbar buttons.
87 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); 95 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
88 96
89 back_button_ = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK); 97 back_button_ = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
90 g_signal_connect(back_button_, "clicked", 98 g_signal_connect(back_button_, "clicked",
91 G_CALLBACK(&OnBackButtonClickedThunk), this); 99 G_CALLBACK(&OnBackButtonClickedThunk), this);
92 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back_button_, -1 /* append */); 100 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back_button_, -1 /* append */);
93 gtk_widget_add_accelerator(GTK_WIDGET(back_button_), "clicked", accel_group, 101 gtk_widget_add_accelerator(GTK_WIDGET(back_button_), "clicked", accel_group,
94 GDK_Left, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); 102 GDK_Left, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 225 }
218 226
219 gboolean Shell::OnCloseWindowKeyPressed(GtkAccelGroup* accel_group, 227 gboolean Shell::OnCloseWindowKeyPressed(GtkAccelGroup* accel_group,
220 GObject* acceleratable, 228 GObject* acceleratable,
221 guint keyval, 229 guint keyval,
222 GdkModifierType modifier) { 230 GdkModifierType modifier) {
223 gtk_widget_destroy(GTK_WIDGET(window_)); 231 gtk_widget_destroy(GTK_WIDGET(window_));
224 return TRUE; 232 return TRUE;
225 } 233 }
226 234
235 gboolean Shell::OnNewWindowKeyPressed(GtkAccelGroup* accel_group,
236 GObject* acceleratable,
237 guint keyval,
238 GdkModifierType modifier) {
239 ShellBrowserContext* browser_context =
240 static_cast<ShellContentBrowserClient*>(
241 GetContentClient()->browser())->browser_context();
242 Shell::CreateNewWindow(browser_context,
243 GURL(),
244 NULL,
245 MSG_ROUTING_NONE,
246 NULL);
247 return TRUE;
248 }
249
227 gboolean Shell::OnHighlightURLView(GtkAccelGroup* accel_group, 250 gboolean Shell::OnHighlightURLView(GtkAccelGroup* accel_group,
228 GObject* acceleratable, 251 GObject* acceleratable,
229 guint keyval, 252 guint keyval,
230 GdkModifierType modifier) { 253 GdkModifierType modifier) {
231 gtk_widget_grab_focus(GTK_WIDGET(url_edit_view_)); 254 gtk_widget_grab_focus(GTK_WIDGET(url_edit_view_));
232 return TRUE; 255 return TRUE;
233 } 256 }
234 257
235 void Shell::PlatformSetTitle(const string16& title) { 258 void Shell::PlatformSetTitle(const string16& title) {
236 std::string title_utf8 = UTF16ToUTF8(title); 259 std::string title_utf8 = UTF16ToUTF8(title);
237 gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str()); 260 gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str());
238 } 261 }
239 262
240 } // namespace content 263 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/shell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698