OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/gtk/import_lock_dialog_gtk.h" | |
6 | |
7 #include "app/l10n_util.h" | |
8 #include "base/message_loop.h" | |
9 #include "chrome/browser/gtk/gtk_util.h" | |
10 #include "chrome/browser/importer/importer.h" | |
11 #include "grit/chromium_strings.h" | |
12 #include "grit/generated_resources.h" | |
13 | |
14 // static | |
15 void ImportLockDialogGtk::Show(GtkWindow* parent, ImporterHost* importer_host) { | |
16 new ImportLockDialogGtk(parent, importer_host); | |
17 } | |
18 | |
19 ImportLockDialogGtk::ImportLockDialogGtk(GtkWindow* parent, | |
20 ImporterHost* importer_host) : importer_host_(importer_host) { | |
21 // Build the dialog. | |
22 dialog_ = gtk_dialog_new_with_buttons( | |
23 l10n_util::GetStringUTF8(IDS_IMPORTER_LOCK_TITLE).c_str(), | |
24 parent, | |
25 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | |
26 NULL); | |
27 | |
28 gtk_util::AddButtonToDialog(dialog_, | |
29 l10n_util::GetStringUTF8(IDS_IMPORTER_LOCK_CANCEL).c_str(), | |
30 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); | |
31 gtk_util::AddButtonToDialog(dialog_, | |
32 l10n_util::GetStringUTF8(IDS_IMPORTER_LOCK_OK).c_str(), | |
33 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); | |
34 | |
35 GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox; | |
36 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); | |
37 GtkWidget* label = gtk_label_new( | |
38 l10n_util::GetStringUTF8(IDS_IMPORTER_LOCK_TEXT).c_str()); | |
39 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
40 gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0); | |
41 | |
42 g_signal_connect(dialog_, "response", | |
43 G_CALLBACK(OnDialogResponseThunk), this); | |
44 gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE); | |
45 gtk_widget_show_all(dialog_); | |
46 } | |
47 | |
48 ImportLockDialogGtk::~ImportLockDialogGtk() {} | |
49 | |
50 void ImportLockDialogGtk::OnDialogResponse(GtkWidget* widget, int response) { | |
51 if (response == GTK_RESPONSE_ACCEPT) { | |
52 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | |
53 importer_host_.get(), &ImporterHost::OnLockViewEnd, true)); | |
54 } else { | |
55 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | |
56 importer_host_.get(), &ImporterHost::OnLockViewEnd, false)); | |
57 } | |
58 gtk_widget_destroy(dialog_); | |
59 delete this; | |
60 } | |
OLD | NEW |