summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/settings_page_view.cc
blob: 0702928d661cd6f728ba7bb14aee26adcc37c5ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chromeos/settings_page_view.h"

#include "chrome/browser/chromeos/settings_contents_view.h"
#include "skia/ext/skia_utils_gtk.h"
#include "views/controls/label.h"
#include "views/fill_layout.h"
#include "views/widget/widget_gtk.h"

SettingsPageView::SettingsPageView(Profile* profile)
    : OptionsPageView(profile) {
  SetLayoutManager(new views::FillLayout());
}

GtkWidget* SettingsPageView::WrapInGtkWidget() {
  views::WidgetGtk* widget =
      new views::WidgetGtk(views::WidgetGtk::TYPE_CHILD);
  widget->Init(NULL, gfx::Rect());
  widget->SetContentsView(this);
  // Set to a solid background with the same color as the widget's bg color.
  GtkStyle* window_style = gtk_widget_get_style(widget->GetNativeView());
  set_background(views::Background::CreateSolidBackground(
      skia::GdkColorToSkColor(window_style->bg[GTK_STATE_NORMAL])));
  widget->Show();
  // Removing the widget from the container results in unref'ing the widget. We
  // need to ref here otherwise the removal deletes the widget. The caller ends
  // up taking ownership.
  g_object_ref(widget->GetNativeView());
  GtkWidget* parent = gtk_widget_get_parent(widget->GetNativeView());
  gtk_container_remove(GTK_CONTAINER(parent), widget->GetNativeView());
  return widget->GetNativeView();
}

void SettingsPageView::InitControlLayout() {
  // We'll likely need to make this scrollable
  settings_contents_view_ = new SettingsContentsView(profile());
  AddChildView(settings_contents_view_);
}