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

Side by Side Diff: chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk2.cc

Issue 2449243002: Gtk3 ui: Add libgtk3ui as a separate build component (Closed)
Patch Set: Add theme_properties dep to //chrome/browser/ui Created 4 years, 1 month 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
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/libgtk2ui/select_file_dialog_impl_gtk2.h" 5 #include "chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk2.h"
6 6
7 #include <gdk/gdkx.h> 7 #include <gdk/gdkx.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 #include <unistd.h> 12 #include <unistd.h>
13 13
14 #include <map> 14 #include <map>
15 #include <memory> 15 #include <memory>
16 #include <set> 16 #include <set>
17 #include <vector> 17 #include <vector>
18 18
19 // Xlib defines RootWindow 19 // Xlib defines RootWindow
20 #undef RootWindow 20 #undef RootWindow
21 21
22 #include "base/logging.h" 22 #include "base/logging.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/strings/sys_string_conversions.h" 25 #include "base/strings/sys_string_conversions.h"
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "base/threading/thread.h" 27 #include "base/threading/thread.h"
28 #include "base/threading/thread_restrictions.h" 28 #include "base/threading/thread_restrictions.h"
29 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" 29 #include "chrome/browser/ui/libgtkui/gtk2_signal.h"
30 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" 30 #include "chrome/browser/ui/libgtkui/gtk2_util.h"
31 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" 31 #include "chrome/browser/ui/libgtkui/select_file_dialog_impl.h"
32 #include "ui/aura/window_observer.h" 32 #include "ui/aura/window_observer.h"
33 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/events/platform/x11/x11_event_source.h" 34 #include "ui/events/platform/x11/x11_event_source.h"
35 #include "ui/shell_dialogs/select_file_dialog.h" 35 #include "ui/shell_dialogs/select_file_dialog.h"
36 #include "ui/strings/grit/ui_strings.h" 36 #include "ui/strings/grit/ui_strings.h"
37 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 37 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
38 38
39 namespace { 39 namespace {
40 40
41 // Makes sure that .jpg also shows .JPG. 41 // Makes sure that .jpg also shows .JPG.
42 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info, 42 gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
43 std::string* file_extension) { 43 std::string* file_extension) {
44 return base::EndsWith(file_info->filename, *file_extension, 44 return base::EndsWith(file_info->filename, *file_extension,
45 base::CompareCase::INSENSITIVE_ASCII); 45 base::CompareCase::INSENSITIVE_ASCII);
46 } 46 }
47 47
48 // Deletes |data| when gtk_file_filter_add_custom() is done with it. 48 // Deletes |data| when gtk_file_filter_add_custom() is done with it.
49 void OnFileFilterDataDestroyed(std::string* file_extension) { 49 void OnFileFilterDataDestroyed(std::string* file_extension) {
50 delete file_extension; 50 delete file_extension;
51 } 51 }
52 52
53 // Runs DesktopWindowTreeHostX11::EnableEventListening() when the file-picker 53 // Runs DesktopWindowTreeHostX11::EnableEventListening() when the file-picker
54 // is closed. 54 // is closed.
55 void OnFilePickerDestroy(base::Closure* callback) { 55 void OnFilePickerDestroy(base::Closure* callback) {
56 callback->Run(); 56 callback->Run();
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 namespace libgtk2ui { 61 namespace libgtkui {
62 62
63 // The size of the preview we display for selected image files. We set height 63 // The size of the preview we display for selected image files. We set height
64 // larger than width because generally there is more free space vertically 64 // larger than width because generally there is more free space vertically
65 // than horiztonally (setting the preview image will alway expand the width of 65 // than horiztonally (setting the preview image will alway expand the width of
66 // the dialog, but usually not the height). The image's aspect ratio will always 66 // the dialog, but usually not the height). The image's aspect ratio will always
67 // be preserved. 67 // be preserved.
68 static const int kPreviewWidth = 256; 68 static const int kPreviewWidth = 256;
69 static const int kPreviewHeight = 512; 69 static const int kPreviewHeight = 512;
70 70
71 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK( 71 SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK(
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 kPreviewHeight, NULL); 551 kPreviewHeight, NULL);
552 g_free(filename); 552 g_free(filename);
553 if (pixbuf) { 553 if (pixbuf) {
554 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); 554 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
555 g_object_unref(pixbuf); 555 g_object_unref(pixbuf);
556 } 556 }
557 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), 557 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
558 pixbuf ? TRUE : FALSE); 558 pixbuf ? TRUE : FALSE);
559 } 559 }
560 560
561 } // namespace libgtk2ui 561 } // namespace libgtkui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk2.h ('k') | chrome/browser/ui/libgtkui/select_file_dialog_impl_kde.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698