| OLD | NEW |
| 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/nix/mime_util_xdg.h" | 11 #include "base/nix/mime_util_xdg.h" |
| 12 #include "base/nix/xdg_util.h" | 12 #include "base/nix/xdg_util.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.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/libgtk2ui/select_file_dialog_impl.h" |
| 19 | 19 |
| 20 // TODO(erg): Move all of this into WorkerPool. | |
| 21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 22 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 22 #include "grit/ui_strings.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 | 24 |
| 25 // These conflict with base/tracked_objects.h, so need to come last. | 25 // These conflict with base/tracked_objects.h, so need to come last. |
| 26 #include <gdk/gdkx.h> | 26 #include <gdk/gdkx.h> |
| 27 #include <gtk/gtk.h> | 27 #include <gtk/gtk.h> |
| 28 | 28 |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 std::string GetTitle(const std::string& title, int message_id) { | 33 std::string GetTitle(const std::string& title, int message_id) { |
| 34 return title.empty() ? l10n_util::GetStringUTF8(message_id) : title; | 34 return title.empty() ? l10n_util::GetStringUTF8(message_id) : title; |
| 35 } | 35 } |
| 36 | 36 |
| 37 const char kKdialogBinary[] = "kdialog"; | 37 const char kKdialogBinary[] = "kdialog"; |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 namespace libgtk2ui { |
| 42 |
| 41 // Implementation of SelectFileDialog that shows a KDE common dialog for | 43 // Implementation of SelectFileDialog that shows a KDE common dialog for |
| 42 // choosing a file or folder. This acts as a modal dialog. | 44 // choosing a file or folder. This acts as a modal dialog. |
| 43 class SelectFileDialogImplKDE : public SelectFileDialogImpl { | 45 class SelectFileDialogImplKDE : public SelectFileDialogImpl { |
| 44 public: | 46 public: |
| 45 SelectFileDialogImplKDE(Listener* listener, | 47 SelectFileDialogImplKDE(Listener* listener, |
| 46 ui::SelectFilePolicy* policy, | 48 ui::SelectFilePolicy* policy, |
| 47 base::nix::DesktopEnvironment desktop); | 49 base::nix::DesktopEnvironment desktop); |
| 48 | 50 |
| 49 protected: | 51 protected: |
| 50 virtual ~SelectFileDialogImplKDE(); | 52 virtual ~SelectFileDialogImplKDE(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 CommandLine command_line(cmd_vector); | 266 CommandLine command_line(cmd_vector); |
| 265 GetKDialogCommandLine(params.type, params.title, params.default_path, | 267 GetKDialogCommandLine(params.type, params.title, params.default_path, |
| 266 params.parent, params.file_operation, | 268 params.parent, params.file_operation, |
| 267 params.multiple_selection, &command_line); | 269 params.multiple_selection, &command_line); |
| 268 std::string output; | 270 std::string output; |
| 269 int exit_code; | 271 int exit_code; |
| 270 // Get output from KDialog | 272 // Get output from KDialog |
| 271 base::GetAppOutputWithExitCode(command_line, &output, &exit_code); | 273 base::GetAppOutputWithExitCode(command_line, &output, &exit_code); |
| 272 if (!output.empty()) | 274 if (!output.empty()) |
| 273 output.erase(output.size() - 1); | 275 output.erase(output.size() - 1); |
| 276 |
| 274 // Now the dialog is no longer showing. We can erase its parent from the | 277 // Now the dialog is no longer showing. We can erase its parent from the |
| 275 // parent set. | 278 // parent set. |
| 276 std::set<GtkWindow*>::iterator iter = parents_.find(params.parent); | 279 // TODO(erg): FIX THIS. |
| 277 if (iter != parents_.end()) | 280 // std::set<GtkWindow*>::iterator iter = parents_.find(params.parent); |
| 278 parents_.erase(iter); | 281 // if (iter != parents_.end()) |
| 282 // parents_.erase(iter); |
| 283 |
| 279 BrowserThread::PostTask( | 284 BrowserThread::PostTask( |
| 280 BrowserThread::UI, FROM_HERE, | 285 BrowserThread::UI, FROM_HERE, |
| 281 base::Bind(params.callback, this, output, exit_code, | 286 base::Bind(params.callback, this, output, exit_code, |
| 282 params.kdialog_params)); | 287 params.kdialog_params)); |
| 283 } | 288 } |
| 284 | 289 |
| 285 void SelectFileDialogImplKDE::GetKDialogCommandLine(const std::string& type, | 290 void SelectFileDialogImplKDE::GetKDialogCommandLine(const std::string& type, |
| 286 const std::string& title, const FilePath& path, | 291 const std::string& title, const FilePath& path, |
| 287 gfx::NativeWindow parent, bool file_operation, bool multiple_selection, | 292 gfx::NativeWindow parent, bool file_operation, bool multiple_selection, |
| 288 CommandLine* command_line) { | 293 CommandLine* command_line) { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 continue; | 463 continue; |
| 459 filenames_fp.push_back(path); | 464 filenames_fp.push_back(path); |
| 460 } | 465 } |
| 461 | 466 |
| 462 if (filenames_fp.empty()) { | 467 if (filenames_fp.empty()) { |
| 463 FileNotSelected(params); | 468 FileNotSelected(params); |
| 464 return; | 469 return; |
| 465 } | 470 } |
| 466 MultiFilesSelected(filenames_fp, params); | 471 MultiFilesSelected(filenames_fp, params); |
| 467 } | 472 } |
| 473 |
| 474 } // namespace libgtk2ui |
| OLD | NEW |