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

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

Issue 275011: Make the multiple download request dialog an infobar.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « chrome/browser/gtk/download_request_dialog_delegate_gtk.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_request_dialog_delegate_gtk.h"
6
7 #include "app/l10n_util.h"
8 #include "chrome/browser/gtk/constrained_window_gtk.h"
9 #include "chrome/common/gtk_util.h"
10 #include "chrome/browser/tab_contents/tab_contents.h"
11 #include "grit/generated_resources.h"
12
13 static const int kButtonSpacing = 3;
14
15 // static
16 DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create(
17 TabContents* tab,
18 DownloadRequestManager::TabDownloadState* host) {
19 return new DownloadRequestDialogDelegateGtk(tab, host);
20 }
21
22 DownloadRequestDialogDelegateGtk::~DownloadRequestDialogDelegateGtk() {
23 root_.Destroy();
24 }
25
26 DownloadRequestDialogDelegateGtk::DownloadRequestDialogDelegateGtk(
27 TabContents* tab,
28 DownloadRequestManager::TabDownloadState* host)
29 : DownloadRequestDialogDelegate(host),
30 responded_(false) {
31 // Create dialog.
32 root_.Own(gtk_vbox_new(NULL, gtk_util::kContentAreaBorder));
33 GtkWidget* label = gtk_label_new(
34 l10n_util::GetStringUTF8(IDS_MULTI_DOWNLOAD_WARNING).c_str());
35 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
36 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
37 gtk_box_pack_start(GTK_BOX(root_.get()), label, FALSE, FALSE, 0);
38
39 GtkWidget* hbox = gtk_hbutton_box_new();
40 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
41 gtk_box_set_spacing(GTK_BOX(hbox), kButtonSpacing);
42 gtk_box_pack_start(GTK_BOX(root_.get()), hbox, FALSE, FALSE, 0);
43
44 GtkWidget* deny = gtk_button_new_with_label(
45 l10n_util::GetStringUTF8(IDS_MULTI_DOWNLOAD_WARNING_DENY).c_str());
46 gtk_button_set_image(
47 GTK_BUTTON(deny),
48 gtk_image_new_from_stock(GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
49 g_signal_connect(deny, "clicked", G_CALLBACK(OnDenyClickedThunk), this);
50 gtk_box_pack_end(GTK_BOX(hbox), deny, FALSE, FALSE, 0);
51
52 GtkWidget* allow = gtk_button_new_with_label(
53 l10n_util::GetStringUTF8(IDS_MULTI_DOWNLOAD_WARNING_ALLOW).c_str());
54 gtk_button_set_image(
55 GTK_BUTTON(allow),
56 gtk_image_new_from_stock(GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
57 g_signal_connect(allow, "clicked", G_CALLBACK(OnAllowClickedThunk), this);
58 gtk_box_pack_end(GTK_BOX(hbox), allow, FALSE, FALSE, 0);
59
60 // Attach to window.
61 window_ = tab->CreateConstrainedDialog(this);
62
63 // Now that we have attached ourself to the window, we can make our deny
64 // button the default action and mess with the focus.
65 GTK_WIDGET_SET_FLAGS(deny, GTK_CAN_DEFAULT);
66 gtk_widget_grab_default(deny);
67 }
68
69 void DownloadRequestDialogDelegateGtk::CloseWindow() {
70 window_->CloseConstrainedWindow();
71 }
72
73 GtkWidget* DownloadRequestDialogDelegateGtk::GetWidgetRoot() {
74 return root_.get();
75 }
76
77 void DownloadRequestDialogDelegateGtk::DeleteDelegate() {
78 if (!responded_)
79 DoCancel();
80 DCHECK(!host_);
81 delete this;
82 }
83
84 void DownloadRequestDialogDelegateGtk::OnAllowClicked() {
85 DoAccept();
86 responded_ = true;
87 CloseWindow();
88 }
89
90 void DownloadRequestDialogDelegateGtk::OnDenyClicked() {
91 DoCancel();
92 responded_ = true;
93 CloseWindow();
94 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/download_request_dialog_delegate_gtk.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698