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

Side by Side Diff: ui/base/dialogs/gtk/select_file_dialog_impl_gtk.cc

Issue 10790083: shell dialogs: Move the linux implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 "grit/ui_strings.h"
19 #include "chrome/browser/ui/select_file_dialog.h" 19 #include "ui/base/dialogs/gtk/select_file_dialog_impl.h"
20 #include "grit/generated_resources.h" 20 #include "ui/base/dialogs/select_file_dialog.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 namespace {
25
24 // Implementation of SelectFileDialog that shows a Gtk common dialog for 26 // Implementation of SelectFileDialog that shows a Gtk common dialog for
25 // choosing a file or folder. This acts as a modal dialog. 27 // choosing a file or folder. This acts as a modal dialog.
26 class SelectFileDialogImplGTK : public SelectFileDialogImpl { 28 class SelectFileDialogImplGTK : public ui::SelectFileDialogImpl {
27 public: 29 public:
28 explicit SelectFileDialogImplGTK(Listener* listener, 30 explicit SelectFileDialogImplGTK(Listener* listener,
29 ui::SelectFilePolicy* policy); 31 ui::SelectFilePolicy* policy);
30 32
31 protected: 33 protected:
32 virtual ~SelectFileDialogImplGTK(); 34 virtual ~SelectFileDialogImplGTK();
33 35
34 // SelectFileDialog implementation. 36 // SelectFileDialog implementation.
35 // |params| is user data we pass back via the Listener interface. 37 // |params| is user data we pass back via the Listener interface.
36 virtual void SelectFileImpl(Type type, 38 virtual void SelectFileImpl(Type type,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 }; 127 };
126 128
127 // The size of the preview we display for selected image files. We set height 129 // The size of the preview we display for selected image files. We set height
128 // larger than width because generally there is more free space vertically 130 // larger than width because generally there is more free space vertically
129 // than horiztonally (setting the preview image will alway expand the width of 131 // than horiztonally (setting the preview image will alway expand the width of
130 // the dialog, but usually not the height). The image's aspect ratio will always 132 // the dialog, but usually not the height). The image's aspect ratio will always
131 // be preserved. 133 // be preserved.
132 static const int kPreviewWidth = 256; 134 static const int kPreviewWidth = 256;
133 static const int kPreviewHeight = 512; 135 static const int kPreviewHeight = 512;
134 136
135 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK(
136 Listener* listener, ui::SelectFilePolicy* policy) {
137 return new SelectFileDialogImplGTK(listener, policy);
138 }
139
140 SelectFileDialogImplGTK::SelectFileDialogImplGTK(Listener* listener, 137 SelectFileDialogImplGTK::SelectFileDialogImplGTK(Listener* listener,
141 ui::SelectFilePolicy* policy) 138 ui::SelectFilePolicy* policy)
142 : SelectFileDialogImpl(listener, policy), 139 : SelectFileDialogImpl(listener, policy),
143 preview_(NULL) { 140 preview_(NULL) {
144 } 141 }
145 142
146 SelectFileDialogImplGTK::~SelectFileDialogImplGTK() { 143 SelectFileDialogImplGTK::~SelectFileDialogImplGTK() {
147 while (dialogs_.begin() != dialogs_.end()) { 144 while (dialogs_.begin() != dialogs_.end()) {
148 gtk_widget_destroy(*(dialogs_.begin())); 145 gtk_widget_destroy(*(dialogs_.begin()));
149 } 146 }
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth, 536 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth,
540 kPreviewHeight, NULL); 537 kPreviewHeight, NULL);
541 g_free(filename); 538 g_free(filename);
542 if (pixbuf) { 539 if (pixbuf) {
543 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); 540 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
544 g_object_unref(pixbuf); 541 g_object_unref(pixbuf);
545 } 542 }
546 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), 543 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
547 pixbuf ? TRUE : FALSE); 544 pixbuf ? TRUE : FALSE);
548 } 545 }
546
547 } // namespace
548
549 namespace ui {
550
551 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK(
552 Listener* listener, ui::SelectFilePolicy* policy) {
553 return new SelectFileDialogImplGTK(listener, policy);
554 }
555
556 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698