Chromium Code Reviews| 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 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 GTK_FILE_CHOOSER_ACTION_SAVE, | 397 GTK_FILE_CHOOSER_ACTION_SAVE, |
| 398 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 398 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| 399 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, | 399 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
| 400 NULL); | 400 NULL); |
| 401 | 401 |
| 402 AddFilters(GTK_FILE_CHOOSER(dialog)); | 402 AddFilters(GTK_FILE_CHOOSER(dialog)); |
| 403 if (!default_path.empty()) { | 403 if (!default_path.empty()) { |
| 404 // Since the file may not already exist, we use | 404 // Since the file may not already exist, we use |
| 405 // set_current_folder() followed by set_current_name(), as per the | 405 // set_current_folder() followed by set_current_name(), as per the |
| 406 // recommendation of the GTK docs. | 406 // recommendation of the GTK docs. |
| 407 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 407 if (CallDirectoryExistsOnUIThread(default_path)) { |
|
Evan Stade
2012/06/28 03:52:18
there has to be a way to do this without consultin
viettrungluu
2012/06/28 03:59:52
I agree that this is really awful (especially sinc
| |
| 408 default_path.DirName().value().c_str()); | 408 gtk_file_chooser_set_current_folder( |
| 409 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), | 409 GTK_FILE_CHOOSER(dialog), default_path.value().c_str()); |
| 410 default_path.BaseName().value().c_str()); | 410 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), ""); |
| 411 } else { | |
| 412 gtk_file_chooser_set_current_folder( | |
| 413 GTK_FILE_CHOOSER(dialog), default_path.DirName().value().c_str()); | |
| 414 gtk_file_chooser_set_current_name( | |
| 415 GTK_FILE_CHOOSER(dialog), default_path.BaseName().value().c_str()); | |
| 416 } | |
| 411 } else if (!last_saved_path_->empty()) { | 417 } else if (!last_saved_path_->empty()) { |
| 412 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), | 418 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
| 413 last_saved_path_->value().c_str()); | 419 last_saved_path_->value().c_str()); |
| 414 } | 420 } |
| 415 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); | 421 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); |
| 416 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), | 422 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), |
| 417 TRUE); | 423 TRUE); |
| 418 g_signal_connect(dialog, "response", | 424 g_signal_connect(dialog, "response", |
| 419 G_CALLBACK(OnSelectSingleFileDialogResponseThunk), this); | 425 G_CALLBACK(OnSelectSingleFileDialogResponseThunk), this); |
| 420 return dialog; | 426 return dialog; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth, | 543 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth, |
| 538 kPreviewHeight, NULL); | 544 kPreviewHeight, NULL); |
| 539 g_free(filename); | 545 g_free(filename); |
| 540 if (pixbuf) { | 546 if (pixbuf) { |
| 541 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); | 547 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); |
| 542 g_object_unref(pixbuf); | 548 g_object_unref(pixbuf); |
| 543 } | 549 } |
| 544 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), | 550 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), |
| 545 pixbuf ? TRUE : FALSE); | 551 pixbuf ? TRUE : FALSE); |
| 546 } | 552 } |
| OLD | NEW |