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 "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" | 5 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 269 |
270 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper( | 270 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper( |
271 const std::string& title, | 271 const std::string& title, |
272 const base::FilePath& default_path, | 272 const base::FilePath& default_path, |
273 gfx::NativeWindow parent) { | 273 gfx::NativeWindow parent) { |
274 GtkWidget* dialog = | 274 GtkWidget* dialog = |
275 gtk_file_chooser_dialog_new(title.c_str(), NULL, | 275 gtk_file_chooser_dialog_new(title.c_str(), NULL, |
276 GTK_FILE_CHOOSER_ACTION_OPEN, | 276 GTK_FILE_CHOOSER_ACTION_OPEN, |
277 "_Cancel", GTK_RESPONSE_CANCEL, | 277 "_Cancel", GTK_RESPONSE_CANCEL, |
278 "_Open", GTK_RESPONSE_ACCEPT, | 278 "_Open", GTK_RESPONSE_ACCEPT, |
279 NULL); | 279 nullptr); |
280 SetGtkTransientForAura(dialog, parent); | 280 SetGtkTransientForAura(dialog, parent); |
281 AddFilters(GTK_FILE_CHOOSER(dialog)); | 281 AddFilters(GTK_FILE_CHOOSER(dialog)); |
282 | 282 |
283 if (!default_path.empty()) { | 283 if (!default_path.empty()) { |
284 if (CallDirectoryExistsOnUIThread(default_path)) { | 284 if (CallDirectoryExistsOnUIThread(default_path)) { |
285 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 285 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
286 default_path.value().c_str()); | 286 default_path.value().c_str()); |
287 } else { | 287 } else { |
288 // If the file doesn't exist, this will just switch to the correct | 288 // If the file doesn't exist, this will just switch to the correct |
289 // directory. That's good enough. | 289 // directory. That's good enough. |
(...skipping 21 matching lines...) Expand all Loading... |
311 std::string accept_button_label = (type == SELECT_UPLOAD_FOLDER) ? | 311 std::string accept_button_label = (type == SELECT_UPLOAD_FOLDER) ? |
312 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) : | 312 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) : |
313 "_Open"; | 313 "_Open"; |
314 | 314 |
315 GtkWidget* dialog = | 315 GtkWidget* dialog = |
316 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, | 316 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, |
317 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, | 317 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, |
318 "_Cancel", GTK_RESPONSE_CANCEL, | 318 "_Cancel", GTK_RESPONSE_CANCEL, |
319 accept_button_label.c_str(), | 319 accept_button_label.c_str(), |
320 GTK_RESPONSE_ACCEPT, | 320 GTK_RESPONSE_ACCEPT, |
321 NULL); | 321 nullptr); |
322 SetGtkTransientForAura(dialog, parent); | 322 SetGtkTransientForAura(dialog, parent); |
323 | 323 |
324 if (!default_path.empty()) { | 324 if (!default_path.empty()) { |
325 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | 325 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
326 default_path.value().c_str()); | 326 default_path.value().c_str()); |
327 } else if (!last_opened_path_->empty()) { | 327 } else if (!last_opened_path_->empty()) { |
328 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 328 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
329 last_opened_path_->value().c_str()); | 329 last_opened_path_->value().c_str()); |
330 } | 330 } |
331 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); | 331 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title, | 365 GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title, |
366 const base::FilePath& default_path, gfx::NativeWindow parent) { | 366 const base::FilePath& default_path, gfx::NativeWindow parent) { |
367 std::string title_string = !title.empty() ? title : | 367 std::string title_string = !title.empty() ? title : |
368 l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE); | 368 l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE); |
369 | 369 |
370 GtkWidget* dialog = | 370 GtkWidget* dialog = |
371 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, | 371 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, |
372 GTK_FILE_CHOOSER_ACTION_SAVE, | 372 GTK_FILE_CHOOSER_ACTION_SAVE, |
373 "_Cancel", GTK_RESPONSE_CANCEL, | 373 "_Cancel", GTK_RESPONSE_CANCEL, |
374 "_Save", GTK_RESPONSE_ACCEPT, | 374 "_Save", GTK_RESPONSE_ACCEPT, |
375 NULL); | 375 nullptr); |
376 SetGtkTransientForAura(dialog, parent); | 376 SetGtkTransientForAura(dialog, parent); |
377 | 377 |
378 AddFilters(GTK_FILE_CHOOSER(dialog)); | 378 AddFilters(GTK_FILE_CHOOSER(dialog)); |
379 if (!default_path.empty()) { | 379 if (!default_path.empty()) { |
380 if (CallDirectoryExistsOnUIThread(default_path)) { | 380 if (CallDirectoryExistsOnUIThread(default_path)) { |
381 // If this is an existing directory, navigate to that directory, with no | 381 // If this is an existing directory, navigate to that directory, with no |
382 // filename. | 382 // filename. |
383 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 383 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
384 default_path.value().c_str()); | 384 default_path.value().c_str()); |
385 } else { | 385 } else { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 g_free(filename); | 531 g_free(filename); |
532 if (pixbuf) { | 532 if (pixbuf) { |
533 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 533 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
534 g_object_unref(pixbuf); | 534 g_object_unref(pixbuf); |
535 } | 535 } |
536 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 536 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
537 pixbuf ? TRUE : FALSE); | 537 pixbuf ? TRUE : FALSE); |
538 } | 538 } |
539 | 539 |
540 } // namespace libgtk2ui | 540 } // namespace libgtk2ui |
OLD | NEW |