OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/constrained_window_gtk.h" | 5 #include "chrome/browser/gtk/constrained_window_gtk.h" |
6 | 6 |
7 #include "chrome/browser/tab_contents/tab_contents.h" | 7 #include "chrome/browser/tab_contents/tab_contents.h" |
8 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" | 8 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" |
9 #include "chrome/common/gtk_util.h" | 9 #include "chrome/common/gtk_util.h" |
10 | 10 |
11 // The minimal border around the edge of the notification. | |
12 const int kSmallPadding = 2; | |
13 | |
14 ConstrainedWindowGtk::ConstrainedWindowGtk( | 11 ConstrainedWindowGtk::ConstrainedWindowGtk( |
15 TabContents* owner, ConstrainedWindowGtkDelegate* delegate) | 12 TabContents* owner, ConstrainedWindowGtkDelegate* delegate) |
16 : owner_(owner), | 13 : owner_(owner), |
17 delegate_(delegate) { | 14 delegate_(delegate) { |
18 DCHECK(owner); | 15 DCHECK(owner); |
19 DCHECK(delegate); | 16 DCHECK(delegate); |
20 GtkWidget* dialog = delegate->GetWidgetRoot(); | 17 GtkWidget* dialog = delegate->GetWidgetRoot(); |
21 | 18 |
22 // Unlike other users of CreateBorderBin, we need a dedicated frame around | 19 // Unlike other users of CreateBorderBin, we need a dedicated frame around |
23 // our "window". | 20 // our "window". |
24 GtkWidget* ebox = gtk_event_box_new(); | 21 GtkWidget* ebox = gtk_event_box_new(); |
25 GtkWidget* frame = gtk_frame_new(NULL); | 22 GtkWidget* frame = gtk_frame_new(NULL); |
26 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT); | 23 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); |
27 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 24 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
28 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), | 25 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), |
29 kSmallPadding, kSmallPadding, kSmallPadding, kSmallPadding); | 26 gtk_util::kContentAreaBorder, gtk_util::kContentAreaBorder, |
| 27 gtk_util::kContentAreaBorder, gtk_util::kContentAreaBorder); |
30 gtk_container_add(GTK_CONTAINER(alignment), dialog); | 28 gtk_container_add(GTK_CONTAINER(alignment), dialog); |
31 gtk_container_add(GTK_CONTAINER(frame), alignment); | 29 gtk_container_add(GTK_CONTAINER(frame), alignment); |
32 gtk_container_add(GTK_CONTAINER(ebox), frame); | 30 gtk_container_add(GTK_CONTAINER(ebox), frame); |
33 border_.Own(ebox); | 31 border_.Own(ebox); |
34 | 32 |
35 gtk_widget_show_all(border_.get()); | 33 gtk_widget_show_all(border_.get()); |
36 | 34 |
37 // We collaborate with TabContentsViewGtk and stick ourselves in the | 35 // We collaborate with TabContentsViewGtk and stick ourselves in the |
38 // TabContentsViewGtk's floating container. | 36 // TabContentsViewGtk's floating container. |
39 ContainingView()->AttachConstrainedWindow(this); | 37 ContainingView()->AttachConstrainedWindow(this); |
(...skipping 14 matching lines...) Expand all Loading... |
54 TabContentsViewGtk* ConstrainedWindowGtk::ContainingView() { | 52 TabContentsViewGtk* ConstrainedWindowGtk::ContainingView() { |
55 return static_cast<TabContentsViewGtk*>(owner_->view()); | 53 return static_cast<TabContentsViewGtk*>(owner_->view()); |
56 } | 54 } |
57 | 55 |
58 // static | 56 // static |
59 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 57 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
60 TabContents* parent, | 58 TabContents* parent, |
61 ConstrainedWindowGtkDelegate* delegate) { | 59 ConstrainedWindowGtkDelegate* delegate) { |
62 return new ConstrainedWindowGtk(parent, delegate); | 60 return new ConstrainedWindowGtk(parent, delegate); |
63 } | 61 } |
OLD | NEW |