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

Side by Side Diff: chrome/browser/ui/gtk/extensions/media_galleries_dialog_gtk.cc

Issue 10834242: Cocoa: Implement media gallery dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/media_galleries_dialog_gtk.h" 5 #include "chrome/browser/ui/gtk/extensions/media_galleries_dialog_gtk.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/media_gallery/media_galleries_preferences.h" 9 #include "chrome/browser/media_gallery/media_galleries_preferences.h"
10 #include "chrome/browser/ui/gtk/gtk_util.h" 10 #include "chrome/browser/ui/gtk/gtk_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 GtkWidget* subtext = 42 GtkWidget* subtext =
43 gtk_label_new(UTF16ToUTF8(controller_->GetSubtext()).c_str()); 43 gtk_label_new(UTF16ToUTF8(controller_->GetSubtext()).c_str());
44 gtk_label_set_line_wrap(GTK_LABEL(subtext), TRUE); 44 gtk_label_set_line_wrap(GTK_LABEL(subtext), TRUE);
45 gtk_widget_set_size_request(subtext, 500, -1); 45 gtk_widget_set_size_request(subtext, 500, -1);
46 gtk_box_pack_start(GTK_BOX(contents_.get()), subtext, FALSE, FALSE, 0); 46 gtk_box_pack_start(GTK_BOX(contents_.get()), subtext, FALSE, FALSE, 0);
47 47
48 checkbox_container_ = gtk_vbox_new(FALSE, 0); 48 checkbox_container_ = gtk_vbox_new(FALSE, 0);
49 gtk_box_pack_start(GTK_BOX(contents_.get()), checkbox_container_, 49 gtk_box_pack_start(GTK_BOX(contents_.get()), checkbox_container_,
50 FALSE, FALSE, 0); 50 FALSE, FALSE, 0);
51 51
52 // As a safeguard against the user skipping reading over the dialog and just
53 // confirming, the button will be unavailable for dialogs without any checks
54 // until the user toggles something.
55 bool confirm_available = false;
56 const GalleryPermissions& permissions = controller_->permissions(); 52 const GalleryPermissions& permissions = controller_->permissions();
57 for (GalleryPermissions::const_iterator iter = permissions.begin(); 53 for (GalleryPermissions::const_iterator iter = permissions.begin();
58 iter != permissions.end(); iter++) { 54 iter != permissions.end(); iter++) {
59 confirm_available = confirm_available || iter->second.allowed;
60 UpdateGallery(&iter->second.pref_info, iter->second.allowed); 55 UpdateGallery(&iter->second.pref_info, iter->second.allowed);
61 } 56 }
62 57
63 // Holds the "add gallery" and cancel/confirm buttons. 58 // Holds the "add gallery" and cancel/confirm buttons.
64 GtkWidget* bottom_area = gtk_hbox_new(FALSE, ui::kControlSpacing); 59 GtkWidget* bottom_area = gtk_hbox_new(FALSE, ui::kControlSpacing);
65 gtk_box_pack_start(GTK_BOX(contents_.get()), bottom_area, FALSE, FALSE, 0); 60 gtk_box_pack_start(GTK_BOX(contents_.get()), bottom_area, FALSE, FALSE, 0);
66 61
67 // Add gallery button. 62 // Add gallery button.
68 GtkWidget* add_folder = gtk_button_new_with_label( 63 GtkWidget* add_folder = gtk_button_new_with_label(
69 l10n_util::GetStringUTF8(IDS_MEDIA_GALLERIES_DIALOG_ADD_GALLERY).c_str()); 64 l10n_util::GetStringUTF8(IDS_MEDIA_GALLERIES_DIALOG_ADD_GALLERY).c_str());
(...skipping 10 matching lines...) Expand all
80 gtk_box_pack_end(GTK_BOX(bottom_area), confirm_, FALSE, FALSE, 0); 75 gtk_box_pack_end(GTK_BOX(bottom_area), confirm_, FALSE, FALSE, 0);
81 76
82 GtkWidget* cancel = gtk_button_new_with_label(l10n_util::GetStringUTF8( 77 GtkWidget* cancel = gtk_button_new_with_label(l10n_util::GetStringUTF8(
83 IDS_MEDIA_GALLERIES_DIALOG_CANCEL).c_str()); 78 IDS_MEDIA_GALLERIES_DIALOG_CANCEL).c_str());
84 gtk_button_set_image( 79 gtk_button_set_image(
85 GTK_BUTTON(cancel), 80 GTK_BUTTON(cancel),
86 gtk_image_new_from_stock(GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); 81 gtk_image_new_from_stock(GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
87 g_signal_connect(cancel, "clicked", G_CALLBACK(OnCancelThunk), this); 82 g_signal_connect(cancel, "clicked", G_CALLBACK(OnCancelThunk), this);
88 gtk_box_pack_end(GTK_BOX(bottom_area), cancel, FALSE, FALSE, 0); 83 gtk_box_pack_end(GTK_BOX(bottom_area), cancel, FALSE, FALSE, 0);
89 84
90 gtk_widget_set_sensitive(confirm_, confirm_available); 85 // As a safeguard against the user skipping reading over the dialog and just
86 // confirming, the button will be unavailable for dialogs without any checks
87 // until the user toggles something.
88 gtk_widget_set_sensitive(confirm_, controller_->HasPermittedGalleries());
91 } 89 }
92 90
93 void MediaGalleriesDialogGtk::UpdateGallery( 91 void MediaGalleriesDialogGtk::UpdateGallery(
94 const MediaGalleryPrefInfo* gallery, 92 const MediaGalleryPrefInfo* gallery,
95 bool permitted) { 93 bool permitted) {
96 CheckboxMap::iterator iter = checkbox_map_.find(gallery); 94 CheckboxMap::iterator iter = checkbox_map_.find(gallery);
97 95
98 GtkWidget* widget = NULL; 96 GtkWidget* widget = NULL;
99 if (iter != checkbox_map_.end()) { 97 if (iter != checkbox_map_.end()) {
100 widget = iter->second; 98 widget = iter->second;
(...skipping 24 matching lines...) Expand all
125 123
126 void MediaGalleriesDialogGtk::OnToggled(GtkWidget* widget) { 124 void MediaGalleriesDialogGtk::OnToggled(GtkWidget* widget) {
127 gtk_widget_set_sensitive(confirm_, TRUE); 125 gtk_widget_set_sensitive(confirm_, TRUE);
128 126
129 if (ignore_toggles_) 127 if (ignore_toggles_)
130 return; 128 return;
131 129
132 for (CheckboxMap::iterator iter = checkbox_map_.begin(); 130 for (CheckboxMap::iterator iter = checkbox_map_.begin();
133 iter != checkbox_map_.end(); ++iter) { 131 iter != checkbox_map_.end(); ++iter) {
134 if (iter->second == widget) { 132 if (iter->second == widget) {
135 controller_->GalleryToggled( 133 controller_->DidToggleGallery(
136 iter->first, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))); 134 iter->first, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
137 return; 135 return;
138 } 136 }
139 } 137 }
140 138
141 NOTREACHED(); 139 NOTREACHED();
142 return; 140 return;
143 } 141 }
144 142
145 void MediaGalleriesDialogGtk::OnAddFolder(GtkWidget* widget) { 143 void MediaGalleriesDialogGtk::OnAddFolder(GtkWidget* widget) {
(...skipping 11 matching lines...) Expand all
157 155
158 // MediaGalleriesDialogController ---------------------------------------------- 156 // MediaGalleriesDialogController ----------------------------------------------
159 157
160 // static 158 // static
161 MediaGalleriesDialog* MediaGalleriesDialog::Create( 159 MediaGalleriesDialog* MediaGalleriesDialog::Create(
162 MediaGalleriesDialogController* controller) { 160 MediaGalleriesDialogController* controller) {
163 return new MediaGalleriesDialogGtk(controller); 161 return new MediaGalleriesDialogGtk(controller);
164 } 162 }
165 163
166 } // namespace chrome 164 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698