Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: chrome/browser/gtk/download_in_progress_dialog_gtk.cc

Issue 212051: Download in progress dialog:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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/download_in_progress_dialog_gtk.h"
6
7 #include <gtk/gtk.h>
8
9 #include "app/l10n_util.h"
10 #include "base/string16.h"
11 #include "chrome/browser/browser.h"
12 #include "chrome/browser/browser_window.h"
13 #include "chrome/browser/download/download_manager.h"
14 #include "chrome/browser/profile.h"
15 #include "chrome/common/gtk_util.h"
16 #include "grit/chromium_strings.h"
17 #include "grit/generated_resources.h"
18
19 DownloadInProgressDialogGtk::DownloadInProgressDialogGtk(Browser* browser)
20 : browser_(browser) {
21 int download_count = browser->profile()->GetDownloadManager()->
22 in_progress_count();
23
24 std::string warning_text;
25 std::string explanation_text;
26 std::string ok_button_text;
27 std::string cancel_button_text;
28 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
29 if (download_count == 1) {
30 warning_text =
31 l10n_util::GetStringFUTF8(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING,
32 product_name);
33 explanation_text =
34 l10n_util::GetStringFUTF8(
35 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION,
36 product_name);
37 ok_button_text = l10n_util::GetStringUTF8(
38 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL);
39 cancel_button_text = l10n_util::GetStringUTF8(
40 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL);
41 } else {
42 warning_text =
43 l10n_util::GetStringFUTF8(IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING,
44 product_name, IntToString16(download_count));
45 explanation_text =
46 l10n_util::GetStringFUTF8(
47 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION, product_name);
48 ok_button_text = l10n_util::GetStringUTF8(
49 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_OK_BUTTON_LABEL);
50 cancel_button_text = l10n_util::GetStringUTF8(
51 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL);
52 }
53
54 GtkWidget* dialog = gtk_dialog_new_with_buttons(
55 UTF16ToUTF8(product_name).c_str(),
56 browser_->window()->GetNativeHandle(),
57 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
58 NULL);
59 gtk_util::AddButtonToDialog(dialog,
60 cancel_button_text.c_str(),
61 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
62 gtk_util::AddButtonToDialog(dialog,
63 ok_button_text.c_str(),
64 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
65
66 GtkWidget* content_area = GTK_DIALOG(dialog)->vbox;
67
68 // There are two lines of text: the bold warning label and the text
69 // explanation label. Neither one wraps.
70 GtkWidget* warning_label = gtk_label_new(NULL);
71 gtk_label_set_markup(GTK_LABEL(warning_label),
72 (std::string("<b>") + warning_text + "</b>").c_str());
73 gtk_misc_set_alignment(GTK_MISC(warning_label), 0.0, 0.5);
74 gtk_container_add(GTK_CONTAINER(content_area), warning_label);
75
76 // Spacing line.
77 gtk_container_add(GTK_CONTAINER(content_area), gtk_label_new(NULL));
78
79 GtkWidget* explanation_label = gtk_label_new(explanation_text.c_str());
80 gtk_misc_set_alignment(GTK_MISC(explanation_label), 0.0, 0.5);
81 gtk_container_add(GTK_CONTAINER(content_area), explanation_label);
82
83 // Spacing line.
84 gtk_container_add(GTK_CONTAINER(content_area), gtk_label_new(NULL));
85
86 g_signal_connect(dialog, "response", G_CALLBACK(OnResponse), this);
87
88 gtk_widget_show_all(dialog);
89 }
90
91 void DownloadInProgressDialogGtk::OnResponse(
92 GtkWidget* widget,
93 int response,
94 DownloadInProgressDialogGtk* dialog) {
95 gtk_widget_destroy(widget);
96 dialog->browser_->InProgressDownloadResponse(response == GTK_RESPONSE_ACCEPT);
97 delete dialog;
98 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/download_in_progress_dialog_gtk.h ('k') | chrome/browser/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698