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 "views/controls/tabbed_pane/native_tabbed_pane_gtk.h" | 5 #include "views/controls/tabbed_pane/native_tabbed_pane_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
10 #include "app/gfx/font.h" | 10 #include "app/gfx/font.h" |
11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "skia/ext/skia_utils_gtk.h" |
| 16 #include "views/background.h" |
15 #include "views/controls/tabbed_pane/tabbed_pane.h" | 17 #include "views/controls/tabbed_pane/tabbed_pane.h" |
16 #include "views/fill_layout.h" | 18 #include "views/fill_layout.h" |
17 #include "views/widget/root_view.h" | 19 #include "views/widget/root_view.h" |
18 #include "views/widget/widget_gtk.h" | 20 #include "views/widget/widget_gtk.h" |
19 | 21 |
20 namespace views { | 22 namespace views { |
21 | 23 |
22 //////////////////////////////////////////////////////////////////////////////// | 24 //////////////////////////////////////////////////////////////////////////////// |
23 // NativeTabbedPaneGtk, public: | 25 // NativeTabbedPaneGtk, public: |
24 | 26 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 View* contents, | 124 View* contents, |
123 bool select_if_first_tab) { | 125 bool select_if_first_tab) { |
124 int tab_count = GetTabCount(); | 126 int tab_count = GetTabCount(); |
125 DCHECK(index <= tab_count); | 127 DCHECK(index <= tab_count); |
126 | 128 |
127 WidgetGtk* page_container = new WidgetGtk(WidgetGtk::TYPE_CHILD); | 129 WidgetGtk* page_container = new WidgetGtk(WidgetGtk::TYPE_CHILD); |
128 page_container->Init(NULL, gfx::Rect()); | 130 page_container->Init(NULL, gfx::Rect()); |
129 page_container->SetContentsView(contents); | 131 page_container->SetContentsView(contents); |
130 page_container->Show(); | 132 page_container->Show(); |
131 | 133 |
| 134 if (!contents->background()) { |
| 135 GtkStyle* window_style = |
| 136 gtk_widget_get_style(page_container->GetNativeView()); |
| 137 contents->set_background( |
| 138 Background::CreateSolidBackground( |
| 139 skia::GdkColorToSkColor(window_style->bg[GTK_STATE_NORMAL]))); |
| 140 } |
| 141 |
132 GtkWidget* page = page_container->GetNativeView(); | 142 GtkWidget* page = page_container->GetNativeView(); |
133 | 143 |
134 // increment ref count not to delete on remove below | 144 // increment ref count not to delete on remove below |
135 g_object_ref(page); | 145 g_object_ref(page); |
136 // detach parent from the page so that we can add it to notebook | 146 // detach parent from the page so that we can add it to notebook |
137 GtkWidget* parent = gtk_widget_get_parent(page); | 147 GtkWidget* parent = gtk_widget_get_parent(page); |
138 gtk_container_remove(GTK_CONTAINER(parent), page); | 148 gtk_container_remove(GTK_CONTAINER(parent), page); |
139 | 149 |
140 GtkWidget* label = gtk_label_new(WideToUTF8(title).c_str()); | 150 GtkWidget* label = gtk_label_new(WideToUTF8(title).c_str()); |
141 gtk_widget_show(label); | 151 gtk_widget_show(label); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 //////////////////////////////////////////////////////////////////////////////// | 185 //////////////////////////////////////////////////////////////////////////////// |
176 // NativeTabbedPaneWrapper, public: | 186 // NativeTabbedPaneWrapper, public: |
177 | 187 |
178 // static | 188 // static |
179 NativeTabbedPaneWrapper* NativeTabbedPaneWrapper::CreateNativeWrapper( | 189 NativeTabbedPaneWrapper* NativeTabbedPaneWrapper::CreateNativeWrapper( |
180 TabbedPane* tabbed_pane) { | 190 TabbedPane* tabbed_pane) { |
181 return new NativeTabbedPaneGtk(tabbed_pane); | 191 return new NativeTabbedPaneGtk(tabbed_pane); |
182 } | 192 } |
183 | 193 |
184 } // namespace views | 194 } // namespace views |
OLD | NEW |