OLD | NEW |
---|---|
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/extensions/shell_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/shell_window_gtk.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
9 #include "content/public/browser/render_widget_host_view.h" | 9 #include "content/public/browser/render_widget_host_view.h" |
10 | 10 |
11 ShellWindowGtk::ShellWindowGtk(ExtensionHost* host) | 11 ShellWindowGtk::ShellWindowGtk(ExtensionHost* host) |
12 : ShellWindow(host) { | 12 : ShellWindow(host) { |
13 host_->view()->SetContainer(this); | 13 host_->view()->SetContainer(this); |
14 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 14 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
15 | 15 |
16 gtk_container_add(GTK_CONTAINER(window_), host_->view()->native_view()); | 16 gtk_container_add(GTK_CONTAINER(window_), host_->view()->native_view()); |
17 | 17 |
18 // TOOD(mihaip): Allow window dimensions to be specified in manifest (and | 18 const Extension* extension = host_->extension(); |
19 // restore prior window dimensions and positions on relaunch). | 19 |
20 gtk_widget_set_size_request(GTK_WIDGET(window_), 512, 384); | 20 // TOOD(mihaip): restore prior window dimensions and positions on relaunch. |
21 gtk_window_set_default_size( | |
22 window_, extension->launch_width(), extension->launch_height()); | |
23 | |
24 int min_width = extension->launch_min_width(); | |
25 int min_height = extension->launch_min_height(); | |
26 int max_width = extension->launch_max_width(); | |
27 int max_height = extension->launch_max_height(); | |
28 GdkGeometry hints; | |
29 int hints_mask = 0; | |
30 if (min_width || min_height) { | |
31 hints.min_height = min_height; | |
32 hints.min_width = min_width; | |
33 hints_mask |= GDK_HINT_MIN_SIZE; | |
34 } | |
35 if (max_width || max_height) { | |
36 hints.max_height = max_height ? max_height : G_MAXINT; | |
Mihai Parparita -not on Chrome
2012/03/02 02:01:00
Per http://developer.gnome.org/gdk/stable/gdk-Wind
| |
37 hints.max_width = max_width ? max_width : G_MAXINT; | |
38 hints_mask |= GDK_HINT_MAX_SIZE; | |
39 } | |
40 if (hints_mask) { | |
41 gtk_window_set_geometry_hints( | |
42 window_, | |
43 GTK_WIDGET(window_), | |
44 &hints, | |
45 static_cast<GdkWindowHints>(hints_mask)); | |
46 } | |
21 | 47 |
22 // TODO(mihaip): Mirror contents of <title> tag in window title | 48 // TODO(mihaip): Mirror contents of <title> tag in window title |
23 gtk_window_set_title(window_, host->extension()->name().c_str()); | 49 gtk_window_set_title(window_, extension->name().c_str()); |
24 | 50 |
25 g_signal_connect(window_, "delete-event", | 51 g_signal_connect(window_, "delete-event", |
26 G_CALLBACK(OnMainWindowDeleteEventThunk), this); | 52 G_CALLBACK(OnMainWindowDeleteEventThunk), this); |
27 | 53 |
28 gtk_window_present(window_); | 54 gtk_window_present(window_); |
29 } | 55 } |
30 | 56 |
31 ShellWindowGtk::~ShellWindowGtk() { | 57 ShellWindowGtk::~ShellWindowGtk() { |
32 } | 58 } |
33 | 59 |
(...skipping 10 matching lines...) Expand all Loading... | |
44 | 70 |
45 // Return true to prevent the GTK window from being destroyed. Close will | 71 // Return true to prevent the GTK window from being destroyed. Close will |
46 // destroy it for us. | 72 // destroy it for us. |
47 return TRUE; | 73 return TRUE; |
48 } | 74 } |
49 | 75 |
50 // static | 76 // static |
51 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { | 77 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { |
52 return new ShellWindowGtk(host); | 78 return new ShellWindowGtk(host); |
53 } | 79 } |
OLD | NEW |