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

Side by Side Diff: chrome/browser/ui/gtk/select_file_dialog_impl_gtk.cc

Issue 10667026: Start consolidating cross-port file selection code into ui/base/dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix win Created 8 years, 5 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 <gtk/gtk.h> 5 #include <gtk/gtk.h>
6 #include <map> 6 #include <map>
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/ui/gtk/select_file_dialog_impl.h" 18 #include "chrome/browser/ui/gtk/select_file_dialog_impl.h"
19 #include "chrome/browser/ui/select_file_dialog.h" 19 #include "chrome/browser/ui/select_file_dialog.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "ui/base/gtk/gtk_signal.h" 21 #include "ui/base/gtk/gtk_signal.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 23
24 // Implementation of SelectFileDialog that shows a Gtk common dialog for 24 // Implementation of SelectFileDialog that shows a Gtk common dialog for
25 // choosing a file or folder. This acts as a modal dialog. 25 // choosing a file or folder. This acts as a modal dialog.
26 class SelectFileDialogImplGTK : public SelectFileDialogImpl { 26 class SelectFileDialogImplGTK : public SelectFileDialogImpl {
27 public: 27 public:
28 explicit SelectFileDialogImplGTK(Listener* listener); 28 explicit SelectFileDialogImplGTK(Listener* listener,
29 ui::SelectFilePolicy* policy);
29 30
30 protected: 31 protected:
31 virtual ~SelectFileDialogImplGTK(); 32 virtual ~SelectFileDialogImplGTK();
32 33
33 // SelectFileDialog implementation. 34 // SelectFileDialog implementation.
34 // |params| is user data we pass back via the Listener interface. 35 // |params| is user data we pass back via the Listener interface.
35 virtual void SelectFileImpl(Type type, 36 virtual void SelectFileImpl(Type type,
36 const string16& title, 37 const string16& title,
37 const FilePath& default_path, 38 const FilePath& default_path,
38 const FileTypeInfo* file_types, 39 const FileTypeInfo* file_types,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 // The size of the preview we display for selected image files. We set height 127 // The size of the preview we display for selected image files. We set height
127 // larger than width because generally there is more free space vertically 128 // larger than width because generally there is more free space vertically
128 // than horiztonally (setting the preview image will alway expand the width of 129 // than horiztonally (setting the preview image will alway expand the width of
129 // the dialog, but usually not the height). The image's aspect ratio will always 130 // the dialog, but usually not the height). The image's aspect ratio will always
130 // be preserved. 131 // be preserved.
131 static const int kPreviewWidth = 256; 132 static const int kPreviewWidth = 256;
132 static const int kPreviewHeight = 512; 133 static const int kPreviewHeight = 512;
133 134
134 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK( 135 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK(
135 Listener* listener) { 136 Listener* listener, ui::SelectFilePolicy* policy) {
136 return new SelectFileDialogImplGTK(listener); 137 return new SelectFileDialogImplGTK(listener, policy);
137 } 138 }
138 139
139 SelectFileDialogImplGTK::SelectFileDialogImplGTK(Listener* listener) 140 SelectFileDialogImplGTK::SelectFileDialogImplGTK(Listener* listener,
140 : SelectFileDialogImpl(listener), 141 ui::SelectFilePolicy* policy)
142 : SelectFileDialogImpl(listener, policy),
141 preview_(NULL) { 143 preview_(NULL) {
142 } 144 }
143 145
144 SelectFileDialogImplGTK::~SelectFileDialogImplGTK() { 146 SelectFileDialogImplGTK::~SelectFileDialogImplGTK() {
145 while (dialogs_.begin() != dialogs_.end()) { 147 while (dialogs_.begin() != dialogs_.end()) {
146 gtk_widget_destroy(*(dialogs_.begin())); 148 gtk_widget_destroy(*(dialogs_.begin()));
147 } 149 }
148 } 150 }
149 151
150 bool SelectFileDialogImplGTK::HasMultipleFileTypeChoicesImpl() { 152 bool SelectFileDialogImplGTK::HasMultipleFileTypeChoicesImpl() {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth, 539 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth,
538 kPreviewHeight, NULL); 540 kPreviewHeight, NULL);
539 g_free(filename); 541 g_free(filename);
540 if (pixbuf) { 542 if (pixbuf) {
541 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); 543 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
542 g_object_unref(pixbuf); 544 g_object_unref(pixbuf);
543 } 545 }
544 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), 546 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
545 pixbuf ? TRUE : FALSE); 547 pixbuf ? TRUE : FALSE);
546 } 548 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/select_file_dialog_impl.cc ('k') | chrome/browser/ui/gtk/select_file_dialog_impl_kde.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698