2007-02-26 19:45:33 +00:00
|
|
|
|
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
|
2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
2003-10-23 00:26:15 +00:00
|
|
|
|
* gtkfilechooserdefault.c: Default implementation of GtkFileChooser
|
2003-03-21 20:34:02 +00:00
|
|
|
|
* Copyright (C) 2003, Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2003-03-21 20:34:02 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2012-09-07 19:35:56 +00:00
|
|
|
|
/* TODO:
|
|
|
|
|
*
|
|
|
|
|
* * Fix FIXME-places-sidebar
|
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2008-07-02 10:14:45 +00:00
|
|
|
|
|
2010-09-14 01:33:06 +00:00
|
|
|
|
#include "gtkfilechooserdefault.h"
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
#include "gtkbindings.h"
|
2004-03-02 02:59:02 +00:00
|
|
|
|
#include "gtkcelllayout.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkcellrendererpixbuf.h"
|
2004-08-07 22:21:25 +00:00
|
|
|
|
#include "gtkcellrenderertext.h"
|
2004-04-02 00:35:07 +00:00
|
|
|
|
#include "gtkcheckmenuitem.h"
|
2006-06-12 15:11:39 +00:00
|
|
|
|
#include "gtkclipboard.h"
|
2010-10-02 16:19:46 +00:00
|
|
|
|
#include "gtkcomboboxtext.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkentry.h"
|
2004-02-23 19:55:49 +00:00
|
|
|
|
#include "gtkexpander.h"
|
2005-09-15 21:51:31 +00:00
|
|
|
|
#include "gtkfilechooserprivate.h"
|
2009-01-14 20:19:10 +00:00
|
|
|
|
#include "gtkfilechooserdialog.h"
|
2004-02-27 23:51:16 +00:00
|
|
|
|
#include "gtkfilechooserembed.h"
|
2003-03-25 00:11:06 +00:00
|
|
|
|
#include "gtkfilechooserentry.h"
|
2003-03-21 20:34:02 +00:00
|
|
|
|
#include "gtkfilechooserutils.h"
|
|
|
|
|
#include "gtkfilechooser.h"
|
2008-06-10 00:39:35 +00:00
|
|
|
|
#include "gtkfilesystem.h"
|
2003-03-21 20:34:02 +00:00
|
|
|
|
#include "gtkfilesystemmodel.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkframe.h"
|
2012-03-03 18:22:22 +00:00
|
|
|
|
#include "gtkgrid.h"
|
2013-07-20 00:29:11 +00:00
|
|
|
|
#include "deprecated/gtkiconfactory.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkicontheme.h"
|
|
|
|
|
#include "gtkimage.h"
|
2013-07-20 00:29:11 +00:00
|
|
|
|
#include "deprecated/gtkimagemenuitem.h"
|
2011-06-30 21:23:12 +00:00
|
|
|
|
#include "gtkinfobar.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtklabel.h"
|
2004-02-23 19:55:49 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2003-11-03 00:50:33 +00:00
|
|
|
|
#include "gtkmessagedialog.h"
|
2008-06-10 00:39:35 +00:00
|
|
|
|
#include "gtkmountoperation.h"
|
2012-03-03 18:22:22 +00:00
|
|
|
|
#include "gtkpaned.h"
|
2004-02-20 23:21:01 +00:00
|
|
|
|
#include "gtkpathbar.h"
|
2012-09-06 00:48:16 +00:00
|
|
|
|
#include "gtkplacessidebar.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkprivate.h"
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
#include "gtkradiobutton.h"
|
2007-05-11 19:26:32 +00:00
|
|
|
|
#include "gtkrecentfilter.h"
|
|
|
|
|
#include "gtkrecentmanager.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkscrolledwindow.h"
|
2004-07-29 20:53:52 +00:00
|
|
|
|
#include "gtkseparatormenuitem.h"
|
2012-03-03 18:22:22 +00:00
|
|
|
|
#include "gtksettings.h"
|
2003-12-01 18:57:17 +00:00
|
|
|
|
#include "gtksizegroup.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
#include "gtksizerequest.h"
|
2011-01-27 20:21:10 +00:00
|
|
|
|
#include "gtktoolbar.h"
|
|
|
|
|
#include "gtktoolbutton.h"
|
2007-07-20 09:53:20 +00:00
|
|
|
|
#include "gtktooltip.h"
|
2004-03-11 06:24:15 +00:00
|
|
|
|
#include "gtktreednd.h"
|
|
|
|
|
#include "gtktreeprivate.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtktreeselection.h"
|
2011-06-07 22:36:57 +00:00
|
|
|
|
#include "gtkbox.h"
|
|
|
|
|
#include "gtkorientable.h"
|
2008-07-02 10:14:45 +00:00
|
|
|
|
#include "gtkintl.h"
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2013-07-03 11:26:03 +00:00
|
|
|
|
#include <cairo-gobject.h>
|
2004-08-25 19:10:38 +00:00
|
|
|
|
#include <errno.h>
|
2003-03-24 15:41:40 +00:00
|
|
|
|
#include <string.h>
|
2003-09-09 15:18:29 +00:00
|
|
|
|
#include <time.h>
|
2007-05-02 22:51:43 +00:00
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/types.h>
|
2008-05-23 20:29:27 +00:00
|
|
|
|
#include <locale.h>
|
2005-07-20 02:11:37 +00:00
|
|
|
|
|
2005-07-26 18:43:27 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-07-20 02:11:37 +00:00
|
|
|
|
#include <unistd.h>
|
2005-07-26 18:43:27 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-08-04 18:34:16 +00:00
|
|
|
|
/* Values for GtkSelection-related "info" fields */
|
|
|
|
|
#define SELECTION_TEXT 0
|
|
|
|
|
#define SELECTION_URI 1
|
|
|
|
|
|
2005-10-07 20:03:36 +00:00
|
|
|
|
/* Profiling stuff */
|
2006-06-08 19:20:12 +00:00
|
|
|
|
#undef PROFILE_FILE_CHOOSER
|
2005-10-07 20:03:36 +00:00
|
|
|
|
#ifdef PROFILE_FILE_CHOOSER
|
|
|
|
|
|
|
|
|
|
|
2005-07-26 18:43:27 +00:00
|
|
|
|
#ifndef F_OK
|
|
|
|
|
#define F_OK 0
|
|
|
|
|
#endif
|
2005-07-20 02:11:37 +00:00
|
|
|
|
|
|
|
|
|
#define PROFILE_INDENT 4
|
2011-08-04 18:34:16 +00:00
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
static int profile_indent;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
profile_add_indent (int indent)
|
|
|
|
|
{
|
|
|
|
|
profile_indent += indent;
|
|
|
|
|
if (profile_indent < 0)
|
|
|
|
|
g_error ("You screwed up your indentation");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gtk_file_chooser_profile_log (const char *func, int indent, const char *msg1, const char *msg2)
|
|
|
|
|
{
|
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
|
|
if (indent < 0)
|
|
|
|
|
profile_add_indent (indent);
|
|
|
|
|
|
|
|
|
|
if (profile_indent == 0)
|
2005-09-29 00:19:32 +00:00
|
|
|
|
str = g_strdup_printf ("MARK: %s %s %s", func ? func : "", msg1 ? msg1 : "", msg2 ? msg2 : "");
|
2005-07-20 02:11:37 +00:00
|
|
|
|
else
|
2005-09-29 00:19:32 +00:00
|
|
|
|
str = g_strdup_printf ("MARK: %*c %s %s %s", profile_indent - 1, ' ', func ? func : "", msg1 ? msg1 : "", msg2 ? msg2 : "");
|
2005-07-20 02:11:37 +00:00
|
|
|
|
|
|
|
|
|
access (str, F_OK);
|
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
|
|
if (indent > 0)
|
|
|
|
|
profile_add_indent (indent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define profile_start(x, y) _gtk_file_chooser_profile_log (G_STRFUNC, PROFILE_INDENT, x, y)
|
|
|
|
|
#define profile_end(x, y) _gtk_file_chooser_profile_log (G_STRFUNC, -PROFILE_INDENT, x, y)
|
|
|
|
|
#define profile_msg(x, y) _gtk_file_chooser_profile_log (NULL, 0, x, y)
|
|
|
|
|
#else
|
|
|
|
|
#define profile_start(x, y)
|
|
|
|
|
#define profile_end(x, y)
|
|
|
|
|
#define profile_msg(x, y)
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-03-23 05:13:56 +00:00
|
|
|
|
|
2013-04-12 02:44:21 +00:00
|
|
|
|
typedef enum {
|
|
|
|
|
LOAD_EMPTY, /* There is no model */
|
|
|
|
|
LOAD_PRELOAD, /* Model is loading and a timer is running; model isn't inserted into the tree yet */
|
|
|
|
|
LOAD_LOADING, /* Timeout expired, model is inserted into the tree, but not fully loaded yet */
|
|
|
|
|
LOAD_FINISHED /* Model is fully loaded and inserted into the tree */
|
|
|
|
|
} LoadState;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
RELOAD_EMPTY, /* No folder has been set */
|
|
|
|
|
RELOAD_HAS_FOLDER /* We have a folder, although it may not be completely loaded yet; no need to reload */
|
|
|
|
|
} ReloadState;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
LOCATION_MODE_PATH_BAR,
|
|
|
|
|
LOCATION_MODE_FILENAME_ENTRY
|
|
|
|
|
} LocationMode;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
OPERATION_MODE_BROWSE,
|
|
|
|
|
OPERATION_MODE_SEARCH,
|
|
|
|
|
OPERATION_MODE_RECENT
|
|
|
|
|
} OperationMode;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
STARTUP_MODE_RECENT,
|
|
|
|
|
STARTUP_MODE_CWD
|
|
|
|
|
} StartupMode;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
typedef struct {
|
2013-04-12 02:44:21 +00:00
|
|
|
|
GtkFileChooserAction action;
|
|
|
|
|
|
|
|
|
|
GtkFileSystem *file_system;
|
|
|
|
|
|
|
|
|
|
/* Save mode widgets */
|
|
|
|
|
GtkWidget *save_widgets;
|
|
|
|
|
GtkWidget *save_widgets_table;
|
|
|
|
|
|
|
|
|
|
GtkWidget *save_folder_label;
|
|
|
|
|
|
|
|
|
|
/* The file browsing widgets */
|
|
|
|
|
GtkWidget *browse_widgets_box;
|
|
|
|
|
GtkWidget *browse_widgets_hpaned;
|
|
|
|
|
GtkWidget *browse_header_box;
|
|
|
|
|
GtkWidget *browse_files_tree_view;
|
|
|
|
|
GtkWidget *browse_files_popup_menu;
|
|
|
|
|
GtkWidget *browse_files_popup_menu_add_shortcut_item;
|
|
|
|
|
GtkWidget *browse_files_popup_menu_hidden_files_item;
|
|
|
|
|
GtkWidget *browse_files_popup_menu_size_column_item;
|
|
|
|
|
GtkWidget *browse_files_popup_menu_copy_file_location_item;
|
|
|
|
|
GtkWidget *browse_files_popup_menu_visit_file_item;
|
|
|
|
|
GtkWidget *browse_new_folder_button;
|
|
|
|
|
GtkWidget *browse_path_bar_hbox;
|
|
|
|
|
GtkSizeGroup *browse_path_bar_size_group;
|
|
|
|
|
GtkWidget *browse_path_bar;
|
|
|
|
|
GtkWidget *browse_special_mode_icon;
|
|
|
|
|
GtkWidget *browse_special_mode_label;
|
|
|
|
|
GtkWidget *browse_select_a_folder_info_bar;
|
|
|
|
|
GtkWidget *browse_select_a_folder_label;
|
|
|
|
|
GtkWidget *browse_select_a_folder_icon;
|
|
|
|
|
|
|
|
|
|
GtkFileSystemModel *browse_files_model;
|
|
|
|
|
char *browse_files_last_selected_name;
|
|
|
|
|
|
|
|
|
|
GtkWidget *places_sidebar;
|
|
|
|
|
StartupMode startup_mode;
|
|
|
|
|
|
|
|
|
|
/* OPERATION_MODE_SEARCH */
|
|
|
|
|
GtkWidget *search_hbox;
|
|
|
|
|
GtkWidget *search_entry;
|
|
|
|
|
GtkSearchEngine *search_engine;
|
|
|
|
|
GtkQuery *search_query;
|
|
|
|
|
GtkFileSystemModel *search_model;
|
|
|
|
|
|
|
|
|
|
/* OPERATION_MODE_RECENT */
|
|
|
|
|
GtkRecentManager *recent_manager;
|
|
|
|
|
GtkFileSystemModel *recent_model;
|
|
|
|
|
guint load_recent_id;
|
|
|
|
|
|
|
|
|
|
GtkWidget *filter_combo_hbox;
|
|
|
|
|
GtkWidget *filter_combo;
|
|
|
|
|
GtkWidget *preview_box;
|
|
|
|
|
GtkWidget *preview_label;
|
|
|
|
|
GtkWidget *preview_widget;
|
|
|
|
|
GtkWidget *extra_align;
|
|
|
|
|
GtkWidget *extra_widget;
|
|
|
|
|
|
|
|
|
|
GtkWidget *location_button;
|
|
|
|
|
GtkWidget *location_entry_box;
|
|
|
|
|
GtkWidget *location_label;
|
|
|
|
|
GtkWidget *location_entry;
|
|
|
|
|
LocationMode location_mode;
|
|
|
|
|
|
|
|
|
|
/* Handles */
|
|
|
|
|
GSList *loading_shortcuts;
|
|
|
|
|
GSList *reload_icon_cancellables;
|
|
|
|
|
GCancellable *file_list_drag_data_received_cancellable;
|
|
|
|
|
GCancellable *update_current_folder_cancellable;
|
|
|
|
|
GCancellable *should_respond_get_info_cancellable;
|
|
|
|
|
GCancellable *file_exists_get_info_cancellable;
|
|
|
|
|
GCancellable *update_from_entry_cancellable;
|
|
|
|
|
GCancellable *shortcuts_activate_iter_cancellable;
|
|
|
|
|
|
|
|
|
|
LoadState load_state;
|
|
|
|
|
ReloadState reload_state;
|
|
|
|
|
guint load_timeout_id;
|
|
|
|
|
|
|
|
|
|
OperationMode operation_mode;
|
|
|
|
|
|
|
|
|
|
GSList *pending_select_files;
|
|
|
|
|
|
|
|
|
|
GtkFileFilter *current_filter;
|
|
|
|
|
GSList *filters;
|
|
|
|
|
|
|
|
|
|
GtkBookmarksManager *bookmarks_manager;
|
|
|
|
|
|
|
|
|
|
int num_volumes;
|
|
|
|
|
int num_shortcuts;
|
|
|
|
|
int num_bookmarks;
|
|
|
|
|
|
|
|
|
|
gulong volumes_changed_id;
|
|
|
|
|
gulong bookmarks_changed_id;
|
|
|
|
|
|
|
|
|
|
GFile *current_volume_file;
|
|
|
|
|
GFile *current_folder;
|
|
|
|
|
GFile *preview_file;
|
|
|
|
|
char *preview_display_name;
|
|
|
|
|
|
|
|
|
|
GtkTreeViewColumn *list_name_column;
|
|
|
|
|
GtkCellRenderer *list_name_renderer;
|
2013-04-12 01:37:01 +00:00
|
|
|
|
GtkCellRenderer *list_pixbuf_renderer;
|
2013-04-12 02:44:21 +00:00
|
|
|
|
GtkTreeViewColumn *list_mtime_column;
|
|
|
|
|
GtkTreeViewColumn *list_size_column;
|
|
|
|
|
|
|
|
|
|
GSource *edited_idle;
|
|
|
|
|
char *edited_new_text;
|
|
|
|
|
|
|
|
|
|
gulong settings_signal_id;
|
|
|
|
|
int icon_size;
|
|
|
|
|
|
|
|
|
|
GSource *focus_entry_idle;
|
|
|
|
|
|
|
|
|
|
gulong toplevel_set_focus_id;
|
|
|
|
|
GtkWidget *toplevel_last_focus_widget;
|
|
|
|
|
|
|
|
|
|
gint sort_column;
|
|
|
|
|
GtkSortType sort_order;
|
|
|
|
|
|
|
|
|
|
/* Flags */
|
|
|
|
|
|
|
|
|
|
guint local_only : 1;
|
|
|
|
|
guint preview_widget_active : 1;
|
|
|
|
|
guint use_preview_label : 1;
|
|
|
|
|
guint select_multiple : 1;
|
|
|
|
|
guint show_hidden : 1;
|
2013-12-03 17:10:29 +00:00
|
|
|
|
guint sort_directories_first : 1;
|
2013-04-12 02:44:21 +00:00
|
|
|
|
guint do_overwrite_confirmation : 1;
|
|
|
|
|
guint list_sort_ascending : 1;
|
|
|
|
|
guint shortcuts_current_folder_active : 1;
|
|
|
|
|
guint show_size_column : 1;
|
|
|
|
|
guint create_folders : 1;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
} GtkFileChooserDefaultPrivate;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
#define GTK_FILE_CHOOSER_DEFAULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_CHOOSER_DEFAULT, GtkFileChooserDefaultClass))
|
|
|
|
|
#define GTK_IS_FILE_CHOOSER_DEFAULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_CHOOSER_DEFAULT))
|
|
|
|
|
#define GTK_FILE_CHOOSER_DEFAULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_CHOOSER_DEFAULT, GtkFileChooserDefaultClass))
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2004-11-20 00:17:30 +00:00
|
|
|
|
#define MAX_LOADING_TIME 500
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2009-06-12 16:45:43 +00:00
|
|
|
|
#define DEFAULT_NEW_FOLDER_NAME _("Type name of new folder")
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
typedef struct _GtkFileChooserDefaultClass GtkFileChooserDefaultClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkFileChooserDefault
|
|
|
|
|
{
|
|
|
|
|
GtkBox parent_instance;
|
|
|
|
|
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv;
|
|
|
|
|
};
|
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
struct _GtkFileChooserDefaultClass
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2011-06-07 22:36:57 +00:00
|
|
|
|
GtkBoxClass parent_class;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Signal IDs */
|
|
|
|
|
enum {
|
|
|
|
|
LOCATION_POPUP,
|
2006-06-12 15:11:39 +00:00
|
|
|
|
LOCATION_POPUP_ON_PASTE,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
UP_FOLDER,
|
2004-03-15 02:12:08 +00:00
|
|
|
|
DOWN_FOLDER,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
HOME_FOLDER,
|
2005-10-04 20:08:32 +00:00
|
|
|
|
DESKTOP_FOLDER,
|
Take a shortcut position, not a ShortcutsIndex, to make the function more
2005-10-04 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c (switch_to_shortcut): Take a
shortcut position, not a ShortcutsIndex, to make the function more
generic.
(home_folder_handler): Pass the resolved index to
switch_to_shortcut(), rather than just SHORTCUTS_HOME.
(desktop_folder_handler): Likewise for SHORTCUTS_DESKTOP.
(gtk_file_chooser_default_class_init): Add a "quick-bookmark"
binding signal, and bind it to Alt-1, Alt-2. ..., Alt-0. These
make the respective key switch to the first, second, ..., tenth
bookmark.
(quick_bookmark_handler): Implement.
2005-10-05 05:05:42 +00:00
|
|
|
|
QUICK_BOOKMARK,
|
2007-03-23 05:06:00 +00:00
|
|
|
|
LOCATION_TOGGLE_POPUP,
|
2007-03-23 05:13:56 +00:00
|
|
|
|
SHOW_HIDDEN,
|
2007-05-11 19:16:59 +00:00
|
|
|
|
SEARCH_SHORTCUT,
|
2007-05-11 19:26:32 +00:00
|
|
|
|
RECENT_SHORTCUT,
|
2007-05-11 19:16:59 +00:00
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2009-06-30 21:45:39 +00:00
|
|
|
|
#define MODEL_ATTRIBUTES "standard::name,standard::type,standard::display-name," \
|
|
|
|
|
"standard::is-hidden,standard::is-backup,standard::size," \
|
|
|
|
|
"standard::content-type,time::modified"
|
2009-06-30 19:24:52 +00:00
|
|
|
|
enum {
|
|
|
|
|
/* the first 3 must be these due to settings caching sort column */
|
|
|
|
|
MODEL_COL_NAME,
|
|
|
|
|
MODEL_COL_SIZE,
|
|
|
|
|
MODEL_COL_MTIME,
|
|
|
|
|
MODEL_COL_FILE,
|
|
|
|
|
MODEL_COL_NAME_COLLATED,
|
|
|
|
|
MODEL_COL_IS_FOLDER,
|
2012-07-08 07:25:02 +00:00
|
|
|
|
MODEL_COL_IS_SENSITIVE,
|
2013-07-03 11:26:03 +00:00
|
|
|
|
MODEL_COL_SURFACE,
|
2009-06-30 19:24:52 +00:00
|
|
|
|
MODEL_COL_SIZE_TEXT,
|
|
|
|
|
MODEL_COL_MTIME_TEXT,
|
|
|
|
|
MODEL_COL_ELLIPSIZE,
|
|
|
|
|
MODEL_COL_NUM_COLUMNS
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-11 19:28:36 +00:00
|
|
|
|
/* This list of types is passed to _gtk_file_system_model_new*() */
|
|
|
|
|
#define MODEL_COLUMN_TYPES \
|
|
|
|
|
MODEL_COL_NUM_COLUMNS, \
|
|
|
|
|
G_TYPE_STRING, /* MODEL_COL_NAME */ \
|
|
|
|
|
G_TYPE_INT64, /* MODEL_COL_SIZE */ \
|
|
|
|
|
G_TYPE_LONG, /* MODEL_COL_MTIME */ \
|
|
|
|
|
G_TYPE_FILE, /* MODEL_COL_FILE */ \
|
|
|
|
|
G_TYPE_STRING, /* MODEL_COL_NAME_COLLATED */ \
|
|
|
|
|
G_TYPE_BOOLEAN, /* MODEL_COL_IS_FOLDER */ \
|
2012-07-08 07:25:02 +00:00
|
|
|
|
G_TYPE_BOOLEAN, /* MODEL_COL_IS_SENSITIVE */ \
|
2013-07-03 11:26:03 +00:00
|
|
|
|
CAIRO_GOBJECT_TYPE_SURFACE, /* MODEL_COL_SURFACE */ \
|
2009-09-11 19:28:36 +00:00
|
|
|
|
G_TYPE_STRING, /* MODEL_COL_SIZE_TEXT */ \
|
|
|
|
|
G_TYPE_STRING, /* MODEL_COL_MTIME_TEXT */ \
|
|
|
|
|
PANGO_TYPE_ELLIPSIZE_MODE /* MODEL_COL_ELLIPSIZE */
|
|
|
|
|
|
2003-12-01 15:33:37 +00:00
|
|
|
|
/* Identifiers for target types */
|
|
|
|
|
enum {
|
2004-03-11 06:24:15 +00:00
|
|
|
|
GTK_TREE_MODEL_ROW,
|
2007-05-11 19:44:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
2013-07-08 20:42:44 +00:00
|
|
|
|
#define DEFAULT_RECENT_FILES_LIMIT 50
|
|
|
|
|
|
2004-03-09 21:22:42 +00:00
|
|
|
|
/* Icon size for if we can't get it from the theme */
|
2005-02-01 23:55:44 +00:00
|
|
|
|
#define FALLBACK_ICON_SIZE 16
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-02-29 07:55:24 +00:00
|
|
|
|
#define PREVIEW_HBOX_SPACING 12
|
2007-02-26 19:45:33 +00:00
|
|
|
|
#define NUM_LINES 45
|
2004-02-29 07:55:24 +00:00
|
|
|
|
#define NUM_CHARS 60
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void gtk_file_chooser_default_iface_init (GtkFileChooserIface *iface);
|
|
|
|
|
static void gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
|
|
|
|
|
static GObject* gtk_file_chooser_default_constructor (GType type,
|
|
|
|
|
guint n_construct_properties,
|
|
|
|
|
GObjectConstructParam *construct_params);
|
|
|
|
|
static void gtk_file_chooser_default_finalize (GObject *object);
|
|
|
|
|
static void gtk_file_chooser_default_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_file_chooser_default_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
static void gtk_file_chooser_default_dispose (GObject *object);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void gtk_file_chooser_default_show_all (GtkWidget *widget);
|
2009-01-14 20:18:40 +00:00
|
|
|
|
static void gtk_file_chooser_default_realize (GtkWidget *widget);
|
2004-12-15 01:37:41 +00:00
|
|
|
|
static void gtk_file_chooser_default_map (GtkWidget *widget);
|
2005-09-27 23:57:09 +00:00
|
|
|
|
static void gtk_file_chooser_default_unmap (GtkWidget *widget);
|
2004-07-29 01:26:51 +00:00
|
|
|
|
static void gtk_file_chooser_default_hierarchy_changed (GtkWidget *widget,
|
|
|
|
|
GtkWidget *previous_toplevel);
|
2011-01-04 01:34:28 +00:00
|
|
|
|
static void gtk_file_chooser_default_style_updated (GtkWidget *widget);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void gtk_file_chooser_default_screen_changed (GtkWidget *widget,
|
|
|
|
|
GdkScreen *previous_screen);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
static gboolean gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *folder,
|
2004-03-05 20:47:05 +00:00
|
|
|
|
GError **error);
|
2005-07-07 12:40:50 +00:00
|
|
|
|
static gboolean gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *folder,
|
2005-07-07 12:40:50 +00:00
|
|
|
|
gboolean keep_trail,
|
add a new struct field to clear the file entry after the current folder
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
svn path=/trunk/; revision=17754
2007-05-01 20:35:33 +00:00
|
|
|
|
gboolean clear_entry,
|
2005-07-07 12:40:50 +00:00
|
|
|
|
GError **error);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static GFile * gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
const gchar *name);
|
2013-06-17 18:47:56 +00:00
|
|
|
|
static gchar * gtk_file_chooser_default_get_current_name (GtkFileChooser *chooser);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static gboolean gtk_file_chooser_default_select_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
2004-03-05 20:47:05 +00:00
|
|
|
|
GError **error);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static void gtk_file_chooser_default_unselect_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void gtk_file_chooser_default_select_all (GtkFileChooser *chooser);
|
|
|
|
|
static void gtk_file_chooser_default_unselect_all (GtkFileChooser *chooser);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static GSList * gtk_file_chooser_default_get_files (GtkFileChooser *chooser);
|
|
|
|
|
static GFile * gtk_file_chooser_default_get_preview_file (GtkFileChooser *chooser);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static GtkFileSystem *gtk_file_chooser_default_get_file_system (GtkFileChooser *chooser);
|
|
|
|
|
static void gtk_file_chooser_default_add_filter (GtkFileChooser *chooser,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
GtkFileFilter *filter);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void gtk_file_chooser_default_remove_filter (GtkFileChooser *chooser,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
GtkFileFilter *filter);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static GSList * gtk_file_chooser_default_list_filters (GtkFileChooser *chooser);
|
|
|
|
|
static gboolean gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GError **error);
|
|
|
|
|
static gboolean gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser *chooser,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GError **error);
|
|
|
|
|
static GSList * gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void gtk_file_chooser_default_get_default_size (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
|
gint *default_width,
|
|
|
|
|
gint *default_height);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
static gboolean gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed);
|
2004-03-08 22:21:47 +00:00
|
|
|
|
static void gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
|
2011-07-13 21:04:54 +00:00
|
|
|
|
static void add_selection_to_recent_list (GtkFileChooserDefault *impl);
|
|
|
|
|
|
2007-05-11 19:16:59 +00:00
|
|
|
|
static void location_popup_handler (GtkFileChooserDefault *impl,
|
|
|
|
|
const gchar *path);
|
2006-06-12 15:11:39 +00:00
|
|
|
|
static void location_popup_on_paste_handler (GtkFileChooserDefault *impl);
|
2007-03-23 05:06:00 +00:00
|
|
|
|
static void location_toggle_popup_handler (GtkFileChooserDefault *impl);
|
2007-05-11 19:16:59 +00:00
|
|
|
|
static void up_folder_handler (GtkFileChooserDefault *impl);
|
|
|
|
|
static void down_folder_handler (GtkFileChooserDefault *impl);
|
|
|
|
|
static void home_folder_handler (GtkFileChooserDefault *impl);
|
|
|
|
|
static void desktop_folder_handler (GtkFileChooserDefault *impl);
|
|
|
|
|
static void quick_bookmark_handler (GtkFileChooserDefault *impl,
|
|
|
|
|
gint bookmark_index);
|
|
|
|
|
static void show_hidden_handler (GtkFileChooserDefault *impl);
|
|
|
|
|
static void search_shortcut_handler (GtkFileChooserDefault *impl);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
static void recent_shortcut_handler (GtkFileChooserDefault *impl);
|
2007-05-11 19:16:59 +00:00
|
|
|
|
static void update_appearance (GtkFileChooserDefault *impl);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2012-12-10 23:14:12 +00:00
|
|
|
|
static void operation_mode_set (GtkFileChooserDefault *impl, OperationMode mode);
|
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void set_current_filter (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkFileFilter *filter);
|
|
|
|
|
static void check_preview_change (GtkFileChooserDefault *impl);
|
|
|
|
|
|
2003-10-23 05:10:47 +00:00
|
|
|
|
static void filter_combo_changed (GtkComboBox *combo_box,
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl);
|
2004-04-29 23:13:50 +00:00
|
|
|
|
|
2004-11-07 05:15:25 +00:00
|
|
|
|
static gboolean list_select_func (GtkTreeSelection *selection,
|
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
|
gpointer data);
|
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void list_selection_changed (GtkTreeSelection *tree_selection,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
|
|
|
|
static void list_row_activated (GtkTreeView *tree_view,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2007-05-11 19:22:38 +00:00
|
|
|
|
static void path_bar_clicked (GtkPathBar *path_bar,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
|
|
|
|
GFile *child,
|
2007-05-11 19:22:38 +00:00
|
|
|
|
gboolean child_is_hidden,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2009-06-30 20:58:55 +00:00
|
|
|
|
static void update_cell_renderer_attributes (GtkFileChooserDefault *impl);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
|
2013-02-21 00:02:24 +00:00
|
|
|
|
static void load_remove_timer (GtkFileChooserDefault *impl, LoadState new_load_state);
|
2005-07-07 17:11:26 +00:00
|
|
|
|
static void browse_files_center_selected_row (GtkFileChooserDefault *impl);
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
static void location_button_toggled_cb (GtkToggleButton *toggle,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
|
|
|
|
static void location_switch_to_path_bar (GtkFileChooserDefault *impl);
|
|
|
|
|
|
2009-11-02 18:48:05 +00:00
|
|
|
|
static void stop_loading_and_clear_list_model (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean remove_from_treeview);
|
2011-07-26 21:43:36 +00:00
|
|
|
|
|
|
|
|
|
static void search_setup_widgets (GtkFileChooserDefault *impl);
|
2007-05-11 19:22:38 +00:00
|
|
|
|
static void search_stop_searching (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean remove_query);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
static void search_clear_model (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean remove_from_treeview);
|
|
|
|
|
static gboolean search_should_respond (GtkFileChooserDefault *impl);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static GSList *search_get_selected_files (GtkFileChooserDefault *impl);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
static void search_entry_activate_cb (GtkEntry *entry,
|
|
|
|
|
gpointer data);
|
2007-05-18 10:38:42 +00:00
|
|
|
|
static void settings_load (GtkFileChooserDefault *impl);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
|
2011-07-26 21:43:36 +00:00
|
|
|
|
static void recent_start_loading (GtkFileChooserDefault *impl);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
static void recent_stop_loading (GtkFileChooserDefault *impl);
|
|
|
|
|
static void recent_clear_model (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean remove_from_treeview);
|
|
|
|
|
static gboolean recent_should_respond (GtkFileChooserDefault *impl);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static GSList * recent_get_selected_files (GtkFileChooserDefault *impl);
|
|
|
|
|
static void set_file_system_backend (GtkFileChooserDefault *impl);
|
2008-09-22 18:32:31 +00:00
|
|
|
|
static void unset_file_system_backend (GtkFileChooserDefault *impl);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2007-05-11 19:44:32 +00:00
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
2011-06-07 22:36:57 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkFileChooserDefault, _gtk_file_chooser_default, GTK_TYPE_BOX,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkFileChooserDefault)
|
2006-05-02 23:56:43 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER,
|
|
|
|
|
gtk_file_chooser_default_iface_init)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED,
|
|
|
|
|
gtk_file_chooser_embed_default_iface_init));
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2013-04-11 21:47:38 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_iface_init (GtkFileChooserIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->select_file = gtk_file_chooser_default_select_file;
|
|
|
|
|
iface->unselect_file = gtk_file_chooser_default_unselect_file;
|
|
|
|
|
iface->select_all = gtk_file_chooser_default_select_all;
|
|
|
|
|
iface->unselect_all = gtk_file_chooser_default_unselect_all;
|
|
|
|
|
iface->get_files = gtk_file_chooser_default_get_files;
|
|
|
|
|
iface->get_preview_file = gtk_file_chooser_default_get_preview_file;
|
|
|
|
|
iface->get_file_system = gtk_file_chooser_default_get_file_system;
|
|
|
|
|
iface->set_current_folder = gtk_file_chooser_default_set_current_folder;
|
|
|
|
|
iface->get_current_folder = gtk_file_chooser_default_get_current_folder;
|
|
|
|
|
iface->set_current_name = gtk_file_chooser_default_set_current_name;
|
2013-06-17 18:47:56 +00:00
|
|
|
|
iface->get_current_name = gtk_file_chooser_default_get_current_name;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
iface->add_filter = gtk_file_chooser_default_add_filter;
|
|
|
|
|
iface->remove_filter = gtk_file_chooser_default_remove_filter;
|
|
|
|
|
iface->list_filters = gtk_file_chooser_default_list_filters;
|
|
|
|
|
iface->add_shortcut_folder = gtk_file_chooser_default_add_shortcut_folder;
|
|
|
|
|
iface->remove_shortcut_folder = gtk_file_chooser_default_remove_shortcut_folder;
|
|
|
|
|
iface->list_shortcut_folders = gtk_file_chooser_default_list_shortcut_folders;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_default_size = gtk_file_chooser_default_get_default_size;
|
|
|
|
|
iface->should_respond = gtk_file_chooser_default_should_respond;
|
|
|
|
|
iface->initial_focus = gtk_file_chooser_default_initial_focus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-04-12 01:37:01 +00:00
|
|
|
|
pending_select_files_free (GtkFileChooserDefault *impl)
|
2013-04-11 21:47:38 +00:00
|
|
|
|
{
|
2013-04-12 01:37:01 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
|
2013-04-12 01:37:01 +00:00
|
|
|
|
g_slist_free_full (priv->pending_select_files, g_object_unref);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->pending_select_files = NULL;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
pending_select_files_add (GtkFileChooserDefault *impl,
|
|
|
|
|
GFile *file)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
priv->pending_select_files =
|
|
|
|
|
g_slist_prepend (priv->pending_select_files, g_object_ref (file));
|
2013-04-11 21:47:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
|
|
unset_file_system_backend (impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_free (priv->browse_files_last_selected_name);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
for (l = priv->filters; l; l = l->next)
|
2013-04-11 21:47:38 +00:00
|
|
|
|
{
|
|
|
|
|
GtkFileFilter *filter;
|
|
|
|
|
|
|
|
|
|
filter = GTK_FILE_FILTER (l->data);
|
|
|
|
|
g_object_unref (filter);
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_slist_free (priv->filters);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->current_filter)
|
|
|
|
|
g_object_unref (priv->current_filter);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->current_volume_file)
|
|
|
|
|
g_object_unref (priv->current_volume_file);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->current_folder)
|
|
|
|
|
g_object_unref (priv->current_folder);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->preview_file)
|
|
|
|
|
g_object_unref (priv->preview_file);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->browse_path_bar_size_group)
|
|
|
|
|
g_object_unref (priv->browse_path_bar_size_group);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
|
|
|
|
/* Free all the Models we have */
|
|
|
|
|
stop_loading_and_clear_list_model (impl, FALSE);
|
|
|
|
|
search_clear_model (impl, FALSE);
|
|
|
|
|
recent_clear_model (impl, FALSE);
|
|
|
|
|
|
|
|
|
|
/* stopping the load above should have cleared this */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_timeout_id == 0);
|
|
|
|
|
|
|
|
|
|
g_free (priv->preview_display_name);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_free (priv->edited_new_text);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
impl->priv = NULL;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (_gtk_file_chooser_default_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Shows an error dialog set as transient for the specified window */
|
|
|
|
|
static void
|
|
|
|
|
error_message_with_parent (GtkWindow *parent,
|
|
|
|
|
const char *msg,
|
|
|
|
|
const char *detail)
|
|
|
|
|
{
|
2003-11-03 00:50:33 +00:00
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
dialog = gtk_message_dialog_new (parent,
|
2003-11-03 00:50:33 +00:00
|
|
|
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
|
GTK_MESSAGE_ERROR,
|
2004-03-11 18:48:46 +00:00
|
|
|
|
GTK_BUTTONS_OK,
|
2003-11-04 01:56:56 +00:00
|
|
|
|
"%s",
|
|
|
|
|
msg);
|
2004-12-30 07:42:07 +00:00
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
|
|
|
|
"%s", detail);
|
2005-08-15 18:17:01 +00:00
|
|
|
|
|
2010-08-24 14:10:38 +00:00
|
|
|
|
if (parent && gtk_window_has_group (parent))
|
|
|
|
|
gtk_window_group_add_window (gtk_window_get_group (parent),
|
|
|
|
|
GTK_WINDOW (dialog));
|
2005-08-15 18:17:01 +00:00
|
|
|
|
|
2003-11-03 00:50:33 +00:00
|
|
|
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
/* Returns a toplevel GtkWindow, or NULL if none */
|
|
|
|
|
static GtkWindow *
|
|
|
|
|
get_toplevel (GtkWidget *widget)
|
2004-03-19 19:41:06 +00:00
|
|
|
|
{
|
2004-03-19 21:16:24 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
toplevel = gtk_widget_get_toplevel (widget);
|
2010-01-04 06:49:26 +00:00
|
|
|
|
if (!gtk_widget_is_toplevel (toplevel))
|
2004-03-29 19:52:16 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
else
|
|
|
|
|
return GTK_WINDOW (toplevel);
|
|
|
|
|
}
|
2004-03-19 21:16:24 +00:00
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
/* Shows an error dialog for the file chooser */
|
|
|
|
|
static void
|
|
|
|
|
error_message (GtkFileChooserDefault *impl,
|
2004-12-30 07:42:07 +00:00
|
|
|
|
const char *msg,
|
|
|
|
|
const char *detail)
|
2004-03-29 19:52:16 +00:00
|
|
|
|
{
|
2004-12-30 07:42:07 +00:00
|
|
|
|
error_message_with_parent (get_toplevel (GTK_WIDGET (impl)), msg, detail);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-04 01:56:56 +00:00
|
|
|
|
/* Shows a simple error dialog relative to a path. Frees the GError as well. */
|
|
|
|
|
static void
|
|
|
|
|
error_dialog (GtkFileChooserDefault *impl,
|
|
|
|
|
const char *msg,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2003-11-04 01:56:56 +00:00
|
|
|
|
GError *error)
|
|
|
|
|
{
|
2007-05-11 19:42:40 +00:00
|
|
|
|
if (error)
|
2004-03-14 19:47:20 +00:00
|
|
|
|
{
|
2004-12-30 07:42:07 +00:00
|
|
|
|
char *uri = NULL;
|
|
|
|
|
char *text;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (file)
|
|
|
|
|
uri = g_file_get_uri (file);
|
2004-12-30 07:42:07 +00:00
|
|
|
|
text = g_strdup_printf (msg, uri);
|
|
|
|
|
error_message (impl, text, error->message);
|
2004-03-14 19:47:20 +00:00
|
|
|
|
g_free (text);
|
|
|
|
|
g_free (uri);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2003-11-04 01:56:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-30 07:42:07 +00:00
|
|
|
|
/* Shows an error dialog about not being able to create a folder */
|
|
|
|
|
static void
|
|
|
|
|
error_creating_folder_dialog (GtkFileChooserDefault *impl,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2004-12-30 07:42:07 +00:00
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("The folder could not be created"),
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file, error);
|
2004-12-30 07:42:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-06-10 05:54:28 +00:00
|
|
|
|
/* Shows an error about not being able to create a folder because a file with
|
|
|
|
|
* the same name is already there.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
error_creating_folder_over_existing_file_dialog (GtkFileChooserDefault *impl,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2005-06-10 05:54:28 +00:00
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
error_dialog (impl,
|
2007-05-11 19:22:38 +00:00
|
|
|
|
_("The folder could not be created, as a file with the same "
|
|
|
|
|
"name already exists. Try using a different name for the "
|
|
|
|
|
"folder, or rename the file first."),
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file, error);
|
2005-06-10 05:54:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-21 18:37:35 +00:00
|
|
|
|
static void
|
|
|
|
|
error_with_file_under_nonfolder (GtkFileChooserDefault *impl,
|
|
|
|
|
GFile *parent_file)
|
|
|
|
|
{
|
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
|
|
error = NULL;
|
|
|
|
|
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY,
|
|
|
|
|
_("You need to choose a valid filename."));
|
|
|
|
|
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Cannot create a file under %s as it is not a folder"),
|
|
|
|
|
parent_file, error);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 08:09:58 +00:00
|
|
|
|
static void
|
|
|
|
|
error_filename_to_long_dialog (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
error_message (impl,
|
2013-09-04 16:39:16 +00:00
|
|
|
|
_("Cannot create file as the filename is too long"),
|
2013-05-23 08:09:58 +00:00
|
|
|
|
_("Try using a shorter name."));
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 17:55:03 +00:00
|
|
|
|
/* Shows an error about not being able to select a folder because a file with
|
|
|
|
|
* the same name is already there.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2013-05-23 08:00:36 +00:00
|
|
|
|
error_selecting_folder_over_existing_file_dialog (GtkFileChooserDefault *impl)
|
2010-10-05 17:55:03 +00:00
|
|
|
|
{
|
2013-05-23 08:00:36 +00:00
|
|
|
|
error_message (impl,
|
|
|
|
|
_("You may only select folders"),
|
|
|
|
|
_("The item that you selected is not a folder try using a different item."));
|
2010-10-05 17:55:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-30 07:42:07 +00:00
|
|
|
|
/* Shows an error dialog about not being able to create a filename */
|
2004-01-17 04:34:49 +00:00
|
|
|
|
static void
|
|
|
|
|
error_building_filename_dialog (GtkFileChooserDefault *impl,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
2004-12-30 07:42:07 +00:00
|
|
|
|
error_dialog (impl, _("Invalid file name"),
|
|
|
|
|
NULL, error);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
/* Shows an error dialog when we cannot switch to a folder */
|
|
|
|
|
static void
|
|
|
|
|
error_changing_folder_dialog (GtkFileChooserDefault *impl,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2004-03-05 20:47:05 +00:00
|
|
|
|
GError *error)
|
|
|
|
|
{
|
2004-12-30 07:42:07 +00:00
|
|
|
|
error_dialog (impl, _("The folder contents could not be displayed"),
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file, error);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Changes folders, displaying an error dialog if this fails */
|
|
|
|
|
static gboolean
|
|
|
|
|
change_folder_and_display_error (GtkFileChooserDefault *impl,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
add a new struct field to clear the file entry after the current folder
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
svn path=/trunk/; revision=17754
2007-05-01 20:35:33 +00:00
|
|
|
|
gboolean clear_entry)
|
2004-03-05 20:47:05 +00:00
|
|
|
|
{
|
|
|
|
|
GError *error;
|
|
|
|
|
gboolean result;
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_return_val_if_fail (G_IS_FILE (file), FALSE);
|
2005-07-20 02:11:37 +00:00
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
/* We copy the path because of this case:
|
|
|
|
|
*
|
|
|
|
|
* list_row_activated()
|
|
|
|
|
* fetches path from model; path belongs to the model (*)
|
|
|
|
|
* calls change_folder_and_display_error()
|
2008-08-04 14:43:05 +00:00
|
|
|
|
* calls gtk_file_chooser_set_current_folder_file()
|
2004-07-09 00:53:48 +00:00
|
|
|
|
* changing folders fails, sets model to NULL, thus freeing the path in (*)
|
|
|
|
|
*/
|
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
error = NULL;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
result = gtk_file_chooser_default_update_current_folder (GTK_FILE_CHOOSER (impl), file, TRUE, clear_entry, &error);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
|
|
|
|
if (!result)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
error_changing_folder_dialog (impl, file, error);
|
2005-07-20 02:11:37 +00:00
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-20 01:11:45 +00:00
|
|
|
|
static void
|
|
|
|
|
emit_default_size_changed (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
profile_msg (" emit default-size-changed start", NULL);
|
|
|
|
|
g_signal_emit_by_name (impl, "default-size-changed");
|
|
|
|
|
profile_msg (" emit default-size-changed end", NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
update_preview_widget_visibility (GtkFileChooserDefault *impl)
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->use_preview_label)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->preview_label)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->preview_label = gtk_label_new (priv->preview_display_name);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->preview_box), priv->preview_label, FALSE, FALSE, 0);
|
|
|
|
|
gtk_box_reorder_child (GTK_BOX (priv->preview_box), priv->preview_label, 0);
|
|
|
|
|
gtk_label_set_ellipsize (GTK_LABEL (priv->preview_label), PANGO_ELLIPSIZE_MIDDLE);
|
|
|
|
|
gtk_widget_show (priv->preview_label);
|
2004-02-29 06:35:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->preview_label)
|
2004-02-29 07:55:24 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_destroy (priv->preview_label);
|
|
|
|
|
priv->preview_label = NULL;
|
2004-02-29 07:55:24 +00:00
|
|
|
|
}
|
2004-02-29 06:35:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->preview_widget_active && priv->preview_widget)
|
|
|
|
|
gtk_widget_show (priv->preview_box);
|
2003-07-23 22:30:32 +00:00
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_hide (priv->preview_box);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2010-03-02 04:19:28 +00:00
|
|
|
|
if (!gtk_widget_get_mapped (GTK_WIDGET (impl)))
|
2009-01-14 20:18:40 +00:00
|
|
|
|
emit_default_size_changed (impl);
|
2003-07-23 22:30:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-26 17:09:26 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
set_preview_widget (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkWidget *preview_widget)
|
2003-03-26 17:09:26 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (preview_widget == priv->preview_widget)
|
2003-03-26 17:09:26 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->preview_widget)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->preview_box),
|
|
|
|
|
priv->preview_widget);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->preview_widget = preview_widget;
|
|
|
|
|
if (priv->preview_widget)
|
2003-03-26 17:09:26 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_show (priv->preview_widget);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->preview_box), priv->preview_widget, TRUE, TRUE, 0);
|
|
|
|
|
gtk_box_reorder_child (GTK_BOX (priv->preview_box),
|
|
|
|
|
priv->preview_widget,
|
|
|
|
|
(priv->use_preview_label && priv->preview_label) ? 1 : 0);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
}
|
2003-07-23 22:30:32 +00:00
|
|
|
|
|
|
|
|
|
update_preview_widget_visibility (impl);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* Callback used when the "New Folder" button is clicked */
|
2004-03-11 06:24:15 +00:00
|
|
|
|
static void
|
2012-12-06 00:09:44 +00:00
|
|
|
|
new_folder_button_clicked (GtkButton *button,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2004-03-11 06:24:15 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
GtkTreeIter iter;
|
2004-03-11 06:24:15 +00:00
|
|
|
|
GtkTreePath *path;
|
2008-05-24 18:56:22 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->browse_files_model)
|
2012-12-06 00:09:44 +00:00
|
|
|
|
return; /* FIXME: this sucks. Disable the New Folder button or something. */
|
2008-05-24 18:56:22 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* Prevent button from being clicked twice */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->browse_new_folder_button, FALSE);
|
2008-05-24 18:56:22 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_add_editable (priv->browse_files_model, &iter);
|
2007-11-26 23:16:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->browse_files_model), &iter);
|
|
|
|
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
|
|
|
|
path, priv->list_name_column,
|
2012-12-06 00:09:44 +00:00
|
|
|
|
FALSE, 0.0, 0.0);
|
2007-11-26 23:16:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_set (priv->list_name_renderer, "editable", TRUE, NULL);
|
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
2012-12-06 00:09:44 +00:00
|
|
|
|
path,
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->list_name_column,
|
2012-12-06 00:09:44 +00:00
|
|
|
|
TRUE);
|
2007-11-26 23:16:19 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2003-12-10 03:46:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
static GSource *
|
|
|
|
|
add_idle_while_impl_is_alive (GtkFileChooserDefault *impl, GCallback callback)
|
2004-08-07 22:21:25 +00:00
|
|
|
|
{
|
2012-12-06 00:09:44 +00:00
|
|
|
|
GSource *source;
|
2004-08-07 22:21:25 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
source = g_idle_source_new ();
|
|
|
|
|
g_source_set_closure (source,
|
|
|
|
|
g_cclosure_new_object (callback, G_OBJECT (impl)));
|
|
|
|
|
g_source_attach (source, NULL);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
return source;
|
2004-08-07 22:21:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* Idle handler for creating a new folder after editing its name cell, or for
|
|
|
|
|
* canceling the editing.
|
|
|
|
|
*/
|
2004-08-25 19:10:38 +00:00
|
|
|
|
static gboolean
|
2012-12-06 00:09:44 +00:00
|
|
|
|
edited_idle_cb (GtkFileChooserDefault *impl)
|
2004-08-25 19:10:38 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
gdk_threads_enter ();
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_source_destroy (priv->edited_idle);
|
|
|
|
|
priv->edited_idle = NULL;
|
2009-07-27 23:04:51 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_remove_editable (priv->browse_files_model);
|
|
|
|
|
g_object_set (priv->list_name_renderer, "editable", FALSE, NULL);
|
2009-07-27 23:04:51 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->browse_new_folder_button, TRUE);
|
2009-07-27 23:04:51 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->edited_new_text /* not cancelled? */
|
|
|
|
|
&& (strlen (priv->edited_new_text) != 0)
|
|
|
|
|
&& (strcmp (priv->edited_new_text, DEFAULT_NEW_FOLDER_NAME) != 0)) /* Don't create folder if name is empty or has not been edited */
|
2004-08-25 19:10:38 +00:00
|
|
|
|
{
|
2012-12-06 00:09:44 +00:00
|
|
|
|
GError *error = NULL;
|
|
|
|
|
GFile *file;
|
2004-08-25 19:10:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
file = g_file_get_child_for_display_name (priv->current_folder,
|
|
|
|
|
priv->edited_new_text,
|
2012-12-06 00:09:44 +00:00
|
|
|
|
&error);
|
|
|
|
|
if (file)
|
|
|
|
|
{
|
|
|
|
|
GError *error = NULL;
|
2005-03-22 20:23:19 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
if (g_file_make_directory (file, NULL, &error))
|
|
|
|
|
change_folder_and_display_error (impl, file, FALSE);
|
|
|
|
|
else
|
|
|
|
|
error_creating_folder_dialog (impl, file, error);
|
2005-03-22 20:23:19 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
g_object_unref (file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2012-12-06 00:09:44 +00:00
|
|
|
|
else
|
|
|
|
|
error_creating_folder_dialog (impl, file, error);
|
2005-03-22 20:23:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_free (priv->edited_new_text);
|
|
|
|
|
priv->edited_new_text = NULL;
|
2005-03-22 20:23:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
gdk_threads_leave ();
|
2006-03-07 17:48:07 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
return FALSE;
|
2005-11-28 14:03:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-03-22 20:23:19 +00:00
|
|
|
|
static void
|
2012-12-06 00:09:44 +00:00
|
|
|
|
queue_edited_idle (GtkFileChooserDefault *impl,
|
|
|
|
|
const gchar *new_text)
|
2005-03-22 20:23:19 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* We create the folder in an idle handler so that we don't modify the tree
|
|
|
|
|
* just now.
|
|
|
|
|
*/
|
2005-03-22 20:23:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->edited_idle)
|
|
|
|
|
priv->edited_idle = add_idle_while_impl_is_alive (impl, G_CALLBACK (edited_idle_cb));
|
2005-03-22 20:23:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_free (priv->edited_new_text);
|
|
|
|
|
priv->edited_new_text = g_strdup (new_text);
|
2005-03-22 20:23:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* Callback used from the text cell renderer when the new folder is named */
|
2005-03-22 20:23:19 +00:00
|
|
|
|
static void
|
2012-12-06 00:09:44 +00:00
|
|
|
|
renderer_edited_cb (GtkCellRendererText *cell_renderer_text,
|
|
|
|
|
const gchar *path,
|
|
|
|
|
const gchar *new_text,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2005-03-22 20:23:19 +00:00
|
|
|
|
{
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* work around bug #154921 */
|
|
|
|
|
g_object_set (cell_renderer_text,
|
|
|
|
|
"mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
|
|
|
|
|
queue_edited_idle (impl, new_text);
|
2005-03-22 20:23:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* Callback used from the text cell renderer when the new folder edition gets
|
|
|
|
|
* canceled.
|
|
|
|
|
*/
|
2005-03-22 20:23:19 +00:00
|
|
|
|
static void
|
2012-12-06 00:09:44 +00:00
|
|
|
|
renderer_editing_canceled_cb (GtkCellRendererText *cell_renderer_text,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2005-03-22 20:23:19 +00:00
|
|
|
|
{
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* work around bug #154921 */
|
|
|
|
|
g_object_set (cell_renderer_text,
|
|
|
|
|
"mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
|
|
|
|
|
queue_edited_idle (impl, NULL);
|
2005-03-22 20:23:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
struct selection_check_closure {
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
int num_selected;
|
|
|
|
|
gboolean all_files;
|
|
|
|
|
gboolean all_folders;
|
|
|
|
|
};
|
2003-12-10 03:46:30 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* Used from gtk_tree_selection_selected_foreach() */
|
2005-03-22 20:23:19 +00:00
|
|
|
|
static void
|
2012-12-06 00:09:44 +00:00
|
|
|
|
selection_check_foreach_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2005-03-22 20:23:19 +00:00
|
|
|
|
{
|
2012-12-06 00:09:44 +00:00
|
|
|
|
struct selection_check_closure *closure;
|
|
|
|
|
gboolean is_folder;
|
|
|
|
|
GFile *file;
|
2004-01-20 02:44:58 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
|
MODEL_COL_FILE, &file,
|
|
|
|
|
MODEL_COL_IS_FOLDER, &is_folder,
|
|
|
|
|
-1);
|
2005-03-22 20:23:19 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
if (file == NULL)
|
|
|
|
|
return;
|
2005-03-22 20:23:19 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
g_object_unref (file);
|
2006-02-25 02:45:57 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
closure = data;
|
|
|
|
|
closure->num_selected++;
|
2005-03-22 20:23:19 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
closure->all_folders = closure->all_folders && is_folder;
|
|
|
|
|
closure->all_files = closure->all_files && !is_folder;
|
2005-03-22 20:23:19 +00:00
|
|
|
|
}
|
2004-08-25 19:10:38 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
/* Checks whether the selected items in the file list are all files or all folders */
|
|
|
|
|
static void
|
|
|
|
|
selection_check (GtkFileChooserDefault *impl,
|
|
|
|
|
gint *num_selected,
|
|
|
|
|
gboolean *all_files,
|
|
|
|
|
gboolean *all_folders)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2012-12-06 00:09:44 +00:00
|
|
|
|
struct selection_check_closure closure;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
closure.impl = impl;
|
|
|
|
|
closure.num_selected = 0;
|
|
|
|
|
closure.all_files = TRUE;
|
|
|
|
|
closure.all_folders = TRUE;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2012-12-06 00:09:44 +00:00
|
|
|
|
gtk_tree_selection_selected_foreach (selection,
|
|
|
|
|
selection_check_foreach_cb,
|
|
|
|
|
&closure);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
g_assert (closure.num_selected == 0 || !(closure.all_files && closure.all_folders));
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
if (num_selected)
|
|
|
|
|
*num_selected = closure.num_selected;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
if (all_files)
|
|
|
|
|
*all_files = closure.all_files;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-06 00:09:44 +00:00
|
|
|
|
if (all_folders)
|
|
|
|
|
*all_folders = closure.all_folders;
|
2003-12-01 18:57:17 +00:00
|
|
|
|
}
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-10 23:14:12 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
file_is_recent_uri (GFile *file)
|
|
|
|
|
{
|
|
|
|
|
GFile *recent;
|
|
|
|
|
gboolean same;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-10 23:14:12 +00:00
|
|
|
|
recent = g_file_new_for_uri ("recent:///");
|
|
|
|
|
same = g_file_equal (file, recent);
|
|
|
|
|
g_object_unref (recent);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-10 23:14:12 +00:00
|
|
|
|
return same;
|
|
|
|
|
}
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-09-07 19:35:56 +00:00
|
|
|
|
static void
|
2013-01-10 22:19:03 +00:00
|
|
|
|
places_sidebar_open_location_cb (GtkPlacesSidebar *sidebar, GFile *location, GtkPlacesOpenFlags open_flags, GtkFileChooserDefault *impl)
|
2012-09-07 19:35:56 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2012-09-07 19:35:56 +00:00
|
|
|
|
gboolean clear_entry;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-09-07 19:35:56 +00:00
|
|
|
|
/* In the Save modes, we want to preserve what the uesr typed in the filename
|
|
|
|
|
* entry, so that he may choose another folder without erasing his typed name.
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_entry
|
|
|
|
|
&& !(priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
|
2012-09-07 19:35:56 +00:00
|
|
|
|
clear_entry = TRUE;
|
|
|
|
|
else
|
|
|
|
|
clear_entry = FALSE;
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-10 23:14:12 +00:00
|
|
|
|
/* FIXME-places-sidebar:
|
|
|
|
|
*
|
|
|
|
|
* GtkPlacesSidebar doesn't have a Search item anymore. We should put that function in a toolbar-like button, like
|
|
|
|
|
* in Nautilus, and do operation_mode_set (impl, OPERATION_MODE_SEARCH);
|
|
|
|
|
*/
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-12-10 23:14:12 +00:00
|
|
|
|
if (file_is_recent_uri (location))
|
|
|
|
|
operation_mode_set (impl, OPERATION_MODE_RECENT);
|
|
|
|
|
else
|
|
|
|
|
change_folder_and_display_error (impl, location, clear_entry);
|
2012-09-07 19:35:56 +00:00
|
|
|
|
}
|
2013-04-11 21:47:38 +00:00
|
|
|
|
|
2012-10-22 22:52:27 +00:00
|
|
|
|
/* Callback used when the places sidebar needs us to display an error message */
|
|
|
|
|
static void
|
|
|
|
|
places_sidebar_show_error_message_cb (GtkPlacesSidebar *sidebar,
|
|
|
|
|
const char *primary,
|
|
|
|
|
const char *secondary,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
error_message (impl, primary, secondary);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
key_is_left_or_right (GdkEventKey *event)
|
|
|
|
|
{
|
|
|
|
|
guint modifiers;
|
|
|
|
|
|
|
|
|
|
modifiers = gtk_accelerator_get_default_mod_mask ();
|
|
|
|
|
|
|
|
|
|
return ((event->keyval == GDK_KEY_Right
|
|
|
|
|
|| event->keyval == GDK_KEY_KP_Right
|
|
|
|
|
|| event->keyval == GDK_KEY_Left
|
|
|
|
|
|| event->keyval == GDK_KEY_KP_Left)
|
|
|
|
|
&& (event->state & modifiers) == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handles key press events on the file list, so that we can trap Enter to
|
|
|
|
|
* activate the default button on our own. Also, checks to see if '/' has been
|
|
|
|
|
* pressed.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
browse_files_key_press_event_cb (GtkWidget *widget,
|
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = (GtkFileChooserDefault *) data;
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2013-03-24 16:40:08 +00:00
|
|
|
|
GdkModifierType no_text_input_mask;
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2013-03-24 16:40:08 +00:00
|
|
|
|
no_text_input_mask =
|
|
|
|
|
gtk_widget_get_modifier_mask (widget, GDK_MODIFIER_INTENT_NO_TEXT_INPUT);
|
2009-07-27 23:04:51 +00:00
|
|
|
|
|
2013-03-24 16:40:08 +00:00
|
|
|
|
if ((event->keyval == GDK_KEY_slash
|
|
|
|
|
|| event->keyval == GDK_KEY_KP_Divide
|
|
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
|
|| event->keyval == GDK_KEY_asciitilde
|
|
|
|
|
#endif
|
|
|
|
|
) && !(event->state & no_text_input_mask))
|
|
|
|
|
{
|
|
|
|
|
location_popup_handler (impl, event->string);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-02-29 06:35:15 +00:00
|
|
|
|
|
2013-03-24 16:40:08 +00:00
|
|
|
|
if (key_is_left_or_right (event))
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->places_sidebar);
|
2013-03-24 16:40:08 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2009-07-28 00:24:42 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
if ((event->keyval == GDK_KEY_Return
|
|
|
|
|
|| event->keyval == GDK_KEY_ISO_Enter
|
|
|
|
|
|| event->keyval == GDK_KEY_KP_Enter
|
|
|
|
|
|| event->keyval == GDK_KEY_space
|
|
|
|
|
|| event->keyval == GDK_KEY_KP_Space)
|
2011-09-17 13:25:02 +00:00
|
|
|
|
&& !(event->state & gtk_accelerator_get_default_mod_mask ())
|
2013-04-12 03:44:19 +00:00
|
|
|
|
&& !(priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
|
2004-03-07 19:38:49 +00:00
|
|
|
|
{
|
2004-03-29 19:52:16 +00:00
|
|
|
|
GtkWindow *window;
|
2004-03-07 19:38:49 +00:00
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
window = get_toplevel (widget);
|
2010-08-17 13:13:06 +00:00
|
|
|
|
if (window)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *default_widget, *focus_widget;
|
|
|
|
|
|
|
|
|
|
default_widget = gtk_window_get_default_widget (window);
|
|
|
|
|
focus_widget = gtk_window_get_focus (window);
|
|
|
|
|
|
|
|
|
|
if (widget != default_widget &&
|
|
|
|
|
!(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
|
|
|
|
|
{
|
|
|
|
|
gtk_window_activate_default (window);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-03-07 19:38:49 +00:00
|
|
|
|
}
|
2004-05-31 18:29:02 +00:00
|
|
|
|
|
2004-03-07 19:38:49 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
/* Callback used when the file list's popup menu is detached */
|
|
|
|
|
static void
|
|
|
|
|
popup_menu_detach_cb (GtkWidget *attach_widget,
|
|
|
|
|
GtkMenu *menu)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = g_object_get_data (G_OBJECT (attach_widget), "GtkFileChooserDefault");
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv;
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
|
|
|
|
g_assert (GTK_IS_FILE_CHOOSER_DEFAULT (impl));
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
priv->browse_files_popup_menu = NULL;
|
|
|
|
|
priv->browse_files_popup_menu_add_shortcut_item = NULL;
|
|
|
|
|
priv->browse_files_popup_menu_hidden_files_item = NULL;
|
|
|
|
|
priv->browse_files_popup_menu_copy_file_location_item = NULL;
|
2004-04-02 00:35:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-10 20:18:00 +00:00
|
|
|
|
/* Callback used from gtk_tree_selection_selected_foreach(); adds a bookmark for
|
|
|
|
|
* each selected item in the file list.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
add_bookmark_foreach_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = (GtkFileChooserDefault *) data;
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2012-12-10 20:18:00 +00:00
|
|
|
|
GFile *file;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
|
MODEL_COL_FILE, &file,
|
|
|
|
|
-1);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_bookmarks_manager_insert_bookmark (priv->bookmarks_manager, file, 0, NULL); /* NULL-GError */
|
2012-12-10 20:18:00 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-07 19:10:11 +00:00
|
|
|
|
/* Callback used when the "Add to Bookmarks" menu item is activated */
|
2004-07-29 20:53:52 +00:00
|
|
|
|
static void
|
|
|
|
|
add_to_shortcuts_cb (GtkMenuItem *item,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2012-12-10 20:18:00 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2012-12-10 20:18:00 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_selection_selected_foreach (selection,
|
|
|
|
|
add_bookmark_foreach_cb,
|
|
|
|
|
impl);
|
2004-07-29 20:53:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-04 18:34:16 +00:00
|
|
|
|
/* callback used to set data to clipboard */
|
|
|
|
|
static void
|
|
|
|
|
copy_file_get_cb (GtkClipboard *clipboard,
|
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
|
guint info,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GSList *selected_files = data;
|
|
|
|
|
|
|
|
|
|
if (selected_files)
|
|
|
|
|
{
|
|
|
|
|
gint num_files = g_slist_length (selected_files);
|
|
|
|
|
gchar **uris;
|
|
|
|
|
gint i;
|
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
|
|
uris = g_new (gchar *, num_files + 1);
|
|
|
|
|
uris[num_files] = NULL; /* null terminator */
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
|
|
for (l = selected_files; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GFile *file = (GFile *) l->data;
|
|
|
|
|
|
|
|
|
|
if (info == SELECTION_URI)
|
|
|
|
|
uris[i] = g_file_get_uri (file);
|
|
|
|
|
else /* if (info == SELECTION_TEXT) - let this be the fallback */
|
|
|
|
|
uris[i] = g_file_get_parse_name (file);
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info == SELECTION_URI)
|
|
|
|
|
gtk_selection_data_set_uris (selection_data, uris);
|
|
|
|
|
else /* if (info == SELECTION_TEXT) - let this be the fallback */
|
|
|
|
|
{
|
|
|
|
|
char *str = g_strjoinv (" ", uris);
|
|
|
|
|
gtk_selection_data_set_text (selection_data, str, -1);
|
|
|
|
|
g_free (str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_strfreev (uris);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* callback used to clear the clipboard data */
|
|
|
|
|
static void
|
|
|
|
|
copy_file_clear_cb (GtkClipboard *clipboard,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GSList *selected_files = data;
|
|
|
|
|
|
|
|
|
|
g_slist_foreach (selected_files, (GFunc) g_object_unref, NULL);
|
|
|
|
|
g_slist_free (selected_files);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-25 06:05:45 +00:00
|
|
|
|
/* Callback used when the "Copy file’s location" menu item is activated */
|
2011-08-04 18:34:16 +00:00
|
|
|
|
static void
|
|
|
|
|
copy_file_location_cb (GtkMenuItem *item,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GSList *selected_files = NULL;
|
|
|
|
|
|
|
|
|
|
selected_files = search_get_selected_files (impl);
|
|
|
|
|
|
|
|
|
|
if (selected_files)
|
|
|
|
|
{
|
|
|
|
|
GtkClipboard *clipboard;
|
|
|
|
|
GtkTargetList *target_list;
|
|
|
|
|
GtkTargetEntry *targets;
|
|
|
|
|
int n_targets;
|
|
|
|
|
|
|
|
|
|
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (impl), GDK_SELECTION_CLIPBOARD);
|
|
|
|
|
|
|
|
|
|
target_list = gtk_target_list_new (NULL, 0);
|
|
|
|
|
gtk_target_list_add_text_targets (target_list, SELECTION_TEXT);
|
|
|
|
|
gtk_target_list_add_uri_targets (target_list, SELECTION_URI);
|
|
|
|
|
|
|
|
|
|
targets = gtk_target_table_new_from_list (target_list, &n_targets);
|
|
|
|
|
gtk_target_list_unref (target_list);
|
|
|
|
|
|
|
|
|
|
gtk_clipboard_set_with_data (clipboard, targets, n_targets,
|
|
|
|
|
copy_file_get_cb,
|
|
|
|
|
copy_file_clear_cb,
|
|
|
|
|
selected_files);
|
|
|
|
|
|
|
|
|
|
gtk_target_table_free (targets, n_targets);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-05 18:19:50 +00:00
|
|
|
|
/* Callback used when the "Visit this file" menu item is activated */
|
|
|
|
|
static void
|
|
|
|
|
visit_file_cb (GtkMenuItem *item,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GSList *files;
|
|
|
|
|
|
|
|
|
|
files = search_get_selected_files (impl);
|
|
|
|
|
|
|
|
|
|
/* Sigh, just use the first one */
|
|
|
|
|
if (files)
|
|
|
|
|
{
|
|
|
|
|
GFile *file = files->data;
|
|
|
|
|
|
2011-09-10 14:11:27 +00:00
|
|
|
|
gtk_file_chooser_default_select_file (GTK_FILE_CHOOSER (impl), file, NULL); /* NULL-GError */
|
2011-09-05 18:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
|
|
|
|
|
g_slist_free (files);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* callback used when the "Show Hidden Files" menu item is toggled */
|
2004-04-02 00:35:07 +00:00
|
|
|
|
static void
|
|
|
|
|
show_hidden_toggled_cb (GtkCheckMenuItem *item,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
g_object_set (impl,
|
|
|
|
|
"show-hidden", gtk_check_menu_item_get_active (item),
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-18 15:29:33 +00:00
|
|
|
|
/* Callback used when the "Show Size Column" menu item is toggled */
|
|
|
|
|
static void
|
|
|
|
|
show_size_column_toggled_cb (GtkCheckMenuItem *item,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2008-09-18 15:29:33 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->show_size_column = gtk_check_menu_item_get_active (item);
|
|
|
|
|
|
|
|
|
|
gtk_tree_view_column_set_visible (priv->list_size_column,
|
|
|
|
|
priv->show_size_column);
|
2008-09-18 15:29:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-07 17:11:26 +00:00
|
|
|
|
/* Shows an error dialog about not being able to select a dragged file */
|
|
|
|
|
static void
|
|
|
|
|
error_selecting_dragged_file_dialog (GtkFileChooserDefault *impl,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2005-07-07 17:11:26 +00:00
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Could not select file"),
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file, error);
|
2005-07-07 17:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-05-01 21:41:12 +00:00
|
|
|
|
file_list_drag_data_select_uris (GtkFileChooserDefault *impl,
|
|
|
|
|
gchar **uris)
|
2005-07-07 17:11:26 +00:00
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
int i;
|
2005-07-07 17:11:26 +00:00
|
|
|
|
char *uri;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkFileChooser *chooser = GTK_FILE_CHOOSER (impl);
|
|
|
|
|
|
|
|
|
|
for (i = 1; uris[i]; i++)
|
2005-07-07 17:11:26 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
|
|
|
|
GError *error = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
uri = uris[i];
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file = g_file_new_for_uri (uri);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_select_file (chooser, file, &error);
|
|
|
|
|
if (error)
|
|
|
|
|
error_selecting_dragged_file_dialog (impl, file, error);
|
2005-07-07 17:11:26 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct FileListDragData
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
gchar **uris;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file_list_drag_data_received_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct FileListDragData *data = user_data;
|
|
|
|
|
GtkFileChooser *chooser = GTK_FILE_CHOOSER (data->impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = data->impl->priv;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (cancellable != priv->file_list_drag_data_received_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->file_list_drag_data_received_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (cancelled || error)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if ((priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SAVE) &&
|
2008-12-14 02:14:19 +00:00
|
|
|
|
data->uris[1] == 0 && !error && _gtk_file_info_consider_as_directory (info))
|
2008-06-10 00:39:35 +00:00
|
|
|
|
change_folder_and_display_error (data->impl, data->file, FALSE);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
gtk_file_chooser_default_unselect_all (chooser);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_select_file (chooser, data->file, &error);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
if (error)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
error_selecting_dragged_file_dialog (data->impl, data->file, error);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
else
|
|
|
|
|
browse_files_center_selected_row (data->impl);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->select_multiple)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
file_list_drag_data_select_uris (data->impl, data->uris);
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_object_unref (data->impl);
|
|
|
|
|
g_strfreev (data->uris);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
g_free (data);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-01-24 02:50:39 +00:00
|
|
|
|
file_list_drag_data_received_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
|
guint info,
|
|
|
|
|
guint time_,
|
|
|
|
|
gpointer data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gchar **uris;
|
|
|
|
|
char *uri;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
|
|
|
|
|
2008-06-19 12:52:40 +00:00
|
|
|
|
/* Allow only drags from other widgets; see bug #533891. */
|
|
|
|
|
if (gtk_drag_get_source_widget (context) == widget)
|
2008-09-05 19:53:30 +00:00
|
|
|
|
{
|
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-data-received");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-06-19 12:52:40 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
/* Parse the text/uri-list string, navigate to the first one */
|
2008-06-19 12:52:40 +00:00
|
|
|
|
uris = gtk_selection_data_get_uris (selection_data);
|
|
|
|
|
if (uris && uris[0])
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
struct FileListDragData *data;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
uri = uris[0];
|
|
|
|
|
file = g_file_new_for_uri (uri);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
data = g_new0 (struct FileListDragData, 1);
|
|
|
|
|
data->impl = g_object_ref (impl);
|
|
|
|
|
data->uris = uris;
|
|
|
|
|
data->file = file;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->file_list_drag_data_received_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->file_list_drag_data_received_cancellable);
|
2005-07-07 17:11:26 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->file_list_drag_data_received_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (priv->file_system, file,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
"standard::type",
|
|
|
|
|
file_list_drag_data_received_get_info_cb,
|
|
|
|
|
data);
|
2005-07-07 17:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-12 14:37:03 +00:00
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-data-received");
|
2005-07-07 17:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Don't do anything with the drag_drop signal */
|
|
|
|
|
static gboolean
|
|
|
|
|
file_list_drag_drop_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
guint time_,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2008-08-12 14:37:03 +00:00
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-drop");
|
2005-07-07 17:11:26 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Disable the normal tree drag motion handler, it makes it look like you're
|
|
|
|
|
dropping the dragged item onto a tree item */
|
|
|
|
|
static gboolean
|
|
|
|
|
file_list_drag_motion_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
guint time_,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2008-08-12 14:37:03 +00:00
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-motion");
|
2005-07-07 17:11:26 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-13 02:17:15 +00:00
|
|
|
|
/* Sensitizes the "Copy file’s location" and other context menu items if there is actually
|
2011-08-04 18:34:16 +00:00
|
|
|
|
* a selection active.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2013-05-13 02:17:15 +00:00
|
|
|
|
check_file_list_menu_sensitivity (GtkFileChooserDefault *impl)
|
2011-08-04 18:34:16 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2013-05-22 22:22:28 +00:00
|
|
|
|
gint num_selected;
|
|
|
|
|
gboolean all_files;
|
|
|
|
|
gboolean all_folders;
|
2011-08-04 18:34:16 +00:00
|
|
|
|
gboolean active;
|
|
|
|
|
|
2013-05-22 22:22:28 +00:00
|
|
|
|
selection_check (impl, &num_selected, &all_files, &all_folders);
|
|
|
|
|
|
|
|
|
|
active = (num_selected != 0);
|
2011-08-04 18:34:16 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->browse_files_popup_menu_copy_file_location_item)
|
|
|
|
|
gtk_widget_set_sensitive (priv->browse_files_popup_menu_copy_file_location_item, active);
|
2013-05-13 02:17:15 +00:00
|
|
|
|
if (priv->browse_files_popup_menu_add_shortcut_item)
|
2013-05-22 22:22:28 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->browse_files_popup_menu_add_shortcut_item, active && all_folders);
|
2013-05-13 02:17:15 +00:00
|
|
|
|
if (priv->browse_files_popup_menu_visit_file_item)
|
|
|
|
|
gtk_widget_set_sensitive (priv->browse_files_popup_menu_visit_file_item, active);
|
2011-08-04 18:34:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-05 18:19:17 +00:00
|
|
|
|
static GtkWidget *
|
2013-06-24 23:28:53 +00:00
|
|
|
|
file_list_add_menu_item (GtkFileChooserDefault *impl,
|
|
|
|
|
const char *mnemonic_label,
|
|
|
|
|
GCallback callback)
|
2011-09-05 18:19:17 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-09-05 18:19:17 +00:00
|
|
|
|
GtkWidget *item;
|
|
|
|
|
|
2013-06-24 23:28:53 +00:00
|
|
|
|
item = gtk_menu_item_new_with_mnemonic (mnemonic_label);
|
2011-09-05 18:19:17 +00:00
|
|
|
|
g_signal_connect (item, "activate", callback, impl);
|
|
|
|
|
gtk_widget_show (item);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (priv->browse_files_popup_menu), item);
|
2011-09-05 18:19:17 +00:00
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
|
file_list_add_check_menu_item (GtkFileChooserDefault *impl,
|
|
|
|
|
const char *mnemonic_label,
|
|
|
|
|
GCallback callback)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-09-05 18:19:17 +00:00
|
|
|
|
GtkWidget *item;
|
|
|
|
|
|
|
|
|
|
item = gtk_check_menu_item_new_with_mnemonic (mnemonic_label);
|
|
|
|
|
g_signal_connect (item, "toggled", callback, impl);
|
|
|
|
|
gtk_widget_show (item);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (priv->browse_files_popup_menu), item);
|
2011-09-05 18:19:17 +00:00
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
/* Constructs the popup menu for the file list if needed */
|
|
|
|
|
static void
|
|
|
|
|
file_list_build_popup_menu (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-07-29 20:53:52 +00:00
|
|
|
|
GtkWidget *item;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->browse_files_popup_menu)
|
2004-07-29 20:53:52 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->browse_files_popup_menu = gtk_menu_new ();
|
|
|
|
|
gtk_menu_attach_to_widget (GTK_MENU (priv->browse_files_popup_menu),
|
|
|
|
|
priv->browse_files_tree_view,
|
2004-07-29 20:53:52 +00:00
|
|
|
|
popup_menu_detach_cb);
|
|
|
|
|
|
2013-06-24 23:28:53 +00:00
|
|
|
|
priv->browse_files_popup_menu_visit_file_item = file_list_add_menu_item (impl, _("_Visit File"),
|
2011-09-05 18:19:50 +00:00
|
|
|
|
G_CALLBACK (visit_file_cb));
|
|
|
|
|
|
2013-06-24 23:28:53 +00:00
|
|
|
|
priv->browse_files_popup_menu_copy_file_location_item = file_list_add_menu_item (impl, _("_Copy Location"),
|
2011-09-05 18:19:17 +00:00
|
|
|
|
G_CALLBACK (copy_file_location_cb));
|
2011-08-04 18:34:16 +00:00
|
|
|
|
|
2013-06-24 23:28:53 +00:00
|
|
|
|
priv->browse_files_popup_menu_add_shortcut_item = file_list_add_menu_item (impl, _("_Add to Bookmarks"),
|
2011-09-05 18:19:17 +00:00
|
|
|
|
G_CALLBACK (add_to_shortcuts_cb));
|
2004-07-29 20:53:52 +00:00
|
|
|
|
|
|
|
|
|
item = gtk_separator_menu_item_new ();
|
|
|
|
|
gtk_widget_show (item);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (priv->browse_files_popup_menu), item);
|
2004-07-29 20:53:52 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->browse_files_popup_menu_hidden_files_item = file_list_add_check_menu_item (impl, _("Show _Hidden Files"),
|
2011-09-05 18:19:17 +00:00
|
|
|
|
G_CALLBACK (show_hidden_toggled_cb));
|
2008-09-18 15:29:33 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->browse_files_popup_menu_size_column_item = file_list_add_check_menu_item (impl, _("Show _Size Column"),
|
2011-09-05 18:19:17 +00:00
|
|
|
|
G_CALLBACK (show_size_column_toggled_cb));
|
2009-06-22 03:30:27 +00:00
|
|
|
|
|
2013-05-13 02:17:15 +00:00
|
|
|
|
check_file_list_menu_sensitivity (impl);
|
2004-07-29 20:53:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Updates the popup menu for the file list, creating it if necessary */
|
|
|
|
|
static void
|
|
|
|
|
file_list_update_popup_menu (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
file_list_build_popup_menu (impl);
|
|
|
|
|
|
2005-04-07 19:10:11 +00:00
|
|
|
|
/* The sensitivity of the Add to Bookmarks item is set in
|
2004-07-29 20:53:52 +00:00
|
|
|
|
* bookmarks_check_add_sensitivity()
|
|
|
|
|
*/
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
2011-09-05 18:19:50 +00:00
|
|
|
|
/* 'Visit this file' */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_set_visible (priv->browse_files_popup_menu_visit_file_item, (priv->operation_mode != OPERATION_MODE_BROWSE));
|
2011-09-05 18:19:50 +00:00
|
|
|
|
|
2008-09-18 15:29:33 +00:00
|
|
|
|
/* 'Show Hidden Files' */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_signal_handlers_block_by_func (priv->browse_files_popup_menu_hidden_files_item,
|
2004-04-02 00:35:07 +00:00
|
|
|
|
G_CALLBACK (show_hidden_toggled_cb), impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->browse_files_popup_menu_hidden_files_item),
|
|
|
|
|
priv->show_hidden);
|
|
|
|
|
g_signal_handlers_unblock_by_func (priv->browse_files_popup_menu_hidden_files_item,
|
2004-04-02 00:35:07 +00:00
|
|
|
|
G_CALLBACK (show_hidden_toggled_cb), impl);
|
2008-09-18 15:29:33 +00:00
|
|
|
|
|
|
|
|
|
/* 'Show Size Column' */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_signal_handlers_block_by_func (priv->browse_files_popup_menu_size_column_item,
|
2008-09-18 15:29:33 +00:00
|
|
|
|
G_CALLBACK (show_size_column_toggled_cb), impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->browse_files_popup_menu_size_column_item),
|
|
|
|
|
priv->show_size_column);
|
|
|
|
|
g_signal_handlers_unblock_by_func (priv->browse_files_popup_menu_size_column_item,
|
2008-09-18 15:29:33 +00:00
|
|
|
|
G_CALLBACK (show_size_column_toggled_cb), impl);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-06 06:02:57 +00:00
|
|
|
|
static void
|
|
|
|
|
popup_position_func (GtkMenu *menu,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
gboolean *push_in,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2010-08-11 21:12:39 +00:00
|
|
|
|
GtkAllocation allocation;
|
2004-07-06 06:02:57 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (user_data);
|
|
|
|
|
GdkScreen *screen = gtk_widget_get_screen (widget);
|
|
|
|
|
GtkRequisition req;
|
|
|
|
|
gint monitor_num;
|
|
|
|
|
GdkRectangle monitor;
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
|
g_return_if_fail (gtk_widget_get_realized (widget));
|
2004-07-06 06:02:57 +00:00
|
|
|
|
|
2010-08-11 21:12:39 +00:00
|
|
|
|
gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
|
2004-07-06 06:02:57 +00:00
|
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
|
gtk_widget_get_preferred_size (GTK_WIDGET (menu),
|
|
|
|
|
&req, NULL);
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
2010-08-11 21:12:39 +00:00
|
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
|
*x += (allocation.width - req.width) / 2;
|
|
|
|
|
*y += (allocation.height - req.height) / 2;
|
2004-07-06 06:02:57 +00:00
|
|
|
|
|
|
|
|
|
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
|
|
|
|
|
gtk_menu_set_monitor (menu, monitor_num);
|
2011-12-18 19:28:01 +00:00
|
|
|
|
gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
|
2004-07-06 06:02:57 +00:00
|
|
|
|
|
|
|
|
|
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
|
|
|
|
|
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
|
|
|
|
|
|
|
|
|
*push_in = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
static void
|
|
|
|
|
file_list_popup_menu (GtkFileChooserDefault *impl,
|
|
|
|
|
GdkEventButton *event)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
file_list_update_popup_menu (impl);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
if (event)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_menu_popup (GTK_MENU (priv->browse_files_popup_menu),
|
2004-07-06 06:02:57 +00:00
|
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
|
event->button, event->time);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_menu_popup (GTK_MENU (priv->browse_files_popup_menu),
|
2004-07-09 00:53:48 +00:00
|
|
|
|
NULL, NULL,
|
2013-04-12 03:44:19 +00:00
|
|
|
|
popup_position_func, priv->browse_files_tree_view,
|
2004-07-06 06:02:57 +00:00
|
|
|
|
0, GDK_CURRENT_TIME);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->browse_files_popup_menu),
|
2004-07-06 06:02:57 +00:00
|
|
|
|
FALSE);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used for the GtkWidget::popup-menu signal of the file list */
|
|
|
|
|
static gboolean
|
|
|
|
|
list_popup_menu_cb (GtkWidget *widget,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
file_list_popup_menu (impl, NULL);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used when a button is pressed on the file list. We trap button 3 to
|
|
|
|
|
* bring up a popup menu.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
list_button_press_event_cb (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2006-03-07 17:48:07 +00:00
|
|
|
|
static gboolean in_press = FALSE;
|
|
|
|
|
|
|
|
|
|
if (in_press)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2011-09-27 13:37:28 +00:00
|
|
|
|
if (!gdk_event_triggers_context_menu ((GdkEvent *) event))
|
2004-04-02 00:35:07 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-03-07 17:48:07 +00:00
|
|
|
|
in_press = TRUE;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_event (priv->browse_files_tree_view, (GdkEvent *) event);
|
2006-03-07 17:48:07 +00:00
|
|
|
|
in_press = FALSE;
|
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
file_list_popup_menu (impl, event);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-03-07 19:38:49 +00:00
|
|
|
|
|
2009-06-12 22:31:28 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
OperationMode operation_mode;
|
|
|
|
|
gint general_column;
|
|
|
|
|
gint model_column;
|
|
|
|
|
} ColumnMap;
|
|
|
|
|
|
2011-07-26 21:43:36 +00:00
|
|
|
|
/* Sets the sort column IDs for the file list; needs to be done whenever we
|
|
|
|
|
* change the model on the treeview.
|
|
|
|
|
*/
|
2007-05-02 22:51:43 +00:00
|
|
|
|
static void
|
|
|
|
|
file_list_set_sort_column_ids (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id (priv->list_name_column, MODEL_COL_NAME);
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id (priv->list_mtime_column, MODEL_COL_MTIME);
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id (priv->list_size_column, MODEL_COL_SIZE);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-20 09:53:20 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
file_list_query_tooltip_cb (GtkWidget *widget,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gboolean keyboard_tip,
|
|
|
|
|
GtkTooltip *tooltip,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = user_data;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2009-06-19 20:36:26 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
GtkTreeIter iter;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2007-07-20 09:53:20 +00:00
|
|
|
|
gchar *filename;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_BROWSE)
|
2007-07-20 09:53:20 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
2009-06-19 20:36:26 +00:00
|
|
|
|
&x, &y,
|
|
|
|
|
keyboard_tip,
|
|
|
|
|
&model, &path, &iter))
|
2007-07-20 09:53:20 +00:00
|
|
|
|
return FALSE;
|
2009-06-19 20:36:26 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
|
MODEL_COL_FILE, &file,
|
|
|
|
|
-1);
|
2007-07-20 09:53:20 +00:00
|
|
|
|
|
2009-06-19 20:36:26 +00:00
|
|
|
|
if (file == NULL)
|
2007-07-20 09:53:20 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
filename = g_file_get_path (file);
|
2007-07-20 09:53:20 +00:00
|
|
|
|
gtk_tooltip_set_text (tooltip, filename);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
2007-07-20 09:53:20 +00:00
|
|
|
|
tooltip,
|
|
|
|
|
path);
|
|
|
|
|
|
|
|
|
|
g_free (filename);
|
2009-06-19 20:36:26 +00:00
|
|
|
|
g_object_unref (file);
|
2007-07-20 09:53:20 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2009-09-11 18:14:49 +00:00
|
|
|
|
static void
|
2013-04-12 01:37:01 +00:00
|
|
|
|
set_icon_cell_renderer_fixed_size (GtkFileChooserDefault *impl)
|
2009-09-11 18:14:49 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2010-05-30 20:38:33 +00:00
|
|
|
|
gint xpad, ypad;
|
|
|
|
|
|
2013-04-12 01:37:01 +00:00
|
|
|
|
gtk_cell_renderer_get_padding (priv->list_pixbuf_renderer, &xpad, &ypad);
|
|
|
|
|
gtk_cell_renderer_set_fixed_size (priv->list_pixbuf_renderer,
|
2013-04-12 03:44:19 +00:00
|
|
|
|
xpad * 2 + priv->icon_size,
|
|
|
|
|
ypad * 2 + priv->icon_size);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-27 01:34:24 +00:00
|
|
|
|
|
2011-07-27 22:44:55 +00:00
|
|
|
|
static void
|
|
|
|
|
location_entry_create (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (!priv->location_entry)
|
|
|
|
|
priv->location_entry = _gtk_file_chooser_entry_new (TRUE);
|
2011-07-27 22:44:55 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->local_only);
|
|
|
|
|
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->action);
|
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (priv->location_entry), 45);
|
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (priv->location_entry), TRUE);
|
2011-07-27 22:44:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Creates the widgets specific to Save mode */
|
2005-09-27 01:34:24 +00:00
|
|
|
|
static void
|
2004-02-23 19:55:49 +00:00
|
|
|
|
save_widgets_create (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkWidget *vbox;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->save_widgets != NULL)
|
2005-09-27 01:34:24 +00:00
|
|
|
|
return;
|
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
location_switch_to_path_bar (impl);
|
|
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->save_widgets_table = gtk_grid_new ();
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), priv->save_widgets_table, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (priv->save_widgets_table);
|
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (priv->save_widgets_table), 12);
|
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (priv->save_widgets_table), 12);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
/* Label */
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
|
|
|
|
widget = gtk_label_new_with_mnemonic (_("_Name:"));
|
2011-06-09 01:54:37 +00:00
|
|
|
|
gtk_widget_set_halign (widget, GTK_ALIGN_START);
|
|
|
|
|
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_grid_attach (GTK_GRID (priv->save_widgets_table), widget, 0, 0, 1, 1);
|
2004-01-06 04:18:42 +00:00
|
|
|
|
gtk_widget_show (widget);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
/* Location entry */
|
|
|
|
|
|
2011-07-27 22:44:55 +00:00
|
|
|
|
location_entry_create (impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_set_hexpand (priv->location_entry, TRUE);
|
|
|
|
|
gtk_grid_attach (GTK_GRID (priv->save_widgets_table), priv->location_entry, 1, 0, 1, 1);
|
|
|
|
|
gtk_widget_show (priv->location_entry);
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (widget), priv->location_entry);
|
2004-01-06 04:18:42 +00:00
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Folder combo */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->save_folder_label = gtk_label_new (NULL);
|
|
|
|
|
gtk_widget_set_halign (priv->save_folder_label, GTK_ALIGN_START);
|
|
|
|
|
gtk_widget_set_valign (priv->save_folder_label, GTK_ALIGN_CENTER);
|
|
|
|
|
gtk_grid_attach (GTK_GRID (priv->save_widgets_table), priv->save_folder_label, 0, 1, 1, 1);
|
|
|
|
|
gtk_widget_show (priv->save_folder_label);
|
2003-03-25 00:11:06 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->save_widgets = vbox;
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (impl), priv->save_widgets, FALSE, FALSE, 0);
|
|
|
|
|
gtk_box_reorder_child (GTK_BOX (impl), priv->save_widgets, 0);
|
|
|
|
|
gtk_widget_show (priv->save_widgets);
|
2005-09-27 01:34:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Destroys the widgets specific to Save mode */
|
|
|
|
|
static void
|
|
|
|
|
save_widgets_destroy (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->save_widgets == NULL)
|
2005-09-27 01:34:24 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_destroy (priv->save_widgets);
|
|
|
|
|
priv->save_widgets = NULL;
|
|
|
|
|
priv->save_widgets_table = NULL;
|
|
|
|
|
priv->location_entry = NULL;
|
|
|
|
|
priv->save_folder_label = NULL;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
/* Turns on the path bar widget. Can be called even if we are already in that
|
|
|
|
|
* mode.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
location_switch_to_path_bar (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->location_entry)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_destroy (priv->location_entry);
|
|
|
|
|
priv->location_entry = NULL;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_hide (priv->location_entry_box);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Turns on the location entry. Can be called even if we are already in that
|
|
|
|
|
* mode.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
location_switch_to_filename_entry (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2007-05-11 19:26:32 +00:00
|
|
|
|
/* when in search or recent files mode, we are not showing the
|
|
|
|
|
* location_entry_box container, so there's no point in switching
|
|
|
|
|
* to it.
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_SEARCH ||
|
|
|
|
|
priv->operation_mode == OPERATION_MODE_RECENT)
|
2007-05-11 19:26:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
/* Box */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_show (priv->location_entry_box);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
|
|
|
|
/* Entry */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->location_entry)
|
2011-11-29 21:08:25 +00:00
|
|
|
|
{
|
|
|
|
|
location_entry_create (impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->location_entry_box), priv->location_entry, TRUE, TRUE, 0);
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (priv->location_label), priv->location_entry);
|
2011-11-29 21:08:25 +00:00
|
|
|
|
}
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
|
|
|
|
/* Configure the entry */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->current_folder);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
|
|
|
|
/* Done */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_show (priv->location_entry);
|
|
|
|
|
gtk_widget_grab_focus (priv->location_entry);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sets a new location mode. set_buttons determines whether the toggle button
|
|
|
|
|
* for the mode will also be changed.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
location_mode_set (GtkFileChooserDefault *impl,
|
|
|
|
|
LocationMode new_mode,
|
|
|
|
|
gboolean set_button)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
GtkWidget *current_focus;
|
|
|
|
|
gboolean button_active;
|
|
|
|
|
gboolean switch_to_file_list;
|
|
|
|
|
|
|
|
|
|
switch (new_mode)
|
|
|
|
|
{
|
|
|
|
|
case LOCATION_MODE_PATH_BAR:
|
|
|
|
|
button_active = FALSE;
|
|
|
|
|
|
|
|
|
|
/* The location_entry will disappear when we switch to path bar mode. So,
|
|
|
|
|
* we'll focus the file list in that case, to avoid having a window with
|
|
|
|
|
* no focused widget.
|
|
|
|
|
*/
|
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (impl));
|
|
|
|
|
switch_to_file_list = FALSE;
|
|
|
|
|
if (toplevel)
|
|
|
|
|
{
|
|
|
|
|
current_focus = gtk_window_get_focus (toplevel);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!current_focus || current_focus == priv->location_entry)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
switch_to_file_list = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location_switch_to_path_bar (impl);
|
|
|
|
|
|
|
|
|
|
if (switch_to_file_list)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->browse_files_tree_view);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LOCATION_MODE_FILENAME_ENTRY:
|
|
|
|
|
button_active = TRUE;
|
|
|
|
|
location_switch_to_filename_entry (impl);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (set_button)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_signal_handlers_block_by_func (priv->location_button,
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
G_CALLBACK (location_button_toggled_cb), impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->location_button), button_active);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_signal_handlers_unblock_by_func (priv->location_button,
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
G_CALLBACK (location_button_toggled_cb), impl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->location_mode = new_mode;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-23 05:06:00 +00:00
|
|
|
|
static void
|
|
|
|
|
location_toggle_popup_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2008-05-24 18:59:56 +00:00
|
|
|
|
/* when in search or recent files mode, we are not showing the
|
|
|
|
|
* location_entry_box container, so there's no point in switching
|
|
|
|
|
* to it.
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_SEARCH ||
|
|
|
|
|
priv->operation_mode == OPERATION_MODE_RECENT)
|
2008-05-24 18:59:56 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2007-10-02 15:50:27 +00:00
|
|
|
|
/* If the file entry is not visible, show it.
|
|
|
|
|
* If it is visible, turn it off only if it is focused. Otherwise, switch to the entry.
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_mode == LOCATION_MODE_PATH_BAR)
|
2007-10-02 15:50:27 +00:00
|
|
|
|
{
|
|
|
|
|
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY, TRUE);
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY)
|
2007-10-02 15:50:27 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (gtk_widget_has_focus (priv->location_entry))
|
2007-10-02 15:50:27 +00:00
|
|
|
|
{
|
|
|
|
|
location_mode_set (impl, LOCATION_MODE_PATH_BAR, TRUE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->location_entry);
|
2007-10-02 15:50:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-03-23 05:06:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
/* Callback used when one of the location mode buttons is toggled */
|
|
|
|
|
static void
|
|
|
|
|
location_button_toggled_cb (GtkToggleButton *toggle,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
gboolean is_active;
|
2007-10-02 15:50:27 +00:00
|
|
|
|
LocationMode new_mode;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
|
|
|
|
is_active = gtk_toggle_button_get_active (toggle);
|
|
|
|
|
|
|
|
|
|
if (is_active)
|
2007-10-02 15:50:27 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->location_mode == LOCATION_MODE_PATH_BAR);
|
2007-10-02 15:50:27 +00:00
|
|
|
|
new_mode = LOCATION_MODE_FILENAME_ENTRY;
|
|
|
|
|
}
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
else
|
2007-10-02 15:50:27 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY);
|
2007-10-02 15:50:27 +00:00
|
|
|
|
new_mode = LOCATION_MODE_PATH_BAR;
|
|
|
|
|
}
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2007-10-02 15:50:27 +00:00
|
|
|
|
location_mode_set (impl, new_mode, FALSE);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-01 19:36:52 +00:00
|
|
|
|
typedef enum {
|
|
|
|
|
PATH_BAR_FOLDER_PATH,
|
|
|
|
|
PATH_BAR_SELECT_A_FOLDER,
|
|
|
|
|
PATH_BAR_ERROR_NO_FILENAME,
|
|
|
|
|
PATH_BAR_ERROR_NO_FOLDER,
|
|
|
|
|
PATH_BAR_RECENTLY_USED,
|
|
|
|
|
PATH_BAR_SEARCH
|
|
|
|
|
} PathBarMode;
|
|
|
|
|
|
|
|
|
|
/* Sets the info bar to show the appropriate informational or warning message */
|
2011-07-01 17:57:44 +00:00
|
|
|
|
static void
|
2011-07-01 19:36:52 +00:00
|
|
|
|
info_bar_set (GtkFileChooserDefault *impl, PathBarMode mode)
|
2011-07-01 17:57:44 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-07-01 19:36:52 +00:00
|
|
|
|
char *str;
|
|
|
|
|
gboolean free_str;
|
|
|
|
|
GtkMessageType message_type;
|
2011-07-01 17:57:44 +00:00
|
|
|
|
|
2011-07-01 19:36:52 +00:00
|
|
|
|
free_str = FALSE;
|
|
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case PATH_BAR_SELECT_A_FOLDER:
|
|
|
|
|
str = g_strconcat ("<i>", _("Please select a folder below"), "</i>", NULL);
|
|
|
|
|
free_str = TRUE;
|
|
|
|
|
message_type = GTK_MESSAGE_OTHER;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PATH_BAR_ERROR_NO_FILENAME:
|
|
|
|
|
str = _("Please type a file name");
|
|
|
|
|
message_type = GTK_MESSAGE_WARNING;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PATH_BAR_ERROR_NO_FOLDER:
|
|
|
|
|
str = _("Please select a folder below");
|
|
|
|
|
message_type = GTK_MESSAGE_WARNING;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->browse_select_a_folder_info_bar), message_type);
|
2013-06-24 23:28:53 +00:00
|
|
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (priv->browse_select_a_folder_icon),
|
|
|
|
|
(message_type == GTK_MESSAGE_WARNING) ? "dialog-warning-symbolic" : "folder-symbolic",
|
|
|
|
|
GTK_ICON_SIZE_MENU);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_label_set_markup (GTK_LABEL (priv->browse_select_a_folder_label), str);
|
2011-07-01 19:36:52 +00:00
|
|
|
|
|
|
|
|
|
if (free_str)
|
|
|
|
|
g_free (str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sets the path bar's mode to show a label, the actual folder path, or a
|
|
|
|
|
* warning message. You may call this function with PATH_BAR_ERROR_* directly
|
|
|
|
|
* if the pathbar is already showing the widgets you expect; otherwise, call
|
|
|
|
|
* path_bar_update() instead to set the appropriate widgets automatically.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
path_bar_set_mode (GtkFileChooserDefault *impl, PathBarMode mode)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-07-01 19:36:52 +00:00
|
|
|
|
gboolean path_bar_visible = FALSE;
|
|
|
|
|
gboolean special_mode_widgets_visible = FALSE;
|
|
|
|
|
gboolean info_bar_visible = FALSE;
|
|
|
|
|
gboolean create_folder_visible = FALSE;
|
|
|
|
|
|
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case PATH_BAR_FOLDER_PATH:
|
|
|
|
|
path_bar_visible = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PATH_BAR_SELECT_A_FOLDER:
|
|
|
|
|
case PATH_BAR_ERROR_NO_FILENAME:
|
|
|
|
|
case PATH_BAR_ERROR_NO_FOLDER:
|
|
|
|
|
info_bar_set (impl, mode);
|
|
|
|
|
info_bar_visible = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PATH_BAR_RECENTLY_USED:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (priv->browse_special_mode_icon), "document-open-recent", GTK_ICON_SIZE_BUTTON);
|
2011-07-01 19:36:52 +00:00
|
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("<b>%s</b>", _("Recently Used"));
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_label_set_markup (GTK_LABEL (priv->browse_special_mode_label), tmp);
|
2011-07-01 19:36:52 +00:00
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
|
|
special_mode_widgets_visible = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PATH_BAR_SEARCH:
|
2013-06-24 23:28:53 +00:00
|
|
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (priv->browse_special_mode_icon), "edit-find-symbolic", GTK_ICON_SIZE_BUTTON);
|
2011-07-01 19:36:52 +00:00
|
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("<b>%s</b>", _("Search:"));
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_label_set_markup (GTK_LABEL (priv->browse_special_mode_label), tmp);
|
2011-07-01 19:36:52 +00:00
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
|
|
special_mode_widgets_visible = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_set_visible (priv->browse_path_bar, path_bar_visible);
|
|
|
|
|
gtk_widget_set_visible (priv->browse_special_mode_icon, special_mode_widgets_visible);
|
|
|
|
|
gtk_widget_set_visible (priv->browse_special_mode_label, special_mode_widgets_visible);
|
|
|
|
|
gtk_widget_set_visible (priv->browse_select_a_folder_info_bar, info_bar_visible);
|
2011-07-01 19:36:52 +00:00
|
|
|
|
|
|
|
|
|
if (path_bar_visible)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->create_folders
|
|
|
|
|
&& priv->action != GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
&& priv->operation_mode != OPERATION_MODE_RECENT)
|
2011-07-01 19:36:52 +00:00
|
|
|
|
create_folder_visible = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_set_visible (priv->browse_new_folder_button, create_folder_visible);
|
2013-04-11 21:47:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
|
|
|
|
static GObject*
|
|
|
|
|
gtk_file_chooser_default_constructor (GType type,
|
|
|
|
|
guint n_construct_properties,
|
|
|
|
|
GObjectConstructParam *construct_params)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GObject *object;
|
|
|
|
|
|
2005-09-27 21:33:24 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
object = G_OBJECT_CLASS (_gtk_file_chooser_default_parent_class)->constructor (type,
|
|
|
|
|
n_construct_properties,
|
|
|
|
|
construct_params);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (object);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv = impl->priv;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->file_system);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
update_appearance (impl);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2005-09-27 21:33:24 +00:00
|
|
|
|
profile_end ("end", NULL);
|
|
|
|
|
|
2003-03-26 17:09:26 +00:00
|
|
|
|
return object;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-03 05:52:35 +00:00
|
|
|
|
/* Sets the extra_widget by packing it in the appropriate place */
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
set_extra_widget (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkWidget *extra_widget)
|
2003-09-03 05:52:35 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
if (extra_widget)
|
|
|
|
|
{
|
|
|
|
|
g_object_ref (extra_widget);
|
|
|
|
|
/* FIXME: is this right ? */
|
|
|
|
|
gtk_widget_show (extra_widget);
|
|
|
|
|
}
|
2003-09-03 05:52:35 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->extra_widget)
|
2004-11-20 01:39:26 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->extra_align), priv->extra_widget);
|
|
|
|
|
g_object_unref (priv->extra_widget);
|
2004-11-20 01:39:26 +00:00
|
|
|
|
}
|
2003-09-03 05:52:35 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->extra_widget = extra_widget;
|
|
|
|
|
if (priv->extra_widget)
|
2004-11-20 01:39:26 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->extra_align), priv->extra_widget);
|
|
|
|
|
gtk_widget_show (priv->extra_align);
|
2004-11-20 01:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_hide (priv->extra_align);
|
2003-09-03 05:52:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-10 20:23:06 +00:00
|
|
|
|
static void
|
|
|
|
|
switch_to_home_dir (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
const gchar *home = g_get_home_dir ();
|
|
|
|
|
GFile *home_file;
|
|
|
|
|
|
|
|
|
|
if (home == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
home_file = g_file_new_for_path (home);
|
|
|
|
|
|
|
|
|
|
gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (impl), home_file, NULL); /* NULL-GError */
|
|
|
|
|
|
|
|
|
|
g_object_unref (home_file);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-15 06:09:40 +00:00
|
|
|
|
static void
|
|
|
|
|
set_local_only (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean local_only)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (local_only != priv->local_only)
|
2004-03-15 06:09:40 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->local_only = local_only;
|
2004-03-15 06:09:40 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_entry)
|
|
|
|
|
_gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), local_only);
|
2009-01-21 03:16:46 +00:00
|
|
|
|
|
2013-11-09 23:29:10 +00:00
|
|
|
|
gtk_places_sidebar_set_local_only (GTK_PLACES_SIDEBAR (priv->places_sidebar), local_only);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (local_only && priv->current_folder &&
|
|
|
|
|
!_gtk_file_has_native_path (priv->current_folder))
|
2004-03-15 06:09:40 +00:00
|
|
|
|
{
|
|
|
|
|
/* If we are pointing to a non-local folder, make an effort to change
|
|
|
|
|
* back to a local folder, but it's really up to the app to not cause
|
|
|
|
|
* such a situation, so we ignore errors.
|
|
|
|
|
*/
|
2012-12-10 20:23:06 +00:00
|
|
|
|
switch_to_home_dir (impl);
|
2004-03-15 06:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-20 02:44:58 +00:00
|
|
|
|
/* Sets the file chooser to multiple selection mode */
|
|
|
|
|
static void
|
2004-01-23 20:15:05 +00:00
|
|
|
|
set_select_multiple (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean select_multiple,
|
|
|
|
|
gboolean property_notify)
|
2004-01-20 02:44:58 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-01-23 20:15:05 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
GtkSelectionMode mode;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (select_multiple == priv->select_multiple)
|
2004-01-23 20:15:05 +00:00
|
|
|
|
return;
|
2004-01-20 02:44:58 +00:00
|
|
|
|
|
2012-01-12 18:30:35 +00:00
|
|
|
|
mode = select_multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE;
|
2004-01-23 20:15:05 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2004-01-23 20:15:05 +00:00
|
|
|
|
gtk_tree_selection_set_mode (selection, mode);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (priv->browse_files_tree_view), select_multiple);
|
2008-05-27 00:20:18 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->select_multiple = select_multiple;
|
2004-01-23 20:15:05 +00:00
|
|
|
|
g_object_notify (G_OBJECT (impl), "select-multiple");
|
|
|
|
|
|
2004-01-20 02:44:58 +00:00
|
|
|
|
check_preview_change (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-19 07:43:39 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
set_file_system_backend (GtkFileChooserDefault *impl)
|
2004-02-19 07:43:39 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
profile_start ("start for backend", "default");
|
2005-07-22 02:54:24 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->file_system = _gtk_file_system_new ();
|
2004-02-29 06:35:15 +00:00
|
|
|
|
|
2005-07-22 02:54:24 +00:00
|
|
|
|
profile_end ("end", NULL);
|
2004-02-19 07:43:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-22 18:32:31 +00:00
|
|
|
|
static void
|
|
|
|
|
unset_file_system_backend (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2008-09-22 18:32:31 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->file_system);
|
|
|
|
|
|
|
|
|
|
priv->file_system = NULL;
|
2008-09-22 18:32:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-28 20:21:49 +00:00
|
|
|
|
/* Saves the widgets around the pathbar so they can be reparented later
|
|
|
|
|
* in the correct place. This function must be called paired with
|
|
|
|
|
* restore_path_bar().
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
save_path_bar (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-06-28 20:21:49 +00:00
|
|
|
|
GtkWidget *parent;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_ref (priv->browse_path_bar_hbox);
|
2011-06-28 20:21:49 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
parent = gtk_widget_get_parent (priv->browse_path_bar_hbox);
|
2011-06-28 20:21:49 +00:00
|
|
|
|
if (parent)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (parent), priv->browse_path_bar_hbox);
|
2011-06-28 20:21:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reparents the path bar and the "Create folder" button to the right place:
|
|
|
|
|
* Above the file list in Open mode, or to the right of the "Save in folder:"
|
|
|
|
|
* label in Save mode. The save_path_bar() function must be called before this
|
|
|
|
|
* one.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
restore_path_bar (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2011-06-28 20:21:49 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->browse_header_box), priv->browse_path_bar_hbox, FALSE, FALSE, 0);
|
|
|
|
|
gtk_box_reorder_child (GTK_BOX (priv->browse_header_box), priv->browse_path_bar_hbox, 0);
|
2011-06-28 20:21:49 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2011-06-28 20:21:49 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_set_hexpand (priv->browse_path_bar_hbox, TRUE);
|
|
|
|
|
gtk_grid_attach (GTK_GRID (priv->save_widgets_table), priv->browse_path_bar_hbox, 1, 1, 1, 1);
|
2011-06-28 20:21:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->browse_path_bar_hbox);
|
2011-06-28 20:21:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 21:42:01 +00:00
|
|
|
|
/* Takes the folder stored in a row in the recent_model, and puts it in the pathbar */
|
|
|
|
|
static void
|
|
|
|
|
put_recent_folder_in_pathbar (GtkFileChooserDefault *impl, GtkTreeIter *iter)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-06-29 21:42:01 +00:00
|
|
|
|
GFile *file;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (priv->recent_model), iter,
|
2011-06-29 21:42:01 +00:00
|
|
|
|
MODEL_COL_FILE, &file,
|
|
|
|
|
-1);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_path_bar_set_file (GTK_PATH_BAR (priv->browse_path_bar), file, FALSE);
|
2011-06-29 21:42:01 +00:00
|
|
|
|
g_object_unref (file);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-01 19:36:52 +00:00
|
|
|
|
/* Sets the pathbar in the appropriate mode according to the current operation mode and action. This is the central function for
|
2013-04-11 21:47:38 +00:00
|
|
|
|
* dealing with the pathbar's widgets; as long as impl->action and impl->operation_mode are set correctly, then calling this
|
2011-07-01 19:36:52 +00:00
|
|
|
|
* function will update all the pathbar's widgets.
|
|
|
|
|
*/
|
2011-06-29 21:42:01 +00:00
|
|
|
|
static void
|
2011-07-01 19:36:52 +00:00
|
|
|
|
path_bar_update (GtkFileChooserDefault *impl)
|
2011-06-29 21:42:01 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-07-01 19:36:52 +00:00
|
|
|
|
PathBarMode mode;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
switch (priv->operation_mode)
|
2011-06-29 21:42:01 +00:00
|
|
|
|
{
|
2011-07-01 19:36:52 +00:00
|
|
|
|
case OPERATION_MODE_BROWSE:
|
|
|
|
|
mode = PATH_BAR_FOLDER_PATH;
|
|
|
|
|
break;
|
2011-06-29 21:42:01 +00:00
|
|
|
|
|
2011-07-01 19:36:52 +00:00
|
|
|
|
case OPERATION_MODE_RECENT:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2011-07-01 19:36:52 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
gboolean have_selected;
|
|
|
|
|
GtkTreeIter iter;
|
2011-06-29 21:42:01 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2011-06-29 21:42:01 +00:00
|
|
|
|
|
2011-07-01 19:36:52 +00:00
|
|
|
|
/* Save mode means single-selection mode, so the following is valid */
|
|
|
|
|
have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter);
|
|
|
|
|
|
|
|
|
|
if (have_selected)
|
|
|
|
|
{
|
|
|
|
|
mode = PATH_BAR_FOLDER_PATH;
|
|
|
|
|
put_recent_folder_in_pathbar (impl, &iter);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
mode = PATH_BAR_SELECT_A_FOLDER;
|
2011-06-29 21:42:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2011-07-01 19:36:52 +00:00
|
|
|
|
mode = PATH_BAR_RECENTLY_USED;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OPERATION_MODE_SEARCH:
|
|
|
|
|
mode = PATH_BAR_SEARCH;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
return;
|
2011-06-29 21:42:01 +00:00
|
|
|
|
}
|
2011-07-01 19:36:52 +00:00
|
|
|
|
|
|
|
|
|
path_bar_set_mode (impl, mode);
|
2011-06-29 21:42:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-27 21:52:12 +00:00
|
|
|
|
static void
|
|
|
|
|
operation_mode_discard_search_widgets (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->search_hbox)
|
2011-07-27 21:52:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_destroy (priv->search_hbox);
|
2011-07-27 21:52:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->search_hbox = NULL;
|
|
|
|
|
priv->search_entry = NULL;
|
2011-07-27 21:52:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-26 21:00:35 +00:00
|
|
|
|
/* Stops running operations like populating the browse model, searches, and the recent-files model */
|
|
|
|
|
static void
|
|
|
|
|
operation_mode_stop (GtkFileChooserDefault *impl, OperationMode mode)
|
|
|
|
|
{
|
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case OPERATION_MODE_BROWSE:
|
|
|
|
|
stop_loading_and_clear_list_model (impl, TRUE);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OPERATION_MODE_SEARCH:
|
|
|
|
|
search_stop_searching (impl, FALSE);
|
|
|
|
|
search_clear_model (impl, TRUE);
|
|
|
|
|
|
2011-07-27 21:52:12 +00:00
|
|
|
|
operation_mode_discard_search_widgets (impl);
|
2011-07-26 21:00:35 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OPERATION_MODE_RECENT:
|
|
|
|
|
recent_stop_loading (impl);
|
|
|
|
|
recent_clear_model (impl, TRUE);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-26 21:17:43 +00:00
|
|
|
|
static void
|
|
|
|
|
operation_mode_set_browse (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2011-07-26 21:17:43 +00:00
|
|
|
|
path_bar_update (impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2011-07-26 21:17:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_show (priv->location_button);
|
|
|
|
|
location_mode_set (impl, priv->location_mode, TRUE);
|
2011-07-26 21:17:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY)
|
|
|
|
|
gtk_widget_show (priv->location_entry_box);
|
2011-07-26 21:17:43 +00:00
|
|
|
|
}
|
2011-07-26 21:43:36 +00:00
|
|
|
|
}
|
2011-07-26 21:17:43 +00:00
|
|
|
|
|
2011-07-26 21:43:36 +00:00
|
|
|
|
static void
|
|
|
|
|
operation_mode_set_search (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->search_hbox == NULL);
|
|
|
|
|
g_assert (priv->search_entry == NULL);
|
|
|
|
|
g_assert (priv->search_model == NULL);
|
2011-07-26 21:43:36 +00:00
|
|
|
|
|
|
|
|
|
search_setup_widgets (impl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
operation_mode_set_recent (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2011-07-26 21:43:36 +00:00
|
|
|
|
path_bar_update (impl);
|
|
|
|
|
|
|
|
|
|
/* Hide the location widgets temporarily */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2011-07-26 21:43:36 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_hide (priv->location_button);
|
|
|
|
|
gtk_widget_hide (priv->location_entry_box);
|
2011-07-26 21:43:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recent_start_loading (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-26 21:17:43 +00:00
|
|
|
|
static void
|
|
|
|
|
operation_mode_set (GtkFileChooserDefault *impl, OperationMode mode)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2012-12-10 23:14:12 +00:00
|
|
|
|
GFile *file;
|
2011-07-26 21:43:36 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
operation_mode_stop (impl, priv->operation_mode);
|
2011-07-26 21:17:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->operation_mode = mode;
|
2011-07-26 21:17:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
switch (priv->operation_mode)
|
2011-07-26 21:17:43 +00:00
|
|
|
|
{
|
|
|
|
|
case OPERATION_MODE_BROWSE:
|
|
|
|
|
operation_mode_set_browse (impl);
|
2011-07-26 21:43:36 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OPERATION_MODE_SEARCH:
|
|
|
|
|
operation_mode_set_search (impl);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OPERATION_MODE_RECENT:
|
|
|
|
|
operation_mode_set_recent (impl);
|
2012-12-10 23:14:12 +00:00
|
|
|
|
file = g_file_new_for_uri ("recent:///");
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_places_sidebar_set_location (GTK_PLACES_SIDEBAR (priv->places_sidebar), file);
|
2012-12-10 23:14:12 +00:00
|
|
|
|
g_object_unref (file);
|
2011-07-26 21:17:43 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
2011-07-26 21:43:36 +00:00
|
|
|
|
return;
|
2011-07-26 21:17:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* This function is basically a do_all function.
|
2004-02-29 06:35:15 +00:00
|
|
|
|
*
|
2004-02-25 08:55:48 +00:00
|
|
|
|
* It sets the visibility on all the widgets based on the current state, and
|
|
|
|
|
* moves the custom_widget if needed.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
update_appearance (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2011-06-28 20:21:49 +00:00
|
|
|
|
save_path_bar (impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
2004-03-08 20:06:50 +00:00
|
|
|
|
const char *text;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_hide (priv->location_button);
|
2005-09-27 01:34:24 +00:00
|
|
|
|
save_widgets_create (impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2013-08-21 14:50:42 +00:00
|
|
|
|
text = _("Save in folder:");
|
2004-03-08 20:06:50 +00:00
|
|
|
|
else
|
2013-08-21 14:50:42 +00:00
|
|
|
|
text = _("Create in folder:");
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
2013-08-21 14:50:42 +00:00
|
|
|
|
gtk_label_set_text (GTK_LABEL (priv->save_folder_label), text);
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->select_multiple)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
|
|
|
|
g_warning ("Save mode cannot be set in conjunction with multiple selection mode. "
|
|
|
|
|
"Re-setting to single selection mode.");
|
|
|
|
|
set_select_multiple (impl, FALSE, TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_show (priv->location_button);
|
2005-09-27 01:34:24 +00:00
|
|
|
|
save_widgets_destroy (impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
location_mode_set (impl, priv->location_mode, TRUE);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_entry)
|
|
|
|
|
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->action);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2011-06-28 20:21:49 +00:00
|
|
|
|
restore_path_bar (impl);
|
2011-07-01 19:36:52 +00:00
|
|
|
|
path_bar_update (impl);
|
2004-03-04 21:29:51 +00:00
|
|
|
|
|
2005-09-27 01:34:24 +00:00
|
|
|
|
/* This *is* needed; we need to redraw the file list because the "sensitivity"
|
|
|
|
|
* of files may change depending whether we are in a file or folder-only mode.
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_queue_draw (priv->browse_files_tree_view);
|
2004-11-20 01:39:26 +00:00
|
|
|
|
|
2008-08-20 01:11:45 +00:00
|
|
|
|
emit_default_size_changed (impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_ACTION:
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
|
|
|
|
GtkFileChooserAction action = g_value_get_enum (value);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (action != priv->action)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
2004-11-19 23:18:38 +00:00
|
|
|
|
gtk_file_chooser_default_unselect_all (GTK_FILE_CHOOSER (impl));
|
2004-11-07 05:15:25 +00:00
|
|
|
|
|
2007-05-11 19:22:38 +00:00
|
|
|
|
if ((action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
&& priv->select_multiple)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
2005-06-10 05:54:28 +00:00
|
|
|
|
g_warning ("Tried to change the file chooser action to SAVE or CREATE_FOLDER, but "
|
|
|
|
|
"this is not allowed in multiple selection mode. Resetting the file chooser "
|
|
|
|
|
"to single selection mode.");
|
2004-02-25 08:55:48 +00:00
|
|
|
|
set_select_multiple (impl, FALSE, TRUE);
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->action = action;
|
2009-06-30 20:58:55 +00:00
|
|
|
|
update_cell_renderer_attributes (impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
update_appearance (impl);
|
2007-05-18 10:38:42 +00:00
|
|
|
|
settings_load (impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILTER:
|
|
|
|
|
set_current_filter (impl, g_value_get_object (value));
|
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
|
2004-03-15 06:09:40 +00:00
|
|
|
|
set_local_only (impl, g_value_get_boolean (value));
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
|
|
|
|
|
set_preview_widget (impl, g_value_get_object (value));
|
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->preview_widget_active = g_value_get_boolean (value);
|
2003-07-23 22:30:32 +00:00
|
|
|
|
update_preview_widget_visibility (impl);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2004-02-29 06:35:15 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->use_preview_label = g_value_get_boolean (value);
|
2004-02-29 06:35:15 +00:00
|
|
|
|
update_preview_widget_visibility (impl);
|
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-09-03 05:52:35 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
|
|
|
|
|
set_extra_widget (impl, g_value_get_object (value));
|
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
|
|
|
|
|
{
|
|
|
|
|
gboolean select_multiple = g_value_get_boolean (value);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if ((priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2005-06-10 05:54:28 +00:00
|
|
|
|
&& select_multiple)
|
2004-01-16 05:12:21 +00:00
|
|
|
|
{
|
2005-06-10 05:54:28 +00:00
|
|
|
|
g_warning ("Tried to set the file chooser to multiple selection mode, but this is "
|
|
|
|
|
"not allowed in SAVE or CREATE_FOLDER modes. Ignoring the change and "
|
|
|
|
|
"leaving the file chooser in single selection mode.");
|
2004-01-16 05:12:21 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-23 20:15:05 +00:00
|
|
|
|
set_select_multiple (impl, select_multiple, FALSE);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
|
|
|
|
|
{
|
|
|
|
|
gboolean show_hidden = g_value_get_boolean (value);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (show_hidden != priv->show_hidden)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->show_hidden = show_hidden;
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->browse_files_model)
|
|
|
|
|
_gtk_file_system_model_set_show_hidden (priv->browse_files_model, show_hidden);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
|
|
|
|
|
{
|
|
|
|
|
gboolean do_overwrite_confirmation = g_value_get_boolean (value);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->do_overwrite_confirmation = do_overwrite_confirmation;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2009-07-28 12:15:59 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
|
|
|
|
{
|
|
|
|
|
gboolean create_folders = g_value_get_boolean (value);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->create_folders = create_folders;
|
2009-07-28 12:15:59 +00:00
|
|
|
|
update_appearance (impl);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
break;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_ACTION:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_enum (value, priv->action);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILTER:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_object (value, priv->current_filter);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_boolean (value, priv->local_only);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_object (value, priv->preview_widget);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_boolean (value, priv->preview_widget_active);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2004-02-29 06:35:15 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_boolean (value, priv->use_preview_label);
|
2004-02-29 06:35:15 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-09-03 05:52:35 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_object (value, priv->extra_widget);
|
2003-09-03 05:52:35 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_boolean (value, priv->select_multiple);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_boolean (value, priv->show_hidden);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_boolean (value, priv->do_overwrite_confirmation);
|
2005-07-15 04:55:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2009-07-28 12:15:59 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_value_set_boolean (value, priv->create_folders);
|
2009-07-28 12:15:59 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
break;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-28 22:17:22 +00:00
|
|
|
|
/* This cancels everything that may be going on in the background. */
|
2004-03-11 20:03:38 +00:00
|
|
|
|
static void
|
2011-06-28 22:17:22 +00:00
|
|
|
|
cancel_all_operations (GtkFileChooserDefault *impl)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GSList *l;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
pending_select_files_free (impl);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->reload_icon_cancellables)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
for (l = priv->reload_icon_cancellables; l; l = l->next)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable = G_CANCELLABLE (l->data);
|
|
|
|
|
g_cancellable_cancel (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_slist_free (priv->reload_icon_cancellables);
|
|
|
|
|
priv->reload_icon_cancellables = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->loading_shortcuts)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
for (l = priv->loading_shortcuts; l; l = l->next)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GCancellable *cancellable = G_CANCELLABLE (l->data);
|
|
|
|
|
g_cancellable_cancel (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_slist_free (priv->loading_shortcuts);
|
|
|
|
|
priv->loading_shortcuts = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->file_list_drag_data_received_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_cancellable_cancel (priv->file_list_drag_data_received_cancellable);
|
|
|
|
|
priv->file_list_drag_data_received_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->update_current_folder_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_cancellable_cancel (priv->update_current_folder_cancellable);
|
|
|
|
|
priv->update_current_folder_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->should_respond_get_info_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_cancellable_cancel (priv->should_respond_get_info_cancellable);
|
|
|
|
|
priv->should_respond_get_info_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->file_exists_get_info_cancellable)
|
2013-02-13 21:07:33 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_cancellable_cancel (priv->file_exists_get_info_cancellable);
|
|
|
|
|
priv->file_exists_get_info_cancellable = NULL;
|
2013-02-13 21:07:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->update_from_entry_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_cancellable_cancel (priv->update_from_entry_cancellable);
|
|
|
|
|
priv->update_from_entry_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->shortcuts_activate_iter_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_cancellable_cancel (priv->shortcuts_activate_iter_cancellable);
|
|
|
|
|
priv->shortcuts_activate_iter_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 19:22:38 +00:00
|
|
|
|
search_stop_searching (impl, TRUE);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
recent_stop_loading (impl);
|
2011-06-28 22:17:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Removes the settings signal handler. It's safe to call multiple times */
|
|
|
|
|
static void
|
|
|
|
|
remove_settings_signal (GtkFileChooserDefault *impl,
|
|
|
|
|
GdkScreen *screen)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->settings_signal_id)
|
2011-06-28 22:17:22 +00:00
|
|
|
|
{
|
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
|
|
|
|
|
settings = gtk_settings_get_for_screen (screen);
|
|
|
|
|
g_signal_handler_disconnect (settings,
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->settings_signal_id);
|
|
|
|
|
priv->settings_signal_id = 0;
|
2011-06-28 22:17:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = (GtkFileChooserDefault *) object;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-06-28 22:17:22 +00:00
|
|
|
|
|
|
|
|
|
cancel_all_operations (impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->extra_widget)
|
2011-06-28 22:17:22 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->extra_widget);
|
|
|
|
|
priv->extra_widget = NULL;
|
2011-06-28 22:17:22 +00:00
|
|
|
|
}
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2004-03-11 20:03:38 +00:00
|
|
|
|
remove_settings_signal (impl, gtk_widget_get_screen (GTK_WIDGET (impl)));
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->bookmarks_manager)
|
2011-09-29 19:36:35 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_bookmarks_manager_free (priv->bookmarks_manager);
|
|
|
|
|
priv->bookmarks_manager = NULL;
|
2011-09-29 19:36:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
G_OBJECT_CLASS (_gtk_file_chooser_default_parent_class)->dispose (object);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
/* We override show-all since we have internal widgets that
|
|
|
|
|
* shouldn't be shown when you call show_all(), like the filter
|
2003-10-23 05:10:47 +00:00
|
|
|
|
* combo box.
|
2003-07-23 15:31:10 +00:00
|
|
|
|
*/
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_show_all (GtkWidget *widget)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2004-03-05 09:49:00 +00:00
|
|
|
|
GtkFileChooserDefault *impl = (GtkFileChooserDefault *) widget;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-03-05 08:37:11 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
gtk_widget_show (widget);
|
2004-03-05 08:37:11 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->extra_widget)
|
|
|
|
|
gtk_widget_show_all (priv->extra_widget);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
/* Handler for GtkWindow::set-focus; this is where we save the last-focused
|
|
|
|
|
* widget on our toplevel. See gtk_file_chooser_default_hierarchy_changed()
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
toplevel_set_focus_cb (GtkWindow *window,
|
|
|
|
|
GtkWidget *focus,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
priv->toplevel_last_focus_widget = gtk_window_get_focus (window);
|
2004-07-29 01:26:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We monitor the focus widget on our toplevel to be able to know which widget
|
|
|
|
|
* was last focused at the time our "should_respond" method gets called.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_hierarchy_changed (GtkWidget *widget,
|
|
|
|
|
GtkWidget *previous_toplevel)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
2010-12-26 10:13:19 +00:00
|
|
|
|
toplevel = gtk_widget_get_toplevel (widget);
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2010-12-26 10:13:19 +00:00
|
|
|
|
if (previous_toplevel &&
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->toplevel_set_focus_id != 0)
|
2004-07-29 01:26:51 +00:00
|
|
|
|
{
|
2008-08-11 09:17:49 +00:00
|
|
|
|
g_signal_handler_disconnect (previous_toplevel,
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->toplevel_set_focus_id);
|
|
|
|
|
priv->toplevel_set_focus_id = 0;
|
|
|
|
|
priv->toplevel_last_focus_widget = NULL;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-24 03:01:43 +00:00
|
|
|
|
if (gtk_widget_is_toplevel (toplevel))
|
2004-07-29 01:26:51 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->toplevel_set_focus_id == 0);
|
|
|
|
|
priv->toplevel_set_focus_id = g_signal_connect (toplevel, "set-focus",
|
2004-07-29 01:26:51 +00:00
|
|
|
|
G_CALLBACK (toplevel_set_focus_cb), impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->toplevel_last_focus_widget = gtk_window_get_focus (GTK_WINDOW (toplevel));
|
2004-07-29 01:26:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-09 21:22:42 +00:00
|
|
|
|
/* Changes the icons wherever it is needed */
|
|
|
|
|
static void
|
|
|
|
|
change_icon_theme (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
gint width, height;
|
|
|
|
|
|
2005-09-27 21:33:24 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2013-06-26 22:41:15 +00:00
|
|
|
|
if (gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height))
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->icon_size = MAX (width, height);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->icon_size = FALLBACK_ICON_SIZE;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2013-04-11 21:47:38 +00:00
|
|
|
|
/* the first cell in the first column is the icon column, and we have a fixed size there */
|
2013-04-12 01:37:01 +00:00
|
|
|
|
set_icon_cell_renderer_fixed_size (impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->browse_files_model)
|
2013-07-03 11:26:03 +00:00
|
|
|
|
_gtk_file_system_model_clear_cache (priv->browse_files_model, MODEL_COL_SURFACE);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_queue_resize (priv->browse_files_tree_view);
|
2005-09-27 21:33:24 +00:00
|
|
|
|
|
|
|
|
|
profile_end ("end", NULL);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used when a GtkSettings value changes */
|
|
|
|
|
static void
|
|
|
|
|
settings_notify_cb (GObject *object,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
|
2005-09-27 21:33:24 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2004-03-09 21:22:42 +00:00
|
|
|
|
name = g_param_spec_get_name (pspec);
|
|
|
|
|
|
2013-06-26 22:01:22 +00:00
|
|
|
|
if (strcmp (name, "gtk-icon-theme-name") == 0)
|
2004-03-09 21:22:42 +00:00
|
|
|
|
change_icon_theme (impl);
|
2005-09-27 21:33:24 +00:00
|
|
|
|
|
|
|
|
|
profile_end ("end", NULL);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Installs a signal handler for GtkSettings so that we can monitor changes in
|
|
|
|
|
* the icon theme.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
check_icon_theme (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
|
2005-09-27 21:33:24 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->settings_signal_id)
|
2005-09-27 21:33:24 +00:00
|
|
|
|
{
|
|
|
|
|
profile_end ("end", NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-03-17 15:34:21 +00:00
|
|
|
|
if (gtk_widget_has_screen (GTK_WIDGET (impl)))
|
|
|
|
|
{
|
|
|
|
|
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->settings_signal_id = g_signal_connect (settings, "notify",
|
2004-03-17 15:34:21 +00:00
|
|
|
|
G_CALLBACK (settings_notify_cb), impl);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-03-17 15:34:21 +00:00
|
|
|
|
change_icon_theme (impl);
|
|
|
|
|
}
|
2005-09-27 21:33:24 +00:00
|
|
|
|
|
|
|
|
|
profile_end ("end", NULL);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void
|
2011-01-04 01:34:28 +00:00
|
|
|
|
gtk_file_chooser_default_style_updated (GtkWidget *widget)
|
2004-02-27 23:51:16 +00:00
|
|
|
|
{
|
2004-03-09 21:22:42 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2004-03-09 21:22:42 +00:00
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
|
2011-01-04 01:34:28 +00:00
|
|
|
|
profile_msg (" parent class style_udpated start", NULL);
|
|
|
|
|
GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->style_updated (widget);
|
|
|
|
|
profile_msg (" parent class style_updated end", NULL);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2004-08-13 18:09:29 +00:00
|
|
|
|
if (gtk_widget_has_screen (GTK_WIDGET (impl)))
|
|
|
|
|
change_icon_theme (impl);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2008-08-20 01:11:45 +00:00
|
|
|
|
emit_default_size_changed (impl);
|
2005-07-20 02:11:37 +00:00
|
|
|
|
|
|
|
|
|
profile_end ("end", NULL);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_screen_changed (GtkWidget *widget,
|
|
|
|
|
GdkScreen *previous_screen)
|
|
|
|
|
{
|
2004-03-09 21:22:42 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
2005-09-27 21:33:24 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2004-03-09 21:22:42 +00:00
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
if (GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->screen_changed)
|
|
|
|
|
GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->screen_changed (widget, previous_screen);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2004-03-11 20:03:38 +00:00
|
|
|
|
remove_settings_signal (impl, previous_screen);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
check_icon_theme (impl);
|
|
|
|
|
|
2008-08-20 01:11:45 +00:00
|
|
|
|
emit_default_size_changed (impl);
|
2005-09-27 21:33:24 +00:00
|
|
|
|
|
|
|
|
|
profile_end ("end", NULL);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-12 22:31:28 +00:00
|
|
|
|
static void
|
|
|
|
|
set_sort_column (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2009-06-12 22:31:28 +00:00
|
|
|
|
GtkTreeSortable *sortable;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
sortable = GTK_TREE_SORTABLE (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view)));
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2009-06-30 21:17:26 +00:00
|
|
|
|
/* can happen when we're still populating the model */
|
|
|
|
|
if (sortable == NULL)
|
|
|
|
|
return;
|
2009-06-12 22:31:28 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_column_id (sortable,
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->sort_column,
|
|
|
|
|
priv->sort_order);
|
2009-06-12 22:31:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
static void
|
|
|
|
|
settings_load (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
LocationMode location_mode;
|
|
|
|
|
gboolean show_hidden;
|
2008-09-18 15:29:33 +00:00
|
|
|
|
gboolean show_size_column;
|
2013-12-03 17:10:29 +00:00
|
|
|
|
gboolean sort_directories_first;
|
2009-06-12 22:31:28 +00:00
|
|
|
|
gint sort_column;
|
|
|
|
|
GtkSortType sort_order;
|
2012-11-21 16:28:26 +00:00
|
|
|
|
StartupMode startup_mode;
|
2012-11-14 12:10:59 +00:00
|
|
|
|
gint sidebar_width;
|
2013-01-23 02:23:33 +00:00
|
|
|
|
GSettings *settings;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2013-01-23 02:23:33 +00:00
|
|
|
|
settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2013-01-23 02:23:33 +00:00
|
|
|
|
location_mode = g_settings_get_enum (settings, SETTINGS_KEY_LOCATION_MODE);
|
|
|
|
|
show_hidden = g_settings_get_boolean (settings, SETTINGS_KEY_SHOW_HIDDEN);
|
|
|
|
|
show_size_column = g_settings_get_boolean (settings, SETTINGS_KEY_SHOW_SIZE_COLUMN);
|
|
|
|
|
sort_column = g_settings_get_enum (settings, SETTINGS_KEY_SORT_COLUMN);
|
|
|
|
|
sort_order = g_settings_get_enum (settings, SETTINGS_KEY_SORT_ORDER);
|
|
|
|
|
sidebar_width = g_settings_get_int (settings, SETTINGS_KEY_SIDEBAR_WIDTH);
|
2013-02-14 02:15:46 +00:00
|
|
|
|
startup_mode = g_settings_get_enum (settings, SETTINGS_KEY_STARTUP_MODE);
|
2013-12-03 17:10:29 +00:00
|
|
|
|
sort_directories_first = g_settings_get_boolean (settings, SETTINGS_KEY_SORT_DIRECTORIES_FIRST);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
|
|
|
|
location_mode_set (impl, location_mode, TRUE);
|
2008-09-22 14:25:45 +00:00
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
gtk_file_chooser_set_show_hidden (GTK_FILE_CHOOSER (impl), show_hidden);
|
2008-09-22 14:25:45 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->show_size_column = show_size_column;
|
|
|
|
|
gtk_tree_view_column_set_visible (priv->list_size_column, show_size_column);
|
2009-06-12 22:31:28 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->sort_column = sort_column;
|
|
|
|
|
priv->sort_order = sort_order;
|
|
|
|
|
priv->startup_mode = startup_mode;
|
2013-12-03 17:10:29 +00:00
|
|
|
|
priv->sort_directories_first = sort_directories_first;
|
2013-02-14 02:15:46 +00:00
|
|
|
|
|
2009-06-18 01:33:57 +00:00
|
|
|
|
/* We don't call set_sort_column() here as the models may not have been
|
|
|
|
|
* created yet. The individual functions that create and set the models will
|
|
|
|
|
* call set_sort_column() themselves.
|
|
|
|
|
*/
|
2012-11-14 12:10:59 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_paned_set_position (GTK_PANED (priv->browse_widgets_hpaned), sidebar_width);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
settings_save (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2013-01-23 02:23:33 +00:00
|
|
|
|
GSettings *settings;
|
2011-04-14 19:14:26 +00:00
|
|
|
|
|
2013-01-23 02:23:33 +00:00
|
|
|
|
settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2011-04-14 19:14:26 +00:00
|
|
|
|
/* All the other state */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_settings_set_enum (settings, SETTINGS_KEY_LOCATION_MODE, priv->location_mode);
|
2013-01-23 02:23:33 +00:00
|
|
|
|
g_settings_set_boolean (settings, SETTINGS_KEY_SHOW_HIDDEN,
|
2010-09-28 20:56:02 +00:00
|
|
|
|
gtk_file_chooser_get_show_hidden (GTK_FILE_CHOOSER (impl)));
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_settings_set_boolean (settings, SETTINGS_KEY_SHOW_SIZE_COLUMN, priv->show_size_column);
|
|
|
|
|
g_settings_set_enum (settings, SETTINGS_KEY_SORT_COLUMN, priv->sort_column);
|
|
|
|
|
g_settings_set_enum (settings, SETTINGS_KEY_SORT_ORDER, priv->sort_order);
|
2013-01-23 02:23:33 +00:00
|
|
|
|
g_settings_set_int (settings, SETTINGS_KEY_SIDEBAR_WIDTH,
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_paned_get_position (GTK_PANED (priv->browse_widgets_hpaned)));
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2010-09-28 20:56:02 +00:00
|
|
|
|
/* Now apply the settings */
|
2013-01-23 02:23:33 +00:00
|
|
|
|
g_settings_apply (settings);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-14 20:18:40 +00:00
|
|
|
|
/* GtkWidget::realize method */
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_realize (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->realize (widget);
|
|
|
|
|
|
|
|
|
|
emit_default_size_changed (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-21 16:40:34 +00:00
|
|
|
|
/* Changes the current folder to $CWD */
|
|
|
|
|
static void
|
|
|
|
|
switch_to_cwd (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
char *current_working_dir;
|
|
|
|
|
|
|
|
|
|
current_working_dir = g_get_current_dir ();
|
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), current_working_dir);
|
|
|
|
|
g_free (current_working_dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sets the file chooser to showing Recent Files or $CWD, depending on the
|
|
|
|
|
* user's settings.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
set_startup_mode (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
switch (priv->startup_mode)
|
2012-11-21 16:40:34 +00:00
|
|
|
|
{
|
|
|
|
|
case STARTUP_MODE_RECENT:
|
2012-12-10 23:14:12 +00:00
|
|
|
|
operation_mode_set (impl, OPERATION_MODE_RECENT);
|
2012-11-21 16:40:34 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case STARTUP_MODE_CWD:
|
|
|
|
|
switch_to_cwd (impl);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-11 21:52:17 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
shortcut_exists (GtkFileChooserDefault *impl, GFile *needle)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2012-12-11 21:52:17 +00:00
|
|
|
|
GSList *haystack;
|
|
|
|
|
GSList *l;
|
|
|
|
|
gboolean exists;
|
|
|
|
|
|
|
|
|
|
exists = FALSE;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
haystack = gtk_places_sidebar_list_shortcuts (GTK_PLACES_SIDEBAR (priv->places_sidebar));
|
2012-12-11 21:52:17 +00:00
|
|
|
|
for (l = haystack; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GFile *hay;
|
|
|
|
|
|
|
|
|
|
hay = G_FILE (l->data);
|
|
|
|
|
if (g_file_equal (hay, needle))
|
|
|
|
|
{
|
|
|
|
|
exists = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_slist_free_full (haystack, g_object_unref);
|
|
|
|
|
|
|
|
|
|
return exists;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_cwd_to_sidebar_if_needed (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2012-12-11 21:52:17 +00:00
|
|
|
|
char *cwd;
|
|
|
|
|
GFile *cwd_file;
|
|
|
|
|
GFile *home_file;
|
|
|
|
|
|
|
|
|
|
cwd = g_get_current_dir ();
|
|
|
|
|
cwd_file = g_file_new_for_path (cwd);
|
|
|
|
|
g_free (cwd);
|
|
|
|
|
|
|
|
|
|
if (shortcut_exists (impl, cwd_file))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
home_file = g_file_new_for_path (g_get_home_dir ());
|
|
|
|
|
|
|
|
|
|
/* We only add an item for $CWD if it is different from $HOME. This way,
|
|
|
|
|
* applications which get launched from a shell in a terminal (by someone who
|
|
|
|
|
* knows what they are doing) will get an item for $CWD in the places sidebar,
|
|
|
|
|
* and "normal" applications launched from the desktop shell (whose $CWD is
|
|
|
|
|
* $HOME) won't get any extra clutter in the sidebar.
|
|
|
|
|
*/
|
|
|
|
|
if (!g_file_equal (home_file, cwd_file))
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_places_sidebar_add_shortcut (GTK_PLACES_SIDEBAR (priv->places_sidebar), cwd_file);
|
2012-12-11 21:52:17 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (home_file);
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_object_unref (cwd_file);
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-15 01:37:41 +00:00
|
|
|
|
/* GtkWidget::map method */
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_map (GtkWidget *widget)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-12-15 01:37:41 +00:00
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->map (widget);
|
2004-12-15 01:37:41 +00:00
|
|
|
|
|
2012-11-21 16:40:34 +00:00
|
|
|
|
settings_load (impl);
|
|
|
|
|
|
2012-12-11 21:52:17 +00:00
|
|
|
|
add_cwd_to_sidebar_if_needed (impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_BROWSE)
|
2005-01-25 01:35:09 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
switch (priv->reload_state)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2007-05-02 22:51:43 +00:00
|
|
|
|
case RELOAD_EMPTY:
|
2012-11-21 16:40:34 +00:00
|
|
|
|
set_startup_mode (impl);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case RELOAD_HAS_FOLDER:
|
|
|
|
|
/* Nothing; we are already loading or loaded, so we
|
|
|
|
|
* don't need to reload
|
|
|
|
|
*/
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
2005-01-25 01:35:09 +00:00
|
|
|
|
}
|
2005-01-06 01:46:39 +00:00
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_end ("end", NULL);
|
2004-12-15 01:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-09-27 23:57:09 +00:00
|
|
|
|
/* GtkWidget::unmap method */
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_unmap (GtkWidget *widget)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2005-09-27 23:57:09 +00:00
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
settings_save (impl);
|
|
|
|
|
|
2011-06-28 22:17:22 +00:00
|
|
|
|
cancel_all_operations (impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->reload_state = RELOAD_EMPTY;
|
2011-06-28 22:17:22 +00:00
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->unmap (widget);
|
2005-09-27 23:57:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-17 04:34:49 +00:00
|
|
|
|
#define COMPARE_DIRECTORIES \
|
|
|
|
|
GtkFileChooserDefault *impl = user_data; \
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv; \
|
2009-07-01 08:20:04 +00:00
|
|
|
|
GtkFileSystemModel *fs_model = GTK_FILE_SYSTEM_MODEL (model); \
|
2004-01-17 04:34:49 +00:00
|
|
|
|
gboolean dir_a, dir_b; \
|
|
|
|
|
\
|
2009-07-01 08:20:04 +00:00
|
|
|
|
dir_a = g_value_get_boolean (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_IS_FOLDER)); \
|
|
|
|
|
dir_b = g_value_get_boolean (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_IS_FOLDER)); \
|
2004-01-17 04:34:49 +00:00
|
|
|
|
\
|
2013-12-03 17:10:29 +00:00
|
|
|
|
if (priv->sort_directories_first && dir_a != dir_b) \
|
2013-04-12 03:44:19 +00:00
|
|
|
|
return priv->list_sort_ascending ? (dir_a ? -1 : 1) : (dir_a ? 1 : -1) /* Directories *always* go first */
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
|
|
|
|
/* Sort callback for the filename column */
|
|
|
|
|
static gint
|
|
|
|
|
name_sort_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *a,
|
|
|
|
|
GtkTreeIter *b,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
COMPARE_DIRECTORIES;
|
|
|
|
|
else
|
2008-06-10 00:39:35 +00:00
|
|
|
|
{
|
2009-07-01 08:20:04 +00:00
|
|
|
|
const char *key_a, *key_b;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gint result;
|
|
|
|
|
|
2009-07-01 08:20:04 +00:00
|
|
|
|
key_a = g_value_get_string (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_NAME_COLLATED));
|
|
|
|
|
key_b = g_value_get_string (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_NAME_COLLATED));
|
2009-06-30 19:24:52 +00:00
|
|
|
|
|
|
|
|
|
if (key_a && key_b)
|
|
|
|
|
result = strcmp (key_a, key_b);
|
|
|
|
|
else if (key_a)
|
2009-07-01 08:20:04 +00:00
|
|
|
|
result = 1;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
else if (key_b)
|
2009-07-01 08:20:04 +00:00
|
|
|
|
result = -1;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
else
|
2009-07-01 08:20:04 +00:00
|
|
|
|
result = 0;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sort callback for the size column */
|
|
|
|
|
static gint
|
|
|
|
|
size_sort_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *a,
|
|
|
|
|
GtkTreeIter *b,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
COMPARE_DIRECTORIES;
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-06-30 19:24:52 +00:00
|
|
|
|
gint64 size_a, size_b;
|
|
|
|
|
|
2009-07-01 08:20:04 +00:00
|
|
|
|
size_a = g_value_get_int64 (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_SIZE));
|
|
|
|
|
size_b = g_value_get_int64 (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_SIZE));
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2010-06-08 17:09:48 +00:00
|
|
|
|
return size_a < size_b ? -1 : (size_a == size_b ? 0 : 1);
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sort callback for the mtime column */
|
|
|
|
|
static gint
|
|
|
|
|
mtime_sort_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *a,
|
|
|
|
|
GtkTreeIter *b,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
COMPARE_DIRECTORIES;
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-06-30 19:24:52 +00:00
|
|
|
|
glong ta, tb;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2009-07-01 08:20:04 +00:00
|
|
|
|
ta = g_value_get_long (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_MTIME));
|
|
|
|
|
tb = g_value_get_long (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_MTIME));
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2010-06-08 17:09:48 +00:00
|
|
|
|
return ta < tb ? -1 : (ta == tb ? 0 : 1);
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used when the sort column changes. We cache the sort order for use
|
|
|
|
|
* in name_sort_func().
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
list_sort_column_changed_cb (GtkTreeSortable *sortable,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2009-06-12 22:31:28 +00:00
|
|
|
|
gint sort_column_id;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
GtkSortType sort_type;
|
|
|
|
|
|
2009-06-12 22:31:28 +00:00
|
|
|
|
if (gtk_tree_sortable_get_sort_column_id (sortable, &sort_column_id, &sort_type))
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->list_sort_ascending = (sort_type == GTK_SORT_ASCENDING);
|
|
|
|
|
priv->sort_column = sort_column_id;
|
|
|
|
|
priv->sort_order = sort_type;
|
2009-06-12 22:31:28 +00:00
|
|
|
|
}
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
static void
|
|
|
|
|
set_busy_cursor (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean busy)
|
|
|
|
|
{
|
2010-08-11 21:12:39 +00:00
|
|
|
|
GtkWidget *widget;
|
2004-03-29 19:52:16 +00:00
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (impl));
|
2010-08-11 21:12:39 +00:00
|
|
|
|
widget = GTK_WIDGET (toplevel);
|
|
|
|
|
if (!toplevel || !gtk_widget_get_realized (widget))
|
2004-03-29 19:52:16 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2010-08-11 21:12:39 +00:00
|
|
|
|
display = gtk_widget_get_display (widget);
|
2004-03-29 19:52:16 +00:00
|
|
|
|
|
|
|
|
|
if (busy)
|
|
|
|
|
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
|
|
|
|
|
else
|
|
|
|
|
cursor = NULL;
|
|
|
|
|
|
2010-08-11 21:12:39 +00:00
|
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
|
2004-03-29 19:52:16 +00:00
|
|
|
|
gdk_display_flush (display);
|
|
|
|
|
|
|
|
|
|
if (cursor)
|
2010-12-20 02:14:38 +00:00
|
|
|
|
g_object_unref (cursor);
|
2004-03-29 19:52:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-11-20 00:17:30 +00:00
|
|
|
|
/* Creates a sort model to wrap the file system model and sets it on the tree view */
|
|
|
|
|
static void
|
|
|
|
|
load_set_model (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2005-09-29 00:19:32 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->browse_files_model != NULL);
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
2005-09-29 00:19:32 +00:00
|
|
|
|
profile_msg (" gtk_tree_view_set_model start", NULL);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
|
|
|
|
GTK_TREE_MODEL (priv->browse_files_model));
|
|
|
|
|
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
|
|
|
|
gtk_tree_view_set_search_column (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
2009-06-30 19:24:52 +00:00
|
|
|
|
MODEL_COL_NAME);
|
2011-07-26 21:43:36 +00:00
|
|
|
|
file_list_set_sort_column_ids (impl);
|
2009-06-19 20:36:26 +00:00
|
|
|
|
set_sort_column (impl);
|
2009-06-30 21:17:26 +00:00
|
|
|
|
profile_msg (" gtk_tree_view_set_model end", NULL);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->list_sort_ascending = TRUE;
|
2005-09-29 00:19:32 +00:00
|
|
|
|
|
|
|
|
|
profile_end ("end", NULL);
|
2004-11-20 00:17:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Timeout callback used when the loading timer expires */
|
|
|
|
|
static gboolean
|
|
|
|
|
load_timeout_cb (gpointer data)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_state == LOAD_PRELOAD);
|
|
|
|
|
g_assert (priv->load_timeout_id != 0);
|
|
|
|
|
g_assert (priv->browse_files_model != NULL);
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->load_timeout_id = 0;
|
|
|
|
|
priv->load_state = LOAD_LOADING;
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
|
|
|
|
load_set_model (impl);
|
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_end ("end", NULL);
|
|
|
|
|
|
2004-11-20 00:17:30 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-17 21:31:08 +00:00
|
|
|
|
/* Sets up a new load timer for the model and switches to the LOAD_PRELOAD state */
|
2004-11-20 00:17:30 +00:00
|
|
|
|
static void
|
|
|
|
|
load_setup_timer (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_timeout_id == 0);
|
|
|
|
|
g_assert (priv->load_state != LOAD_PRELOAD);
|
|
|
|
|
|
|
|
|
|
priv->load_timeout_id = gdk_threads_add_timeout (MAX_LOADING_TIME, load_timeout_cb, impl);
|
2013-10-22 13:43:43 +00:00
|
|
|
|
g_source_set_name_by_id (priv->load_timeout_id, "[gtk+] load_timeout_cb");
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->load_state = LOAD_PRELOAD;
|
2004-11-20 00:17:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-11 21:47:38 +00:00
|
|
|
|
/* Removes the load timeout; changes the impl->load_state to the specified value. */
|
2004-11-20 00:17:30 +00:00
|
|
|
|
static void
|
2013-02-21 00:02:24 +00:00
|
|
|
|
load_remove_timer (GtkFileChooserDefault *impl, LoadState new_load_state)
|
2004-11-20 00:17:30 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->load_timeout_id != 0)
|
2004-11-20 00:17:30 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_state == LOAD_PRELOAD);
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_source_remove (priv->load_timeout_id);
|
|
|
|
|
priv->load_timeout_id = 0;
|
2004-11-20 00:17:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_state == LOAD_EMPTY ||
|
|
|
|
|
priv->load_state == LOAD_LOADING ||
|
|
|
|
|
priv->load_state == LOAD_FINISHED);
|
2013-02-21 00:02:24 +00:00
|
|
|
|
|
|
|
|
|
g_assert (new_load_state == LOAD_EMPTY ||
|
|
|
|
|
new_load_state == LOAD_LOADING ||
|
|
|
|
|
new_load_state == LOAD_FINISHED);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->load_state = new_load_state;
|
2004-12-02 21:36:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Selects the first row in the file list */
|
|
|
|
|
static void
|
|
|
|
|
browse_files_select_first_row (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-12-02 21:36:14 +00:00
|
|
|
|
GtkTreePath *path;
|
2008-07-03 22:40:33 +00:00
|
|
|
|
GtkTreeIter dummy_iter;
|
|
|
|
|
GtkTreeModel *tree_model;
|
2004-12-02 21:36:14 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2008-07-03 22:40:33 +00:00
|
|
|
|
|
2009-06-30 21:17:26 +00:00
|
|
|
|
if (!tree_model)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-11 18:25:29 +00:00
|
|
|
|
path = gtk_tree_path_new_from_indices (0, -1);
|
|
|
|
|
|
2008-07-03 22:40:33 +00:00
|
|
|
|
/* If the list is empty, do nothing. */
|
|
|
|
|
if (gtk_tree_model_get_iter (tree_model, &dummy_iter, path))
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->browse_files_tree_view), path, NULL, FALSE);
|
2008-07-03 22:40:33 +00:00
|
|
|
|
|
2004-12-02 21:36:14 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-25 01:35:09 +00:00
|
|
|
|
struct center_selected_row_closure {
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
gboolean already_centered;
|
|
|
|
|
};
|
|
|
|
|
|
2004-12-09 02:12:47 +00:00
|
|
|
|
/* Callback used from gtk_tree_selection_selected_foreach(); centers the
|
|
|
|
|
* selected row in the tree view.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
center_selected_row_foreach_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2005-01-25 01:35:09 +00:00
|
|
|
|
struct center_selected_row_closure *closure;
|
2004-12-09 02:12:47 +00:00
|
|
|
|
|
2005-01-25 01:35:09 +00:00
|
|
|
|
closure = data;
|
|
|
|
|
if (closure->already_centered)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (closure->impl->priv->browse_files_tree_view), path, NULL, TRUE, 0.5, 0.0);
|
2005-01-25 01:35:09 +00:00
|
|
|
|
closure->already_centered = TRUE;
|
2004-12-09 02:12:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Centers the selected row in the tree view */
|
|
|
|
|
static void
|
|
|
|
|
browse_files_center_selected_row (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2005-01-25 01:35:09 +00:00
|
|
|
|
struct center_selected_row_closure closure;
|
2004-12-09 02:12:47 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
2005-01-25 01:35:09 +00:00
|
|
|
|
closure.impl = impl;
|
|
|
|
|
closure.already_centered = FALSE;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2005-01-25 01:35:09 +00:00
|
|
|
|
gtk_tree_selection_selected_foreach (selection, center_selected_row_foreach_cb, &closure);
|
2004-12-09 02:12:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-07-01 08:32:26 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
show_and_select_files (GtkFileChooserDefault *impl,
|
|
|
|
|
GSList *files)
|
2004-12-02 21:36:14 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2009-07-01 08:32:26 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
GtkFileSystemModel *fsmodel;
|
2011-02-24 20:53:09 +00:00
|
|
|
|
gboolean enabled_hidden, removed_filters;
|
|
|
|
|
gboolean selected_a_file;
|
2009-07-01 08:32:26 +00:00
|
|
|
|
GSList *walk;
|
2005-01-25 01:35:09 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_state == LOAD_FINISHED);
|
|
|
|
|
g_assert (priv->browse_files_model != NULL);
|
2013-02-20 23:14:20 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
|
|
|
|
fsmodel = GTK_FILE_SYSTEM_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view)));
|
2011-02-24 20:53:09 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (fsmodel == priv->browse_files_model);
|
2013-02-20 23:14:20 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
enabled_hidden = priv->show_hidden;
|
|
|
|
|
removed_filters = (priv->current_filter == NULL);
|
2011-02-24 20:53:09 +00:00
|
|
|
|
|
2009-07-01 08:32:26 +00:00
|
|
|
|
selected_a_file = FALSE;
|
2005-01-25 01:35:09 +00:00
|
|
|
|
|
2011-02-24 20:53:09 +00:00
|
|
|
|
for (walk = files; walk; walk = walk->next)
|
2005-01-25 01:35:09 +00:00
|
|
|
|
{
|
2009-07-01 08:32:26 +00:00
|
|
|
|
GFile *file = walk->data;
|
2009-06-30 13:15:55 +00:00
|
|
|
|
GtkTreeIter iter;
|
2005-01-25 01:35:09 +00:00
|
|
|
|
|
2011-02-24 20:53:09 +00:00
|
|
|
|
/* Is it a hidden file? */
|
|
|
|
|
|
2009-07-01 08:32:26 +00:00
|
|
|
|
if (!_gtk_file_system_model_get_iter_for_file (fsmodel, &iter, file))
|
|
|
|
|
continue;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2009-09-10 21:33:37 +00:00
|
|
|
|
if (!_gtk_file_system_model_iter_is_visible (fsmodel, &iter))
|
2009-07-01 08:32:26 +00:00
|
|
|
|
{
|
|
|
|
|
GFileInfo *info = _gtk_file_system_model_get_info (fsmodel, &iter);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2011-02-24 20:53:09 +00:00
|
|
|
|
if (!enabled_hidden &&
|
2009-07-01 08:32:26 +00:00
|
|
|
|
(g_file_info_get_is_hidden (info) ||
|
|
|
|
|
g_file_info_get_is_backup (info)))
|
|
|
|
|
{
|
|
|
|
|
g_object_set (impl, "show-hidden", TRUE, NULL);
|
2011-02-24 20:53:09 +00:00
|
|
|
|
enabled_hidden = TRUE;
|
2009-07-01 08:32:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-24 20:53:09 +00:00
|
|
|
|
|
|
|
|
|
/* Is it a filtered file? */
|
|
|
|
|
|
|
|
|
|
if (!_gtk_file_system_model_get_iter_for_file (fsmodel, &iter, file))
|
|
|
|
|
continue; /* re-get the iter as it may change when the model refilters */
|
|
|
|
|
|
|
|
|
|
if (!_gtk_file_system_model_iter_is_visible (fsmodel, &iter))
|
|
|
|
|
{
|
|
|
|
|
/* Maybe we should have a way to ask the fsmodel if it had filtered a file */
|
|
|
|
|
if (!removed_filters)
|
|
|
|
|
{
|
|
|
|
|
set_current_filter (impl, NULL);
|
|
|
|
|
removed_filters = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Okay, can we select the file now? */
|
2009-07-01 08:32:26 +00:00
|
|
|
|
|
2011-02-24 20:53:09 +00:00
|
|
|
|
if (!_gtk_file_system_model_get_iter_for_file (fsmodel, &iter, file))
|
|
|
|
|
continue;
|
|
|
|
|
|
2009-09-10 21:33:37 +00:00
|
|
|
|
if (_gtk_file_system_model_iter_is_visible (fsmodel, &iter))
|
2009-07-01 08:32:26 +00:00
|
|
|
|
{
|
2010-10-12 19:20:16 +00:00
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
2009-07-01 08:32:26 +00:00
|
|
|
|
gtk_tree_selection_select_iter (selection, &iter);
|
2010-10-12 19:20:16 +00:00
|
|
|
|
|
2010-10-14 09:32:44 +00:00
|
|
|
|
path = gtk_tree_model_get_path (GTK_TREE_MODEL (fsmodel), &iter);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
2010-10-12 19:20:16 +00:00
|
|
|
|
path, NULL, FALSE);
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
2009-07-01 08:32:26 +00:00
|
|
|
|
selected_a_file = TRUE;
|
|
|
|
|
}
|
2005-01-25 01:35:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-07-01 08:32:26 +00:00
|
|
|
|
browse_files_center_selected_row (impl);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2009-07-01 08:32:26 +00:00
|
|
|
|
return selected_a_file;
|
2005-01-25 01:35:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Processes the pending operation when a folder is finished loading */
|
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
pending_select_files_process (GtkFileChooserDefault *impl)
|
2005-01-25 01:35:09 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2005-01-25 01:35:09 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_state == LOAD_FINISHED);
|
|
|
|
|
g_assert (priv->browse_files_model != NULL);
|
|
|
|
|
|
|
|
|
|
if (priv->pending_select_files)
|
2005-01-25 01:35:09 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
show_and_select_files (impl, priv->pending_select_files);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
pending_select_files_free (impl);
|
2005-01-25 01:35:09 +00:00
|
|
|
|
browse_files_center_selected_row (impl);
|
|
|
|
|
}
|
|
|
|
|
else
|
2005-02-02 18:25:27 +00:00
|
|
|
|
{
|
|
|
|
|
/* We only select the first row if the chooser is actually mapped ---
|
|
|
|
|
* selecting the first row is to help the user when he is interacting with
|
|
|
|
|
* the chooser, but sometimes a chooser works not on behalf of the user,
|
|
|
|
|
* but rather on behalf of something else like GtkFileChooserButton. In
|
|
|
|
|
* that case, the chooser's selection should be what the caller expects,
|
|
|
|
|
* as the user can't see that something else got selected. See bug #165264.
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN &&
|
2010-03-02 04:19:28 +00:00
|
|
|
|
gtk_widget_get_mapped (GTK_WIDGET (impl)))
|
2005-02-02 18:25:27 +00:00
|
|
|
|
browse_files_select_first_row (impl);
|
|
|
|
|
}
|
2005-01-25 01:35:09 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->pending_select_files == NULL);
|
2004-12-02 21:36:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-02 18:43:03 +00:00
|
|
|
|
static void
|
|
|
|
|
show_error_on_reading_current_folder (GtkFileChooserDefault *impl, GError *error)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2009-09-02 18:43:03 +00:00
|
|
|
|
GFileInfo *info;
|
|
|
|
|
char *msg;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
info = g_file_query_info (priv->current_folder,
|
2009-09-02 18:43:03 +00:00
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
|
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
if (info)
|
|
|
|
|
{
|
2009-09-30 22:55:12 +00:00
|
|
|
|
msg = g_strdup_printf (_("Could not read the contents of %s"), g_file_info_get_display_name (info));
|
2009-09-02 18:43:03 +00:00
|
|
|
|
g_object_unref (info);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
msg = g_strdup (_("Could not read the contents of the folder"));
|
|
|
|
|
|
|
|
|
|
error_message (impl, msg, error->message);
|
|
|
|
|
g_free (msg);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
/* Callback used when the file system model finishes loading */
|
|
|
|
|
static void
|
|
|
|
|
browse_files_model_finished_loading_cb (GtkFileSystemModel *model,
|
2009-06-30 13:15:55 +00:00
|
|
|
|
GError *error,
|
2004-03-29 19:52:16 +00:00
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2009-09-02 18:43:03 +00:00
|
|
|
|
if (error)
|
|
|
|
|
show_error_on_reading_current_folder (impl, error);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->load_state == LOAD_PRELOAD)
|
2004-11-20 00:17:30 +00:00
|
|
|
|
{
|
2013-02-21 00:02:24 +00:00
|
|
|
|
load_remove_timer (impl, LOAD_FINISHED);
|
2004-11-20 00:17:30 +00:00
|
|
|
|
load_set_model (impl);
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->load_state == LOAD_LOADING)
|
2005-01-25 01:35:09 +00:00
|
|
|
|
{
|
|
|
|
|
/* Nothing */
|
|
|
|
|
}
|
2004-11-20 00:17:30 +00:00
|
|
|
|
else
|
2005-02-02 00:53:10 +00:00
|
|
|
|
{
|
|
|
|
|
/* We can't g_assert_not_reached(), as something other than us may have
|
|
|
|
|
* initiated a folder reload. See #165556.
|
|
|
|
|
*/
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_end ("end", NULL);
|
2005-02-02 00:53:10 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2005-01-25 01:35:09 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_timeout_id == 0);
|
2005-01-25 01:35:09 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->load_state = LOAD_FINISHED;
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
pending_select_files_process (impl);
|
2004-03-29 19:52:16 +00:00
|
|
|
|
set_busy_cursor (impl, FALSE);
|
2005-09-15 00:59:16 +00:00
|
|
|
|
#ifdef PROFILE_FILE_CHOOSER
|
|
|
|
|
access ("MARK: *** FINISHED LOADING", F_OK);
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_end ("end", NULL);
|
2004-03-29 19:52:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
static void
|
2009-11-02 18:48:05 +00:00
|
|
|
|
stop_loading_and_clear_list_model (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean remove_from_treeview)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2013-02-21 00:02:24 +00:00
|
|
|
|
load_remove_timer (impl, LOAD_EMPTY);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->browse_files_model)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->browse_files_model);
|
|
|
|
|
priv->browse_files_model = NULL;
|
2004-11-20 00:17:30 +00:00
|
|
|
|
}
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
2009-11-02 18:48:05 +00:00
|
|
|
|
if (remove_from_treeview)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view), NULL);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-30 19:24:52 +00:00
|
|
|
|
static char *
|
|
|
|
|
my_g_format_time_for_display (glong secs)
|
|
|
|
|
{
|
|
|
|
|
GDate mtime, now;
|
|
|
|
|
gint days_diff;
|
|
|
|
|
struct tm tm_mtime;
|
|
|
|
|
time_t time_mtime, time_now;
|
|
|
|
|
const gchar *format;
|
|
|
|
|
gchar *locale_format = NULL;
|
|
|
|
|
gchar buf[256];
|
|
|
|
|
char *date_str = NULL;
|
2009-10-16 10:29:54 +00:00
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
const char *locale, *dot = NULL;
|
|
|
|
|
gint64 codepage = -1;
|
|
|
|
|
char charset[20];
|
|
|
|
|
#endif
|
2009-06-30 19:24:52 +00:00
|
|
|
|
|
|
|
|
|
time_mtime = secs;
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LOCALTIME_R
|
|
|
|
|
localtime_r ((time_t *) &time_mtime, &tm_mtime);
|
|
|
|
|
#else
|
|
|
|
|
{
|
2009-10-16 10:29:54 +00:00
|
|
|
|
struct tm *ptm = localtime ((time_t *) &time_mtime);
|
2009-06-30 19:24:52 +00:00
|
|
|
|
|
|
|
|
|
if (!ptm)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("ptm != NULL failed");
|
|
|
|
|
|
|
|
|
|
return g_strdup (_("Unknown"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
memcpy ((void *) &tm_mtime, (void *) ptm, sizeof (struct tm));
|
|
|
|
|
}
|
|
|
|
|
#endif /* HAVE_LOCALTIME_R */
|
|
|
|
|
|
|
|
|
|
g_date_set_time_t (&mtime, time_mtime);
|
|
|
|
|
time_now = time (NULL);
|
|
|
|
|
g_date_set_time_t (&now, time_now);
|
|
|
|
|
|
|
|
|
|
days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
|
|
|
|
|
|
|
|
|
|
/* Translators: %H means "hours" and %M means "minutes" */
|
|
|
|
|
if (days_diff == 0)
|
|
|
|
|
format = _("%H:%M");
|
|
|
|
|
else if (days_diff == 1)
|
|
|
|
|
format = _("Yesterday at %H:%M");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (days_diff > 1 && days_diff < 7)
|
|
|
|
|
format = "%A"; /* Days from last week */
|
|
|
|
|
else
|
|
|
|
|
format = "%x"; /* Any other date */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
/* g_locale_from_utf8() returns a string in the system
|
|
|
|
|
* code-page, which is not always the same as that used by the C
|
|
|
|
|
* library. For instance when running a GTK+ program with
|
|
|
|
|
* LANG=ko on an English version of Windows, the system
|
|
|
|
|
* code-page is 1252, but the code-page used by the C library is
|
|
|
|
|
* 949. (It's GTK+ itself that sets the C library locale when it
|
|
|
|
|
* notices the LANG environment variable. See gtkmain.c The
|
|
|
|
|
* Microsoft C library doesn't look at any locale environment
|
|
|
|
|
* variables.) We need to pass strftime() a string in the C
|
|
|
|
|
* library's code-page. See bug #509885.
|
|
|
|
|
*/
|
|
|
|
|
locale = setlocale (LC_ALL, NULL);
|
|
|
|
|
if (locale != NULL)
|
|
|
|
|
dot = strchr (locale, '.');
|
|
|
|
|
if (dot != NULL)
|
|
|
|
|
{
|
|
|
|
|
codepage = g_ascii_strtoll (dot+1, NULL, 10);
|
|
|
|
|
|
|
|
|
|
/* All codepages should fit in 16 bits AFAIK */
|
|
|
|
|
if (codepage > 0 && codepage < 65536)
|
|
|
|
|
{
|
|
|
|
|
sprintf (charset, "CP%u", (guint) codepage);
|
|
|
|
|
locale_format = g_convert (format, -1, charset, "UTF-8", NULL, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
|
|
|
|
|
#endif
|
|
|
|
|
if (locale_format != NULL &&
|
|
|
|
|
strftime (buf, sizeof (buf), locale_format, &tm_mtime) != 0)
|
|
|
|
|
{
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
/* As above but in opposite direction... */
|
|
|
|
|
if (codepage > 0 && codepage < 65536)
|
|
|
|
|
date_str = g_convert (buf, -1, "UTF-8", charset, NULL, NULL, NULL);
|
|
|
|
|
#else
|
|
|
|
|
date_str = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (date_str == NULL)
|
|
|
|
|
date_str = g_strdup (_("Unknown"));
|
|
|
|
|
|
|
|
|
|
g_free (locale_format);
|
|
|
|
|
return date_str;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-11 18:32:08 +00:00
|
|
|
|
static void
|
|
|
|
|
copy_attribute (GFileInfo *to, GFileInfo *from, const char *attribute)
|
|
|
|
|
{
|
|
|
|
|
GFileAttributeType type;
|
|
|
|
|
gpointer value;
|
|
|
|
|
|
|
|
|
|
if (g_file_info_get_attribute_data (from, attribute, &type, &value, NULL))
|
|
|
|
|
g_file_info_set_attribute (to, attribute, type, value);
|
|
|
|
|
}
|
2009-06-30 21:33:29 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
file_system_model_got_thumbnail (GObject *object, GAsyncResult *res, gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileSystemModel *model = data; /* might be unreffed if operation was cancelled */
|
|
|
|
|
GFile *file = G_FILE (object);
|
|
|
|
|
GFileInfo *queried, *info;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
|
|
queried = g_file_query_info_finish (file, res, NULL);
|
|
|
|
|
if (queried == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-07-28 12:52:40 +00:00
|
|
|
|
gdk_threads_enter ();
|
2011-03-25 09:53:05 +00:00
|
|
|
|
|
2009-06-30 21:33:29 +00:00
|
|
|
|
/* now we know model is valid */
|
|
|
|
|
|
|
|
|
|
/* file was deleted */
|
|
|
|
|
if (!_gtk_file_system_model_get_iter_for_file (model, &iter, file))
|
2011-03-25 09:53:05 +00:00
|
|
|
|
{
|
2012-07-28 12:52:40 +00:00
|
|
|
|
gdk_threads_leave ();
|
2011-03-25 09:53:05 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2009-06-30 21:33:29 +00:00
|
|
|
|
|
|
|
|
|
info = g_file_info_dup (_gtk_file_system_model_get_info (model, &iter));
|
|
|
|
|
|
|
|
|
|
copy_attribute (info, queried, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
|
|
|
|
|
copy_attribute (info, queried, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
|
|
|
|
|
copy_attribute (info, queried, G_FILE_ATTRIBUTE_STANDARD_ICON);
|
|
|
|
|
|
2012-11-01 02:54:02 +00:00
|
|
|
|
_gtk_file_system_model_update_file (model, file, info);
|
2009-06-30 21:33:29 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (info);
|
2011-03-25 09:53:05 +00:00
|
|
|
|
|
2012-07-28 12:52:40 +00:00
|
|
|
|
gdk_threads_leave ();
|
2009-06-30 21:33:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2009-06-30 13:15:55 +00:00
|
|
|
|
file_system_model_set (GtkFileSystemModel *model,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
int column,
|
|
|
|
|
GValue *value,
|
2009-06-30 19:24:52 +00:00
|
|
|
|
gpointer data)
|
2009-06-30 13:15:55 +00:00
|
|
|
|
{
|
2009-06-30 19:24:52 +00:00
|
|
|
|
GtkFileChooserDefault *impl = data;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
|
2009-06-30 13:15:55 +00:00
|
|
|
|
switch (column)
|
|
|
|
|
{
|
2009-06-30 19:24:52 +00:00
|
|
|
|
case MODEL_COL_FILE:
|
|
|
|
|
g_value_set_object (value, file);
|
2009-06-30 13:15:55 +00:00
|
|
|
|
break;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
case MODEL_COL_NAME:
|
|
|
|
|
if (info == NULL)
|
|
|
|
|
g_value_set_string (value, DEFAULT_NEW_FOLDER_NAME);
|
|
|
|
|
else
|
|
|
|
|
g_value_set_string (value, g_file_info_get_display_name (info));
|
|
|
|
|
break;
|
|
|
|
|
case MODEL_COL_NAME_COLLATED:
|
|
|
|
|
if (info == NULL)
|
|
|
|
|
g_value_take_string (value, g_utf8_collate_key_for_filename (DEFAULT_NEW_FOLDER_NAME, -1));
|
|
|
|
|
else
|
|
|
|
|
g_value_take_string (value, g_utf8_collate_key_for_filename (g_file_info_get_display_name (info), -1));
|
|
|
|
|
break;
|
|
|
|
|
case MODEL_COL_IS_FOLDER:
|
|
|
|
|
g_value_set_boolean (value, info == NULL || _gtk_file_info_consider_as_directory (info));
|
|
|
|
|
break;
|
2012-07-08 07:25:02 +00:00
|
|
|
|
case MODEL_COL_IS_SENSITIVE:
|
|
|
|
|
if (info)
|
|
|
|
|
{
|
|
|
|
|
gboolean sensitive = TRUE;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!(priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
|
2012-07-08 07:25:02 +00:00
|
|
|
|
{
|
2012-07-11 22:50:15 +00:00
|
|
|
|
sensitive = TRUE; /* for file modes... */
|
2012-07-08 07:25:02 +00:00
|
|
|
|
}
|
|
|
|
|
else if (!_gtk_file_info_consider_as_directory (info))
|
|
|
|
|
{
|
2012-07-11 22:50:15 +00:00
|
|
|
|
sensitive = FALSE; /* for folder modes, files are not sensitive... */
|
2012-07-08 07:25:02 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-07-11 22:50:15 +00:00
|
|
|
|
/* ... and for folder modes, folders are sensitive only if the filter says so */
|
2012-07-08 07:25:02 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
if (!_gtk_file_system_model_get_iter_for_file (model, &iter, file))
|
|
|
|
|
g_assert_not_reached ();
|
2012-07-11 20:47:53 +00:00
|
|
|
|
sensitive = !_gtk_file_system_model_iter_is_filtered_out (model, &iter);
|
2012-07-08 07:25:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_value_set_boolean (value, sensitive);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_value_set_boolean (value, TRUE);
|
|
|
|
|
break;
|
2013-07-03 11:26:03 +00:00
|
|
|
|
case MODEL_COL_SURFACE:
|
2009-06-30 13:15:55 +00:00
|
|
|
|
if (info)
|
2009-06-30 21:33:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_ICON))
|
|
|
|
|
{
|
2013-07-03 11:26:03 +00:00
|
|
|
|
g_value_take_boxed (value, _gtk_file_info_render_icon (info, GTK_WIDGET (impl), priv->icon_size));
|
2009-06-30 21:33:29 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkTreeModel *tree_model;
|
|
|
|
|
GtkTreePath *path, *start, *end;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->browse_files_tree_view == NULL ||
|
2009-06-30 21:33:29 +00:00
|
|
|
|
g_file_info_has_attribute (info, "filechooser::queried"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2009-06-30 21:33:29 +00:00
|
|
|
|
if (tree_model != GTK_TREE_MODEL (model))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2009-06-24 20:43:14 +00:00
|
|
|
|
if (!_gtk_file_system_model_get_iter_for_file (model,
|
|
|
|
|
&iter,
|
|
|
|
|
file))
|
2009-06-30 21:33:29 +00:00
|
|
|
|
g_assert_not_reached ();
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!gtk_tree_view_get_visible_range (GTK_TREE_VIEW (priv->browse_files_tree_view), &start, &end))
|
2009-06-30 21:33:29 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
path = gtk_tree_model_get_path (tree_model, &iter);
|
|
|
|
|
if (gtk_tree_path_compare (start, path) != 1 &&
|
|
|
|
|
gtk_tree_path_compare (path, end) != 1)
|
|
|
|
|
{
|
|
|
|
|
g_file_info_set_attribute_boolean (info, "filechooser::queried", TRUE);
|
|
|
|
|
g_file_query_info_async (file,
|
|
|
|
|
G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
|
|
|
|
|
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED ","
|
|
|
|
|
G_FILE_ATTRIBUTE_STANDARD_ICON,
|
2009-09-11 19:20:19 +00:00
|
|
|
|
G_FILE_QUERY_INFO_NONE,
|
2009-06-30 21:33:29 +00:00
|
|
|
|
G_PRIORITY_DEFAULT,
|
|
|
|
|
_gtk_file_system_model_get_cancellable (model),
|
|
|
|
|
file_system_model_got_thumbnail,
|
|
|
|
|
model);
|
|
|
|
|
}
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
gtk_tree_path_free (start);
|
|
|
|
|
gtk_tree_path_free (end);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-30 19:24:52 +00:00
|
|
|
|
else
|
|
|
|
|
g_value_set_object (value, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case MODEL_COL_SIZE:
|
|
|
|
|
g_value_set_int64 (value, info ? g_file_info_get_size (info) : 0);
|
|
|
|
|
break;
|
|
|
|
|
case MODEL_COL_SIZE_TEXT:
|
|
|
|
|
if (info == NULL || _gtk_file_info_consider_as_directory (info))
|
|
|
|
|
g_value_set_string (value, NULL);
|
|
|
|
|
else
|
2011-07-20 18:22:26 +00:00
|
|
|
|
g_value_take_string (value, g_format_size (g_file_info_get_size (info)));
|
2009-06-30 19:24:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case MODEL_COL_MTIME:
|
|
|
|
|
case MODEL_COL_MTIME_TEXT:
|
|
|
|
|
{
|
|
|
|
|
GTimeVal tv;
|
|
|
|
|
if (info == NULL)
|
|
|
|
|
break;
|
|
|
|
|
g_file_info_get_modification_time (info, &tv);
|
|
|
|
|
if (column == MODEL_COL_MTIME)
|
|
|
|
|
g_value_set_long (value, tv.tv_sec);
|
|
|
|
|
else if (tv.tv_sec == 0)
|
|
|
|
|
g_value_set_static_string (value, _("Unknown"));
|
|
|
|
|
else
|
|
|
|
|
g_value_take_string (value, my_g_format_time_for_display (tv.tv_sec));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MODEL_COL_ELLIPSIZE:
|
|
|
|
|
g_value_set_enum (value, info ? PANGO_ELLIPSIZE_END : PANGO_ELLIPSIZE_NONE);
|
2009-06-30 13:15:55 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
2009-06-30 19:24:52 +00:00
|
|
|
|
break;
|
2009-06-30 13:15:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
/* Gets rid of the old list model and creates a new one for the current folder */
|
|
|
|
|
static gboolean
|
|
|
|
|
set_list_model (GtkFileChooserDefault *impl,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->current_folder != NULL);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
|
2009-11-02 18:48:05 +00:00
|
|
|
|
stop_loading_and_clear_list_model (impl, TRUE);
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
set_busy_cursor (impl, TRUE);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->browse_files_model =
|
|
|
|
|
_gtk_file_system_model_new_for_directory (priv->current_folder,
|
2009-09-11 19:28:36 +00:00
|
|
|
|
MODEL_ATTRIBUTES,
|
|
|
|
|
file_system_model_set,
|
|
|
|
|
impl,
|
|
|
|
|
MODEL_COLUMN_TYPES);
|
2009-06-30 13:15:55 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_set_show_hidden (priv->browse_files_model, priv->show_hidden);
|
2009-06-30 21:17:26 +00:00
|
|
|
|
|
|
|
|
|
profile_msg (" set sort function", NULL);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->browse_files_model), MODEL_COL_NAME, name_sort_func, impl, NULL);
|
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->browse_files_model), MODEL_COL_SIZE, size_sort_func, impl, NULL);
|
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->browse_files_model), MODEL_COL_MTIME, mtime_sort_func, impl, NULL);
|
|
|
|
|
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (priv->browse_files_model), NULL, NULL, NULL);
|
2009-06-30 21:17:26 +00:00
|
|
|
|
set_sort_column (impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->list_sort_ascending = TRUE;
|
|
|
|
|
g_signal_connect (priv->browse_files_model, "sort-column-changed",
|
2009-06-30 21:17:26 +00:00
|
|
|
|
G_CALLBACK (list_sort_column_changed_cb), impl);
|
|
|
|
|
|
2005-01-25 01:35:09 +00:00
|
|
|
|
load_setup_timer (impl); /* This changes the state to LOAD_PRELOAD */
|
2004-11-20 00:17:30 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_signal_connect (priv->browse_files_model, "finished-loading",
|
2004-03-29 19:52:16 +00:00
|
|
|
|
G_CALLBACK (browse_files_model_finished_loading_cb), impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_set_filter (priv->browse_files_model, priv->current_filter);
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_end ("end", NULL);
|
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
return TRUE;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
struct update_chooser_entry_selected_foreach_closure {
|
|
|
|
|
int num_selected;
|
|
|
|
|
GtkTreeIter first_selected_iter;
|
|
|
|
|
};
|
|
|
|
|
|
2006-07-18 16:36:19 +00:00
|
|
|
|
static gint
|
|
|
|
|
compare_utf8_filenames (const gchar *a,
|
|
|
|
|
const gchar *b)
|
|
|
|
|
{
|
|
|
|
|
gchar *a_folded, *b_folded;
|
|
|
|
|
gint retval;
|
|
|
|
|
|
|
|
|
|
a_folded = g_utf8_strdown (a, -1);
|
|
|
|
|
b_folded = g_utf8_strdown (b, -1);
|
|
|
|
|
|
|
|
|
|
retval = strcmp (a_folded, b_folded);
|
|
|
|
|
|
|
|
|
|
g_free (a_folded);
|
|
|
|
|
g_free (b_folded);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
static void
|
|
|
|
|
update_chooser_entry_selected_foreach (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
struct update_chooser_entry_selected_foreach_closure *closure;
|
|
|
|
|
|
|
|
|
|
closure = data;
|
|
|
|
|
closure->num_selected++;
|
|
|
|
|
|
|
|
|
|
if (closure->num_selected == 1)
|
|
|
|
|
closure->first_selected_iter = *iter;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-13 02:31:09 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
update_chooser_entry (GtkFileChooserDefault *impl)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
struct update_chooser_entry_selected_foreach_closure closure;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2007-05-30 12:27:47 +00:00
|
|
|
|
/* no need to update the file chooser's entry if there's no entry */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_SEARCH ||
|
|
|
|
|
!priv->location_entry)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!(priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
|
|
|
|
|
|| ((priv->action == GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
|
|
|
&& priv->location_mode == LOCATION_MODE_FILENAME_ENTRY)))
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->location_entry != NULL);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
closure.num_selected = 0;
|
|
|
|
|
gtk_tree_selection_selected_foreach (selection, update_chooser_entry_selected_foreach, &closure);
|
|
|
|
|
|
|
|
|
|
if (closure.num_selected == 0)
|
2005-06-10 05:54:28 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_RECENT)
|
|
|
|
|
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), NULL);
|
2011-06-29 22:58:10 +00:00
|
|
|
|
else
|
|
|
|
|
goto maybe_clear_entry;
|
2005-06-10 05:54:28 +00:00
|
|
|
|
}
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
else if (closure.num_selected == 1)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_BROWSE)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFileInfo *info;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
gboolean change_entry;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
info = _gtk_file_system_model_get_info (priv->browse_files_model, &closure.first_selected_iter);
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2011-01-24 02:50:39 +00:00
|
|
|
|
/* If the cursor moved to the row of the newly created folder,
|
2007-05-02 22:51:43 +00:00
|
|
|
|
* retrieving info will return NULL.
|
|
|
|
|
*/
|
|
|
|
|
if (!info)
|
|
|
|
|
return;
|
2007-01-04 01:45:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_free (priv->browse_files_last_selected_name);
|
|
|
|
|
priv->browse_files_last_selected_name =
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_strdup (g_file_info_get_display_name (info));
|
2006-07-18 16:36:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2011-01-24 02:50:39 +00:00
|
|
|
|
{
|
|
|
|
|
/* Don't change the name when clicking on a folder... */
|
|
|
|
|
change_entry = (! _gtk_file_info_consider_as_directory (info));
|
|
|
|
|
}
|
2007-05-02 22:51:43 +00:00
|
|
|
|
else
|
2011-01-24 02:50:39 +00:00
|
|
|
|
change_entry = TRUE; /* ... unless we are in SELECT_FOLDER mode */
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
if (change_entry)
|
2008-02-12 17:34:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), priv->browse_files_last_selected_name);
|
2008-02-12 17:34:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
|
|
|
|
_gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (priv->location_entry));
|
2008-02-12 17:34:43 +00:00
|
|
|
|
}
|
2006-07-18 16:36:19 +00:00
|
|
|
|
|
2007-05-30 12:27:47 +00:00
|
|
|
|
return;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->operation_mode == OPERATION_MODE_RECENT
|
|
|
|
|
&& priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2011-06-29 22:58:10 +00:00
|
|
|
|
{
|
|
|
|
|
GFile *folder;
|
|
|
|
|
|
|
|
|
|
/* Set the base folder on the name entry, so it will do completion relative to the correct recent-folder */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (priv->recent_model), &closure.first_selected_iter,
|
2011-06-29 22:58:10 +00:00
|
|
|
|
MODEL_COL_FILE, &folder,
|
|
|
|
|
-1);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), folder);
|
2011-06-29 22:58:10 +00:00
|
|
|
|
g_object_unref (folder);
|
|
|
|
|
return;
|
|
|
|
|
}
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
2005-06-10 05:54:28 +00:00
|
|
|
|
else
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (!(priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER));
|
2006-07-18 16:36:19 +00:00
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
/* Multiple selection, so just clear the entry. */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_free (priv->browse_files_last_selected_name);
|
|
|
|
|
priv->browse_files_last_selected_name = NULL;
|
2006-07-18 16:36:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), "");
|
2006-07-18 16:36:19 +00:00
|
|
|
|
return;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
2006-07-18 16:36:19 +00:00
|
|
|
|
maybe_clear_entry:
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if ((priv->action == GTK_FILE_CHOOSER_ACTION_OPEN || priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
|
|
|
&& priv->browse_files_last_selected_name)
|
2006-07-18 16:36:19 +00:00
|
|
|
|
{
|
|
|
|
|
const char *entry_text;
|
|
|
|
|
int len;
|
|
|
|
|
gboolean clear_entry;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
entry_text = gtk_entry_get_text (GTK_ENTRY (priv->location_entry));
|
2006-07-18 16:36:19 +00:00
|
|
|
|
len = strlen (entry_text);
|
|
|
|
|
if (len != 0)
|
2011-01-24 02:50:39 +00:00
|
|
|
|
{
|
|
|
|
|
/* The file chooser entry may have appended a "/" to its text.
|
|
|
|
|
* So take it out, and compare the result to the old selection.
|
|
|
|
|
*/
|
|
|
|
|
if (entry_text[len - 1] == G_DIR_SEPARATOR)
|
|
|
|
|
{
|
|
|
|
|
gchar *tmp;
|
2006-07-18 16:36:19 +00:00
|
|
|
|
|
2011-01-24 02:50:39 +00:00
|
|
|
|
tmp = g_strndup (entry_text, len - 1);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
clear_entry = (compare_utf8_filenames (priv->browse_files_last_selected_name, tmp) == 0);
|
2011-01-24 02:50:39 +00:00
|
|
|
|
g_free (tmp);
|
|
|
|
|
}
|
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
clear_entry = (compare_utf8_filenames (priv->browse_files_last_selected_name, entry_text) == 0);
|
2011-01-24 02:50:39 +00:00
|
|
|
|
}
|
2006-07-18 16:36:19 +00:00
|
|
|
|
else
|
2011-01-24 02:50:39 +00:00
|
|
|
|
clear_entry = FALSE;
|
2006-07-18 16:36:19 +00:00
|
|
|
|
|
|
|
|
|
if (clear_entry)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), "");
|
2006-07-18 16:36:19 +00:00
|
|
|
|
}
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
static gboolean
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
2005-07-07 12:40:50 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
return gtk_file_chooser_default_update_current_folder (chooser, file, FALSE, FALSE, error);
|
2005-07-07 12:40:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
struct UpdateCurrentFolderData
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gboolean keep_trail;
|
add a new struct field to clear the file entry after the current folder
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
svn path=/trunk/; revision=17754
2007-05-01 20:35:33 +00:00
|
|
|
|
gboolean clear_entry;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *original_file;
|
2006-09-04 20:09:08 +00:00
|
|
|
|
GError *original_error;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
};
|
2003-03-25 00:11:06 +00:00
|
|
|
|
|
2008-12-14 03:33:41 +00:00
|
|
|
|
static void
|
|
|
|
|
update_current_folder_mount_enclosing_volume_cb (GCancellable *cancellable,
|
|
|
|
|
GtkFileSystemVolume *volume,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
struct UpdateCurrentFolderData *data = user_data;
|
|
|
|
|
GtkFileChooserDefault *impl = data->impl;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2008-12-14 03:33:41 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (cancellable != priv->update_current_folder_cancellable)
|
2008-12-14 03:33:41 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->update_current_folder_cancellable = NULL;
|
2008-12-14 03:33:41 +00:00
|
|
|
|
set_busy_cursor (impl, FALSE);
|
|
|
|
|
|
|
|
|
|
if (cancelled)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
|
{
|
|
|
|
|
error_changing_folder_dialog (data->impl, data->file, g_error_copy (error));
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->reload_state = RELOAD_EMPTY;
|
2008-12-14 03:33:41 +00:00
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
change_folder_and_display_error (impl, data->file, data->clear_entry);
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_object_unref (data->file);
|
|
|
|
|
g_free (data);
|
|
|
|
|
|
|
|
|
|
g_object_unref (cancellable);
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
update_current_folder_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct UpdateCurrentFolderData *data = user_data;
|
|
|
|
|
GtkFileChooserDefault *impl = data->impl;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2005-07-20 02:11:37 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (cancellable != priv->update_current_folder_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
2005-01-06 01:46:39 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->update_current_folder_cancellable = NULL;
|
|
|
|
|
priv->reload_state = RELOAD_EMPTY;
|
2004-03-15 23:15:31 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
set_busy_cursor (impl, FALSE);
|
2004-03-15 06:09:40 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
if (cancelled)
|
|
|
|
|
goto out;
|
2004-03-19 20:18:09 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
if (error)
|
2005-07-20 02:11:37 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *parent_file;
|
2006-09-04 20:09:08 +00:00
|
|
|
|
|
2008-12-14 03:33:41 +00:00
|
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED))
|
|
|
|
|
{
|
|
|
|
|
GMountOperation *mount_operation;
|
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
|
|
|
|
g_object_unref (cancellable);
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (impl));
|
|
|
|
|
|
|
|
|
|
mount_operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
|
|
|
|
|
|
|
|
|
|
set_busy_cursor (impl, TRUE);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->update_current_folder_cancellable =
|
|
|
|
|
_gtk_file_system_mount_enclosing_volume (priv->file_system, data->file,
|
2008-12-14 03:33:41 +00:00
|
|
|
|
mount_operation,
|
|
|
|
|
update_current_folder_mount_enclosing_volume_cb,
|
|
|
|
|
data);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!data->original_file)
|
2006-09-04 20:09:08 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
data->original_file = g_object_ref (data->file);
|
2006-09-04 20:09:08 +00:00
|
|
|
|
data->original_error = g_error_copy (error);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
parent_file = g_file_get_parent (data->file);
|
|
|
|
|
|
2006-09-04 20:09:08 +00:00
|
|
|
|
/* get parent path and try to change the folder to that */
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (parent_file)
|
2006-09-04 20:09:08 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->file);
|
|
|
|
|
data->file = parent_file;
|
2006-09-04 20:09:08 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-09-04 20:09:08 +00:00
|
|
|
|
|
|
|
|
|
/* restart the update current folder operation */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->reload_state = RELOAD_HAS_FOLDER;
|
2006-09-04 20:09:08 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->update_current_folder_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (priv->file_system, data->file,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
"standard::type",
|
|
|
|
|
update_current_folder_get_info_cb,
|
|
|
|
|
data);
|
2006-09-04 20:09:08 +00:00
|
|
|
|
|
|
|
|
|
set_busy_cursor (impl, TRUE);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-06-12 18:25:26 +00:00
|
|
|
|
/* Error and bail out, ignoring "not found" errors since they're useless:
|
2008-12-14 00:43:09 +00:00
|
|
|
|
* they only happen when a program defaults to a folder that has been (re)moved.
|
|
|
|
|
*/
|
2008-12-14 01:16:05 +00:00
|
|
|
|
if (!g_error_matches (data->original_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
2009-06-12 18:25:26 +00:00
|
|
|
|
error_changing_folder_dialog (impl, data->original_file, data->original_error);
|
2008-12-14 00:43:09 +00:00
|
|
|
|
else
|
|
|
|
|
g_error_free (data->original_error);
|
2009-06-12 18:25:26 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->original_file);
|
2006-09-04 20:09:08 +00:00
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (data->original_file)
|
2006-09-04 20:09:08 +00:00
|
|
|
|
{
|
2009-06-12 18:25:26 +00:00
|
|
|
|
/* Error and bail out, ignoring "not found" errors since they're useless:
|
|
|
|
|
* they only happen when a program defaults to a folder that has been (re)moved.
|
|
|
|
|
*/
|
|
|
|
|
if (!g_error_matches (data->original_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
|
|
|
|
error_changing_folder_dialog (impl, data->original_file, data->original_error);
|
|
|
|
|
else
|
|
|
|
|
g_error_free (data->original_error);
|
2006-09-04 20:09:08 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->original_file);
|
2005-07-20 02:11:37 +00:00
|
|
|
|
}
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
2008-12-14 02:14:19 +00:00
|
|
|
|
if (! _gtk_file_info_consider_as_directory (info))
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_path_bar_set_file (GTK_PATH_BAR (priv->browse_path_bar), data->file, data->keep_trail);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->current_folder != data->file)
|
2004-03-03 00:38:19 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->current_folder)
|
|
|
|
|
g_object_unref (priv->current_folder);
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->current_folder = g_object_ref (data->file);
|
2004-03-03 00:38:19 +00:00
|
|
|
|
}
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->reload_state = RELOAD_HAS_FOLDER;
|
2008-10-08 15:32:23 +00:00
|
|
|
|
|
2004-08-06 19:25:25 +00:00
|
|
|
|
/* Set the folder on the save entry */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_entry)
|
add a new struct field to clear the file entry after the current folder
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
svn path=/trunk/; revision=17754
2007-05-01 20:35:33 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry),
|
|
|
|
|
priv->current_folder);
|
add a new struct field to clear the file entry after the current folder
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
svn path=/trunk/; revision=17754
2007-05-01 20:35:33 +00:00
|
|
|
|
|
|
|
|
|
if (data->clear_entry)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), "");
|
add a new struct field to clear the file entry after the current folder
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
svn path=/trunk/; revision=17754
2007-05-01 20:35:33 +00:00
|
|
|
|
}
|
2004-08-06 19:25:25 +00:00
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
/* Create a new list model. This is slightly evil; we store the result value
|
|
|
|
|
* but perform more actions rather than returning immediately even if it
|
|
|
|
|
* generates an error.
|
|
|
|
|
*/
|
2006-05-01 21:41:12 +00:00
|
|
|
|
set_list_model (impl, NULL);
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
|
|
|
|
/* Refresh controls */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_places_sidebar_set_location (GTK_PLACES_SIDEBAR (priv->places_sidebar), priv->current_folder);
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (impl, "current-folder-changed", 0);
|
|
|
|
|
|
|
|
|
|
check_preview_change (impl);
|
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (impl, "selection-changed", 0);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
out:
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
g_free (data);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gboolean keep_trail,
|
add a new struct field to clear the file entry after the current folder
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
svn path=/trunk/; revision=17754
2007-05-01 20:35:33 +00:00
|
|
|
|
gboolean clear_entry,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct UpdateCurrentFolderData *data;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
profile_start ("start", NULL);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-15 23:32:11 +00:00
|
|
|
|
g_object_ref (file);
|
|
|
|
|
|
2011-07-26 21:17:43 +00:00
|
|
|
|
operation_mode_set (impl, OPERATION_MODE_BROWSE);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->local_only && !_gtk_file_has_native_path (file))
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-19 12:47:48 +00:00
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
GTK_FILE_CHOOSER_ERROR,
|
|
|
|
|
GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
|
|
|
|
|
_("Cannot change to folder because it is not local"));
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2008-06-15 23:32:11 +00:00
|
|
|
|
g_object_unref (file);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
profile_end ("end - not local", NULL);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->update_current_folder_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->update_current_folder_cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
/* Test validity of path here. */
|
|
|
|
|
data = g_new0 (struct UpdateCurrentFolderData, 1);
|
|
|
|
|
data->impl = impl;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
data->file = g_object_ref (file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
data->keep_trail = keep_trail;
|
add a new struct field to clear the file entry after the current folder
2007-05-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (struct UpdateCurrentFolderData),
(update_current_folder_get_info_cb): add a new struct field to clear
the file entry after the current folder has been updated.
(gtk_file_chooser_default_update_current_folder),
(change_folder_and_display_error): Add a new function parameter to
trigger file entry clearing.
(edited_idle_create_folder_cb),
(file_list_drag_data_received_get_info_cb),
(gtk_file_chooser_default_map),
(gtk_file_chooser_default_set_current_folder),
(switch_to_selected_folder), (save_entry_get_info_cb),
(shortcuts_activate_volume_mount_cb), (shortcuts_activate_volume),
(shortcuts_activate_get_info_cb), (list_row_activated),
(path_bar_clicked): use new function parameter appropriately.
(gtk_file_chooser_default_should_respond): trigger file entry clearing
after the directory is updated instead of clearing it before, this way
we avoid reloading the completion model with the soon to be old folder,
causing a warning and a glitch in the folder where completion happens.
(#379414, Carlos Garnacho)
svn path=/trunk/; revision=17754
2007-05-01 20:35:33 +00:00
|
|
|
|
data->clear_entry = clear_entry;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->reload_state = RELOAD_HAS_FOLDER;
|
2006-05-16 12:34:01 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->update_current_folder_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (priv->file_system, file,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
"standard::type",
|
|
|
|
|
update_current_folder_get_info_cb,
|
|
|
|
|
data);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
set_busy_cursor (impl, TRUE);
|
2008-06-15 23:32:11 +00:00
|
|
|
|
g_object_unref (file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2005-07-20 02:11:37 +00:00
|
|
|
|
profile_end ("end", NULL);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
return TRUE;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static GFile *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_SEARCH ||
|
|
|
|
|
priv->operation_mode == OPERATION_MODE_RECENT)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->current_folder)
|
|
|
|
|
return g_object_ref (priv->current_folder);
|
2008-06-26 09:41:13 +00:00
|
|
|
|
|
|
|
|
|
return NULL;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 19:18:36 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser,
|
|
|
|
|
const gchar *name)
|
2003-07-11 19:18:36 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-07-11 19:18:36 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_return_if_fail (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
pending_select_files_free (impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), name);
|
2003-07-11 19:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-17 18:47:56 +00:00
|
|
|
|
static gchar *
|
|
|
|
|
gtk_file_chooser_default_get_current_name (GtkFileChooser *chooser)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
return g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->location_entry)));
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
static gboolean
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_select_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *parent_file;
|
2005-01-25 01:35:09 +00:00
|
|
|
|
gboolean same_path;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
parent_file = g_file_get_parent (file);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!parent_file)
|
2008-08-04 14:43:05 +00:00
|
|
|
|
return gtk_file_chooser_set_current_folder_file (chooser, file, error);
|
2005-01-25 01:35:09 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_SEARCH ||
|
|
|
|
|
priv->operation_mode == OPERATION_MODE_RECENT ||
|
|
|
|
|
priv->load_state == LOAD_EMPTY)
|
2007-05-11 19:26:32 +00:00
|
|
|
|
{
|
|
|
|
|
same_path = FALSE;
|
|
|
|
|
}
|
2003-03-21 20:34:02 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->current_folder != NULL);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
same_path = g_file_equal (parent_file, priv->current_folder);
|
2005-01-25 01:35:09 +00:00
|
|
|
|
}
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (same_path && priv->load_state == LOAD_FINISHED)
|
2005-01-25 01:35:09 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean result;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GSList files;
|
2005-11-28 22:25:03 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
files.data = (gpointer) file;
|
|
|
|
|
files.next = NULL;
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
2009-07-01 08:32:26 +00:00
|
|
|
|
result = show_and_select_files (impl, &files);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (parent_file);
|
2005-01-25 01:35:09 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
pending_select_files_add (impl, file);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
2005-01-25 01:35:09 +00:00
|
|
|
|
if (!same_path)
|
|
|
|
|
{
|
|
|
|
|
gboolean result;
|
2004-12-09 22:06:55 +00:00
|
|
|
|
|
2008-08-04 14:43:05 +00:00
|
|
|
|
result = gtk_file_chooser_set_current_folder_file (chooser, parent_file, error);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (parent_file);
|
2005-01-25 01:35:09 +00:00
|
|
|
|
return result;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (parent_file);
|
2005-01-27 20:08:56 +00:00
|
|
|
|
return TRUE;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_unselect_file (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
GtkTreeView *tree_view = GTK_TREE_VIEW (priv->browse_files_tree_view);
|
2009-06-30 21:17:26 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->browse_files_model)
|
2009-06-30 21:17:26 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!_gtk_file_system_model_get_iter_for_file (priv->browse_files_model,
|
2009-06-30 13:15:55 +00:00
|
|
|
|
&iter,
|
|
|
|
|
file))
|
|
|
|
|
return;
|
|
|
|
|
|
2009-06-30 19:10:07 +00:00
|
|
|
|
gtk_tree_selection_unselect_iter (gtk_tree_view_get_selection (tree_view),
|
2009-06-30 21:17:26 +00:00
|
|
|
|
&iter);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-09-20 23:47:38 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
maybe_select (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-09-20 23:47:38 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
2012-07-08 07:25:02 +00:00
|
|
|
|
gboolean is_sensitive;
|
2004-09-20 23:47:38 +00:00
|
|
|
|
gboolean is_folder;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2004-09-20 23:47:38 +00:00
|
|
|
|
|
2009-06-19 20:36:26 +00:00
|
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
|
MODEL_COL_IS_FOLDER, &is_folder,
|
2012-07-08 07:25:02 +00:00
|
|
|
|
MODEL_COL_IS_SENSITIVE, &is_sensitive,
|
2009-06-19 20:36:26 +00:00
|
|
|
|
-1);
|
2004-09-20 23:47:38 +00:00
|
|
|
|
|
2012-07-08 07:25:02 +00:00
|
|
|
|
if (is_sensitive &&
|
2013-04-12 03:44:19 +00:00
|
|
|
|
((is_folder && priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) ||
|
|
|
|
|
(!is_folder && priv->action == GTK_FILE_CHOOSER_ACTION_OPEN)))
|
2004-09-20 23:47:38 +00:00
|
|
|
|
gtk_tree_selection_select_iter (selection, iter);
|
|
|
|
|
else
|
|
|
|
|
gtk_tree_selection_unselect_iter (selection, iter);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_select_all (GtkFileChooser *chooser)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_SEARCH ||
|
|
|
|
|
priv->operation_mode == OPERATION_MODE_RECENT)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2007-05-02 22:51:43 +00:00
|
|
|
|
gtk_tree_selection_select_all (selection);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->select_multiple)
|
|
|
|
|
gtk_tree_model_foreach (GTK_TREE_MODEL (priv->browse_files_model),
|
2004-10-24 04:27:44 +00:00
|
|
|
|
maybe_select, impl);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_unselect_all (GtkFileChooser *chooser)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
gtk_tree_selection_unselect_all (selection);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
pending_select_files_free (impl);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-06-14 23:30:12 +00:00
|
|
|
|
/* Checks whether the filename entry for the Save modes contains a well-formed filename.
|
|
|
|
|
*
|
|
|
|
|
* is_well_formed_ret - whether what the user typed passes gkt_file_system_make_path()
|
|
|
|
|
*
|
|
|
|
|
* is_empty_ret - whether the file entry is totally empty
|
|
|
|
|
*
|
|
|
|
|
* is_file_part_empty_ret - whether the file part is empty (will be if user types "foobar/", and
|
|
|
|
|
* the path will be "$cwd/foobar")
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2004-03-05 00:10:59 +00:00
|
|
|
|
check_save_entry (GtkFileChooserDefault *impl,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile **file_ret,
|
2005-06-14 23:30:12 +00:00
|
|
|
|
gboolean *is_well_formed_ret,
|
|
|
|
|
gboolean *is_empty_ret,
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gboolean *is_file_part_empty_ret,
|
|
|
|
|
gboolean *is_folder)
|
2004-03-05 00:10:59 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-08-06 19:25:25 +00:00
|
|
|
|
GtkFileChooserEntry *chooser_entry;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *current_folder;
|
2004-08-06 19:25:25 +00:00
|
|
|
|
const char *file_part;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
GError *error;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
|
|
|
|
|
|| ((priv->action == GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
|
|
|
&& priv->location_mode == LOCATION_MODE_FILENAME_ENTRY));
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
chooser_entry = GTK_FILE_CHOOSER_ENTRY (priv->location_entry);
|
2004-08-06 19:25:25 +00:00
|
|
|
|
|
2005-06-14 23:30:12 +00:00
|
|
|
|
if (strlen (gtk_entry_get_text (GTK_ENTRY (chooser_entry))) == 0)
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
*file_ret = NULL;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
*is_well_formed_ret = TRUE;
|
|
|
|
|
*is_empty_ret = TRUE;
|
|
|
|
|
*is_file_part_empty_ret = TRUE;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
*is_folder = FALSE;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*is_empty_ret = FALSE;
|
|
|
|
|
|
2004-08-06 19:25:25 +00:00
|
|
|
|
current_folder = _gtk_file_chooser_entry_get_current_folder (chooser_entry);
|
2007-03-12 00:12:25 +00:00
|
|
|
|
if (!current_folder)
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
*file_ret = NULL;
|
2007-03-12 00:12:25 +00:00
|
|
|
|
*is_well_formed_ret = FALSE;
|
|
|
|
|
*is_file_part_empty_ret = FALSE;
|
|
|
|
|
*is_folder = FALSE;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-06 19:25:25 +00:00
|
|
|
|
file_part = _gtk_file_chooser_entry_get_file_part (chooser_entry);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-08-06 19:25:25 +00:00
|
|
|
|
if (!file_part || file_part[0] == '\0')
|
2004-03-05 00:10:59 +00:00
|
|
|
|
{
|
2011-11-05 02:53:32 +00:00
|
|
|
|
*file_ret = current_folder;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
*is_well_formed_ret = TRUE;
|
|
|
|
|
*is_file_part_empty_ret = TRUE;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
*is_folder = TRUE;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
|
|
|
|
|
return;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-06-14 23:30:12 +00:00
|
|
|
|
*is_file_part_empty_ret = FALSE;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
|
|
|
|
error = NULL;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file = g_file_get_child_for_display_name (current_folder, file_part, &error);
|
2011-11-05 02:53:32 +00:00
|
|
|
|
g_object_unref (current_folder);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!file)
|
2004-03-05 00:10:59 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
error_building_filename_dialog (impl, error);
|
|
|
|
|
*file_ret = NULL;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
*is_well_formed_ret = FALSE;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
*is_folder = FALSE;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
|
|
|
|
|
return;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
*file_ret = file;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
*is_well_formed_ret = TRUE;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
*is_folder = _gtk_file_chooser_entry_get_is_folder (chooser_entry, file);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
struct get_files_closure {
|
2003-12-08 23:38:57 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
2004-02-09 20:31:38 +00:00
|
|
|
|
GSList *result;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file_from_entry;
|
2003-12-08 23:38:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
get_files_foreach (GtkTreeModel *model,
|
2004-01-16 05:12:21 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
struct get_files_closure *info;
|
|
|
|
|
GFile *file;
|
2004-01-16 05:12:21 +00:00
|
|
|
|
GtkFileSystemModel *fs_model;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-12-08 23:38:57 +00:00
|
|
|
|
info = data;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
fs_model = info->impl->priv->browse_files_model;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2009-06-30 21:17:26 +00:00
|
|
|
|
file = _gtk_file_system_model_get_file (fs_model, iter);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!file)
|
2004-03-15 23:15:31 +00:00
|
|
|
|
return; /* We are on the editable row */
|
2004-02-09 20:31:38 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!info->file_from_entry || !g_file_equal (info->file_from_entry, file))
|
|
|
|
|
info->result = g_slist_prepend (info->result, g_object_ref (file));
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_get_files (GtkFileChooser *chooser)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
struct get_files_closure info;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
GtkWidget *current_focus;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
gboolean file_list_seen;
|
|
|
|
|
|
2011-06-30 19:38:27 +00:00
|
|
|
|
info.impl = impl;
|
|
|
|
|
info.result = NULL;
|
|
|
|
|
info.file_from_entry = NULL;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_SEARCH)
|
2008-06-10 00:39:35 +00:00
|
|
|
|
return search_get_selected_files (impl);
|
2003-12-08 23:38:57 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_RECENT)
|
2011-06-30 19:38:27 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2011-06-30 19:38:27 +00:00
|
|
|
|
{
|
|
|
|
|
file_list_seen = TRUE;
|
|
|
|
|
goto file_entry;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return recent_get_selected_files (impl);
|
|
|
|
|
}
|
2003-12-08 23:38:57 +00:00
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (impl));
|
|
|
|
|
if (toplevel)
|
|
|
|
|
current_focus = gtk_window_get_focus (toplevel);
|
|
|
|
|
else
|
|
|
|
|
current_focus = NULL;
|
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
file_list_seen = FALSE;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (current_focus == priv->browse_files_tree_view)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
|
|
|
|
file_list:
|
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
file_list_seen = TRUE;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_tree_selection_selected_foreach (selection, get_files_foreach, &info);
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
|
|
|
|
|
/* If there is no selection in the file list, we probably have this situation:
|
|
|
|
|
*
|
|
|
|
|
* 1. The user typed a filename in the SAVE filename entry ("foo.txt").
|
|
|
|
|
* 2. He then double-clicked on a folder ("bar") in the file list
|
|
|
|
|
*
|
|
|
|
|
* So we want the selection to be "bar/foo.txt". Jump to the case for the
|
|
|
|
|
* filename entry to see if that is the case.
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (info.result == NULL && priv->location_entry)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
goto file_entry;
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->location_entry && current_focus == priv->location_entry)
|
2004-02-09 20:31:38 +00:00
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gboolean is_well_formed, is_empty, is_file_part_empty, is_folder;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
file_entry:
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
check_save_entry (impl, &info.file_from_entry, &is_well_formed, &is_empty, &is_file_part_empty, &is_folder);
|
2004-01-16 05:12:21 +00:00
|
|
|
|
|
2006-07-18 16:36:19 +00:00
|
|
|
|
if (is_empty)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2005-06-14 23:30:12 +00:00
|
|
|
|
if (!is_well_formed)
|
2004-03-05 00:10:59 +00:00
|
|
|
|
return NULL;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (is_file_part_empty && priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2005-06-14 23:30:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (info.file_from_entry);
|
2006-07-18 16:36:19 +00:00
|
|
|
|
return NULL;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
}
|
2003-03-24 15:41:40 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (info.file_from_entry)
|
|
|
|
|
info.result = g_slist_prepend (info.result, info.file_from_entry);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
else if (!file_list_seen)
|
|
|
|
|
goto file_list;
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->toplevel_last_focus_widget == priv->browse_files_tree_view)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
goto file_list;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->location_entry && priv->toplevel_last_focus_widget == priv->location_entry)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
goto file_entry;
|
|
|
|
|
else
|
2004-01-16 05:12:21 +00:00
|
|
|
|
{
|
2007-05-11 19:26:32 +00:00
|
|
|
|
/* The focus is on a dialog's action area button or something else */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
goto file_entry;
|
|
|
|
|
else
|
|
|
|
|
goto file_list;
|
2004-01-16 05:12:21 +00:00
|
|
|
|
}
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2006-07-18 16:36:19 +00:00
|
|
|
|
out:
|
|
|
|
|
|
2004-03-07 08:15:09 +00:00
|
|
|
|
/* If there's no folder selected, and we're in SELECT_FOLDER mode, then we
|
|
|
|
|
* fall back to the current directory */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER &&
|
2004-03-07 08:15:09 +00:00
|
|
|
|
info.result == NULL)
|
|
|
|
|
{
|
2008-06-26 09:41:13 +00:00
|
|
|
|
GFile *current_folder;
|
|
|
|
|
|
2008-08-04 14:43:05 +00:00
|
|
|
|
current_folder = gtk_file_chooser_get_current_folder_file (chooser);
|
2008-06-26 09:41:13 +00:00
|
|
|
|
|
|
|
|
|
if (current_folder)
|
|
|
|
|
info.result = g_slist_prepend (info.result, current_folder);
|
2004-03-07 08:15:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
return g_slist_reverse (info.result);
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-04 14:43:05 +00:00
|
|
|
|
GFile *
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_get_preview_file (GtkFileChooser *chooser)
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->preview_file)
|
|
|
|
|
return g_object_ref (priv->preview_file);
|
2003-07-23 22:30:32 +00:00
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-04 22:43:12 +00:00
|
|
|
|
static GtkFileSystem *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_get_file_system (GtkFileChooser *chooser)
|
2003-04-04 22:43:12 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-04-04 22:43:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
return priv->file_system;
|
2003-04-04 22:43:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-10 20:49:44 +00:00
|
|
|
|
/* Shows or hides the filter widgets */
|
|
|
|
|
static void
|
2004-05-04 17:53:13 +00:00
|
|
|
|
show_filters (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean show)
|
2003-12-10 20:49:44 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2003-12-10 20:49:44 +00:00
|
|
|
|
if (show)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_show (priv->filter_combo_hbox);
|
2003-12-10 20:49:44 +00:00
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_hide (priv->filter_combo_hbox);
|
2004-01-20 02:44:58 +00:00
|
|
|
|
}
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_add_filter (GtkFileChooser *chooser,
|
|
|
|
|
GtkFileFilter *filter)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-07-23 15:31:10 +00:00
|
|
|
|
const gchar *name;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (g_slist_find (priv->filters, filter))
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
|
|
|
|
g_warning ("gtk_file_chooser_add_filter() called on filter already in list\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-23 18:06:58 +00:00
|
|
|
|
g_object_ref_sink (filter);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->filters = g_slist_append (priv->filters, filter);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
|
|
|
|
name = gtk_file_filter_get_name (filter);
|
|
|
|
|
if (!name)
|
|
|
|
|
name = "Untitled filter"; /* Place-holder, doesn't need to be marked for translation */
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->filter_combo), name);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!g_slist_find (priv->filters, priv->current_filter))
|
2003-07-23 15:31:10 +00:00
|
|
|
|
set_current_filter (impl, filter);
|
|
|
|
|
|
2004-05-04 17:53:13 +00:00
|
|
|
|
show_filters (impl, TRUE);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_remove_filter (GtkFileChooser *chooser,
|
|
|
|
|
GtkFileFilter *filter)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-10-23 05:10:47 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint filter_index;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
filter_index = g_slist_index (priv->filters, filter);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-10-28 14:13:01 +00:00
|
|
|
|
if (filter_index < 0)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
|
|
|
|
g_warning ("gtk_file_chooser_remove_filter() called on filter not in list\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->filters = g_slist_remove (priv->filters, filter);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (filter == priv->current_filter)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->filters)
|
|
|
|
|
set_current_filter (impl, priv->filters->data);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
else
|
|
|
|
|
set_current_filter (impl, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-23 05:10:47 +00:00
|
|
|
|
/* Remove row from the combo box */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->filter_combo));
|
2006-02-25 02:45:57 +00:00
|
|
|
|
if (!gtk_tree_model_iter_nth_child (model, &iter, NULL, filter_index))
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
2003-10-23 05:10:47 +00:00
|
|
|
|
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
|
2004-01-20 02:44:58 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
g_object_unref (filter);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->filters)
|
2004-05-04 17:53:13 +00:00
|
|
|
|
show_filters (impl, FALSE);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_list_filters (GtkFileChooser *chooser)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
return g_slist_copy (priv->filters);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
static gboolean
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
2003-10-08 04:14:55 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_places_sidebar_add_shortcut (GTK_PLACES_SIDEBAR (priv->places_sidebar), file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
return TRUE;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser *chooser,
|
|
|
|
|
GFile *file,
|
|
|
|
|
GError **error)
|
2003-10-18 04:29:40 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_places_sidebar_remove_shortcut (GTK_PLACES_SIDEBAR (priv->places_sidebar), file);
|
2012-12-11 21:29:11 +00:00
|
|
|
|
return TRUE;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser)
|
2003-10-08 04:14:55 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
return gtk_places_sidebar_list_shortcuts (GTK_PLACES_SIDEBAR (priv->places_sidebar));
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
/* Guesses a size based upon font sizes */
|
|
|
|
|
static void
|
|
|
|
|
find_good_size_from_style (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
2004-02-27 23:51:16 +00:00
|
|
|
|
{
|
2011-01-04 01:34:28 +00:00
|
|
|
|
GtkStyleContext *context;
|
|
|
|
|
GtkStateFlags state;
|
2012-12-06 01:53:43 +00:00
|
|
|
|
double font_size;
|
2007-03-16 00:53:09 +00:00
|
|
|
|
GdkScreen *screen;
|
|
|
|
|
double resolution;
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2011-01-04 01:34:28 +00:00
|
|
|
|
context = gtk_widget_get_style_context (widget);
|
|
|
|
|
state = gtk_widget_get_state_flags (widget);
|
2010-08-11 21:12:39 +00:00
|
|
|
|
|
2008-08-20 01:12:35 +00:00
|
|
|
|
screen = gtk_widget_get_screen (widget);
|
|
|
|
|
if (screen)
|
2007-03-16 00:53:09 +00:00
|
|
|
|
{
|
2008-08-20 01:12:35 +00:00
|
|
|
|
resolution = gdk_screen_get_resolution (screen);
|
|
|
|
|
if (resolution < 0.0) /* will be -1 if the resolution is not defined in the GdkScreen */
|
2011-01-24 02:50:39 +00:00
|
|
|
|
resolution = 96.0;
|
2007-02-26 19:45:33 +00:00
|
|
|
|
}
|
2008-08-20 01:12:35 +00:00
|
|
|
|
else
|
|
|
|
|
resolution = 96.0; /* wheeee */
|
|
|
|
|
|
2012-12-06 01:53:43 +00:00
|
|
|
|
gtk_style_context_get (context, state, "font-size", &font_size, NULL);
|
|
|
|
|
font_size = font_size * resolution / 72.0 + 0.5;
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2008-08-20 01:12:35 +00:00
|
|
|
|
*width = font_size * NUM_CHARS;
|
|
|
|
|
*height = font_size * NUM_LINES;
|
2004-02-27 23:51:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_get_default_size (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
|
gint *default_width,
|
|
|
|
|
gint *default_height)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-18 10:38:42 +00:00
|
|
|
|
GtkRequisition req;
|
2011-06-27 22:51:57 +00:00
|
|
|
|
int x, y, width, height;
|
2013-01-23 02:23:33 +00:00
|
|
|
|
GSettings *settings;
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2013-01-23 02:23:33 +00:00
|
|
|
|
settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
|
2010-09-28 20:56:02 +00:00
|
|
|
|
|
2013-01-23 02:23:33 +00:00
|
|
|
|
g_settings_get (settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", &x, &y);
|
|
|
|
|
g_settings_get (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", &width, &height);
|
2009-01-14 20:19:10 +00:00
|
|
|
|
|
2011-06-27 22:51:57 +00:00
|
|
|
|
if (x >= 0 && y >= 0 && width > 0 && height > 0)
|
|
|
|
|
{
|
|
|
|
|
*default_width = width;
|
|
|
|
|
*default_height = height;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-05-18 10:38:42 +00:00
|
|
|
|
|
2011-06-27 22:51:57 +00:00
|
|
|
|
find_good_size_from_style (GTK_WIDGET (chooser_embed), default_width, default_height);
|
2008-08-20 01:12:54 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->preview_widget_active &&
|
|
|
|
|
priv->preview_widget &&
|
|
|
|
|
gtk_widget_get_visible (priv->preview_widget))
|
2011-06-27 22:51:57 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_get_preferred_size (priv->preview_box,
|
2011-06-27 22:51:57 +00:00
|
|
|
|
&req, NULL);
|
|
|
|
|
*default_width += PREVIEW_HBOX_SPACING + req.width;
|
2008-08-20 01:12:54 +00:00
|
|
|
|
}
|
2011-06-27 22:51:57 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->extra_widget &&
|
|
|
|
|
gtk_widget_get_visible (priv->extra_widget))
|
2007-05-18 10:38:42 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_get_preferred_size (priv->extra_align,
|
2011-06-27 22:51:57 +00:00
|
|
|
|
&req, NULL);
|
|
|
|
|
*default_height += gtk_box_get_spacing (GTK_BOX (chooser_embed)) + req.height;
|
2007-05-18 10:38:42 +00:00
|
|
|
|
}
|
2004-02-27 23:51:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
struct switch_folder_closure {
|
|
|
|
|
GtkFileChooserDefault *impl;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
int num_selected;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Used from gtk_tree_selection_selected_foreach() in switch_to_selected_folder() */
|
|
|
|
|
static void
|
|
|
|
|
switch_folder_foreach_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
struct switch_folder_closure *closure;
|
|
|
|
|
|
|
|
|
|
closure = data;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
closure->file = _gtk_file_system_model_get_file (closure->impl->priv->browse_files_model, iter);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
closure->num_selected++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Changes to the selected folder in the list view */
|
|
|
|
|
static void
|
|
|
|
|
switch_to_selected_folder (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
struct switch_folder_closure closure;
|
|
|
|
|
|
|
|
|
|
/* We do this with foreach() rather than get_selected() as we may be in
|
|
|
|
|
* multiple selection mode
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
closure.impl = impl;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
closure.file = NULL;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
closure.num_selected = 0;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2004-03-05 00:10:59 +00:00
|
|
|
|
gtk_tree_selection_selected_foreach (selection, switch_folder_foreach_cb, &closure);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_assert (closure.file && closure.num_selected == 1);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
change_folder_and_display_error (impl, closure.file, FALSE);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
/* Gets the GFileInfo for the selected row in the file list; assumes single
|
2005-07-15 04:55:56 +00:00
|
|
|
|
* selection mode.
|
|
|
|
|
*/
|
2008-06-10 00:39:35 +00:00
|
|
|
|
static GFileInfo *
|
2005-07-15 04:55:56 +00:00
|
|
|
|
get_selected_file_info_from_file_list (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean *had_selection)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
2009-06-30 21:17:26 +00:00
|
|
|
|
GtkTreeIter iter;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFileInfo *info;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (!priv->select_multiple);
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2005-07-15 04:55:56 +00:00
|
|
|
|
if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
|
|
|
|
|
{
|
|
|
|
|
*had_selection = FALSE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*had_selection = TRUE;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
info = _gtk_file_system_model_get_info (priv->browse_files_model, &iter);
|
2005-07-15 04:55:56 +00:00
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Gets the display name of the selected file in the file list; assumes single
|
|
|
|
|
* selection mode and that something is selected.
|
|
|
|
|
*/
|
|
|
|
|
static const gchar *
|
|
|
|
|
get_display_name_from_file_list (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFileInfo *info;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
gboolean had_selection;
|
|
|
|
|
|
|
|
|
|
info = get_selected_file_info_from_file_list (impl, &had_selection);
|
|
|
|
|
g_assert (had_selection);
|
|
|
|
|
g_assert (info != NULL);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
return g_file_info_get_display_name (info);
|
2005-07-15 04:55:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_custom_button_to_dialog (GtkDialog *dialog,
|
|
|
|
|
const gchar *mnemonic_label,
|
|
|
|
|
gint response_id)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
|
|
button = gtk_button_new_with_mnemonic (mnemonic_label);
|
2010-03-02 06:58:05 +00:00
|
|
|
|
gtk_widget_set_can_default (button, TRUE);
|
2005-07-15 04:55:56 +00:00
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
|
|
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Presents an overwrite confirmation dialog; returns whether we should accept
|
|
|
|
|
* the filename.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
confirm_dialog_should_accept_filename (GtkFileChooserDefault *impl,
|
2005-07-15 13:50:54 +00:00
|
|
|
|
const gchar *file_part,
|
|
|
|
|
const gchar *folder_display_name)
|
2005-07-15 04:55:56 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
int response;
|
|
|
|
|
|
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (impl));
|
|
|
|
|
|
|
|
|
|
dialog = gtk_message_dialog_new (toplevel,
|
|
|
|
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
|
GTK_MESSAGE_QUESTION,
|
|
|
|
|
GTK_BUTTONS_NONE,
|
2013-07-18 02:37:50 +00:00
|
|
|
|
_("A file named “%s” already exists. Do you want to replace it?"),
|
2005-07-15 04:55:56 +00:00
|
|
|
|
file_part);
|
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
2013-07-18 02:37:50 +00:00
|
|
|
|
_("The file already exists in “%s”. Replacing it will "
|
2005-07-15 13:50:54 +00:00
|
|
|
|
"overwrite its contents."),
|
|
|
|
|
folder_display_name);
|
2005-07-15 04:55:56 +00:00
|
|
|
|
|
2013-06-24 23:28:53 +00:00
|
|
|
|
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_CANCEL);
|
|
|
|
|
add_custom_button_to_dialog (GTK_DIALOG (dialog), _("_Replace"), GTK_RESPONSE_ACCEPT);
|
2008-03-13 14:09:02 +00:00
|
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
|
|
|
|
GTK_RESPONSE_ACCEPT,
|
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
|
-1);
|
2005-07-15 13:50:54 +00:00
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
2008-03-13 14:09:02 +00:00
|
|
|
|
|
2010-08-24 14:10:38 +00:00
|
|
|
|
if (gtk_window_has_group (toplevel))
|
|
|
|
|
gtk_window_group_add_window (gtk_window_get_group (toplevel),
|
|
|
|
|
GTK_WINDOW (dialog));
|
2005-08-15 18:17:01 +00:00
|
|
|
|
|
2005-07-15 04:55:56 +00:00
|
|
|
|
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
|
|
|
|
return (response == GTK_RESPONSE_ACCEPT);
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct GetDisplayNameData
|
2005-07-15 13:50:54 +00:00
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
gchar *file_part;
|
|
|
|
|
};
|
2005-07-15 13:50:54 +00:00
|
|
|
|
|
2011-07-13 21:04:54 +00:00
|
|
|
|
/* Every time we request a response explicitly, we need to save the selection to the recently-used list,
|
|
|
|
|
* as requesting a response means, "the dialog is confirmed".
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
request_response_and_add_to_recent_list (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit_by_name (impl, "response-requested");
|
|
|
|
|
add_selection_to_recent_list (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
confirmation_confirm_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
gboolean should_respond = FALSE;
|
|
|
|
|
struct GetDisplayNameData *data = user_data;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = data->impl->priv;
|
2005-07-15 13:50:54 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (cancellable != priv->should_respond_get_info_cancellable)
|
2005-07-15 13:50:54 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->should_respond_get_info_cancellable = NULL;
|
2005-07-15 13:50:54 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
if (cancelled)
|
2005-07-15 13:50:54 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
if (error)
|
|
|
|
|
/* Huh? Did the folder disappear? Let the caller deal with it */
|
|
|
|
|
should_respond = TRUE;
|
|
|
|
|
else
|
2008-06-10 00:39:35 +00:00
|
|
|
|
should_respond = confirm_dialog_should_accept_filename (data->impl, data->file_part, g_file_info_get_display_name (info));
|
2005-07-15 13:50:54 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
set_busy_cursor (data->impl, FALSE);
|
|
|
|
|
if (should_respond)
|
2011-07-13 21:04:54 +00:00
|
|
|
|
request_response_and_add_to_recent_list (data->impl);
|
2005-07-15 13:50:54 +00:00
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
out:
|
|
|
|
|
g_object_unref (data->impl);
|
|
|
|
|
g_free (data->file_part);
|
|
|
|
|
g_free (data);
|
2005-07-15 13:50:54 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2005-07-15 13:50:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-15 15:06:52 +00:00
|
|
|
|
/* Does overwrite confirmation if appropriate, and returns whether the dialog
|
|
|
|
|
* should respond. Can get the file part from the file list or the save entry.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
should_respond_after_confirm_overwrite (GtkFileChooserDefault *impl,
|
|
|
|
|
const gchar *file_part,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *parent_file)
|
2005-07-15 15:06:52 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2005-07-15 15:06:52 +00:00
|
|
|
|
GtkFileChooserConfirmation conf;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->do_overwrite_confirmation)
|
2005-07-15 15:06:52 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
conf = GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM;
|
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (impl, "confirm-overwrite", &conf);
|
|
|
|
|
|
|
|
|
|
switch (conf)
|
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM:
|
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
|
struct GetDisplayNameData *data;
|
2005-07-15 15:06:52 +00:00
|
|
|
|
|
|
|
|
|
g_assert (file_part != NULL);
|
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
data = g_new0 (struct GetDisplayNameData, 1);
|
|
|
|
|
data->impl = g_object_ref (impl);
|
|
|
|
|
data->file_part = g_strdup (file_part);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->should_respond_get_info_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->should_respond_get_info_cancellable);
|
2005-07-15 15:06:52 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->should_respond_get_info_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (priv->file_system, parent_file,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
"standard::display-name",
|
|
|
|
|
confirmation_confirm_get_info_cb,
|
|
|
|
|
data);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
set_busy_cursor (data->impl, TRUE);
|
|
|
|
|
return FALSE;
|
2005-07-15 15:06:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME:
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
case GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN:
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 20:47:54 +00:00
|
|
|
|
struct FileExistsData
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
gboolean file_exists_and_is_not_folder;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *parent_file;
|
|
|
|
|
GFile *file;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
2010-10-05 17:59:45 +00:00
|
|
|
|
name_entry_get_parent_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean parent_is_folder;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2006-09-03 20:47:54 +00:00
|
|
|
|
struct FileExistsData *data = user_data;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = data->impl;
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (cancellable != priv->should_respond_get_info_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->should_respond_get_info_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
set_busy_cursor (impl, FALSE);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (cancelled)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
|
parent_is_folder = FALSE;
|
|
|
|
|
else
|
2008-12-14 02:14:19 +00:00
|
|
|
|
parent_is_folder = _gtk_file_info_consider_as_directory (info);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (parent_is_folder)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
2011-01-21 18:37:35 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
request_response_and_add_to_recent_list (impl); /* even if the file doesn't exist, apps can make good use of that (e.g. Emacs) */
|
2011-01-21 18:37:35 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
|
|
|
|
if (data->file_exists_and_is_not_folder)
|
|
|
|
|
{
|
|
|
|
|
gboolean retval;
|
2009-05-15 19:29:25 +00:00
|
|
|
|
char *file_part;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2009-05-15 19:29:25 +00:00
|
|
|
|
/* Dup the string because the string may be modified
|
|
|
|
|
* depending on what clients do in the confirm-overwrite
|
|
|
|
|
* signal and this corrupts the pointer
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
file_part = g_strdup (_gtk_file_chooser_entry_get_file_part (GTK_FILE_CHOOSER_ENTRY (priv->location_entry)));
|
|
|
|
|
retval = should_respond_after_confirm_overwrite (impl, file_part, data->parent_file);
|
2009-05-15 19:29:25 +00:00
|
|
|
|
g_free (file_part);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
|
|
if (retval)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
request_response_and_add_to_recent_list (impl);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
request_response_and_add_to_recent_list (impl);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2006-05-01 21:41:12 +00:00
|
|
|
|
{
|
2011-01-21 18:37:35 +00:00
|
|
|
|
GError *mkdir_error = NULL;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2010-10-05 19:41:51 +00:00
|
|
|
|
/* In both cases (SELECT_FOLDER and CREATE_FOLDER), if you type
|
|
|
|
|
* "/blah/nonexistent" you *will* want a folder created.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
set_busy_cursor (impl, TRUE);
|
2011-01-21 18:37:35 +00:00
|
|
|
|
g_file_make_directory (data->file, NULL, &mkdir_error);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
set_busy_cursor (impl, FALSE);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2011-01-21 18:37:35 +00:00
|
|
|
|
if (!mkdir_error)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
request_response_and_add_to_recent_list (impl);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
error_creating_folder_dialog (impl, data->file, mkdir_error);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
2010-10-05 17:59:45 +00:00
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-01-21 18:37:35 +00:00
|
|
|
|
if (info)
|
|
|
|
|
{
|
|
|
|
|
/* The parent exists, but it's not a folder! Someone probably typed existing_file.txt/subfile.txt */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
error_with_file_under_nonfolder (impl, data->parent_file);
|
2011-01-21 18:37:35 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GError *error_copy;
|
|
|
|
|
|
|
|
|
|
/* The parent folder is not readable for some reason */
|
|
|
|
|
|
|
|
|
|
error_copy = g_error_copy (error);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
error_changing_folder_dialog (impl, data->parent_file, error_copy);
|
2011-01-21 18:37:35 +00:00
|
|
|
|
}
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_object_unref (data->impl);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->file);
|
|
|
|
|
g_object_unref (data->parent_file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
g_free (data);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-03 20:47:54 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file_exists_get_info_cb (GCancellable *cancellable,
|
|
|
|
|
GFileInfo *info,
|
|
|
|
|
const GError *error,
|
|
|
|
|
gpointer user_data)
|
2006-09-03 20:47:54 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean data_ownership_taken = FALSE;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2010-10-05 17:55:03 +00:00
|
|
|
|
gboolean file_exists;
|
|
|
|
|
gboolean is_folder;
|
2011-01-21 18:37:35 +00:00
|
|
|
|
gboolean needs_parent_check = FALSE;
|
2006-09-03 20:47:54 +00:00
|
|
|
|
struct FileExistsData *data = user_data;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = data->impl;
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2006-09-03 20:47:54 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (cancellable != priv->file_exists_get_info_cancellable)
|
2006-09-03 20:47:54 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->file_exists_get_info_cancellable = NULL;
|
2006-09-03 20:47:54 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
set_busy_cursor (impl, FALSE);
|
2006-09-03 20:47:54 +00:00
|
|
|
|
|
|
|
|
|
if (cancelled)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2010-10-05 17:55:03 +00:00
|
|
|
|
file_exists = (info != NULL);
|
|
|
|
|
is_folder = (file_exists && _gtk_file_info_consider_as_directory (info));
|
2006-09-03 20:47:54 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
2006-09-03 20:47:54 +00:00
|
|
|
|
{
|
2010-10-06 17:59:44 +00:00
|
|
|
|
if (is_folder)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
change_folder_and_display_error (impl, data->file, TRUE);
|
2010-10-06 17:59:44 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2011-01-21 18:37:35 +00:00
|
|
|
|
if (file_exists)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
request_response_and_add_to_recent_list (impl); /* user typed an existing filename; we are done */
|
2011-01-21 18:37:35 +00:00
|
|
|
|
else
|
|
|
|
|
needs_parent_check = TRUE; /* file doesn't exist; see if its parent exists */
|
2010-10-06 17:59:44 +00:00
|
|
|
|
}
|
2010-10-05 17:55:03 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2010-10-05 17:55:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (file_exists && !is_folder)
|
|
|
|
|
{
|
|
|
|
|
/* Oops, the user typed the name of an existing path which is not
|
|
|
|
|
* a folder
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
error_creating_folder_over_existing_file_dialog (impl, data->file,
|
2010-10-05 17:55:03 +00:00
|
|
|
|
g_error_copy (error));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-01-21 18:37:35 +00:00
|
|
|
|
needs_parent_check = TRUE;
|
2010-10-05 17:55:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2010-10-05 17:55:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (!file_exists)
|
|
|
|
|
{
|
2011-01-21 18:37:35 +00:00
|
|
|
|
needs_parent_check = TRUE;
|
2010-10-05 17:55:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (is_folder)
|
|
|
|
|
{
|
|
|
|
|
/* User typed a folder; we are done */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
request_response_and_add_to_recent_list (impl);
|
2010-10-05 17:55:03 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2013-05-23 08:00:36 +00:00
|
|
|
|
error_selecting_folder_over_existing_file_dialog (impl);
|
2010-10-05 17:55:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2010-10-05 17:55:03 +00:00
|
|
|
|
{
|
2010-10-06 17:59:44 +00:00
|
|
|
|
if (is_folder)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
change_folder_and_display_error (impl, data->file, TRUE);
|
2010-10-06 17:59:44 +00:00
|
|
|
|
else
|
2013-05-23 08:09:58 +00:00
|
|
|
|
if (!file_exists && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FILENAME_TOO_LONG))
|
|
|
|
|
error_filename_to_long_dialog (data->impl);
|
|
|
|
|
else
|
|
|
|
|
needs_parent_check = TRUE;
|
2006-09-03 20:47:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-10-05 17:55:03 +00:00
|
|
|
|
g_assert_not_reached();
|
|
|
|
|
}
|
2006-09-03 20:47:54 +00:00
|
|
|
|
|
2011-01-21 18:37:35 +00:00
|
|
|
|
if (needs_parent_check) {
|
|
|
|
|
/* check that everything up to the last path component exists (i.e. the parent) */
|
2006-09-03 20:47:54 +00:00
|
|
|
|
|
2010-10-05 17:55:03 +00:00
|
|
|
|
data->file_exists_and_is_not_folder = file_exists && !is_folder;
|
|
|
|
|
data_ownership_taken = TRUE;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->should_respond_get_info_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->should_respond_get_info_cancellable);
|
2006-09-03 20:47:54 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->should_respond_get_info_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (priv->file_system,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
data->parent_file,
|
|
|
|
|
"standard::type",
|
2010-10-05 17:59:45 +00:00
|
|
|
|
name_entry_get_parent_info_cb,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
data);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
set_busy_cursor (impl, TRUE);
|
2006-09-03 20:47:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (!data_ownership_taken)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (impl);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (data->file);
|
|
|
|
|
g_object_unref (data->parent_file);
|
2006-09-03 20:47:54 +00:00
|
|
|
|
g_free (data);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (cancellable);
|
2006-09-03 20:47:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-06-12 15:11:39 +00:00
|
|
|
|
static void
|
|
|
|
|
paste_text_received (GtkClipboard *clipboard,
|
|
|
|
|
const gchar *text,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2006-06-12 15:11:39 +00:00
|
|
|
|
|
|
|
|
|
if (!text)
|
|
|
|
|
return;
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file = g_file_new_for_uri (text);
|
2006-06-12 15:11:39 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!gtk_file_chooser_default_select_file (GTK_FILE_CHOOSER (impl), file, NULL))
|
2006-06-12 15:11:39 +00:00
|
|
|
|
location_popup_handler (impl, text);
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (file);
|
2006-06-12 15:11:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handler for the "location-popup-on-paste" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
location_popup_on_paste_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (impl),
|
|
|
|
|
GDK_SELECTION_CLIPBOARD);
|
|
|
|
|
gtk_clipboard_request_text (clipboard,
|
|
|
|
|
(GtkClipboardTextReceivedFunc) paste_text_received,
|
|
|
|
|
impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
/* Implementation for GtkFileChooserEmbed::should_respond() */
|
2011-07-12 16:35:57 +00:00
|
|
|
|
static void
|
|
|
|
|
add_selection_to_recent_list (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-07-12 16:35:57 +00:00
|
|
|
|
GSList *files;
|
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
|
|
files = gtk_file_chooser_default_get_files (GTK_FILE_CHOOSER (impl));
|
|
|
|
|
|
|
|
|
|
for (l = files; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GFile *file = l->data;
|
|
|
|
|
char *uri;
|
|
|
|
|
|
|
|
|
|
uri = g_file_get_uri (file);
|
|
|
|
|
if (uri)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_recent_manager_add_item (priv->recent_manager, uri);
|
2011-07-12 16:35:57 +00:00
|
|
|
|
g_free (uri);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
|
|
|
|
|
g_slist_free (files);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-08-12 03:07:01 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
GtkWidget *current_focus;
|
2011-07-12 16:35:57 +00:00
|
|
|
|
gboolean retval;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (impl));
|
|
|
|
|
g_assert (GTK_IS_WINDOW (toplevel));
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2011-07-12 16:35:57 +00:00
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
current_focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (current_focus == priv->browse_files_tree_view)
|
2004-08-12 03:07:01 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
/* The following array encodes what we do based on the priv->action and the
|
2005-06-10 05:54:28 +00:00
|
|
|
|
* number of files selected.
|
|
|
|
|
*/
|
|
|
|
|
typedef enum {
|
|
|
|
|
NOOP, /* Do nothing (don't respond) */
|
|
|
|
|
RESPOND, /* Respond immediately */
|
|
|
|
|
RESPOND_OR_SWITCH, /* Respond immediately if the selected item is a file; switch to it if it is a folder */
|
|
|
|
|
ALL_FILES, /* Respond only if everything selected is a file */
|
|
|
|
|
ALL_FOLDERS, /* Respond only if everything selected is a folder */
|
|
|
|
|
SAVE_ENTRY, /* Go to the code for handling the save entry */
|
|
|
|
|
NOT_REACHED /* Sanity check */
|
|
|
|
|
} ActionToTake;
|
|
|
|
|
static const ActionToTake what_to_do[4][3] = {
|
|
|
|
|
/* 0 selected 1 selected many selected */
|
|
|
|
|
/* ACTION_OPEN */ { NOOP, RESPOND_OR_SWITCH, ALL_FILES },
|
|
|
|
|
/* ACTION_SAVE */ { SAVE_ENTRY, RESPOND_OR_SWITCH, NOT_REACHED },
|
|
|
|
|
/* ACTION_SELECT_FOLDER */ { RESPOND, ALL_FOLDERS, ALL_FOLDERS },
|
|
|
|
|
/* ACTION_CREATE_FOLDER */ { SAVE_ENTRY, ALL_FOLDERS, NOT_REACHED }
|
|
|
|
|
};
|
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
int num_selected;
|
|
|
|
|
gboolean all_files, all_folders;
|
2005-06-10 05:54:28 +00:00
|
|
|
|
int k;
|
|
|
|
|
ActionToTake action;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
file_list:
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->action >= GTK_FILE_CHOOSER_ACTION_OPEN && priv->action <= GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_SEARCH)
|
2011-07-12 16:35:57 +00:00
|
|
|
|
{
|
|
|
|
|
retval = search_should_respond (impl);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_RECENT)
|
2011-06-30 21:23:12 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2011-06-30 21:23:12 +00:00
|
|
|
|
goto save_entry;
|
|
|
|
|
else
|
2011-07-12 16:35:57 +00:00
|
|
|
|
{
|
|
|
|
|
retval = recent_should_respond (impl);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2011-06-30 21:23:12 +00:00
|
|
|
|
}
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
selection_check (impl, &num_selected, &all_files, &all_folders);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2005-06-10 05:54:28 +00:00
|
|
|
|
if (num_selected > 2)
|
|
|
|
|
k = 2;
|
|
|
|
|
else
|
|
|
|
|
k = num_selected;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
action = what_to_do [priv->action] [k];
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
|
|
|
|
switch (action)
|
2004-09-22 20:17:53 +00:00
|
|
|
|
{
|
2005-06-10 05:54:28 +00:00
|
|
|
|
case NOOP:
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
case RESPOND:
|
2011-07-12 16:35:57 +00:00
|
|
|
|
retval = TRUE;
|
|
|
|
|
goto out;
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
|
|
|
|
case RESPOND_OR_SWITCH:
|
|
|
|
|
g_assert (num_selected == 1);
|
|
|
|
|
|
|
|
|
|
if (all_folders)
|
2004-12-03 03:42:48 +00:00
|
|
|
|
{
|
2005-06-10 05:54:28 +00:00
|
|
|
|
switch_to_selected_folder (impl);
|
|
|
|
|
return FALSE;
|
2004-12-03 03:42:48 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2011-07-12 16:35:57 +00:00
|
|
|
|
{
|
|
|
|
|
retval = should_respond_after_confirm_overwrite (impl,
|
|
|
|
|
get_display_name_from_file_list (impl),
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->current_folder);
|
2011-07-12 16:35:57 +00:00
|
|
|
|
goto out;
|
|
|
|
|
}
|
2004-08-12 03:07:01 +00:00
|
|
|
|
else
|
2011-07-12 16:35:57 +00:00
|
|
|
|
{
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2005-06-10 05:54:28 +00:00
|
|
|
|
case ALL_FILES:
|
2011-07-12 16:35:57 +00:00
|
|
|
|
retval = all_files;
|
|
|
|
|
goto out;
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
|
|
|
|
case ALL_FOLDERS:
|
2011-07-12 16:35:57 +00:00
|
|
|
|
retval = all_folders;
|
|
|
|
|
goto out;
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
|
|
|
|
case SAVE_ENTRY:
|
|
|
|
|
goto save_entry;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
2004-08-12 03:07:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if ((priv->location_entry != NULL) && (current_focus == priv->location_entry))
|
2004-03-07 08:15:09 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2005-06-14 23:30:12 +00:00
|
|
|
|
gboolean is_well_formed, is_empty, is_file_part_empty;
|
2004-08-12 03:07:01 +00:00
|
|
|
|
gboolean is_folder;
|
2005-06-10 05:54:28 +00:00
|
|
|
|
GtkFileChooserEntry *entry;
|
|
|
|
|
GError *error;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
save_entry:
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
|
|
|
|
|
|| ((priv->action == GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
|
|
|
&& priv->location_mode == LOCATION_MODE_FILENAME_ENTRY));
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
entry = GTK_FILE_CHOOSER_ENTRY (priv->location_entry);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
check_save_entry (impl, &file, &is_well_formed, &is_empty, &is_file_part_empty, &is_folder);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2010-04-05 17:57:33 +00:00
|
|
|
|
if (!is_well_formed)
|
2011-06-30 21:23:12 +00:00
|
|
|
|
{
|
|
|
|
|
if (!is_empty
|
2013-04-12 03:44:19 +00:00
|
|
|
|
&& priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
&& priv->operation_mode == OPERATION_MODE_RECENT)
|
2011-07-01 19:36:52 +00:00
|
|
|
|
{
|
|
|
|
|
path_bar_set_mode (impl, PATH_BAR_ERROR_NO_FOLDER);
|
|
|
|
|
#if 0
|
|
|
|
|
/* We'll #ifdef this out, as the fucking treeview selects its first row,
|
|
|
|
|
* thus changing our assumption that no selection is present - setting
|
|
|
|
|
* a selection causes the error message from path_bar_set_mode() to go away,
|
|
|
|
|
* but we want the user to see that message!
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->browse_files_tree_view);
|
2011-07-01 19:36:52 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
/* FIXME: else show an "invalid filename" error as the pathbar mode? */
|
2011-06-30 21:23:12 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2010-04-05 17:57:33 +00:00
|
|
|
|
|
|
|
|
|
if (is_empty)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2011-06-30 21:23:12 +00:00
|
|
|
|
{
|
2011-07-01 19:36:52 +00:00
|
|
|
|
path_bar_set_mode (impl, PATH_BAR_ERROR_NO_FILENAME);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->location_entry);
|
2011-06-30 21:23:12 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2010-04-05 17:57:33 +00:00
|
|
|
|
|
|
|
|
|
goto file_list;
|
|
|
|
|
}
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_assert (file != NULL);
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
|
|
|
|
error = NULL;
|
2004-08-12 03:07:01 +00:00
|
|
|
|
if (is_folder)
|
2004-03-05 00:10:59 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2005-06-10 05:54:28 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
change_folder_and_display_error (impl, file, TRUE);
|
2005-06-10 05:54:28 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2005-06-10 05:54:28 +00:00
|
|
|
|
{
|
2005-06-14 23:30:12 +00:00
|
|
|
|
/* The folder already exists, so we do not need to create it.
|
|
|
|
|
* Just respond to terminate the dialog.
|
|
|
|
|
*/
|
2005-06-10 05:54:28 +00:00
|
|
|
|
retval = TRUE;
|
|
|
|
|
}
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2005-01-19 21:05:15 +00:00
|
|
|
|
{
|
2006-09-03 20:47:54 +00:00
|
|
|
|
struct FileExistsData *data;
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
2010-10-05 17:55:03 +00:00
|
|
|
|
/* We need to check whether file exists and whether it is a folder -
|
|
|
|
|
* the GtkFileChooserEntry *does* report is_folder==FALSE as a false
|
|
|
|
|
* negative (it doesn't know yet if your last path component is a
|
|
|
|
|
* folder).
|
|
|
|
|
*/
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
2006-09-03 20:47:54 +00:00
|
|
|
|
data = g_new0 (struct FileExistsData, 1);
|
|
|
|
|
data->impl = g_object_ref (impl);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
data->file = g_object_ref (file);
|
2011-11-05 02:53:32 +00:00
|
|
|
|
data->parent_file = _gtk_file_chooser_entry_get_current_folder (entry);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->file_exists_get_info_cancellable)
|
|
|
|
|
g_cancellable_cancel (priv->file_exists_get_info_cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->file_exists_get_info_cancellable =
|
|
|
|
|
_gtk_file_system_get_info (priv->file_system, file,
|
2008-06-13 16:47:41 +00:00
|
|
|
|
"standard::type",
|
|
|
|
|
file_exists_get_info_cb,
|
|
|
|
|
data);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2006-09-03 20:47:54 +00:00
|
|
|
|
set_busy_cursor (impl, TRUE);
|
2005-06-10 05:54:28 +00:00
|
|
|
|
|
|
|
|
|
if (error != NULL)
|
|
|
|
|
g_error_free (error);
|
2005-01-19 21:05:15 +00:00
|
|
|
|
}
|
2004-08-12 03:07:01 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (file);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->toplevel_last_focus_widget == priv->browse_files_tree_view)
|
2004-09-17 18:13:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* The focus is on a dialog's action area button, *and* the widget that
|
|
|
|
|
* was focused immediately before it is the file list.
|
|
|
|
|
*/
|
|
|
|
|
goto file_list;
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->operation_mode == OPERATION_MODE_SEARCH && priv->toplevel_last_focus_widget == priv->search_entry)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
search_entry_activate_cb (GTK_ENTRY (priv->search_entry), impl);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->location_entry && priv->toplevel_last_focus_widget == priv->location_entry)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
{
|
|
|
|
|
/* The focus is on a dialog's action area button, *and* the widget that
|
|
|
|
|
* was focused immediately before it is the location entry.
|
|
|
|
|
*/
|
|
|
|
|
goto save_entry;
|
|
|
|
|
}
|
2004-08-12 03:07:01 +00:00
|
|
|
|
else
|
2004-09-17 18:13:26 +00:00
|
|
|
|
/* The focus is on a dialog's action area button or something else */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-09-17 18:13:26 +00:00
|
|
|
|
goto save_entry;
|
|
|
|
|
else
|
|
|
|
|
goto file_list;
|
2011-07-12 16:35:57 +00:00
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
|
|
if (retval)
|
|
|
|
|
add_selection_to_recent_list (impl);
|
|
|
|
|
|
|
|
|
|
return retval;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-08 22:21:47 +00:00
|
|
|
|
/* Implementation for GtkFileChooserEmbed::initial_focus() */
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-03-08 22:21:47 +00:00
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_mode == LOCATION_MODE_PATH_BAR
|
|
|
|
|
|| priv->operation_mode == OPERATION_MODE_RECENT)
|
|
|
|
|
widget = priv->browse_files_tree_view;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
widget = priv->location_entry;
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
|
|
|
|
widget = priv->location_entry;
|
2004-03-08 22:21:47 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
widget = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
g_assert (widget != NULL);
|
2004-03-08 22:21:47 +00:00
|
|
|
|
gtk_widget_grab_focus (widget);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
/* Callback used from gtk_tree_selection_selected_foreach(); gets the selected GFiles */
|
2003-07-23 15:31:10 +00:00
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
search_selected_foreach_get_file_cb (GtkTreeModel *model,
|
2007-05-02 22:51:43 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2007-05-02 22:51:43 +00:00
|
|
|
|
GSList **list;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
list = data;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2009-06-30 19:24:52 +00:00
|
|
|
|
gtk_tree_model_get (model, iter, MODEL_COL_FILE, &file, -1);
|
2011-04-01 18:44:10 +00:00
|
|
|
|
*list = g_slist_prepend (*list, file); /* The file already has a new ref courtesy of gtk_tree_model_get(); this will be unreffed by the caller */
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
/* Constructs a list of the selected paths in search mode */
|
|
|
|
|
static GSList *
|
2008-06-10 00:39:35 +00:00
|
|
|
|
search_get_selected_files (GtkFileChooserDefault *impl)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
GSList *result;
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
|
|
|
|
result = NULL;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_tree_selection_selected_foreach (selection, search_selected_foreach_get_file_cb, &result);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
result = g_slist_reverse (result);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Called from ::should_respond(). We return whether there are selected files
|
|
|
|
|
* in the search list.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
search_should_respond (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->operation_mode == OPERATION_MODE_SEARCH);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2007-05-02 22:51:43 +00:00
|
|
|
|
return (gtk_tree_selection_count_selected_rows (selection) != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Adds one hit from the search engine to the search_model */
|
|
|
|
|
static void
|
|
|
|
|
search_add_hit (GtkFileChooserDefault *impl,
|
|
|
|
|
gchar *uri)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
file = g_file_new_for_uri (uri);
|
2008-09-22 14:25:45 +00:00
|
|
|
|
if (!file)
|
|
|
|
|
return;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!g_file_is_native (file))
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
g_object_unref (file);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_add_and_query_file (priv->search_model,
|
2009-06-24 20:43:14 +00:00
|
|
|
|
file,
|
|
|
|
|
MODEL_ATTRIBUTES);
|
2009-06-30 19:24:52 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (file);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used from GtkSearchEngine when we get new hits */
|
|
|
|
|
static void
|
|
|
|
|
search_engine_hits_added_cb (GtkSearchEngine *engine,
|
|
|
|
|
GList *hits,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
|
|
|
|
|
for (l = hits; l; l = l->next)
|
|
|
|
|
search_add_hit (impl, (gchar*)l->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used from GtkSearchEngine when the query is done running */
|
|
|
|
|
static void
|
|
|
|
|
search_engine_finished_cb (GtkSearchEngine *engine,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
|
2007-05-11 19:33:38 +00:00
|
|
|
|
#if 0
|
|
|
|
|
/* EB: setting the model here will avoid loads of row events,
|
|
|
|
|
* but it'll make the search look like blocked.
|
|
|
|
|
*/
|
2013-04-11 21:47:38 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view),
|
|
|
|
|
GTK_TREE_MODEL (impl->search_model));
|
2011-07-26 21:43:36 +00:00
|
|
|
|
file_list_set_sort_column_ids (impl);
|
2007-05-11 19:33:38 +00:00
|
|
|
|
#endif
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2007-05-11 19:33:38 +00:00
|
|
|
|
/* FMQ: if search was empty, say that we got no hits */
|
2007-05-02 22:51:43 +00:00
|
|
|
|
set_busy_cursor (impl, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Displays a generic error when we cannot create a GtkSearchEngine.
|
|
|
|
|
* It would be better if _gtk_search_engine_new() gave us a GError
|
|
|
|
|
* with a better message, but it doesn't do that right now.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
search_error_could_not_create_client (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
error_message (impl,
|
|
|
|
|
_("Could not start the search process"),
|
|
|
|
|
_("The program was not able to create a connection to the indexer "
|
|
|
|
|
"daemon. Please make sure it is running."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
search_engine_error_cb (GtkSearchEngine *engine,
|
|
|
|
|
const gchar *message,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
|
2007-05-11 19:22:38 +00:00
|
|
|
|
search_stop_searching (impl, TRUE);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
error_message (impl, _("Could not send the search request"), message);
|
|
|
|
|
|
|
|
|
|
set_busy_cursor (impl, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Frees the data in the search_model */
|
|
|
|
|
static void
|
|
|
|
|
search_clear_model (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean remove_from_treeview)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (!priv->search_model)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->search_model);
|
|
|
|
|
priv->search_model = NULL;
|
2007-05-11 19:37:26 +00:00
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
if (remove_from_treeview)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view), NULL);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Stops any ongoing searches; does not touch the search_model */
|
|
|
|
|
static void
|
2007-05-11 19:22:38 +00:00
|
|
|
|
search_stop_searching (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean remove_query)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (remove_query && priv->search_query)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->search_query);
|
|
|
|
|
priv->search_query = NULL;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
2007-05-11 19:22:38 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->search_engine)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_search_engine_stop (priv->search_engine);
|
2007-09-25 20:59:15 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->search_engine);
|
|
|
|
|
priv->search_engine = NULL;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Creates the search_model and puts it in the tree view */
|
|
|
|
|
static void
|
|
|
|
|
search_setup_model (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->search_model == NULL);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->search_model = _gtk_file_system_model_new (file_system_model_set,
|
2009-06-24 20:43:14 +00:00
|
|
|
|
impl,
|
2009-09-11 19:28:36 +00:00
|
|
|
|
MODEL_COLUMN_TYPES);
|
2009-06-24 20:43:14 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->search_model),
|
2009-06-30 19:24:52 +00:00
|
|
|
|
MODEL_COL_NAME,
|
|
|
|
|
name_sort_func,
|
2007-05-14 10:16:07 +00:00
|
|
|
|
impl, NULL);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->search_model),
|
2009-06-30 19:24:52 +00:00
|
|
|
|
MODEL_COL_MTIME,
|
|
|
|
|
mtime_sort_func,
|
2007-05-14 10:16:07 +00:00
|
|
|
|
impl, NULL);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->search_model),
|
2009-06-30 19:24:52 +00:00
|
|
|
|
MODEL_COL_SIZE,
|
|
|
|
|
size_sort_func,
|
2008-09-22 14:25:45 +00:00
|
|
|
|
impl, NULL);
|
2009-06-12 22:31:28 +00:00
|
|
|
|
set_sort_column (impl);
|
2007-05-11 19:37:26 +00:00
|
|
|
|
|
2007-05-11 19:33:38 +00:00
|
|
|
|
/* EB: setting the model here will make the hits list update feel
|
|
|
|
|
* more "alive" than setting the model at the end of the search
|
|
|
|
|
* run
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
|
|
|
|
GTK_TREE_MODEL (priv->search_model));
|
2011-07-26 21:43:36 +00:00
|
|
|
|
file_list_set_sort_column_ids (impl);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Creates a new query with the specified text and launches it */
|
|
|
|
|
static void
|
|
|
|
|
search_start_query (GtkFileChooserDefault *impl,
|
|
|
|
|
const gchar *query_text)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2007-05-11 19:22:38 +00:00
|
|
|
|
search_stop_searching (impl, FALSE);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
search_clear_model (impl, TRUE);
|
|
|
|
|
search_setup_model (impl);
|
|
|
|
|
set_busy_cursor (impl, TRUE);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->search_engine == NULL)
|
|
|
|
|
priv->search_engine = _gtk_search_engine_new ();
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->search_engine)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
|
|
|
|
set_busy_cursor (impl, FALSE);
|
|
|
|
|
search_error_could_not_create_client (impl); /* lame; we don't get an error code or anything */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->search_query)
|
2007-05-11 19:22:38 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->search_query = _gtk_query_new ();
|
|
|
|
|
_gtk_query_set_text (priv->search_query, query_text);
|
2007-05-11 19:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_search_engine_set_query (priv->search_engine, priv->search_query);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_signal_connect (priv->search_engine, "hits-added",
|
2007-05-02 22:51:43 +00:00
|
|
|
|
G_CALLBACK (search_engine_hits_added_cb), impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_signal_connect (priv->search_engine, "finished",
|
2007-05-02 22:51:43 +00:00
|
|
|
|
G_CALLBACK (search_engine_finished_cb), impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_signal_connect (priv->search_engine, "error",
|
2007-05-02 22:51:43 +00:00
|
|
|
|
G_CALLBACK (search_engine_error_cb), impl);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_search_engine_start (priv->search_engine);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 19:22:38 +00:00
|
|
|
|
/* Callback used when the user presses Enter while typing on the search
|
|
|
|
|
* entry; starts the query
|
|
|
|
|
*/
|
2007-05-02 22:51:43 +00:00
|
|
|
|
static void
|
|
|
|
|
search_entry_activate_cb (GtkEntry *entry,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
const char *text;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
|
2007-05-02 22:51:43 +00:00
|
|
|
|
if (strlen (text) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-05-11 19:22:38 +00:00
|
|
|
|
/* reset any existing query object */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->search_query)
|
2007-05-11 19:22:38 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->search_query);
|
|
|
|
|
priv->search_query = NULL;
|
2007-05-11 19:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
search_start_query (impl, text);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-16 16:56:34 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
focus_entry_idle_cb (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2012-07-28 12:52:40 +00:00
|
|
|
|
gdk_threads_enter ();
|
2010-11-16 16:56:34 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_source_destroy (priv->focus_entry_idle);
|
|
|
|
|
priv->focus_entry_idle = NULL;
|
2010-11-16 16:56:34 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->search_entry)
|
|
|
|
|
gtk_widget_grab_focus (priv->search_entry);
|
2010-11-16 16:56:34 +00:00
|
|
|
|
|
2012-07-28 12:52:40 +00:00
|
|
|
|
gdk_threads_leave ();
|
2010-11-16 16:56:34 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
focus_search_entry_in_idle (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2010-11-16 16:56:34 +00:00
|
|
|
|
/* bgo#634558 - When the user clicks on the Search entry in the shortcuts
|
|
|
|
|
* pane, we get a selection-changed signal and we set up the search widgets.
|
|
|
|
|
* However, gtk_tree_view_button_press() focuses the treeview *after* making
|
|
|
|
|
* the change to the selection. So, we need to re-focus the search entry
|
|
|
|
|
* after the treeview has finished doing its work; we'll do that in an idle
|
|
|
|
|
* handler.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->focus_entry_idle)
|
|
|
|
|
priv->focus_entry_idle = add_idle_while_impl_is_alive (impl, G_CALLBACK (focus_entry_idle_cb));
|
2010-11-16 16:56:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
/* Hides the path bar and creates the search entry */
|
|
|
|
|
static void
|
|
|
|
|
search_setup_widgets (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
priv->search_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2010-10-31 17:07:20 +00:00
|
|
|
|
|
2011-07-01 19:36:52 +00:00
|
|
|
|
path_bar_update (impl);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->search_entry = gtk_entry_new ();
|
|
|
|
|
g_signal_connect (priv->search_entry, "activate",
|
2007-05-02 22:51:43 +00:00
|
|
|
|
G_CALLBACK (search_entry_activate_cb),
|
|
|
|
|
impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->search_hbox), priv->search_entry, TRUE, TRUE, 0);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2007-05-11 19:22:38 +00:00
|
|
|
|
/* if there already is a query, restart it */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->search_query)
|
2007-05-11 19:22:38 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gchar *query = _gtk_query_get_text (priv->search_query);
|
2007-05-11 19:22:38 +00:00
|
|
|
|
|
|
|
|
|
if (query)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->search_entry), query);
|
2007-05-11 19:22:38 +00:00
|
|
|
|
search_start_query (impl, query);
|
|
|
|
|
|
|
|
|
|
g_free (query);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->search_query);
|
|
|
|
|
priv->search_query = NULL;
|
2007-05-11 19:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
/* Box for search widgets */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->browse_path_bar_hbox), priv->search_hbox, TRUE, TRUE, 0);
|
|
|
|
|
gtk_widget_show_all (priv->search_hbox);
|
|
|
|
|
gtk_size_group_add_widget (GTK_SIZE_GROUP (priv->browse_path_bar_size_group), priv->search_hbox);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
|
|
|
|
/* Hide the location widgets temporarily */
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_hide (priv->location_button);
|
|
|
|
|
gtk_widget_hide (priv->location_entry_box);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-16 16:56:34 +00:00
|
|
|
|
focus_search_entry_in_idle (impl);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
|
|
|
|
/* FMQ: hide the filter combo? */
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 19:26:32 +00:00
|
|
|
|
/*
|
|
|
|
|
* Recent files support
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Frees the data in the recent_model */
|
|
|
|
|
static void
|
|
|
|
|
recent_clear_model (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean remove_from_treeview)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (!priv->recent_model)
|
2007-05-11 19:26:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2007-08-23 10:48:28 +00:00
|
|
|
|
if (remove_from_treeview)
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view), NULL);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->recent_model);
|
|
|
|
|
priv->recent_model = NULL;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Stops any ongoing loading of the recent files list; does
|
|
|
|
|
* not touch the recent_model
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
recent_stop_loading (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->load_recent_id)
|
2007-05-11 19:26:32 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_source_remove (priv->load_recent_id);
|
|
|
|
|
priv->load_recent_id = 0;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
recent_setup_model (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->recent_model == NULL);
|
2009-06-24 21:04:04 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->recent_model = _gtk_file_system_model_new (file_system_model_set,
|
2009-06-24 21:04:04 +00:00
|
|
|
|
impl,
|
2009-09-11 19:28:36 +00:00
|
|
|
|
MODEL_COLUMN_TYPES);
|
2009-06-24 21:04:04 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_set_filter (priv->recent_model,
|
|
|
|
|
priv->current_filter);
|
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->recent_model),
|
2009-06-30 19:24:52 +00:00
|
|
|
|
MODEL_COL_NAME,
|
|
|
|
|
name_sort_func,
|
2007-05-14 10:16:07 +00:00
|
|
|
|
impl, NULL);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->recent_model),
|
2009-06-30 19:24:52 +00:00
|
|
|
|
MODEL_COL_SIZE,
|
|
|
|
|
size_sort_func,
|
|
|
|
|
impl, NULL);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->recent_model),
|
2009-06-30 19:24:52 +00:00
|
|
|
|
MODEL_COL_MTIME,
|
|
|
|
|
mtime_sort_func,
|
2007-05-11 19:42:40 +00:00
|
|
|
|
impl, NULL);
|
2009-06-12 22:31:28 +00:00
|
|
|
|
set_sort_column (impl);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
GList *items;
|
|
|
|
|
} RecentLoadData;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
recent_idle_cleanup (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
RecentLoadData *load_data = data;
|
2007-05-11 19:33:38 +00:00
|
|
|
|
GtkFileChooserDefault *impl = load_data->impl;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
|
|
|
|
GTK_TREE_MODEL (priv->recent_model));
|
2011-07-26 21:43:36 +00:00
|
|
|
|
file_list_set_sort_column_ids (impl);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->recent_model), MODEL_COL_MTIME, GTK_SORT_DESCENDING);
|
2007-08-23 10:48:28 +00:00
|
|
|
|
|
2007-05-11 19:33:38 +00:00
|
|
|
|
set_busy_cursor (impl, FALSE);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->load_recent_id = 0;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
|
|
|
|
g_free (load_data);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 17:22:42 +00:00
|
|
|
|
/* Populates the file system model with the GtkRecentInfo* items in the provided list; frees the items */
|
|
|
|
|
static void
|
|
|
|
|
populate_model_with_recent_items (GtkFileChooserDefault *impl, GList *items)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-06-29 17:22:42 +00:00
|
|
|
|
gint limit;
|
|
|
|
|
GList *l;
|
|
|
|
|
int n;
|
|
|
|
|
|
2013-07-08 20:42:44 +00:00
|
|
|
|
limit = DEFAULT_RECENT_FILES_LIMIT;
|
2011-06-29 17:22:42 +00:00
|
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
|
|
|
|
|
|
for (l = items; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GtkRecentInfo *info = l->data;
|
|
|
|
|
GFile *file;
|
|
|
|
|
|
|
|
|
|
file = g_file_new_for_uri (gtk_recent_info_get_uri (info));
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_add_and_query_file (priv->recent_model,
|
2011-06-29 17:22:42 +00:00
|
|
|
|
file,
|
|
|
|
|
MODEL_ATTRIBUTES);
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
|
|
|
|
|
n++;
|
|
|
|
|
if (limit != -1 && n >= limit)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
populate_model_with_folders (GtkFileChooserDefault *impl, GList *items)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2011-06-29 17:22:42 +00:00
|
|
|
|
GList *folders;
|
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
|
|
folders = _gtk_file_chooser_extract_recent_folders (items);
|
|
|
|
|
|
|
|
|
|
for (l = folders; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GFile *folder = l->data;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_add_and_query_file (priv->recent_model,
|
2011-06-29 17:22:42 +00:00
|
|
|
|
folder,
|
|
|
|
|
MODEL_ATTRIBUTES);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_list_foreach (folders, (GFunc) g_object_unref, NULL);
|
|
|
|
|
g_list_free (folders);
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 19:26:32 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
recent_idle_load (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
RecentLoadData *load_data = data;
|
|
|
|
|
GtkFileChooserDefault *impl = load_data->impl;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (!priv->recent_manager)
|
2007-05-11 19:26:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
load_data->items = gtk_recent_manager_get_items (priv->recent_manager);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
if (!load_data->items)
|
2011-08-26 16:38:11 +00:00
|
|
|
|
return FALSE;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
2011-08-26 16:38:11 +00:00
|
|
|
|
populate_model_with_recent_items (impl, load_data->items);
|
|
|
|
|
else
|
|
|
|
|
populate_model_with_folders (impl, load_data->items);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2011-08-26 16:38:11 +00:00
|
|
|
|
g_list_foreach (load_data->items, (GFunc) gtk_recent_info_unref, NULL);
|
|
|
|
|
g_list_free (load_data->items);
|
|
|
|
|
load_data->items = NULL;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2009-06-24 21:04:04 +00:00
|
|
|
|
return FALSE;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
recent_start_loading (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
RecentLoadData *load_data;
|
|
|
|
|
|
|
|
|
|
recent_stop_loading (impl);
|
|
|
|
|
recent_clear_model (impl, TRUE);
|
|
|
|
|
recent_setup_model (impl);
|
|
|
|
|
set_busy_cursor (impl, TRUE);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->load_recent_id == 0);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
|
|
|
|
load_data = g_new (RecentLoadData, 1);
|
|
|
|
|
load_data->impl = impl;
|
|
|
|
|
load_data->items = NULL;
|
|
|
|
|
|
|
|
|
|
/* begin lazy loading the recent files into the model */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->load_recent_id = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE + 30,
|
2007-05-11 19:26:32 +00:00
|
|
|
|
recent_idle_load,
|
|
|
|
|
load_data,
|
|
|
|
|
recent_idle_cleanup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
|
recent_selected_foreach_get_file_cb (GtkTreeModel *model,
|
2007-05-11 19:26:32 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GSList **list;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
|
|
|
|
list = data;
|
|
|
|
|
|
2009-06-30 19:24:52 +00:00
|
|
|
|
gtk_tree_model_get (model, iter, MODEL_COL_FILE, &file, -1);
|
|
|
|
|
*list = g_slist_prepend (*list, file);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 19:26:32 +00:00
|
|
|
|
/* Constructs a list of the selected paths in recent files mode */
|
|
|
|
|
static GSList *
|
2008-06-10 00:39:35 +00:00
|
|
|
|
recent_get_selected_files (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
GSList *result;
|
|
|
|
|
GtkTreeSelection *selection;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2007-05-11 19:26:32 +00:00
|
|
|
|
result = NULL;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2008-06-10 00:39:35 +00:00
|
|
|
|
gtk_tree_selection_selected_foreach (selection, recent_selected_foreach_get_file_cb, &result);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
result = g_slist_reverse (result);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2007-05-11 19:26:32 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2007-05-11 19:26:32 +00:00
|
|
|
|
/* Called from ::should_respond(). We return whether there are selected
|
|
|
|
|
* files in the recent files list.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
recent_should_respond (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_assert (priv->operation_mode == OPERATION_MODE_RECENT);
|
2010-03-09 04:56:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2007-05-11 19:26:32 +00:00
|
|
|
|
return (gtk_tree_selection_count_selected_rows (selection) != 0);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-01 00:53:59 +00:00
|
|
|
|
static void
|
2007-05-02 22:51:43 +00:00
|
|
|
|
set_current_filter (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkFileFilter *filter)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->current_filter != filter)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
|
|
|
|
int filter_index;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2007-05-02 22:51:43 +00:00
|
|
|
|
/* NULL filters are allowed to reset to non-filtered status
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
filter_index = g_slist_index (priv->filters, filter);
|
|
|
|
|
if (priv->filters && filter && filter_index < 0)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
return;
|
2006-07-18 16:36:19 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->current_filter)
|
|
|
|
|
g_object_unref (priv->current_filter);
|
|
|
|
|
priv->current_filter = filter;
|
|
|
|
|
if (priv->current_filter)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_ref_sink (priv->current_filter);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
}
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->filters)
|
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->filter_combo),
|
2003-10-23 05:10:47 +00:00
|
|
|
|
filter_index);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->browse_files_model)
|
2012-07-15 04:39:02 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_set_filter (priv->browse_files_model, priv->current_filter);
|
|
|
|
|
_gtk_file_system_model_clear_cache (priv->browse_files_model, MODEL_COL_IS_SENSITIVE);
|
2012-07-15 04:39:02 +00:00
|
|
|
|
}
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->search_model)
|
2012-07-15 04:39:02 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_set_filter (priv->search_model, filter);
|
|
|
|
|
_gtk_file_system_model_clear_cache (priv->search_model, MODEL_COL_IS_SENSITIVE);
|
2012-07-15 04:39:02 +00:00
|
|
|
|
}
|
2004-09-17 18:13:26 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->recent_model)
|
2012-07-15 04:39:02 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
_gtk_file_system_model_set_filter (priv->recent_model, filter);
|
|
|
|
|
_gtk_file_system_model_clear_cache (priv->recent_model, MODEL_COL_IS_SENSITIVE);
|
2012-07-15 04:39:02 +00:00
|
|
|
|
}
|
2011-07-27 23:03:22 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
g_object_notify (G_OBJECT (impl), "filter");
|
2003-10-09 01:12:24 +00:00
|
|
|
|
}
|
2003-07-23 15:31:10 +00:00
|
|
|
|
}
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
static void
|
2003-10-23 05:10:47 +00:00
|
|
|
|
filter_combo_changed (GtkComboBox *combo_box,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2003-10-23 05:10:47 +00:00
|
|
|
|
gint new_index = gtk_combo_box_get_active (combo_box);
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileFilter *new_filter = g_slist_nth_data (priv->filters, new_index);
|
2011-07-27 23:03:22 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
set_current_filter (impl, new_filter);
|
|
|
|
|
}
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
check_preview_change (GtkFileChooserDefault *impl)
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-03-25 21:52:04 +00:00
|
|
|
|
GtkTreePath *cursor_path;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *new_file;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
char *new_display_name;
|
|
|
|
|
GtkTreeModel *model;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_tree_view_get_cursor (GTK_TREE_VIEW (priv->browse_files_tree_view), &cursor_path, NULL);
|
|
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
2007-05-02 22:51:43 +00:00
|
|
|
|
if (cursor_path)
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
2009-06-30 19:24:52 +00:00
|
|
|
|
GtkTreeIter iter;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2009-06-30 19:24:52 +00:00
|
|
|
|
gtk_tree_model_get_iter (model, &iter, cursor_path);
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
|
MODEL_COL_FILE, &new_file,
|
|
|
|
|
MODEL_COL_NAME, &new_display_name,
|
|
|
|
|
-1);
|
|
|
|
|
|
|
|
|
|
gtk_tree_path_free (cursor_path);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
new_file = NULL;
|
|
|
|
|
new_display_name = NULL;
|
2003-07-23 22:30:32 +00:00
|
|
|
|
}
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (new_file != priv->preview_file &&
|
|
|
|
|
!(new_file && priv->preview_file &&
|
|
|
|
|
g_file_equal (new_file, priv->preview_file)))
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->preview_file)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
g_object_unref (priv->preview_file);
|
|
|
|
|
g_free (priv->preview_display_name);
|
2004-02-29 06:35:15 +00:00
|
|
|
|
}
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
|
|
|
|
if (new_file)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->preview_file = new_file;
|
|
|
|
|
priv->preview_display_name = new_display_name;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
priv->preview_file = NULL;
|
|
|
|
|
priv->preview_display_name = NULL;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
g_free (new_display_name);
|
2008-06-10 00:39:35 +00:00
|
|
|
|
}
|
2004-04-29 23:13:50 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->use_preview_label && priv->preview_label)
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (priv->preview_label), priv->preview_display_name);
|
2004-04-29 23:13:50 +00:00
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
g_signal_emit_by_name (impl, "update-preview");
|
2009-07-28 00:24:42 +00:00
|
|
|
|
}
|
2011-02-17 23:34:28 +00:00
|
|
|
|
else
|
2004-04-29 23:13:50 +00:00
|
|
|
|
{
|
2011-02-17 23:34:28 +00:00
|
|
|
|
if (new_file)
|
|
|
|
|
g_object_unref (new_file);
|
2004-04-29 23:13:50 +00:00
|
|
|
|
|
2011-02-17 23:34:28 +00:00
|
|
|
|
g_free (new_display_name);
|
2005-11-28 14:03:20 +00:00
|
|
|
|
}
|
2003-11-01 20:17:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-11-07 05:15:25 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
list_select_func (GtkTreeSelection *selection,
|
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = data;
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2004-11-07 05:15:25 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-11-07 05:15:25 +00:00
|
|
|
|
{
|
2009-06-19 20:36:26 +00:00
|
|
|
|
GtkTreeIter iter;
|
2012-07-08 07:25:02 +00:00
|
|
|
|
gboolean is_sensitive;
|
2009-06-19 20:36:26 +00:00
|
|
|
|
gboolean is_folder;
|
2007-05-11 19:42:40 +00:00
|
|
|
|
|
2009-06-19 20:36:26 +00:00
|
|
|
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
|
return FALSE;
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
2012-07-08 07:25:02 +00:00
|
|
|
|
MODEL_COL_IS_SENSITIVE, &is_sensitive,
|
2009-06-19 20:36:26 +00:00
|
|
|
|
MODEL_COL_IS_FOLDER, &is_folder,
|
|
|
|
|
-1);
|
2012-07-08 07:25:02 +00:00
|
|
|
|
if (!is_sensitive || !is_folder)
|
2009-06-19 20:36:26 +00:00
|
|
|
|
return FALSE;
|
2004-11-07 05:15:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
list_selection_changed (GtkTreeSelection *selection,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2004-01-23 20:15:05 +00:00
|
|
|
|
/* See if we are in the new folder editable row for Save mode */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->operation_mode == OPERATION_MODE_BROWSE &&
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2004-01-17 04:34:49 +00:00
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFileInfo *info;
|
2005-07-15 04:55:56 +00:00
|
|
|
|
gboolean had_selection;
|
2004-01-17 04:34:49 +00:00
|
|
|
|
|
2005-07-15 04:55:56 +00:00
|
|
|
|
info = get_selected_file_info_from_file_list (impl, &had_selection);
|
|
|
|
|
if (!had_selection)
|
2005-06-15 01:03:21 +00:00
|
|
|
|
goto out; /* normal processing */
|
2004-01-17 04:34:49 +00:00
|
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
|
return; /* We are on the editable row for New Folder */
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-15 01:03:21 +00:00
|
|
|
|
out:
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_entry)
|
2007-03-23 05:06:00 +00:00
|
|
|
|
update_chooser_entry (impl);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2011-07-01 19:36:52 +00:00
|
|
|
|
path_bar_update (impl);
|
2011-06-29 21:42:01 +00:00
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
check_preview_change (impl);
|
2013-05-13 02:17:15 +00:00
|
|
|
|
check_file_list_menu_sensitivity (impl);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-07-11 19:18:36 +00:00
|
|
|
|
g_signal_emit_by_name (impl, "selection-changed", 0);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-11 00:33:28 +00:00
|
|
|
|
/* Callback used when a row in the file list is activated */
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
list_row_activated (GtkTreeView *tree_view,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-09-11 00:33:28 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
GFile *file;
|
2007-05-11 19:22:38 +00:00
|
|
|
|
GtkTreeIter iter;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
gboolean is_folder;
|
2012-07-08 07:25:02 +00:00
|
|
|
|
gboolean is_sensitive;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2009-06-30 19:24:52 +00:00
|
|
|
|
model = gtk_tree_view_get_model (tree_view);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2009-06-30 19:24:52 +00:00
|
|
|
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
|
return;
|
2003-09-11 00:33:28 +00:00
|
|
|
|
|
2009-06-30 19:24:52 +00:00
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
|
MODEL_COL_FILE, &file,
|
|
|
|
|
MODEL_COL_IS_FOLDER, &is_folder,
|
2012-07-08 07:25:02 +00:00
|
|
|
|
MODEL_COL_IS_SENSITIVE, &is_sensitive,
|
2009-06-30 19:24:52 +00:00
|
|
|
|
-1);
|
2007-05-11 19:22:38 +00:00
|
|
|
|
|
2012-07-08 07:25:02 +00:00
|
|
|
|
if (is_sensitive && is_folder && file)
|
2009-06-30 19:24:52 +00:00
|
|
|
|
{
|
|
|
|
|
change_folder_and_display_error (impl, file, FALSE);
|
2011-04-01 19:25:24 +00:00
|
|
|
|
goto out;
|
2009-06-30 19:24:52 +00:00
|
|
|
|
}
|
2008-06-10 00:39:35 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2009-06-30 19:24:52 +00:00
|
|
|
|
g_signal_emit_by_name (impl, "file-activated");
|
2003-09-11 00:33:28 +00:00
|
|
|
|
|
2011-04-01 19:25:24 +00:00
|
|
|
|
out:
|
|
|
|
|
|
2009-06-30 19:24:52 +00:00
|
|
|
|
if (file)
|
|
|
|
|
g_object_unref (file);
|
2003-09-11 00:33:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-23 07:11:31 +00:00
|
|
|
|
static void
|
|
|
|
|
path_bar_clicked (GtkPathBar *path_bar,
|
2008-06-10 00:39:35 +00:00
|
|
|
|
GFile *file,
|
|
|
|
|
GFile *child_file,
|
2004-04-02 00:35:07 +00:00
|
|
|
|
gboolean child_is_hidden,
|
2004-02-23 07:11:31 +00:00
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (child_file)
|
|
|
|
|
pending_select_files_add (impl, child_file);
|
2005-11-28 22:25:03 +00:00
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
|
if (!change_folder_and_display_error (impl, file, FALSE))
|
2004-04-02 00:35:07 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Say we have "/foo/bar/[.baz]" and the user clicks on "bar". We should then
|
|
|
|
|
* show hidden files so that ".baz" appears in the file list, as it will still
|
|
|
|
|
* be shown in the path bar: "/foo/[bar]/.baz"
|
|
|
|
|
*/
|
|
|
|
|
if (child_is_hidden)
|
|
|
|
|
g_object_set (impl, "show-hidden", TRUE, NULL);
|
2004-02-23 07:11:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-16 21:07:38 +00:00
|
|
|
|
static void
|
2009-06-30 20:58:55 +00:00
|
|
|
|
update_cell_renderer_attributes (GtkFileChooserDefault *impl)
|
2003-07-16 21:07:38 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2009-06-30 20:58:55 +00:00
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
GList *walk, *list;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2009-09-11 18:08:11 +00:00
|
|
|
|
/* Keep the following column numbers in sync with create_file_list() */
|
|
|
|
|
|
2009-06-30 20:58:55 +00:00
|
|
|
|
/* name */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (priv->browse_files_tree_view), 0);
|
2009-06-30 20:58:55 +00:00
|
|
|
|
list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
|
|
|
|
|
for (walk = list; walk; walk = walk->next)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2009-06-30 20:58:55 +00:00
|
|
|
|
renderer = walk->data;
|
|
|
|
|
if (GTK_IS_CELL_RENDERER_PIXBUF (renderer))
|
2007-05-11 19:42:40 +00:00
|
|
|
|
{
|
2009-06-30 20:58:55 +00:00
|
|
|
|
gtk_tree_view_column_set_attributes (column, renderer,
|
2013-07-03 11:26:03 +00:00
|
|
|
|
"surface", MODEL_COL_SURFACE,
|
2009-06-30 20:58:55 +00:00
|
|
|
|
NULL);
|
2007-05-11 19:42:40 +00:00
|
|
|
|
}
|
2009-06-30 20:58:55 +00:00
|
|
|
|
else
|
2007-05-11 19:42:40 +00:00
|
|
|
|
{
|
2009-06-30 20:58:55 +00:00
|
|
|
|
gtk_tree_view_column_set_attributes (column, renderer,
|
|
|
|
|
"text", MODEL_COL_NAME,
|
|
|
|
|
"ellipsize", MODEL_COL_ELLIPSIZE,
|
|
|
|
|
NULL);
|
2007-05-11 19:42:40 +00:00
|
|
|
|
}
|
2012-07-08 07:25:02 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_view_column_add_attribute (column, renderer, "sensitive", MODEL_COL_IS_SENSITIVE);
|
2009-06-30 20:58:55 +00:00
|
|
|
|
}
|
|
|
|
|
g_list_free (list);
|
|
|
|
|
|
|
|
|
|
/* size */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (priv->browse_files_tree_view), 1);
|
2009-06-30 20:58:55 +00:00
|
|
|
|
list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
|
|
|
|
|
renderer = list->data;
|
|
|
|
|
gtk_tree_view_column_set_attributes (column, renderer,
|
|
|
|
|
"text", MODEL_COL_SIZE_TEXT,
|
|
|
|
|
NULL);
|
2012-07-08 07:25:02 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_view_column_add_attribute (column, renderer, "sensitive", MODEL_COL_IS_SENSITIVE);
|
2009-06-30 20:58:55 +00:00
|
|
|
|
g_list_free (list);
|
|
|
|
|
|
|
|
|
|
/* mtime */
|
2013-04-12 03:44:19 +00:00
|
|
|
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (priv->browse_files_tree_view), 2);
|
2009-06-30 20:58:55 +00:00
|
|
|
|
list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
|
|
|
|
|
renderer = list->data;
|
|
|
|
|
gtk_tree_view_column_set_attributes (column, renderer,
|
|
|
|
|
"text", MODEL_COL_MTIME_TEXT,
|
|
|
|
|
NULL);
|
2012-07-08 07:25:02 +00:00
|
|
|
|
gtk_tree_view_column_add_attribute (column, renderer, "sensitive", MODEL_COL_IS_SENSITIVE);
|
2009-06-30 20:58:55 +00:00
|
|
|
|
g_list_free (list);
|
2003-03-21 23:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
GtkWidget *
|
2008-08-04 14:43:53 +00:00
|
|
|
|
_gtk_file_chooser_default_new (void)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2008-08-04 14:43:53 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_FILE_CHOOSER_DEFAULT, NULL);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2006-08-17 21:31:08 +00:00
|
|
|
|
static void
|
|
|
|
|
location_set_user_text (GtkFileChooserDefault *impl,
|
|
|
|
|
const gchar *path)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), path);
|
|
|
|
|
gtk_editable_set_position (GTK_EDITABLE (priv->location_entry), -1);
|
2006-08-17 21:31:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
static void
|
2004-10-24 04:27:44 +00:00
|
|
|
|
location_popup_handler (GtkFileChooserDefault *impl,
|
|
|
|
|
const gchar *path)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
if (priv->operation_mode != OPERATION_MODE_BROWSE)
|
2007-05-02 22:51:43 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget_to_focus;
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2011-07-26 21:17:43 +00:00
|
|
|
|
operation_mode_set (impl, OPERATION_MODE_BROWSE);
|
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->current_folder)
|
|
|
|
|
change_folder_and_display_error (impl, priv->current_folder, FALSE);
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->location_mode == LOCATION_MODE_PATH_BAR)
|
|
|
|
|
widget_to_focus = priv->browse_files_tree_view;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
else
|
2013-04-12 03:44:19 +00:00
|
|
|
|
widget_to_focus = priv->location_entry;
|
2007-05-02 22:51:43 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_grab_focus (widget_to_focus);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-05-11 19:26:32 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2004-03-15 18:12:51 +00:00
|
|
|
|
{
|
2011-07-27 22:46:04 +00:00
|
|
|
|
if (!path)
|
|
|
|
|
return;
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
2011-07-27 22:46:04 +00:00
|
|
|
|
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY, TRUE);
|
|
|
|
|
location_set_user_text (impl, path);
|
2004-03-08 20:06:50 +00:00
|
|
|
|
}
|
2013-04-12 03:44:19 +00:00
|
|
|
|
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2006-08-17 21:31:08 +00:00
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
gtk_widget_grab_focus (priv->location_entry);
|
2006-08-17 21:31:08 +00:00
|
|
|
|
if (path != NULL)
|
|
|
|
|
location_set_user_text (impl, path);
|
|
|
|
|
}
|
Merged the federico-filename-entry branch, to fix bug #136541. Combined
2006-05-03 Federico Mena Quintero <federico@novell.com>
Merged the federico-filename-entry branch, to fix bug #136541.
Combined ChangeLogs:
2006-04-17 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (pending_select_paths_process):
Oops, we *do* need to check that we are in OPEN mode before
selecting the first row in the file list. See
https://bugzilla.novell.com/show_bug.cgi?id=166906
(gtk_file_chooser_default_get_paths): If we are in the case for
the file list, and the list has no selected rows, jump to the case
for the filename entry. This is so that
1. The user types a filename in the SAVE filename entry
("foo.txt").
2. He then double-clicks on a folder ("bar") in the file
list.
will yield the expected "bar/foo.txt" selection.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkpathbar.c (gtk_path_bar_init): Reduce the inter-button
spacing to 0.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Make the
location label bold.
2006-03-29 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserdefault.c (location_mode_set): Just change the
location_mode field if we are in SAVE/CREATE_FOLDER modes.
(gtk_file_chooser_default_get_paths): Get the path based on the
currently focused widget, or the last-focused widget. This is
what we should have been doing in the beginning, but it worked out
fine because we didn't have the possibility of a filename entry in
OPEN mode.
(gtk_file_chooser_default_should_respond): Handle the case where
the last focused widget is the location_entry.
2006-03-28 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechoosersettings.[ch]: New files with a simple
framework for saving/loading settings from the file chooser in
$XDG_CONFIG_HOME/gtk-2.0/gtkfilechooser.
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_unmap):
Save the current settings.
(settings_save): New helper function. We save the location_mode
and show_hidden flags.
(gtk_file_chooser_default_map): Load the settings.
(settings_load): New helper function.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Oops, don't modify
in_change. Our handlers are what set the file_part, so they
*must* be run when we modify the text.
2006-03-27 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Removed the save_file_name_entry. We'll make this be the same as
the location_entry widget.
(struct _GtkFileChooserDefault): Leave only location_button,
location_entry_box, location_label, location_entry. We'll use a
single toggle button for the location entry, which will appear
below the path bar.
(struct _GtkFileChooserDefault): Added a
processing_pending_selections flag.
* gtk/gtkfilechooserdefault.c (save_widgets_create): Destroy the
old location_entry if necessary, and hide the location toggle
widgets.
(update_chooser_entry): In multiple selection mode, just clear the
location_entry.
(check_save_entry): Allow running in OPEN or SELECT_FOLDER modes
if we are in LOCATION_MODE_FILENAME_ENTRY.
(gtk_file_chooser_default_should_respond): Switch to a folder if
the location_entry contains a folder name in OPEN and SAVE mode,
not just SAVE mode. If the entry doesn't contain a folder name,
but is otherwise well-formed, and we are in OPEN mode, return that
we should respond with that filename.
(gtk_file_chooser_default_initial_focus): Focus the location_entry
if appropriate.
(browse_widgets_create): Create the location_entry_box and the
location_label here.
(update_appearance): Call location_mode_set() when switching back
to OPEN/SELECT_FOLDER mode. Hide the location_button when
switching to SAVE/CREATE_FOLDER mode.
(pending_select_paths_process): Turn the
processing_pending_selections flag on and off around changes to
the current selection. Don't special-case OPEN mode anymore,
since the new flag will take care of things in
update_chooser_entry().
(update_chooser_entry): Don't do anything if
processing_pending_selections is TRUE. This keeps the entry from
being polluted when changing folders.
(location_popup_handler): In OPEN/SELECT_FOLDER modes, toggle
between the path bar and the entry. In SAVE/CREATE_FOLDER modes, simply focus the
location_entry.
(update_from_entry): Removed.
(location_entry_create): Removed.
(open_location_cb): Removed.
(file_list_build_popup_menu): Don't add an "Open _Location" menu item.
(location_entry_set_initial_text): Don't do anything if
current_folder is NULL.
* gtk/gtkfilechooserentry.c
(_gtk_file_chooser_entry_set_file_part): Turn in_change on and off
around the call to gtk_entry_set_text(). This makes completion
not happen when the caller has explicitly set a name.
2006-03-24 Federico Mena Quintero <federico@novell.com>
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault):
Added fields location_mode_box, location_pathbar_radio,
location_filename_radio, location_widget_box, location_label,
location_entry. The radio buttons will switch between the pathbar
and the location entry; the other boxes are for layout purposes.
(enum LocationMode): New enum.
(struct _GtkFileChooserDefault): Added a location_mode field.
* gtk/gtkfilechooserdefault.c (browse_widgets_create): Create the
location radio buttons to switch between the pathbar and the
location entry. Pack the browse_path_bar in the new
location_widget_box instead of a generic hbox.
(location_buttons_create): New function.
(gtk_file_chooser_default_init): Initialize impl->location_mode.
(location_switch_to_path_bar): New function.
(location_switch_to_filename_entry): New function.
* gtk/gtkfilechooserbutton.c (model_add_special): The display_name
should not be const.
2006-05-03 22:30:52 +00:00
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handler for the "up-folder" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
up_folder_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
_gtk_path_bar_up (GTK_PATH_BAR (priv->browse_path_bar));
|
2004-03-15 02:12:08 +00:00
|
|
|
|
}
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-03-15 02:12:08 +00:00
|
|
|
|
/* Handler for the "down-folder" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
down_folder_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
_gtk_path_bar_down (GTK_PATH_BAR (priv->browse_path_bar));
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-04 20:08:32 +00:00
|
|
|
|
/* Handler for the "home-folder" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
home_folder_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2012-12-10 20:23:06 +00:00
|
|
|
|
switch_to_home_dir (impl);
|
2005-10-04 20:08:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handler for the "desktop-folder" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
desktop_folder_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2012-12-10 20:45:18 +00:00
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
|
|
name = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
|
|
|
|
|
/* "To disable a directory, point it to the homedir."
|
|
|
|
|
* See http://freedesktop.org/wiki/Software/xdg-user-dirs
|
|
|
|
|
**/
|
|
|
|
|
if (!g_strcmp0 (name, g_get_home_dir ())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), name);
|
Take a shortcut position, not a ShortcutsIndex, to make the function more
2005-10-04 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c (switch_to_shortcut): Take a
shortcut position, not a ShortcutsIndex, to make the function more
generic.
(home_folder_handler): Pass the resolved index to
switch_to_shortcut(), rather than just SHORTCUTS_HOME.
(desktop_folder_handler): Likewise for SHORTCUTS_DESKTOP.
(gtk_file_chooser_default_class_init): Add a "quick-bookmark"
binding signal, and bind it to Alt-1, Alt-2. ..., Alt-0. These
make the respective key switch to the first, second, ..., tenth
bookmark.
(quick_bookmark_handler): Implement.
2005-10-05 05:05:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 19:16:59 +00:00
|
|
|
|
/* Handler for the "search-shortcut" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
search_shortcut_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2012-12-10 23:26:46 +00:00
|
|
|
|
operation_mode_set (impl, OPERATION_MODE_SEARCH);
|
2007-05-11 19:30:38 +00:00
|
|
|
|
|
2012-12-10 23:26:46 +00:00
|
|
|
|
/* we want the entry widget to grab the focus the first
|
|
|
|
|
* time, not the browse_files_tree_view widget.
|
|
|
|
|
*/
|
2013-04-12 03:44:19 +00:00
|
|
|
|
if (priv->search_entry)
|
|
|
|
|
gtk_widget_grab_focus (priv->search_entry);
|
2007-05-11 19:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-11 19:26:32 +00:00
|
|
|
|
/* Handler for the "recent-shortcut" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
recent_shortcut_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2012-12-10 23:14:12 +00:00
|
|
|
|
operation_mode_set (impl, OPERATION_MODE_RECENT);
|
2007-05-11 19:26:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
Take a shortcut position, not a ShortcutsIndex, to make the function more
2005-10-04 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c (switch_to_shortcut): Take a
shortcut position, not a ShortcutsIndex, to make the function more
generic.
(home_folder_handler): Pass the resolved index to
switch_to_shortcut(), rather than just SHORTCUTS_HOME.
(desktop_folder_handler): Likewise for SHORTCUTS_DESKTOP.
(gtk_file_chooser_default_class_init): Add a "quick-bookmark"
binding signal, and bind it to Alt-1, Alt-2. ..., Alt-0. These
make the respective key switch to the first, second, ..., tenth
bookmark.
(quick_bookmark_handler): Implement.
2005-10-05 05:05:42 +00:00
|
|
|
|
static void
|
|
|
|
|
quick_bookmark_handler (GtkFileChooserDefault *impl,
|
|
|
|
|
gint bookmark_index)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
2012-12-10 22:00:42 +00:00
|
|
|
|
GFile *file;
|
Take a shortcut position, not a ShortcutsIndex, to make the function more
2005-10-04 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c (switch_to_shortcut): Take a
shortcut position, not a ShortcutsIndex, to make the function more
generic.
(home_folder_handler): Pass the resolved index to
switch_to_shortcut(), rather than just SHORTCUTS_HOME.
(desktop_folder_handler): Likewise for SHORTCUTS_DESKTOP.
(gtk_file_chooser_default_class_init): Add a "quick-bookmark"
binding signal, and bind it to Alt-1, Alt-2. ..., Alt-0. These
make the respective key switch to the first, second, ..., tenth
bookmark.
(quick_bookmark_handler): Implement.
2005-10-05 05:05:42 +00:00
|
|
|
|
|
2013-04-12 03:44:19 +00:00
|
|
|
|
file = gtk_places_sidebar_get_nth_bookmark (GTK_PLACES_SIDEBAR (priv->places_sidebar), bookmark_index);
|
Take a shortcut position, not a ShortcutsIndex, to make the function more
2005-10-04 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c (switch_to_shortcut): Take a
shortcut position, not a ShortcutsIndex, to make the function more
generic.
(home_folder_handler): Pass the resolved index to
switch_to_shortcut(), rather than just SHORTCUTS_HOME.
(desktop_folder_handler): Likewise for SHORTCUTS_DESKTOP.
(gtk_file_chooser_default_class_init): Add a "quick-bookmark"
binding signal, and bind it to Alt-1, Alt-2. ..., Alt-0. These
make the respective key switch to the first, second, ..., tenth
bookmark.
(quick_bookmark_handler): Implement.
2005-10-05 05:05:42 +00:00
|
|
|
|
|
2012-12-10 22:00:42 +00:00
|
|
|
|
if (file)
|
|
|
|
|
{
|
|
|
|
|
change_folder_and_display_error (impl, file, FALSE);
|
|
|
|
|
g_object_unref (file);
|
|
|
|
|
}
|
2005-10-04 20:08:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-23 05:13:56 +00:00
|
|
|
|
static void
|
|
|
|
|
show_hidden_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2013-04-12 03:44:19 +00:00
|
|
|
|
GtkFileChooserDefaultPrivate *priv = impl->priv;
|
|
|
|
|
|
2007-03-23 05:13:56 +00:00
|
|
|
|
g_object_set (impl,
|
2013-04-12 03:44:19 +00:00
|
|
|
|
"show-hidden", !priv->show_hidden,
|
2007-03-23 05:13:56 +00:00
|
|
|
|
NULL);
|
|
|
|
|
}
|
2013-04-12 01:37:01 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_normal_and_shifted_binding (GtkBindingSet *binding_set,
|
|
|
|
|
guint keyval,
|
|
|
|
|
GdkModifierType modifiers,
|
|
|
|
|
const gchar *signal_name)
|
|
|
|
|
{
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
keyval, modifiers,
|
|
|
|
|
signal_name, 0);
|
|
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
keyval, modifiers | GDK_SHIFT_MASK,
|
|
|
|
|
signal_name, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
|
|
|
|
|
{
|
|
|
|
|
static const guint quick_bookmark_keyvals[10] = {
|
|
|
|
|
GDK_KEY_1, GDK_KEY_2, GDK_KEY_3, GDK_KEY_4, GDK_KEY_5, GDK_KEY_6, GDK_KEY_7, GDK_KEY_8, GDK_KEY_9, GDK_KEY_0
|
|
|
|
|
};
|
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
|
|
|
|
GtkBindingSet *binding_set;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
gobject_class->finalize = gtk_file_chooser_default_finalize;
|
|
|
|
|
gobject_class->constructor = gtk_file_chooser_default_constructor;
|
|
|
|
|
gobject_class->set_property = gtk_file_chooser_default_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_file_chooser_default_get_property;
|
|
|
|
|
gobject_class->dispose = gtk_file_chooser_default_dispose;
|
|
|
|
|
|
|
|
|
|
widget_class->show_all = gtk_file_chooser_default_show_all;
|
|
|
|
|
widget_class->realize = gtk_file_chooser_default_realize;
|
|
|
|
|
widget_class->map = gtk_file_chooser_default_map;
|
|
|
|
|
widget_class->unmap = gtk_file_chooser_default_unmap;
|
|
|
|
|
widget_class->hierarchy_changed = gtk_file_chooser_default_hierarchy_changed;
|
|
|
|
|
widget_class->style_updated = gtk_file_chooser_default_style_updated;
|
|
|
|
|
widget_class->screen_changed = gtk_file_chooser_default_screen_changed;
|
|
|
|
|
|
|
|
|
|
signals[LOCATION_POPUP] =
|
|
|
|
|
g_signal_new_class_handler (I_("location-popup"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (location_popup_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__STRING,
|
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_STRING);
|
|
|
|
|
|
|
|
|
|
signals[LOCATION_POPUP_ON_PASTE] =
|
|
|
|
|
g_signal_new_class_handler (I_("location-popup-on-paste"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (location_popup_on_paste_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[LOCATION_TOGGLE_POPUP] =
|
|
|
|
|
g_signal_new_class_handler (I_("location-toggle-popup"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (location_toggle_popup_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[UP_FOLDER] =
|
|
|
|
|
g_signal_new_class_handler (I_("up-folder"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (up_folder_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[DOWN_FOLDER] =
|
|
|
|
|
g_signal_new_class_handler (I_("down-folder"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (down_folder_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[HOME_FOLDER] =
|
|
|
|
|
g_signal_new_class_handler (I_("home-folder"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (home_folder_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[DESKTOP_FOLDER] =
|
|
|
|
|
g_signal_new_class_handler (I_("desktop-folder"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (desktop_folder_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[QUICK_BOOKMARK] =
|
|
|
|
|
g_signal_new_class_handler (I_("quick-bookmark"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (quick_bookmark_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__INT,
|
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_INT);
|
|
|
|
|
|
|
|
|
|
signals[SHOW_HIDDEN] =
|
|
|
|
|
g_signal_new_class_handler (I_("show-hidden"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (show_hidden_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[SEARCH_SHORTCUT] =
|
|
|
|
|
g_signal_new_class_handler (I_("search-shortcut"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (search_shortcut_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
signals[RECENT_SHORTCUT] =
|
|
|
|
|
g_signal_new_class_handler (I_("recent-shortcut"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (recent_shortcut_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
binding_set = gtk_binding_set_by_class (class);
|
|
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_l, GDK_CONTROL_MASK,
|
|
|
|
|
"location-toggle-popup",
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_slash, 0,
|
|
|
|
|
"location-popup",
|
|
|
|
|
1, G_TYPE_STRING, "/");
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_KP_Divide, 0,
|
|
|
|
|
"location-popup",
|
|
|
|
|
1, G_TYPE_STRING, "/");
|
|
|
|
|
|
|
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_asciitilde, 0,
|
|
|
|
|
"location-popup",
|
|
|
|
|
1, G_TYPE_STRING, "~");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_v, GDK_CONTROL_MASK,
|
|
|
|
|
"location-popup-on-paste",
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
add_normal_and_shifted_binding (binding_set,
|
|
|
|
|
GDK_KEY_Up, GDK_MOD1_MASK,
|
|
|
|
|
"up-folder");
|
|
|
|
|
|
|
|
|
|
add_normal_and_shifted_binding (binding_set,
|
|
|
|
|
GDK_KEY_KP_Up, GDK_MOD1_MASK,
|
|
|
|
|
"up-folder");
|
|
|
|
|
|
|
|
|
|
add_normal_and_shifted_binding (binding_set,
|
|
|
|
|
GDK_KEY_Down, GDK_MOD1_MASK,
|
|
|
|
|
"down-folder");
|
|
|
|
|
add_normal_and_shifted_binding (binding_set,
|
|
|
|
|
GDK_KEY_KP_Down, GDK_MOD1_MASK,
|
|
|
|
|
"down-folder");
|
|
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_Home, GDK_MOD1_MASK,
|
|
|
|
|
"home-folder",
|
|
|
|
|
0);
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_KP_Home, GDK_MOD1_MASK,
|
|
|
|
|
"home-folder",
|
|
|
|
|
0);
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_d, GDK_MOD1_MASK,
|
|
|
|
|
"desktop-folder",
|
|
|
|
|
0);
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_h, GDK_CONTROL_MASK,
|
|
|
|
|
"show-hidden",
|
|
|
|
|
0);
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_s, GDK_MOD1_MASK,
|
|
|
|
|
"search-shortcut",
|
|
|
|
|
0);
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KEY_r, GDK_MOD1_MASK,
|
|
|
|
|
"recent-shortcut",
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
quick_bookmark_keyvals[i], GDK_MOD1_MASK,
|
|
|
|
|
"quick-bookmark",
|
|
|
|
|
1, G_TYPE_INT, i);
|
|
|
|
|
|
|
|
|
|
_gtk_file_chooser_install_properties (gobject_class);
|
|
|
|
|
|
|
|
|
|
/* Bind class to template */
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class,
|
|
|
|
|
"/org/gtk/libgtk/gtkfilechooserdefault.ui");
|
|
|
|
|
|
|
|
|
|
/* A *lot* of widgets that we need to handle .... */
|
2013-07-26 20:29:12 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_widgets_box);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_widgets_hpaned);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_header_box);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_widgets_box);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, places_sidebar);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_files_tree_view);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_new_folder_button);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_path_bar_hbox);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_path_bar_size_group);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_path_bar);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_special_mode_icon);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_special_mode_label);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_select_a_folder_info_bar);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_select_a_folder_label);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, browse_select_a_folder_icon);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, filter_combo_hbox);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, filter_combo);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, preview_box);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, extra_align);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, location_button);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, location_entry_box);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, location_label);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, list_name_column);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, list_pixbuf_renderer);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, list_name_renderer);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, list_mtime_column);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDefault, list_size_column);
|
2013-04-12 01:37:01 +00:00
|
|
|
|
|
|
|
|
|
/* And a *lot* of callbacks to bind ... */
|
2013-07-26 17:49:49 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, browse_files_key_press_event_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, file_list_drag_drop_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, file_list_drag_data_received_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, list_popup_menu_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, file_list_query_tooltip_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, list_button_press_event_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, list_row_activated);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, file_list_drag_motion_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, list_selection_changed);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, renderer_editing_canceled_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, renderer_edited_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, filter_combo_changed);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, location_button_toggled_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, new_folder_button_clicked);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, path_bar_clicked);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, places_sidebar_open_location_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, places_sidebar_show_error_message_cb);
|
2013-04-12 01:37:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
post_process_ui (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
|
GList *cells;
|
|
|
|
|
|
|
|
|
|
/* Some qdata, qdata can't be set with GtkBuilder */
|
|
|
|
|
g_object_set_data (G_OBJECT (impl->priv->browse_files_tree_view), "fmq-name", "file_list");
|
|
|
|
|
g_object_set_data (G_OBJECT (impl->priv->browse_files_tree_view), I_("GtkFileChooserDefault"), impl);
|
|
|
|
|
|
|
|
|
|
/* Setup file list treeview */
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->priv->browse_files_tree_view));
|
|
|
|
|
gtk_tree_selection_set_select_function (selection,
|
|
|
|
|
list_select_func,
|
|
|
|
|
impl, NULL);
|
|
|
|
|
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->priv->browse_files_tree_view),
|
|
|
|
|
GDK_BUTTON1_MASK,
|
|
|
|
|
NULL, 0,
|
|
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
|
|
|
|
gtk_drag_source_add_uri_targets (impl->priv->browse_files_tree_view);
|
|
|
|
|
|
|
|
|
|
gtk_drag_dest_set (impl->priv->browse_files_tree_view,
|
|
|
|
|
GTK_DEST_DEFAULT_ALL,
|
|
|
|
|
NULL, 0,
|
|
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
|
|
|
|
gtk_drag_dest_add_uri_targets (impl->priv->browse_files_tree_view);
|
|
|
|
|
|
|
|
|
|
/* File browser treemodel columns are shared between GtkFileChooser implementations,
|
|
|
|
|
* so we don't set cell renderer attributes in GtkBuilder, but rather keep that
|
|
|
|
|
* in code.
|
|
|
|
|
*/
|
|
|
|
|
file_list_set_sort_column_ids (impl);
|
|
|
|
|
update_cell_renderer_attributes (impl);
|
|
|
|
|
|
|
|
|
|
/* Get the combo's text renderer and set ellipsize parameters,
|
|
|
|
|
* perhaps GtkComboBoxText should declare the cell renderer
|
|
|
|
|
* as an 'internal-child', then we could configure it in GtkBuilder
|
|
|
|
|
* instead of hard coding it here.
|
|
|
|
|
*/
|
|
|
|
|
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (impl->priv->filter_combo));
|
|
|
|
|
g_assert (cells);
|
|
|
|
|
cell = cells->data;
|
|
|
|
|
g_object_set (G_OBJECT (cell),
|
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
g_list_free (cells);
|
|
|
|
|
|
|
|
|
|
/* Set the GtkPathBar file system backend */
|
|
|
|
|
_gtk_path_bar_set_file_system (GTK_PATH_BAR (impl->priv->browse_path_bar), impl->priv->file_system);
|
|
|
|
|
|
|
|
|
|
/* Set the fixed size icon renderer, this requires
|
|
|
|
|
* that priv->icon_size be already setup.
|
|
|
|
|
*/
|
|
|
|
|
set_icon_cell_renderer_fixed_size (impl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefaultPrivate *priv;
|
|
|
|
|
|
|
|
|
|
profile_start ("start", NULL);
|
|
|
|
|
#ifdef PROFILE_FILE_CHOOSER
|
|
|
|
|
access ("MARK: *** CREATE FILE CHOOSER", F_OK);
|
|
|
|
|
#endif
|
2013-06-27 19:02:52 +00:00
|
|
|
|
impl->priv = _gtk_file_chooser_default_get_instance_private (impl);
|
2013-04-12 01:37:01 +00:00
|
|
|
|
priv = impl->priv;
|
|
|
|
|
|
|
|
|
|
priv->local_only = TRUE;
|
|
|
|
|
priv->preview_widget_active = TRUE;
|
|
|
|
|
priv->use_preview_label = TRUE;
|
|
|
|
|
priv->select_multiple = FALSE;
|
|
|
|
|
priv->show_hidden = FALSE;
|
|
|
|
|
priv->show_size_column = TRUE;
|
|
|
|
|
priv->icon_size = FALLBACK_ICON_SIZE;
|
|
|
|
|
priv->load_state = LOAD_EMPTY;
|
|
|
|
|
priv->reload_state = RELOAD_EMPTY;
|
|
|
|
|
priv->pending_select_files = NULL;
|
|
|
|
|
priv->location_mode = LOCATION_MODE_PATH_BAR;
|
|
|
|
|
priv->operation_mode = OPERATION_MODE_BROWSE;
|
|
|
|
|
priv->sort_column = MODEL_COL_NAME;
|
|
|
|
|
priv->sort_order = GTK_SORT_ASCENDING;
|
|
|
|
|
priv->recent_manager = gtk_recent_manager_get_default ();
|
|
|
|
|
priv->create_folders = TRUE;
|
|
|
|
|
|
|
|
|
|
/* Ensure GTK+ private types used by the template
|
|
|
|
|
* definition before calling gtk_widget_init_template()
|
|
|
|
|
*/
|
|
|
|
|
g_type_ensure (GTK_TYPE_PATH_BAR);
|
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (impl));
|
2013-07-17 22:56:08 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->browse_files_tree_view, 280, -1);
|
2013-04-12 01:37:01 +00:00
|
|
|
|
|
|
|
|
|
set_file_system_backend (impl);
|
|
|
|
|
|
|
|
|
|
priv->bookmarks_manager = _gtk_bookmarks_manager_new (NULL, NULL);
|
|
|
|
|
|
|
|
|
|
/* Setup various attributes and callbacks in the UI
|
|
|
|
|
* which cannot be done with GtkBuilder.
|
|
|
|
|
*/
|
|
|
|
|
post_process_ui (impl);
|
|
|
|
|
|
|
|
|
|
profile_end ("end", NULL);
|
|
|
|
|
}
|