| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/importer/import_progress_dialog_gtk.h" | 5 #include "chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 status = "\xE2\x9C\x94 " + status; // U+2714 HEAVY CHECK MARK | 27 status = "\xE2\x9C\x94 " + status; // U+2714 HEAVY CHECK MARK |
| 28 else | 28 else |
| 29 status.append(" ..."); | 29 status.append(" ..."); |
| 30 gtk_label_set_text(GTK_LABEL(label), status.c_str()); | 30 gtk_label_set_text(GTK_LABEL(label), status.c_str()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 // static | 35 // static |
| 36 void ImportProgressDialogGtk::StartImport( | 36 void ImportProgressDialogGtk::StartImport( |
| 37 GtkWindow* parent, | |
| 38 uint16 items, | 37 uint16 items, |
| 39 ImporterHost* importer_host, | 38 ImporterHost* importer_host, |
| 40 ImporterObserver* importer_observer, | 39 ImporterObserver* importer_observer, |
| 41 const importer::SourceProfile& source_profile, | 40 const importer::SourceProfile& source_profile, |
| 42 Profile* profile, | 41 Profile* profile, |
| 43 bool first_run) { | 42 bool first_run) { |
| 44 ImportProgressDialogGtk* dialog = new ImportProgressDialogGtk( | 43 ImportProgressDialogGtk* dialog = new ImportProgressDialogGtk(items, |
| 45 parent, | 44 importer_host, importer_observer, source_profile.importer_name, |
| 46 items, | |
| 47 importer_host, | |
| 48 importer_observer, | |
| 49 source_profile.importer_name, | |
| 50 source_profile.importer_type == importer::TYPE_BOOKMARKS_FILE); | 45 source_profile.importer_type == importer::TYPE_BOOKMARKS_FILE); |
| 51 | 46 |
| 52 // In headless mode it means that we don't show the progress window, but it | 47 // In headless mode it means that we don't show the progress window, but it |
| 53 // still need it to exist. No user interaction will be required. | 48 // still need it to exist. No user interaction will be required. |
| 54 if (!importer_host->is_headless()) | 49 if (!importer_host->is_headless()) |
| 55 dialog->ShowDialog(); | 50 dialog->ShowDialog(); |
| 56 | 51 |
| 57 importer_host->StartImportSettings( | 52 importer_host->StartImportSettings( |
| 58 source_profile, profile, items, new ProfileWriter(profile), first_run); | 53 source_profile, profile, items, new ProfileWriter(profile), first_run); |
| 59 } | 54 } |
| 60 | 55 |
| 61 ImportProgressDialogGtk::ImportProgressDialogGtk( | 56 ImportProgressDialogGtk::ImportProgressDialogGtk( |
| 62 GtkWindow* parent, | |
| 63 uint16 items, | 57 uint16 items, |
| 64 ImporterHost* importer_host, | 58 ImporterHost* importer_host, |
| 65 ImporterObserver* importer_observer, | 59 ImporterObserver* importer_observer, |
| 66 const string16& importer_name, | 60 const string16& importer_name, |
| 67 bool bookmarks_import) | 61 bool bookmarks_import) |
| 68 : parent_(parent), | 62 : items_(items), |
| 69 items_(items), | |
| 70 importer_host_(importer_host), | 63 importer_host_(importer_host), |
| 71 importer_observer_(importer_observer), | 64 importer_observer_(importer_observer), |
| 72 importing_(true) { | 65 importing_(true) { |
| 73 importer_host_->SetObserver(this); | 66 importer_host_->SetObserver(this); |
| 74 | 67 |
| 75 // Build the dialog. | 68 // Build the dialog. |
| 76 dialog_ = gtk_dialog_new_with_buttons( | 69 dialog_ = gtk_dialog_new_with_buttons( |
| 77 l10n_util::GetStringUTF8(IDS_IMPORT_PROGRESS_TITLE).c_str(), | 70 l10n_util::GetStringUTF8(IDS_IMPORT_PROGRESS_TITLE).c_str(), |
| 78 parent_, | 71 NULL, |
| 79 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | 72 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), |
| 80 GTK_STOCK_CANCEL, | 73 GTK_STOCK_CANCEL, |
| 81 GTK_RESPONSE_REJECT, | 74 GTK_RESPONSE_REJECT, |
| 82 NULL); | 75 NULL); |
| 83 importer_host_->set_parent_window(GTK_WINDOW(dialog_)); | 76 importer_host_->set_parent_window(GTK_WINDOW(dialog_)); |
| 84 | 77 |
| 85 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); | 78 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); |
| 86 gtk_box_set_spacing(GTK_BOX(content_area), ui::kContentAreaSpacing); | 79 gtk_box_set_spacing(GTK_BOX(content_area), ui::kContentAreaSpacing); |
| 87 | 80 |
| 88 GtkWidget* control_group = gtk_vbox_new(FALSE, ui::kControlSpacing); | 81 GtkWidget* control_group = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 void ImportProgressDialogGtk::ImportEnded() { | 204 void ImportProgressDialogGtk::ImportEnded() { |
| 212 importing_ = false; | 205 importing_ = false; |
| 213 importer_host_->SetObserver(NULL); | 206 importer_host_->SetObserver(NULL); |
| 214 if (importer_observer_) | 207 if (importer_observer_) |
| 215 importer_observer_->ImportCompleted(); | 208 importer_observer_->ImportCompleted(); |
| 216 CloseDialog(); | 209 CloseDialog(); |
| 217 } | 210 } |
| 218 | 211 |
| 219 namespace importer { | 212 namespace importer { |
| 220 | 213 |
| 221 void ShowImportProgressDialog(GtkWindow* parent, | 214 void ShowImportProgressDialog(uint16 items, |
| 222 uint16 items, | |
| 223 ImporterHost* importer_host, | 215 ImporterHost* importer_host, |
| 224 ImporterObserver* importer_observer, | 216 ImporterObserver* importer_observer, |
| 225 const SourceProfile& source_profile, | 217 const SourceProfile& source_profile, |
| 226 Profile* profile, | 218 Profile* profile, |
| 227 bool first_run) { | 219 bool first_run) { |
| 228 DCHECK_NE(0, items); | 220 DCHECK_NE(0, items); |
| 229 ImportProgressDialogGtk::StartImport( | 221 ImportProgressDialogGtk::StartImport(items, importer_host, importer_observer, |
| 230 parent, items, importer_host, importer_observer, source_profile, profile, | 222 source_profile, profile, first_run); |
| 231 first_run); | |
| 232 } | 223 } |
| 233 | 224 |
| 234 } // namespace importer | 225 } // namespace importer |
| OLD | NEW |