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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// 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/gtk/options/advanced_page_gtk.h"
#include "app/l10n_util.h"
#include "chrome/browser/options_util.h"
#include "chrome/common/gtk_util.h"
#include "grit/generated_resources.h"
#include "grit/chromium_strings.h"
AdvancedPageGtk::AdvancedPageGtk(Profile* profile)
: OptionsPageBase(profile),
advanced_contents_(profile) {
Init();
}
AdvancedPageGtk::~AdvancedPageGtk() {
}
void AdvancedPageGtk::Init() {
page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
gtk_container_set_border_width(GTK_CONTAINER(page_),
gtk_util::kContentAreaBorder);
GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(page_), scroll_window);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
// Note that typically we call gtk_scrolled_window_set_shadow_type right
// here, but the add_with_viewport method of GtkScrolledWindow already adds
// its own shadow.
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll_window),
advanced_contents_.get_page_widget());
GtkWidget* button_box = gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_END);
GtkWidget* reset_button = gtk_button_new_with_label(
l10n_util::GetStringUTF8(IDS_OPTIONS_RESET).c_str());
g_signal_connect(reset_button, "clicked",
G_CALLBACK(OnResetToDefaultsClicked), this);
gtk_container_add(GTK_CONTAINER(button_box), reset_button);
gtk_box_pack_start(GTK_BOX(page_), button_box, FALSE, FALSE, 0);
}
// static
void AdvancedPageGtk::OnResetToDefaultsClicked(
GtkButton* button, AdvancedPageGtk* advanced_page) {
advanced_page->UserMetricsRecordAction("Options_ResetToDefaults", NULL);
GtkWidget* dialog_ = gtk_message_dialog_new(
GTK_WINDOW(gtk_widget_get_toplevel(advanced_page->page_)),
static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"%s",
l10n_util::GetStringUTF8(IDS_OPTIONS_RESET_MESSAGE).c_str());
gtk_util::ApplyMessageDialogQuirks(dialog_);
gtk_dialog_add_buttons(
GTK_DIALOG(dialog_),
l10n_util::GetStringUTF8(IDS_OPTIONS_RESET_CANCELLABEL).c_str(),
GTK_RESPONSE_CANCEL,
l10n_util::GetStringUTF8(IDS_OPTIONS_RESET_OKLABEL).c_str(),
GTK_RESPONSE_OK,
NULL);
gtk_window_set_title(GTK_WINDOW(dialog_),
l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str());
g_signal_connect(dialog_, "response",
G_CALLBACK(OnResetToDefaultsResponse), advanced_page);
gtk_widget_show_all(dialog_);
}
// static
void AdvancedPageGtk::OnResetToDefaultsResponse(
GtkDialog* dialog, int response_id, AdvancedPageGtk* advanced_page) {
if (response_id == GTK_RESPONSE_OK) {
OptionsUtil::ResetToDefaults(advanced_page->profile());
}
gtk_widget_destroy(GTK_WIDGET(dialog));
}
|