summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-11 23:45:25 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-11 23:45:25 +0000
commit1bdf29eb27c00bd1be0a6f3eb65d33ecddde274f (patch)
tree35abd9143abed93d47d2bd4bf63f922e4d5c99dc /chrome/browser/gtk
parent0c557f15b825d1036a1e48a148ff10d9cd51ab0f (diff)
downloadchromium_src-1bdf29eb27c00bd1be0a6f3eb65d33ecddde274f.zip
chromium_src-1bdf29eb27c00bd1be0a6f3eb65d33ecddde274f.tar.gz
chromium_src-1bdf29eb27c00bd1be0a6f3eb65d33ecddde274f.tar.bz2
Add import settings dialog on linux.
BUG=11191 TEST=Open Import Settings dialog from Chrome wrench menu on Linux and make sure it imports Firefox data as selected. Review URL: http://codereview.chromium.org/115133 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc3
-rw-r--r--chrome/browser/gtk/import_dialog_gtk.cc115
-rw-r--r--chrome/browser/gtk/import_dialog_gtk.h56
3 files changed, 173 insertions, 1 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 33f005a..3c40c7f 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/gtk/bookmark_bar_gtk.h"
#include "chrome/browser/gtk/browser_toolbar_gtk.h"
#include "chrome/browser/gtk/go_button_gtk.h"
+#include "chrome/browser/gtk/import_dialog_gtk.h"
#include "chrome/browser/gtk/infobar_container_gtk.h"
#include "chrome/browser/gtk/find_bar_gtk.h"
#include "chrome/browser/gtk/status_bubble_gtk.h"
@@ -565,7 +566,7 @@ void BrowserWindowGtk::ShowClearBrowsingDataDialog() {
}
void BrowserWindowGtk::ShowImportDialog() {
- NOTIMPLEMENTED();
+ ImportDialogGtk::Show(window_, browser_->profile());
}
void BrowserWindowGtk::ShowSearchEnginesDialog() {
diff --git a/chrome/browser/gtk/import_dialog_gtk.cc b/chrome/browser/gtk/import_dialog_gtk.cc
new file mode 100644
index 0000000..c0b9cbd1
--- /dev/null
+++ b/chrome/browser/gtk/import_dialog_gtk.cc
@@ -0,0 +1,115 @@
+// 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/import_dialog_gtk.h"
+
+#include <gtk/gtk.h>
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "chrome/browser/profile.h"
+#include "grit/generated_resources.h"
+
+// static
+void ImportDialogGtk::Show(GtkWindow* parent, Profile* profile) {
+ new ImportDialogGtk(parent, profile);
+}
+
+ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) :
+ profile_(profile), importer_host_(new ImporterHost()) {
+ // Build the dialog.
+ GtkWidget* dialog = gtk_dialog_new_with_buttons(
+ l10n_util::GetStringUTF8(IDS_IMPORT_SETTINGS_TITLE).c_str(),
+ parent,
+ (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
+ l10n_util::GetStringUTF8(IDS_IMPORT_COMMIT).c_str(),
+ GTK_RESPONSE_ACCEPT,
+ l10n_util::GetStringUTF8(IDS_CANCEL).c_str(),
+ GTK_RESPONSE_REJECT,
+ NULL);
+
+ //TODO(rahulk): find how to set size properly so that the dialog box width is
+ // atleast enough to display full title.
+ gtk_widget_set_size_request(dialog, 300, -1);
+
+ GtkWidget* content_area = GTK_DIALOG(dialog)->vbox;
+ GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
+ gtk_box_pack_start(GTK_BOX(content_area), alignment, TRUE, TRUE, 0);
+
+ GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(alignment), vbox);
+
+ GtkWidget* combo_hbox = gtk_hbox_new(FALSE, 5);
+ GtkWidget* from = gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_IMPORT_FROM_LABEL).c_str());
+ gtk_box_pack_start(GTK_BOX(combo_hbox), from, TRUE, TRUE, 5);
+
+ combo_ = gtk_combo_box_new_text();
+ int profiles_count = importer_host_->GetAvailableProfileCount();
+ for (int i = 0; i < profiles_count; i++) {
+ std::wstring profile = importer_host_->GetSourceProfileNameAt(i);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
+ WideToUTF8(profile).c_str());
+ }
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo_), 0);
+ gtk_box_pack_start(GTK_BOX(combo_hbox), combo_, TRUE, TRUE, 5);
+ gtk_box_pack_start(GTK_BOX(vbox), combo_hbox, TRUE, TRUE, 5);
+
+ GtkWidget* description = gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_IMPORT_ITEMS_LABEL).c_str());
+ gtk_box_pack_start(GTK_BOX(vbox), description, TRUE, TRUE, 5);
+
+ GtkWidget* text_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(text_alignment), 0, 0, 25, 0);
+ GtkWidget* text_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(text_alignment), text_vbox);
+ gtk_box_pack_start(GTK_BOX(vbox), text_alignment, TRUE, TRUE, 0);
+
+ bookmarks_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_IMPORT_FAVORITES_CHKBOX).c_str());
+ gtk_box_pack_start(GTK_BOX(text_vbox), bookmarks_, TRUE, TRUE, 5);
+
+ search_engines_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_IMPORT_SEARCH_ENGINES_CHKBOX).c_str());
+ gtk_box_pack_start(GTK_BOX(text_vbox), search_engines_, TRUE, TRUE, 5);
+
+ passwords_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_IMPORT_PASSWORDS_CHKBOX).c_str());
+ gtk_box_pack_start(GTK_BOX(text_vbox), passwords_, TRUE, TRUE, 5);
+
+ history_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_IMPORT_HISTORY_CHKBOX).c_str());
+ gtk_box_pack_start(GTK_BOX(text_vbox), history_, TRUE, TRUE, 5);
+
+ g_signal_connect(dialog, "response",
+ G_CALLBACK(HandleOnResponseDialog), this);
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+ gtk_widget_show_all(dialog);
+}
+
+void ImportDialogGtk::OnDialogResponse(GtkWidget* widget, int response) {
+ if (response == GTK_RESPONSE_ACCEPT) {
+ uint16 items = NONE;
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(bookmarks_)))
+ items |= FAVORITES;
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search_engines_)))
+ items |= SEARCH_ENGINES;
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(passwords_)))
+ items |= PASSWORDS;
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(history_)))
+ items |= HISTORY;
+
+ const ProfileInfo& source_profile = importer_host_->GetSourceProfileInfoAt(
+ gtk_combo_box_get_active(GTK_COMBO_BOX(combo_)));
+
+ // TODO(rahulk): We should not do the import on this thread. Instead
+ // we need to start this asynchronously and launch a UI that shows the
+ // progress of import.
+ importer_host_->StartImportSettings(source_profile, items,
+ new ProfileWriter(profile_), false);
+ }
+
+ delete this;
+ gtk_widget_destroy(GTK_WIDGET(widget));
+}
diff --git a/chrome/browser/gtk/import_dialog_gtk.h b/chrome/browser/gtk/import_dialog_gtk.h
new file mode 100644
index 0000000..ad71b40
--- /dev/null
+++ b/chrome/browser/gtk/import_dialog_gtk.h
@@ -0,0 +1,56 @@
+// 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.
+
+#ifndef CHROME_BROWSER_GTK_IMPORT_DIALOG_GTK_H_
+#define CHROME_BROWSER_GTK_IMPORT_DIALOG_GTK_H_
+
+#include "chrome/browser/importer/importer.h"
+
+#include <gtk/gtk.h>
+
+class Profile;
+typedef struct _GtkWindow GtkWindow;
+
+class ImportDialogGtk {
+ public:
+ // Displays the import box to import data from another browser into |profile|
+ static void Show(GtkWindow* parent, Profile* profile);
+
+ private:
+ ImportDialogGtk(GtkWindow* parent, Profile* profile);
+ ~ImportDialogGtk() { }
+
+ static void HandleOnResponseDialog(GtkWidget* widget,
+ int response,
+ gpointer user_data) {
+ reinterpret_cast<ImportDialogGtk*>(user_data)->OnDialogResponse(widget,
+ response);
+ }
+ void OnDialogResponse(GtkWidget* widget, int response);
+
+ // Combo box that displays list of profiles from which we can import.
+ GtkWidget* combo_;
+
+ // Bookmarks/Favorites checkbox
+ GtkWidget* bookmarks_;
+
+ // Search Engines checkbox
+ GtkWidget* search_engines_;
+
+ // Passwords checkbox
+ GtkWidget* passwords_;
+
+ // History checkbox
+ GtkWidget* history_;
+
+ // Our current profile
+ Profile* profile_;
+
+ // Utility class that does the actual import.
+ scoped_refptr<ImporterHost> importer_host_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImportDialogGtk);
+};
+
+#endif // CHROME_BROWSER_GTK_IMPORT_DIALOG_GTK_H_