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