| 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 <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 // Xlib defines RootWindow | 10 // Xlib defines RootWindow |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 gtk_widget_destroy(dialog); | 379 gtk_widget_destroy(dialog); |
| 380 } | 380 } |
| 381 | 381 |
| 382 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper( | 382 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper( |
| 383 const std::string& title, | 383 const std::string& title, |
| 384 const base::FilePath& default_path, | 384 const base::FilePath& default_path, |
| 385 gfx::NativeWindow parent) { | 385 gfx::NativeWindow parent) { |
| 386 GtkWidget* dialog = | 386 GtkWidget* dialog = |
| 387 gtk_file_chooser_dialog_new(title.c_str(), NULL, | 387 gtk_file_chooser_dialog_new(title.c_str(), NULL, |
| 388 GTK_FILE_CHOOSER_ACTION_OPEN, | 388 GTK_FILE_CHOOSER_ACTION_OPEN, |
| 389 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 389 "_Cancel", GTK_RESPONSE_CANCEL, |
| 390 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | 390 "_Open", GTK_RESPONSE_ACCEPT, |
| 391 NULL); | 391 NULL); |
| 392 SetGtkTransientForAura(dialog, parent); | 392 SetGtkTransientForAura(dialog, parent); |
| 393 AddFilters(GTK_FILE_CHOOSER(dialog)); | 393 AddFilters(GTK_FILE_CHOOSER(dialog)); |
| 394 | 394 |
| 395 if (!default_path.empty()) { | 395 if (!default_path.empty()) { |
| 396 if (CallDirectoryExistsOnUIThread(default_path)) { | 396 if (CallDirectoryExistsOnUIThread(default_path)) { |
| 397 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 397 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
| 398 default_path.value().c_str()); | 398 default_path.value().c_str()); |
| 399 } else { | 399 } else { |
| 400 // If the file doesn't exist, this will just switch to the correct | 400 // If the file doesn't exist, this will just switch to the correct |
| (...skipping 14 matching lines...) Expand all Loading... |
| 415 const base::FilePath& default_path, | 415 const base::FilePath& default_path, |
| 416 gfx::NativeWindow parent) { | 416 gfx::NativeWindow parent) { |
| 417 std::string title_string = title; | 417 std::string title_string = title; |
| 418 if (title_string.empty()) { | 418 if (title_string.empty()) { |
| 419 title_string = (type == SELECT_UPLOAD_FOLDER) ? | 419 title_string = (type == SELECT_UPLOAD_FOLDER) ? |
| 420 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE) : | 420 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE) : |
| 421 l10n_util::GetStringUTF8(IDS_SELECT_FOLDER_DIALOG_TITLE); | 421 l10n_util::GetStringUTF8(IDS_SELECT_FOLDER_DIALOG_TITLE); |
| 422 } | 422 } |
| 423 std::string accept_button_label = (type == SELECT_UPLOAD_FOLDER) ? | 423 std::string accept_button_label = (type == SELECT_UPLOAD_FOLDER) ? |
| 424 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) : | 424 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) : |
| 425 GTK_STOCK_OPEN; | 425 "_Open"; |
| 426 | 426 |
| 427 GtkWidget* dialog = | 427 GtkWidget* dialog = |
| 428 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, | 428 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, |
| 429 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, | 429 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, |
| 430 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 430 "_Cancel", GTK_RESPONSE_CANCEL, |
| 431 accept_button_label.c_str(), | 431 accept_button_label.c_str(), |
| 432 GTK_RESPONSE_ACCEPT, | 432 GTK_RESPONSE_ACCEPT, |
| 433 NULL); | 433 NULL); |
| 434 SetGtkTransientForAura(dialog, parent); | 434 SetGtkTransientForAura(dialog, parent); |
| 435 | 435 |
| 436 if (!default_path.empty()) { | 436 if (!default_path.empty()) { |
| 437 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | 437 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
| 438 default_path.value().c_str()); | 438 default_path.value().c_str()); |
| 439 } else if (!last_opened_path_->empty()) { | 439 } else if (!last_opened_path_->empty()) { |
| 440 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 440 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 } | 475 } |
| 476 | 476 |
| 477 GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title, | 477 GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title, |
| 478 const base::FilePath& default_path, gfx::NativeWindow parent) { | 478 const base::FilePath& default_path, gfx::NativeWindow parent) { |
| 479 std::string title_string = !title.empty() ? title : | 479 std::string title_string = !title.empty() ? title : |
| 480 l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE); | 480 l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE); |
| 481 | 481 |
| 482 GtkWidget* dialog = | 482 GtkWidget* dialog = |
| 483 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, | 483 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, |
| 484 GTK_FILE_CHOOSER_ACTION_SAVE, | 484 GTK_FILE_CHOOSER_ACTION_SAVE, |
| 485 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 485 "_Cancel", GTK_RESPONSE_CANCEL, |
| 486 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, | 486 "_Save", GTK_RESPONSE_ACCEPT, |
| 487 NULL); | 487 NULL); |
| 488 SetGtkTransientForAura(dialog, parent); | 488 SetGtkTransientForAura(dialog, parent); |
| 489 | 489 |
| 490 AddFilters(GTK_FILE_CHOOSER(dialog)); | 490 AddFilters(GTK_FILE_CHOOSER(dialog)); |
| 491 if (!default_path.empty()) { | 491 if (!default_path.empty()) { |
| 492 // Since the file may not already exist, we use | 492 // Since the file may not already exist, we use |
| 493 // set_current_folder() followed by set_current_name(), as per the | 493 // set_current_folder() followed by set_current_name(), as per the |
| 494 // recommendation of the GTK docs. | 494 // recommendation of the GTK docs. |
| 495 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 495 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
| 496 default_path.DirName().value().c_str()); | 496 default_path.DirName().value().c_str()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 g_free(filename); | 629 g_free(filename); |
| 630 if (pixbuf) { | 630 if (pixbuf) { |
| 631 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 631 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
| 632 g_object_unref(pixbuf); | 632 g_object_unref(pixbuf); |
| 633 } | 633 } |
| 634 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 634 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
| 635 pixbuf ? TRUE : FALSE); | 635 pixbuf ? TRUE : FALSE); |
| 636 } | 636 } |
| 637 | 637 |
| 638 } // namespace libgtk2ui | 638 } // namespace libgtk2ui |
| OLD | NEW |