OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/constrained_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/ui/gtk/gtk_util.h" | 10 #include "chrome/browser/ui/gtk/gtk_util.h" |
11 #include "content/browser/browser_thread.h" | 11 #include "content/browser/browser_thread.h" |
12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "ui/gfx/insets.h" |
13 | 14 |
14 #if defined(TOUCH_UI) | 15 #if defined(TOUCH_UI) |
15 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" | 16 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" |
16 #else | 17 #else |
17 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" | 18 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" |
18 #endif | 19 #endif |
19 | 20 |
20 ConstrainedWindowGtkDelegate::~ConstrainedWindowGtkDelegate() { | 21 ConstrainedWindowGtkDelegate::~ConstrainedWindowGtkDelegate() { |
21 } | 22 } |
22 | 23 |
23 bool ConstrainedWindowGtkDelegate::GetBackgroundColor(GdkColor* color) { | 24 bool ConstrainedWindowGtkDelegate::GetBackgroundColor(GdkColor* color) { |
24 return false; | 25 return false; |
25 } | 26 } |
26 | 27 |
| 28 gfx::Insets ConstrainedWindowGtkDelegate::GetInsets() const { |
| 29 return gfx::Insets(gtk_util::kContentAreaBorder, |
| 30 gtk_util::kContentAreaBorder, |
| 31 gtk_util::kContentAreaBorder, |
| 32 gtk_util::kContentAreaBorder); |
| 33 } |
| 34 |
27 ConstrainedWindowGtk::ConstrainedWindowGtk( | 35 ConstrainedWindowGtk::ConstrainedWindowGtk( |
28 TabContents* owner, ConstrainedWindowGtkDelegate* delegate) | 36 TabContents* owner, ConstrainedWindowGtkDelegate* delegate) |
29 : owner_(owner), | 37 : owner_(owner), |
30 delegate_(delegate), | 38 delegate_(delegate), |
31 visible_(false), | 39 visible_(false), |
32 factory_(this) { | 40 factory_(this) { |
33 DCHECK(owner); | 41 DCHECK(owner); |
34 DCHECK(delegate); | 42 DCHECK(delegate); |
35 GtkWidget* dialog = delegate->GetWidgetRoot(); | 43 GtkWidget* dialog = delegate->GetWidgetRoot(); |
36 | 44 |
37 // Unlike other users of CreateBorderBin, we need a dedicated frame around | 45 // Unlike other users of CreateBorderBin, we need a dedicated frame around |
38 // our "window". | 46 // our "window". |
39 GtkWidget* ebox = gtk_event_box_new(); | 47 GtkWidget* ebox = gtk_event_box_new(); |
40 GtkWidget* frame = gtk_frame_new(NULL); | 48 GtkWidget* frame = gtk_frame_new(NULL); |
41 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); | 49 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); |
42 | 50 |
43 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 51 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
| 52 gfx::Insets padding = delegate->GetInsets(); |
44 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), | 53 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), |
45 gtk_util::kContentAreaBorder, gtk_util::kContentAreaBorder, | 54 padding.top(), padding.bottom(), padding.left(), padding.right()); |
46 gtk_util::kContentAreaBorder, gtk_util::kContentAreaBorder); | |
47 GdkColor background; | 55 GdkColor background; |
48 if (delegate->GetBackgroundColor(&background)) { | 56 if (delegate->GetBackgroundColor(&background)) { |
49 gtk_widget_modify_base(ebox, GTK_STATE_NORMAL, &background); | 57 gtk_widget_modify_base(ebox, GTK_STATE_NORMAL, &background); |
50 gtk_widget_modify_fg(ebox, GTK_STATE_NORMAL, &background); | 58 gtk_widget_modify_fg(ebox, GTK_STATE_NORMAL, &background); |
51 gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, &background); | 59 gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, &background); |
52 } | 60 } |
53 | 61 |
54 if (gtk_widget_get_parent(dialog)) | 62 if (gtk_widget_get_parent(dialog)) |
55 gtk_widget_reparent(dialog, alignment); | 63 gtk_widget_reparent(dialog, alignment); |
56 else | 64 else |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 146 |
139 FocusConstrainedWindow(); | 147 FocusConstrainedWindow(); |
140 } | 148 } |
141 | 149 |
142 // static | 150 // static |
143 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 151 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
144 TabContents* parent, | 152 TabContents* parent, |
145 ConstrainedWindowGtkDelegate* delegate) { | 153 ConstrainedWindowGtkDelegate* delegate) { |
146 return new ConstrainedWindowGtk(parent, delegate); | 154 return new ConstrainedWindowGtk(parent, delegate); |
147 } | 155 } |
OLD | NEW |