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

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

Issue 1234223005: Initial gtk3 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed abort on GtkPrintUnixDialog Created 5 years, 5 months 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 <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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 gtk_widget_destroy(dialog); 377 gtk_widget_destroy(dialog);
378 } 378 }
379 379
380 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper( 380 GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper(
381 const std::string& title, 381 const std::string& title,
382 const base::FilePath& default_path, 382 const base::FilePath& default_path,
383 gfx::NativeWindow parent) { 383 gfx::NativeWindow parent) {
384 GtkWidget* dialog = 384 GtkWidget* dialog =
385 gtk_file_chooser_dialog_new(title.c_str(), NULL, 385 gtk_file_chooser_dialog_new(title.c_str(), NULL,
386 GTK_FILE_CHOOSER_ACTION_OPEN, 386 GTK_FILE_CHOOSER_ACTION_OPEN,
387 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 387 "_Cancel", GTK_RESPONSE_CANCEL,
388 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 388 "_Open", GTK_RESPONSE_ACCEPT,
389 NULL); 389 NULL);
390 SetGtkTransientForAura(dialog, parent); 390 SetGtkTransientForAura(dialog, parent);
391 AddFilters(GTK_FILE_CHOOSER(dialog)); 391 AddFilters(GTK_FILE_CHOOSER(dialog));
392 392
393 if (!default_path.empty()) { 393 if (!default_path.empty()) {
394 if (CallDirectoryExistsOnUIThread(default_path)) { 394 if (CallDirectoryExistsOnUIThread(default_path)) {
395 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), 395 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
396 default_path.value().c_str()); 396 default_path.value().c_str());
397 } else { 397 } else {
398 // If the file doesn't exist, this will just switch to the correct 398 // If the file doesn't exist, this will just switch to the correct
(...skipping 14 matching lines...) Expand all
413 const base::FilePath& default_path, 413 const base::FilePath& default_path,
414 gfx::NativeWindow parent) { 414 gfx::NativeWindow parent) {
415 std::string title_string = title; 415 std::string title_string = title;
416 if (title_string.empty()) { 416 if (title_string.empty()) {
417 title_string = (type == SELECT_UPLOAD_FOLDER) ? 417 title_string = (type == SELECT_UPLOAD_FOLDER) ?
418 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE) : 418 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE) :
419 l10n_util::GetStringUTF8(IDS_SELECT_FOLDER_DIALOG_TITLE); 419 l10n_util::GetStringUTF8(IDS_SELECT_FOLDER_DIALOG_TITLE);
420 } 420 }
421 std::string accept_button_label = (type == SELECT_UPLOAD_FOLDER) ? 421 std::string accept_button_label = (type == SELECT_UPLOAD_FOLDER) ?
422 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) : 422 l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) :
423 GTK_STOCK_OPEN; 423 "_Open";
424 424
425 GtkWidget* dialog = 425 GtkWidget* dialog =
426 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, 426 gtk_file_chooser_dialog_new(title_string.c_str(), NULL,
427 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, 427 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
428 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 428 "_Cancel", GTK_RESPONSE_CANCEL,
429 accept_button_label.c_str(), 429 accept_button_label.c_str(),
430 GTK_RESPONSE_ACCEPT, 430 GTK_RESPONSE_ACCEPT,
431 NULL); 431 NULL);
432 SetGtkTransientForAura(dialog, parent); 432 SetGtkTransientForAura(dialog, parent);
433 433
434 if (!default_path.empty()) { 434 if (!default_path.empty()) {
435 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), 435 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
436 default_path.value().c_str()); 436 default_path.value().c_str());
437 } else if (!last_opened_path_->empty()) { 437 } else if (!last_opened_path_->empty()) {
438 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), 438 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 473 }
474 474
475 GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title, 475 GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title,
476 const base::FilePath& default_path, gfx::NativeWindow parent) { 476 const base::FilePath& default_path, gfx::NativeWindow parent) {
477 std::string title_string = !title.empty() ? title : 477 std::string title_string = !title.empty() ? title :
478 l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE); 478 l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE);
479 479
480 GtkWidget* dialog = 480 GtkWidget* dialog =
481 gtk_file_chooser_dialog_new(title_string.c_str(), NULL, 481 gtk_file_chooser_dialog_new(title_string.c_str(), NULL,
482 GTK_FILE_CHOOSER_ACTION_SAVE, 482 GTK_FILE_CHOOSER_ACTION_SAVE,
483 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 483 "_Cancel", GTK_RESPONSE_CANCEL,
484 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, 484 "_Save", GTK_RESPONSE_ACCEPT,
485 NULL); 485 NULL);
486 SetGtkTransientForAura(dialog, parent); 486 SetGtkTransientForAura(dialog, parent);
487 487
488 AddFilters(GTK_FILE_CHOOSER(dialog)); 488 AddFilters(GTK_FILE_CHOOSER(dialog));
489 if (!default_path.empty()) { 489 if (!default_path.empty()) {
490 // Since the file may not already exist, we use 490 // Since the file may not already exist, we use
491 // set_current_folder() followed by set_current_name(), as per the 491 // set_current_folder() followed by set_current_name(), as per the
492 // recommendation of the GTK docs. 492 // recommendation of the GTK docs.
493 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), 493 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
494 default_path.DirName().value().c_str()); 494 default_path.DirName().value().c_str());
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 g_free(filename); 627 g_free(filename);
628 if (pixbuf) { 628 if (pixbuf) {
629 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); 629 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
630 g_object_unref(pixbuf); 630 g_object_unref(pixbuf);
631 } 631 }
632 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), 632 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
633 pixbuf ? TRUE : FALSE); 633 pixbuf ? TRUE : FALSE);
634 } 634 }
635 635
636 } // namespace libgtk2ui 636 } // namespace libgtk2ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698