OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/gtk/extensions/shell_window_gtk.h" |
| 6 |
| 7 #include "chrome/browser/extensions/extension_host.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_view_gtk.h" |
| 9 |
| 10 ShellWindowGtk::ShellWindowGtk(ExtensionHost* host) |
| 11 : ShellWindow(host) { |
| 12 host_->view()->SetContainer(this); |
| 13 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
| 14 |
| 15 gtk_container_add(GTK_CONTAINER(window_), host_->view()->native_view()); |
| 16 |
| 17 // TOOD(mihaip): Allow window dimensions to be specified in manifest (and |
| 18 // restore prior window dimensions and positions on relaunch). |
| 19 gtk_widget_set_size_request(GTK_WIDGET(window_), 512, 384); |
| 20 gtk_window_set_decorated(window_, false); |
| 21 |
| 22 g_signal_connect(window_, "delete-event", |
| 23 G_CALLBACK(OnMainWindowDeleteEventThunk), this); |
| 24 |
| 25 gtk_window_present(window_); |
| 26 } |
| 27 |
| 28 ShellWindowGtk::~ShellWindowGtk() { |
| 29 } |
| 30 |
| 31 void ShellWindowGtk::Close() { |
| 32 gtk_widget_destroy(GTK_WIDGET(window_)); |
| 33 delete this; |
| 34 } |
| 35 |
| 36 // Callback for the delete event. This event is fired when the user tries to |
| 37 // close the window (e.g., clicking on the X in the window manager title bar). |
| 38 gboolean ShellWindowGtk::OnMainWindowDeleteEvent(GtkWidget* widget, |
| 39 GdkEvent* event) { |
| 40 Close(); |
| 41 |
| 42 // Return true to prevent the GTK window from being destroyed. Close will |
| 43 // destroy it for us. |
| 44 return TRUE; |
| 45 } |
| 46 |
| 47 // static |
| 48 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { |
| 49 return new ShellWindowGtk(host); |
| 50 } |
OLD | NEW |