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/import_dialog_gtk.h" | 5 #include "chrome/browser/gtk/import_dialog_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
13 | 13 |
14 // static | 14 // static |
15 void ImportDialogGtk::Show(GtkWindow* parent, Profile* profile) { | 15 void ImportDialogGtk::Show(GtkWindow* parent, Profile* profile) { |
16 new ImportDialogGtk(parent, profile); | 16 new ImportDialogGtk(parent, profile); |
17 } | 17 } |
18 | 18 |
19 ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) : | 19 ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) : |
20 profile_(profile), importer_host_(new ImporterHost()) { | 20 profile_(profile), importer_host_(new ImporterHost()) { |
21 // Build the dialog. | 21 // Build the dialog. |
22 GtkWidget* dialog = gtk_dialog_new_with_buttons( | 22 GtkWidget* dialog = gtk_dialog_new_with_buttons( |
23 l10n_util::GetStringUTF8(IDS_IMPORT_SETTINGS_TITLE).c_str(), | 23 l10n_util::GetStringUTF8(IDS_IMPORT_SETTINGS_TITLE).c_str(), |
24 parent, | 24 parent, |
25 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | 25 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), |
| 26 GTK_STOCK_CANCEL, |
| 27 GTK_RESPONSE_REJECT, |
26 l10n_util::GetStringUTF8(IDS_IMPORT_COMMIT).c_str(), | 28 l10n_util::GetStringUTF8(IDS_IMPORT_COMMIT).c_str(), |
27 GTK_RESPONSE_ACCEPT, | 29 GTK_RESPONSE_ACCEPT, |
28 l10n_util::GetStringUTF8(IDS_CANCEL).c_str(), | |
29 GTK_RESPONSE_REJECT, | |
30 NULL); | 30 NULL); |
31 | 31 |
32 //TODO(rahulk): find how to set size properly so that the dialog box width is | 32 // TODO(rahulk): find how to set size properly so that the dialog |
33 // atleast enough to display full title. | 33 // box width is at least enough to display full title. |
34 gtk_widget_set_size_request(dialog, 300, -1); | 34 gtk_widget_set_size_request(dialog, 300, -1); |
35 | 35 |
36 GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; | 36 GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; |
37 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 0.0, 0.0); | 37 gtk_box_set_spacing(GTK_BOX(content_area), 18); |
38 gtk_box_pack_start(GTK_BOX(content_area), alignment, TRUE, TRUE, 0); | |
39 | 38 |
40 GtkWidget* vbox = gtk_vbox_new(FALSE, 0); | 39 GtkWidget* combo_hbox = gtk_hbox_new(FALSE, 12); |
41 gtk_container_add(GTK_CONTAINER(alignment), vbox); | |
42 | |
43 GtkWidget* combo_hbox = gtk_hbox_new(FALSE, 5); | |
44 GtkWidget* from = gtk_label_new( | 40 GtkWidget* from = gtk_label_new( |
45 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_LABEL).c_str()); | 41 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_LABEL).c_str()); |
46 gtk_box_pack_start(GTK_BOX(combo_hbox), from, TRUE, TRUE, 5); | 42 gtk_box_pack_start(GTK_BOX(combo_hbox), from, FALSE, FALSE, 0); |
47 | 43 |
48 combo_ = gtk_combo_box_new_text(); | 44 combo_ = gtk_combo_box_new_text(); |
49 int profiles_count = importer_host_->GetAvailableProfileCount(); | 45 int profiles_count = importer_host_->GetAvailableProfileCount(); |
50 for (int i = 0; i < profiles_count; i++) { | 46 for (int i = 0; i < profiles_count; i++) { |
51 std::wstring profile = importer_host_->GetSourceProfileNameAt(i); | 47 std::wstring profile = importer_host_->GetSourceProfileNameAt(i); |
52 gtk_combo_box_append_text(GTK_COMBO_BOX(combo_), | 48 gtk_combo_box_append_text(GTK_COMBO_BOX(combo_), |
53 WideToUTF8(profile).c_str()); | 49 WideToUTF8(profile).c_str()); |
54 } | 50 } |
55 gtk_combo_box_set_active(GTK_COMBO_BOX(combo_), 0); | 51 gtk_combo_box_set_active(GTK_COMBO_BOX(combo_), 0); |
56 gtk_box_pack_start(GTK_BOX(combo_hbox), combo_, TRUE, TRUE, 5); | 52 gtk_box_pack_start(GTK_BOX(combo_hbox), combo_, TRUE, TRUE, 0); |
57 gtk_box_pack_start(GTK_BOX(vbox), combo_hbox, TRUE, TRUE, 5); | 53 |
| 54 gtk_box_pack_start(GTK_BOX(content_area), combo_hbox, FALSE, FALSE, 0); |
| 55 |
| 56 GtkWidget* vbox = gtk_vbox_new(FALSE, 6); |
58 | 57 |
59 GtkWidget* description = gtk_label_new( | 58 GtkWidget* description = gtk_label_new( |
60 l10n_util::GetStringUTF8(IDS_IMPORT_ITEMS_LABEL).c_str()); | 59 l10n_util::GetStringUTF8(IDS_IMPORT_ITEMS_LABEL).c_str()); |
61 gtk_box_pack_start(GTK_BOX(vbox), description, TRUE, TRUE, 5); | 60 gtk_misc_set_alignment(GTK_MISC(description), 0, 0); |
62 | 61 gtk_box_pack_start(GTK_BOX(vbox), description, FALSE, FALSE, 0); |
63 GtkWidget* text_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | |
64 gtk_alignment_set_padding(GTK_ALIGNMENT(text_alignment), 0, 0, 25, 0); | |
65 GtkWidget* text_vbox = gtk_vbox_new(FALSE, 0); | |
66 gtk_container_add(GTK_CONTAINER(text_alignment), text_vbox); | |
67 gtk_box_pack_start(GTK_BOX(vbox), text_alignment, TRUE, TRUE, 0); | |
68 | 62 |
69 bookmarks_ = gtk_check_button_new_with_label( | 63 bookmarks_ = gtk_check_button_new_with_label( |
70 l10n_util::GetStringUTF8(IDS_IMPORT_FAVORITES_CHKBOX).c_str()); | 64 l10n_util::GetStringUTF8(IDS_IMPORT_FAVORITES_CHKBOX).c_str()); |
71 gtk_box_pack_start(GTK_BOX(text_vbox), bookmarks_, TRUE, TRUE, 5); | 65 gtk_box_pack_start(GTK_BOX(vbox), bookmarks_, FALSE, FALSE, 0); |
72 | 66 |
73 search_engines_ = gtk_check_button_new_with_label( | 67 search_engines_ = gtk_check_button_new_with_label( |
74 l10n_util::GetStringUTF8(IDS_IMPORT_SEARCH_ENGINES_CHKBOX).c_str()); | 68 l10n_util::GetStringUTF8(IDS_IMPORT_SEARCH_ENGINES_CHKBOX).c_str()); |
75 gtk_box_pack_start(GTK_BOX(text_vbox), search_engines_, TRUE, TRUE, 5); | 69 gtk_box_pack_start(GTK_BOX(vbox), search_engines_, FALSE, FALSE, 0); |
76 | 70 |
77 passwords_ = gtk_check_button_new_with_label( | 71 passwords_ = gtk_check_button_new_with_label( |
78 l10n_util::GetStringUTF8(IDS_IMPORT_PASSWORDS_CHKBOX).c_str()); | 72 l10n_util::GetStringUTF8(IDS_IMPORT_PASSWORDS_CHKBOX).c_str()); |
79 gtk_box_pack_start(GTK_BOX(text_vbox), passwords_, TRUE, TRUE, 5); | 73 gtk_box_pack_start(GTK_BOX(vbox), passwords_, FALSE, FALSE, 0); |
80 | 74 |
81 history_ = gtk_check_button_new_with_label( | 75 history_ = gtk_check_button_new_with_label( |
82 l10n_util::GetStringUTF8(IDS_IMPORT_HISTORY_CHKBOX).c_str()); | 76 l10n_util::GetStringUTF8(IDS_IMPORT_HISTORY_CHKBOX).c_str()); |
83 gtk_box_pack_start(GTK_BOX(text_vbox), history_, TRUE, TRUE, 5); | 77 gtk_box_pack_start(GTK_BOX(vbox), history_, FALSE, FALSE, 0); |
| 78 gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 0); |
84 | 79 |
85 g_signal_connect(dialog, "response", | 80 g_signal_connect(dialog, "response", |
86 G_CALLBACK(HandleOnResponseDialog), this); | 81 G_CALLBACK(HandleOnResponseDialog), this); |
87 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | 82 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
88 gtk_widget_show_all(dialog); | 83 gtk_widget_show_all(dialog); |
89 } | 84 } |
90 | 85 |
91 void ImportDialogGtk::OnDialogResponse(GtkWidget* widget, int response) { | 86 void ImportDialogGtk::OnDialogResponse(GtkWidget* widget, int response) { |
92 if (response == GTK_RESPONSE_ACCEPT) { | 87 if (response == GTK_RESPONSE_ACCEPT) { |
93 uint16 items = NONE; | 88 uint16 items = NONE; |
(...skipping 12 matching lines...) Expand all Loading... |
106 // TODO(rahulk): We should not do the import on this thread. Instead | 101 // TODO(rahulk): We should not do the import on this thread. Instead |
107 // we need to start this asynchronously and launch a UI that shows the | 102 // we need to start this asynchronously and launch a UI that shows the |
108 // progress of import. | 103 // progress of import. |
109 importer_host_->StartImportSettings(source_profile, items, | 104 importer_host_->StartImportSettings(source_profile, items, |
110 new ProfileWriter(profile_), false); | 105 new ProfileWriter(profile_), false); |
111 } | 106 } |
112 | 107 |
113 delete this; | 108 delete this; |
114 gtk_widget_destroy(GTK_WIDGET(widget)); | 109 gtk_widget_destroy(GTK_WIDGET(widget)); |
115 } | 110 } |
OLD | NEW |