};
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 */
+ 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 */
+ 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 {
};
/* 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_TIME */ \
- G_TYPE_FILE, /* MODEL_COL_FILE */ \
- G_TYPE_STRING, /* MODEL_COL_NAME_COLLATED */ \
- G_TYPE_BOOLEAN, /* MODEL_COL_IS_FOLDER */ \
- G_TYPE_BOOLEAN, /* MODEL_COL_IS_SENSITIVE */ \
- CAIRO_GOBJECT_TYPE_SURFACE, /* MODEL_COL_SURFACE */ \
- G_TYPE_STRING, /* MODEL_COL_SIZE_TEXT */ \
- G_TYPE_STRING, /* MODEL_COL_DATE_TEXT */ \
- G_TYPE_STRING, /* MODEL_COL_TIME_TEXT */ \
- G_TYPE_STRING, /* MODEL_COL_LOCATION_TEXT */ \
- PANGO_TYPE_ELLIPSIZE_MODE /* MODEL_COL_ELLIPSIZE */
+#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_TIME */ \
+ G_TYPE_FILE, /* MODEL_COL_FILE */ \
+ G_TYPE_STRING, /* MODEL_COL_NAME_COLLATED */ \
+ G_TYPE_BOOLEAN, /* MODEL_COL_IS_FOLDER */ \
+ G_TYPE_BOOLEAN, /* MODEL_COL_IS_SENSITIVE */ \
+ CAIRO_GOBJECT_TYPE_SURFACE, /* MODEL_COL_SURFACE */ \
+ G_TYPE_STRING, /* MODEL_COL_SIZE_TEXT */ \
+ G_TYPE_STRING, /* MODEL_COL_DATE_TEXT */ \
+ G_TYPE_STRING, /* MODEL_COL_TIME_TEXT */ \
+ G_TYPE_STRING, /* MODEL_COL_LOCATION_TEXT */ \
+ PANGO_TYPE_ELLIPSIZE_MODE /* MODEL_COL_ELLIPSIZE */
/* Identifiers for target types */
enum {
static void gtk_file_chooser_widget_constructed (GObject *object);
static void gtk_file_chooser_widget_finalize (GObject *object);
static void gtk_file_chooser_widget_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void gtk_file_chooser_widget_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
static void gtk_file_chooser_widget_dispose (GObject *object);
static void gtk_file_chooser_widget_show_all (GtkWidget *widget);
static void gtk_file_chooser_widget_realize (GtkWidget *widget);
static void gtk_file_chooser_widget_map (GtkWidget *widget);
static void gtk_file_chooser_widget_unmap (GtkWidget *widget);
static void gtk_file_chooser_widget_hierarchy_changed (GtkWidget *widget,
- GtkWidget *previous_toplevel);
+ GtkWidget *previous_toplevel);
static void gtk_file_chooser_widget_style_updated (GtkWidget *widget);
static void gtk_file_chooser_widget_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen);
static gboolean gtk_file_chooser_widget_key_press_event (GtkWidget *widget,
GdkEventKey *event);
-static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser,
- GFile *folder,
- GError **error);
-static gboolean gtk_file_chooser_widget_update_current_folder (GtkFileChooser *chooser,
- GFile *folder,
- gboolean keep_trail,
- gboolean clear_entry,
- GError **error);
-static GFile * gtk_file_chooser_widget_get_current_folder (GtkFileChooser *chooser);
-static void gtk_file_chooser_widget_set_current_name (GtkFileChooser *chooser,
- const gchar *name);
-static gchar * gtk_file_chooser_widget_get_current_name (GtkFileChooser *chooser);
-static gboolean gtk_file_chooser_widget_select_file (GtkFileChooser *chooser,
- GFile *file,
- GError **error);
-static void gtk_file_chooser_widget_unselect_file (GtkFileChooser *chooser,
- GFile *file);
-static void gtk_file_chooser_widget_select_all (GtkFileChooser *chooser);
-static void gtk_file_chooser_widget_unselect_all (GtkFileChooser *chooser);
-static GSList * gtk_file_chooser_widget_get_files (GtkFileChooser *chooser);
-static GFile * gtk_file_chooser_widget_get_preview_file (GtkFileChooser *chooser);
-static GtkFileSystem *gtk_file_chooser_widget_get_file_system (GtkFileChooser *chooser);
-static void gtk_file_chooser_widget_add_filter (GtkFileChooser *chooser,
- GtkFileFilter *filter);
-static void gtk_file_chooser_widget_remove_filter (GtkFileChooser *chooser,
- GtkFileFilter *filter);
-static GSList * gtk_file_chooser_widget_list_filters (GtkFileChooser *chooser);
+static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser,
+ GFile *folder,
+ GError **error);
+static gboolean gtk_file_chooser_widget_update_current_folder (GtkFileChooser *chooser,
+ GFile *folder,
+ gboolean keep_trail,
+ gboolean clear_entry,
+ GError **error);
+static GFile * gtk_file_chooser_widget_get_current_folder (GtkFileChooser *chooser);
+static void gtk_file_chooser_widget_set_current_name (GtkFileChooser *chooser,
+ const gchar *name);
+static gchar * gtk_file_chooser_widget_get_current_name (GtkFileChooser *chooser);
+static gboolean gtk_file_chooser_widget_select_file (GtkFileChooser *chooser,
+ GFile *file,
+ GError **error);
+static void gtk_file_chooser_widget_unselect_file (GtkFileChooser *chooser,
+ GFile *file);
+static void gtk_file_chooser_widget_select_all (GtkFileChooser *chooser);
+static void gtk_file_chooser_widget_unselect_all (GtkFileChooser *chooser);
+static GSList * gtk_file_chooser_widget_get_files (GtkFileChooser *chooser);
+static GFile * gtk_file_chooser_widget_get_preview_file (GtkFileChooser *chooser);
+static GtkFileSystem *gtk_file_chooser_widget_get_file_system (GtkFileChooser *chooser);
+static void gtk_file_chooser_widget_add_filter (GtkFileChooser *chooser,
+ GtkFileFilter *filter);
+static void gtk_file_chooser_widget_remove_filter (GtkFileChooser *chooser,
+ GtkFileFilter *filter);
+static GSList * gtk_file_chooser_widget_list_filters (GtkFileChooser *chooser);
static gboolean gtk_file_chooser_widget_add_shortcut_folder (GtkFileChooser *chooser,
- GFile *file,
- GError **error);
+ GFile *file,
+ GError **error);
static gboolean gtk_file_chooser_widget_remove_shortcut_folder (GtkFileChooser *chooser,
- GFile *file,
- GError **error);
+ GFile *file,
+ GError **error);
static GSList * gtk_file_chooser_widget_list_shortcut_folders (GtkFileChooser *chooser);
static void gtk_file_chooser_widget_get_default_size (GtkFileChooserEmbed *chooser_embed,
- gint *default_width,
- gint *default_height);
+ gint *default_width,
+ gint *default_height);
static gboolean gtk_file_chooser_widget_should_respond (GtkFileChooserEmbed *chooser_embed);
static void gtk_file_chooser_widget_initial_focus (GtkFileChooserEmbed *chooser_embed);
static void add_selection_to_recent_list (GtkFileChooserWidget *impl);
static void location_popup_handler (GtkFileChooserWidget *impl,
- const gchar *path);
+ const gchar *path);
static void location_popup_on_paste_handler (GtkFileChooserWidget *impl);
static void location_toggle_popup_handler (GtkFileChooserWidget *impl);
static void up_folder_handler (GtkFileChooserWidget *impl);
static void home_folder_handler (GtkFileChooserWidget *impl);
static void desktop_folder_handler (GtkFileChooserWidget *impl);
static void quick_bookmark_handler (GtkFileChooserWidget *impl,
- gint bookmark_index);
+ gint bookmark_index);
static void show_hidden_handler (GtkFileChooserWidget *impl);
static void search_shortcut_handler (GtkFileChooserWidget *impl);
static void recent_shortcut_handler (GtkFileChooserWidget *impl);
static void location_mode_set (GtkFileChooserWidget *impl, LocationMode new_mode);
static void set_current_filter (GtkFileChooserWidget *impl,
- GtkFileFilter *filter);
+ GtkFileFilter *filter);
static void check_preview_change (GtkFileChooserWidget *impl);
static void filter_combo_changed (GtkComboBox *combo_box,
- GtkFileChooserWidget *impl);
+ GtkFileChooserWidget *impl);
static gboolean list_select_func (GtkTreeSelection *selection,
- GtkTreeModel *model,
- GtkTreePath *path,
- gboolean path_currently_selected,
- gpointer data);
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ gpointer data);
static void list_selection_changed (GtkTreeSelection *tree_selection,
- GtkFileChooserWidget *impl);
+ GtkFileChooserWidget *impl);
static void list_row_activated (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- GtkFileChooserWidget *impl);
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ GtkFileChooserWidget *impl);
static void list_cursor_changed (GtkTreeView *treeview,
GtkFileChooserWidget *impl);
static void path_bar_clicked (GtkPathBar *path_bar,
- GFile *file,
- GFile *child,
+ GFile *file,
+ GFile *child,
gboolean child_is_hidden,
GtkFileChooserWidget *impl);
static void search_stop_searching (GtkFileChooserWidget *impl,
gboolean remove_query);
static void search_clear_model (GtkFileChooserWidget *impl,
- gboolean remove_from_treeview);
+ gboolean remove_from_treeview);
static GSList *search_get_selected_files (GtkFileChooserWidget *impl);
static void search_entry_activate_cb (GtkFileChooserWidget *impl);
static void search_entry_stop_cb (GtkFileChooserWidget *impl);
G_DEFINE_TYPE_WITH_CODE (GtkFileChooserWidget, gtk_file_chooser_widget, GTK_TYPE_BOX,
G_ADD_PRIVATE (GtkFileChooserWidget)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER,
- gtk_file_chooser_widget_iface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED,
- gtk_file_chooser_embed_default_iface_init));
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER,
+ gtk_file_chooser_widget_iface_init)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED,
+ gtk_file_chooser_embed_default_iface_init));
static void
gtk_file_chooser_widget_iface_init (GtkFileChooserIface *iface)
static void
pending_select_files_add (GtkFileChooserWidget *impl,
- GFile *file)
+ GFile *file)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
/* 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)
+ const char *msg,
+ const char *detail)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- "%s",
- msg);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s",
+ msg);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", detail);
+ "%s", detail);
if (parent && gtk_window_has_group (parent))
gtk_window_group_add_window (gtk_window_get_group (parent),
/* Shows an error dialog for the file chooser */
static void
error_message (GtkFileChooserWidget *impl,
- const char *msg,
- const char *detail)
+ const char *msg,
+ const char *detail)
{
error_message_with_parent (get_toplevel (GTK_WIDGET (impl)), msg, detail);
}
/* Shows a simple error dialog relative to a path. Frees the GError as well. */
static void
error_dialog (GtkFileChooserWidget *impl,
- const char *msg,
- GFile *file,
- GError *error)
+ const char *msg,
+ GFile *file,
+ GError *error)
{
if (error)
{
char *text;
if (file)
- uri = g_file_get_uri (file);
+ uri = g_file_get_uri (file);
text = g_strdup_printf (msg, uri);
error_message (impl, text, error->message);
g_free (text);
/* Shows an error dialog about not being able to create a folder */
static void
error_creating_folder_dialog (GtkFileChooserWidget *impl,
- GFile *file,
- GError *error)
+ GFile *file,
+ GError *error)
{
error_dialog (impl,
- _("The folder could not be created"),
- file, error);
+ _("The folder could not be created"),
+ file, error);
}
/* Shows an error about not being able to create a folder because a file with
*/
static void
error_creating_folder_over_existing_file_dialog (GtkFileChooserWidget *impl,
- GFile *file,
- GError *error)
+ GFile *file,
+ GError *error)
{
error_dialog (impl,
- _("The folder could not be created, as a file with the same "
+ _("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."),
- file, error);
+ file, error);
}
static void
error_with_file_under_nonfolder (GtkFileChooserWidget *impl,
- GFile *parent_file)
+ 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."));
+ _("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);
+ _("Cannot create a file under %s as it is not a folder"),
+ parent_file, error);
}
static void
/* Shows an error dialog about not being able to create a filename */
static void
error_building_filename_dialog (GtkFileChooserWidget *impl,
- GError *error)
+ GError *error)
{
error_dialog (impl, _("Invalid file name"),
- NULL, error);
+ NULL, error);
}
/* Shows an error dialog when we cannot switch to a folder */
static void
error_changing_folder_dialog (GtkFileChooserWidget *impl,
- GFile *file,
- GError *error)
+ GFile *file,
+ GError *error)
{
error_dialog (impl, _("The folder contents could not be displayed"),
- file, error);
+ file, error);
}
/* Changes folders, displaying an error dialog if this fails */
static gboolean
change_folder_and_display_error (GtkFileChooserWidget *impl,
- GFile *file,
- gboolean clear_entry)
+ GFile *file,
+ gboolean clear_entry)
{
GError *error;
gboolean result;
if (priv->use_preview_label)
{
if (!priv->preview_label)
- {
- 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);
- }
+ {
+ 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);
+ }
}
else
{
if (priv->preview_label)
- {
- gtk_widget_destroy (priv->preview_label);
- priv->preview_label = NULL;
- }
+ {
+ gtk_widget_destroy (priv->preview_label);
+ priv->preview_label = NULL;
+ }
}
if (priv->preview_widget_active && priv->preview_widget)
static void
set_preview_widget (GtkFileChooserWidget *impl,
- GtkWidget *preview_widget)
+ GtkWidget *preview_widget)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
if (priv->preview_widget)
gtk_container_remove (GTK_CONTAINER (priv->preview_box),
- priv->preview_widget);
+ priv->preview_widget);
priv->preview_widget = preview_widget;
if (priv->preview_widget)
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);
+ priv->preview_widget,
+ (priv->use_preview_label && priv->preview_label) ? 1 : 0);
}
update_preview_widget_visibility (impl);
/* Used from gtk_tree_selection_selected_foreach() */
static void
selection_check_foreach_cb (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
struct selection_check_closure *closure;
gboolean is_folder;
/* Checks whether the selected items in the file list are all files or all folders */
static void
selection_check (GtkFileChooserWidget *impl,
- gint *num_selected,
- gboolean *all_files,
- gboolean *all_folders)
+ gint *num_selected,
+ gboolean *all_files,
+ gboolean *all_folders)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
struct selection_check_closure closure;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
gtk_tree_selection_selected_foreach (selection,
- selection_check_foreach_cb,
- &closure);
+ selection_check_foreach_cb,
+ &closure);
g_assert (closure.num_selected == 0 || !(closure.all_files && closure.all_folders));
*/
if (priv->location_entry
&& !(priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
- || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
+ || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
clear_entry = TRUE;
else
clear_entry = FALSE;
/* 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,
- GtkFileChooserWidget *impl)
+ const char *primary,
+ const char *secondary,
+ GtkFileChooserWidget *impl)
{
error_message (impl, primary, secondary);
}
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);
+ || event->keyval == GDK_KEY_KP_Right
+ || event->keyval == GDK_KEY_Left
+ || event->keyval == GDK_KEY_KP_Left)
+ && (event->state & modifiers) == 0);
}
static gboolean
*/
static gboolean
browse_files_key_press_event_cb (GtkWidget *widget,
- GdkEventKey *event,
- gpointer data)
+ GdkEventKey *event,
+ gpointer data)
{
GtkFileChooserWidget *impl = (GtkFileChooserWidget *) data;
GtkFileChooserWidgetPrivate *priv = impl->priv;
|| event->keyval == GDK_KEY_KP_Space)
&& !(event->state & gtk_accelerator_get_default_mod_mask ())
&& !(priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
- priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
{
GtkWindow *window;
if (widget != default_widget &&
!(widget == focus_widget && (!default_widget || !gtk_widget_get_sensitive (default_widget))))
- {
- gtk_window_activate_default (window);
+ {
+ gtk_window_activate_default (window);
- return TRUE;
- }
+ return TRUE;
+ }
}
}
/* Callback used when the file list's popup menu is detached */
static void
popup_menu_detach_cb (GtkWidget *attach_widget,
- GtkMenu *menu)
+ GtkMenu *menu)
{
GtkFileChooserWidget *impl = g_object_get_data (G_OBJECT (attach_widget), "GtkFileChooserWidget");
GtkFileChooserWidgetPrivate *priv;
*/
static void
add_bookmark_foreach_cb (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
GtkFileChooserWidget *impl = (GtkFileChooserWidget *) data;
GtkFileChooserWidgetPrivate *priv = impl->priv;
/* Callback used when the "Add to Bookmarks" menu item is activated */
static void
add_to_shortcuts_cb (GtkMenuItem *item,
- GtkFileChooserWidget *impl)
+ GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
gtk_tree_selection_selected_foreach (selection,
- add_bookmark_foreach_cb,
- impl);
+ add_bookmark_foreach_cb,
+ impl);
}
/* callback used to set data to clipboard */
{
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);
+ 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);
+ 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);
- }
+ {
+ char *str = g_strjoinv (" ", uris);
+ gtk_selection_data_set_text (selection_data, str, -1);
+ g_free (str);
+ }
g_strfreev (uris);
}
gtk_target_list_unref (target_list);
gtk_clipboard_set_with_data (clipboard, targets, n_targets,
- copy_file_get_cb,
+ copy_file_get_cb,
copy_file_clear_cb,
- selected_files);
+ selected_files);
gtk_target_table_free (targets, n_targets);
}
/* Callback used when the "Visit this file" menu item is activated */
static void
visit_file_cb (GtkMenuItem *item,
- GtkFileChooserWidget *impl)
+ GtkFileChooserWidget *impl)
{
GSList *files;
/* Callback used when the "Open this folder" menu item is activated */
static void
open_folder_cb (GtkMenuItem *item,
- GtkFileChooserWidget *impl)
+ GtkFileChooserWidget *impl)
{
GSList *files;
/* callback used when the "Show Hidden Files" menu item is toggled */
static void
show_hidden_toggled_cb (GtkCheckMenuItem *item,
- GtkFileChooserWidget *impl)
+ GtkFileChooserWidget *impl)
{
g_object_set (impl,
- "show-hidden", gtk_check_menu_item_get_active (item),
- NULL);
+ "show-hidden", gtk_check_menu_item_get_active (item),
+ NULL);
}
/* Callback used when the "Show Size Column" menu item is toggled */
/* Shows an error dialog about not being able to select a dragged file */
static void
error_selecting_dragged_file_dialog (GtkFileChooserWidget *impl,
- GFile *file,
- GError *error)
+ GFile *file,
+ GError *error)
{
error_dialog (impl,
- _("Could not select file"),
- file, error);
+ _("Could not select file"),
+ file, error);
}
static void
file_list_drag_data_select_uris (GtkFileChooserWidget *impl,
- gchar **uris)
+ gchar **uris)
{
int i;
char *uri;
gtk_file_chooser_widget_select_file (chooser, file, &error);
if (error)
- error_selecting_dragged_file_dialog (impl, file, error);
+ error_selecting_dragged_file_dialog (impl, file, error);
g_object_unref (file);
}
static void
file_list_drag_data_received_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
- gpointer user_data)
+ GFileInfo *info,
+ const GError *error,
+ gpointer user_data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
struct FileListDragData *data = user_data;
gtk_file_chooser_widget_unselect_all (chooser);
gtk_file_chooser_widget_select_file (chooser, data->file, &local_error);
if (local_error)
- error_selecting_dragged_file_dialog (data->impl, data->file, local_error);
+ error_selecting_dragged_file_dialog (data->impl, data->file, local_error);
else
- browse_files_center_selected_row (data->impl);
+ browse_files_center_selected_row (data->impl);
}
if (priv->select_multiple)
/* 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_,
- GtkFileChooserWidget *impl)
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time_,
+ GtkFileChooserWidget *impl)
{
g_signal_stop_emission_by_name (widget, "drag-drop");
return TRUE;
static GtkWidget *
file_list_add_check_menu_item (GtkFileChooserWidget *impl,
- const char *mnemonic_label,
- GCallback callback)
+ const char *mnemonic_label,
+ GCallback callback)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkWidget *item;
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,
- popup_menu_detach_cb);
+ priv->browse_files_tree_view,
+ popup_menu_detach_cb);
- priv->visit_file_item = file_list_add_menu_item (impl,
+ priv->visit_file_item = file_list_add_menu_item (impl,
_("_Visit File"),
G_CALLBACK (visit_file_cb));
_("_Open With File Manager"),
G_CALLBACK (open_folder_cb));
- priv->copy_file_location_item = file_list_add_menu_item (impl,
+ priv->copy_file_location_item = file_list_add_menu_item (impl,
_("_Copy Location"),
G_CALLBACK (copy_file_location_cb));
/* 'Show Hidden Files' */
g_signal_handlers_block_by_func (priv->hidden_files_item,
- G_CALLBACK (show_hidden_toggled_cb), impl);
+ G_CALLBACK (show_hidden_toggled_cb), impl);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->hidden_files_item),
- priv->show_hidden);
+ priv->show_hidden);
g_signal_handlers_unblock_by_func (priv->hidden_files_item,
- G_CALLBACK (show_hidden_toggled_cb), impl);
+ G_CALLBACK (show_hidden_toggled_cb), impl);
/* 'Show Size Column' */
g_signal_handlers_block_by_func (priv->size_column_item,
- G_CALLBACK (show_size_column_toggled_cb), impl);
+ G_CALLBACK (show_size_column_toggled_cb), impl);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->size_column_item),
- priv->show_size_column);
+ priv->show_size_column);
g_signal_handlers_unblock_by_func (priv->size_column_item,
- G_CALLBACK (show_size_column_toggled_cb), impl);
+ G_CALLBACK (show_size_column_toggled_cb), impl);
g_signal_handlers_block_by_func (priv->sort_directories_item,
G_CALLBACK (sort_directories_toggled_cb), impl);
gint *x,
gint *y,
gboolean *push_in,
- gpointer user_data)
+ gpointer user_data)
{
GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (user_data);
static void
file_list_popup_menu (GtkFileChooserWidget *impl,
- GdkEventButton *event)
+ GdkEventButton *event)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
file_list_update_popup_menu (impl);
if (event)
gtk_menu_popup (GTK_MENU (priv->browse_files_popup_menu),
- NULL, NULL, NULL, NULL,
- event->button, event->time);
+ NULL, NULL, NULL, NULL,
+ event->button, event->time);
else
{
gtk_menu_popup (GTK_MENU (priv->browse_files_popup_menu),
- NULL, NULL,
- popup_position_func, priv->browse_files_tree_view,
- 0, GDK_CURRENT_TIME);
+ NULL, NULL,
+ popup_position_func, priv->browse_files_tree_view,
+ 0, GDK_CURRENT_TIME);
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->browse_files_popup_menu),
- FALSE);
+ FALSE);
}
}
/* Callback used for the GtkWidget::popup-menu signal of the file list */
static gboolean
list_popup_menu_cb (GtkWidget *widget,
- GtkFileChooserWidget *impl)
+ GtkFileChooserWidget *impl)
{
file_list_popup_menu (impl, NULL);
return TRUE;
*/
static gboolean
list_button_press_event_cb (GtkWidget *widget,
- GdkEventButton *event,
- GtkFileChooserWidget *impl)
+ GdkEventButton *event,
+ GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
*/
static void
location_mode_set (GtkFileChooserWidget *impl,
- LocationMode new_mode)
+ LocationMode new_mode)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
gboolean switch_to_file_list;
switch (new_mode)
- {
- case LOCATION_MODE_PATH_BAR:
+ {
+ case LOCATION_MODE_PATH_BAR:
- /* 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);
- if (!current_focus || current_focus == priv->location_entry)
- switch_to_file_list = TRUE;
- }
+ /* 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);
+ if (!current_focus || current_focus == priv->location_entry)
+ switch_to_file_list = TRUE;
+ }
- location_switch_to_path_bar (impl);
+ location_switch_to_path_bar (impl);
- if (switch_to_file_list)
- gtk_widget_grab_focus (priv->browse_files_tree_view);
+ if (switch_to_file_list)
+ gtk_widget_grab_focus (priv->browse_files_tree_view);
- break;
+ break;
- case LOCATION_MODE_FILENAME_ENTRY:
- location_switch_to_filename_entry (impl);
- break;
+ case LOCATION_MODE_FILENAME_ENTRY:
+ location_switch_to_filename_entry (impl);
+ break;
- default:
- g_assert_not_reached ();
- return;
- }
+ default:
+ g_assert_not_reached ();
+ return;
+ }
}
priv->location_mode = new_mode;
/* Sets the extra_widget by packing it in the appropriate place */
static void
set_extra_widget (GtkFileChooserWidget *impl,
- GtkWidget *extra_widget)
+ GtkWidget *extra_widget)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
static void
set_local_only (GtkFileChooserWidget *impl,
- gboolean local_only)
+ gboolean local_only)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
priv->local_only = local_only;
if (priv->location_entry)
- _gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), local_only);
+ _gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), local_only);
gtk_places_sidebar_set_local_only (GTK_PLACES_SIDEBAR (priv->places_sidebar), local_only);
if (local_only && priv->current_folder &&
!_gtk_file_has_native_path (priv->current_folder))
- {
- /* 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.
- */
- switch_to_home_dir (impl);
- }
+ {
+ /* 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.
+ */
+ switch_to_home_dir (impl);
+ }
}
}
/* Sets the file chooser to multiple selection mode */
static void
set_select_multiple (GtkFileChooserWidget *impl,
- gboolean select_multiple,
- gboolean property_notify)
+ gboolean select_multiple,
+ gboolean property_notify)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkTreeSelection *selection;
GFile *file;
gtk_tree_model_get (GTK_TREE_MODEL (priv->recent_model), iter,
- MODEL_COL_FILE, &file,
- -1);
+ MODEL_COL_FILE, &file,
+ -1);
_gtk_path_bar_set_file (GTK_PATH_BAR (priv->browse_path_bar), file, FALSE);
g_object_unref (file);
}
case OPERATION_MODE_RECENT:
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- GtkTreeSelection *selection;
- gboolean have_selected;
- GtkTreeIter iter;
+ {
+ GtkTreeSelection *selection;
+ gboolean have_selected;
+ GtkTreeIter iter;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
- /* Save mode means single-selection mode, so the following is valid */
- have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter);
+ /* Save mode means single-selection mode, so the following is valid */
+ have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter);
- if (have_selected)
- {
- put_recent_folder_in_pathbar (impl, &iter);
- }
- }
+ if (have_selected)
+ {
+ put_recent_folder_in_pathbar (impl, &iter);
+ }
+ }
visible = FALSE;
break;
gtk_places_sidebar_set_show_trash (GTK_PLACES_SIDEBAR (priv->places_sidebar), FALSE);
if (priv->select_multiple)
- {
- 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);
- }
+ {
+ 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);
+ }
}
else if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
save_widgets_destroy (impl);
gtk_places_sidebar_set_show_recent (GTK_PLACES_SIDEBAR (priv->places_sidebar), recent_files_setting_is_enabled (impl));
case GTK_FILE_CHOOSER_PROP_ACTION:
{
- GtkFileChooserAction action = g_value_get_enum (value);
+ GtkFileChooserAction action = g_value_get_enum (value);
- if (action != priv->action)
- {
- gtk_file_chooser_widget_unselect_all (GTK_FILE_CHOOSER (impl));
-
- if ((action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+ if (action != priv->action)
+ {
+ gtk_file_chooser_widget_unselect_all (GTK_FILE_CHOOSER (impl));
+
+ if ((action == GTK_FILE_CHOOSER_ACTION_SAVE ||
action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- && priv->select_multiple)
- {
- 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.");
- set_select_multiple (impl, FALSE, TRUE);
- }
- priv->action = action;
+ && priv->select_multiple)
+ {
+ 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.");
+ set_select_multiple (impl, FALSE, TRUE);
+ }
+ priv->action = action;
update_cell_renderer_attributes (impl);
- update_appearance (impl);
- settings_load (impl);
- }
+ update_appearance (impl);
+ settings_load (impl);
+ }
}
break;
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
{
- gboolean select_multiple = g_value_get_boolean (value);
- if ((priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+ gboolean select_multiple = g_value_get_boolean (value);
+ if ((priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- && select_multiple)
- {
- 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.");
- return;
- }
-
- set_select_multiple (impl, select_multiple, FALSE);
+ && select_multiple)
+ {
+ 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.");
+ return;
+ }
+
+ set_select_multiple (impl, select_multiple, FALSE);
}
break;
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
{
- gboolean show_hidden = g_value_get_boolean (value);
- if (show_hidden != priv->show_hidden)
- {
- priv->show_hidden = show_hidden;
-
- if (priv->browse_files_model)
- _gtk_file_system_model_set_show_hidden (priv->browse_files_model, show_hidden);
- }
+ gboolean show_hidden = g_value_get_boolean (value);
+ if (show_hidden != priv->show_hidden)
+ {
+ priv->show_hidden = show_hidden;
+
+ if (priv->browse_files_model)
+ _gtk_file_system_model_set_show_hidden (priv->browse_files_model, show_hidden);
+ }
}
break;
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
{
- gboolean do_overwrite_confirmation = g_value_get_boolean (value);
- priv->do_overwrite_confirmation = do_overwrite_confirmation;
+ gboolean do_overwrite_confirmation = g_value_get_boolean (value);
+ priv->do_overwrite_confirmation = do_overwrite_confirmation;
}
break;
static void
gtk_file_chooser_widget_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (object);
GtkFileChooserWidgetPrivate *priv = impl->priv;
/* Removes the settings signal handler. It's safe to call multiple times */
static void
remove_settings_signal (GtkFileChooserWidget *impl,
- GdkScreen *screen)
+ GdkScreen *screen)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
settings = gtk_settings_get_for_screen (screen);
g_signal_handler_disconnect (settings,
- priv->settings_signal_id);
+ priv->settings_signal_id);
priv->settings_signal_id = 0;
}
}
*/
static void
toplevel_set_focus_cb (GtkWindow *window,
- GtkWidget *focus,
- GtkFileChooserWidget *impl)
+ GtkWidget *focus,
+ GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
*/
static void
gtk_file_chooser_widget_hierarchy_changed (GtkWidget *widget,
- GtkWidget *previous_toplevel)
+ GtkWidget *previous_toplevel)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (widget);
GtkFileChooserWidgetPrivate *priv = impl->priv;
{
g_assert (priv->toplevel_set_focus_id == 0);
priv->toplevel_set_focus_id = g_signal_connect (toplevel, "set-focus",
- G_CALLBACK (toplevel_set_focus_cb), impl);
+ G_CALLBACK (toplevel_set_focus_cb), impl);
priv->toplevel_last_focus_widget = gtk_window_get_focus (GTK_WINDOW (toplevel));
}
}
/* Callback used when a GtkSettings value changes */
static void
settings_notify_cb (GObject *object,
- GParamSpec *pspec,
- GtkFileChooserWidget *impl)
+ GParamSpec *pspec,
+ GtkFileChooserWidget *impl)
{
const char *name;
{
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
priv->settings_signal_id = g_signal_connect (settings, "notify",
- G_CALLBACK (settings_notify_cb), impl);
+ G_CALLBACK (settings_notify_cb), impl);
change_icon_theme (impl);
}
static void
gtk_file_chooser_widget_screen_changed (GtkWidget *widget,
- GdkScreen *previous_screen)
+ GdkScreen *previous_screen)
{
GtkFileChooserWidget *impl;
hay = G_FILE (l->data);
if (g_file_equal (hay, needle))
- {
- exists = TRUE;
- break;
- }
+ {
+ exists = TRUE;
+ break;
+ }
}
g_slist_free_full (haystack, g_object_unref);
switch (priv->reload_state)
{
case RELOAD_EMPTY:
- set_startup_mode (impl);
+ set_startup_mode (impl);
break;
case RELOAD_HAS_FOLDER:
/* Sort callback for the filename column */
static gint
name_sort_func (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ gpointer user_data)
{
GtkFileSystemModel *fs_model = GTK_FILE_SYSTEM_MODEL (model);
GtkFileChooserWidget *impl = user_data;
/* Sort callback for the size column */
static gint
size_sort_func (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
+ GtkTreeIter *a,
+ GtkTreeIter *b,
+ gpointer user_data)
{
GtkFileSystemModel *fs_model = GTK_FILE_SYSTEM_MODEL (model);
GtkFileChooserWidget *impl = user_data;
*/
static void
list_sort_column_changed_cb (GtkTreeSortable *sortable,
- GtkFileChooserWidget *impl)
+ GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
gint sort_column_id;
static void
set_busy_cursor (GtkFileChooserWidget *impl,
- gboolean busy)
+ gboolean busy)
{
GtkWidget *widget;
GtkWindow *toplevel;
}
else
g_assert (priv->load_state == LOAD_EMPTY ||
- priv->load_state == LOAD_LOADING ||
- priv->load_state == LOAD_FINISHED);
+ priv->load_state == LOAD_LOADING ||
+ priv->load_state == LOAD_FINISHED);
g_assert (new_load_state == LOAD_EMPTY ||
- new_load_state == LOAD_LOADING ||
- new_load_state == LOAD_FINISHED);
+ new_load_state == LOAD_LOADING ||
+ new_load_state == LOAD_FINISHED);
priv->load_state = new_load_state;
}
*/
static void
center_selected_row_foreach_cb (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
struct center_selected_row_closure *closure;
static gboolean
show_and_select_files (GtkFileChooserWidget *impl,
- GSList *files)
+ GSList *files)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkTreeSelection *selection;
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;
- }
- }
+ /* 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? */
*/
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN &&
gtk_widget_get_mapped (GTK_WIDGET (impl)))
- browse_files_select_first_row (impl);
+ browse_files_select_first_row (impl);
}
g_assert (priv->pending_select_files == NULL);
char *msg;
info = g_file_query_info (priv->current_folder,
- G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
- G_FILE_QUERY_INFO_NONE,
- NULL,
- NULL);
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
if (info)
{
msg = g_strdup_printf (_("Could not read the contents of %s"), g_file_info_get_display_name (info));
/* Callback used when the file system model finishes loading */
static void
-browse_files_model_finished_loading_cb (GtkFileSystemModel *model,
- GError *error,
- GtkFileChooserWidget *impl)
+browse_files_model_finished_loading_cb (GtkFileSystemModel *model,
+ GError *error,
+ GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
static void
stop_loading_and_clear_list_model (GtkFileChooserWidget *impl,
- gboolean remove_from_treeview)
+ gboolean remove)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
load_remove_timer (impl, LOAD_EMPTY);
- if (priv->browse_files_model)
- {
- g_object_unref (priv->browse_files_model);
- priv->browse_files_model = NULL;
- }
+ g_set_object (&priv->browse_files_model, NULL);
- if (remove_from_treeview)
+ if (remove)
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view), NULL);
}
return output;
}
+static void
+replace_ratio (gchar **str)
+{
+ if (g_get_charset (NULL))
+ {
+ gchar *ret;
+ ret = string_replace (*str, ":", "\xE2\x80\x8E∶");
+ g_free (*str);
+ *str = ret;
+ }
+}
+
static char *
my_g_format_date_for_display (GtkFileChooserWidget *impl,
glong secs)
format = N_("%-e %b %Y");
}
- g_date_time_unref (now);
-
date_str = g_date_time_format (time, format);
+ replace_ratio (&date_str);
- if (g_get_charset (NULL))
- {
- gchar *ret;
- ret = string_replace (date_str, ":", "\xE2\x80\x8E∶");
- g_free (date_str);
- date_str = ret;
- }
-
+ g_date_time_unref (now);
g_date_time_unref (time);
return date_str;
format = _("%l:%M %p");
date_str = g_date_time_format (time, format);
-
- if (g_get_charset (NULL))
- {
- gchar *ret;
- ret = string_replace (date_str, ":", "\xE2\x80\x8E∶");
- g_free (date_str);
- date_str = ret;
- }
+ replace_ratio (&date_str);
g_date_time_unref (time);
}
static void
-copy_attribute (GFileInfo *to, GFileInfo *from, const char *attribute)
+copy_attribute (GFileInfo *to,
+ GFileInfo *from,
+ const gchar *attribute)
{
GFileAttributeType type;
gpointer value;
}
static void
-file_system_model_got_thumbnail (GObject *object, GAsyncResult *res, gpointer data)
+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);
gboolean sensitive = TRUE;
if (!(priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
- || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
+ || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
{
sensitive = TRUE; /* for file modes... */
}
}
else
{
- /* ... and for folder modes, folders are sensitive only if the filter says so */
+ /* ... and for folder modes, folders are sensitive only if the filter says so */
GtkTreeIter iter;
if (!_gtk_file_system_model_get_iter_for_file (model, &iter, file))
g_assert_not_reached ();
/* Gets rid of the old list model and creates a new one for the current folder */
static gboolean
-set_list_model (GtkFileChooserWidget *impl,
- GError **error)
+set_list_model (GtkFileChooserWidget *impl,
+ GError **error)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
if (priv->browse_files_model &&
_gtk_file_system_model_get_directory (priv->browse_files_model) == priv->current_folder)
- {
- g_print ("avoid reloading\n");
- return TRUE;
- }
+ return TRUE;
profile_start ("start", NULL);
set_busy_cursor (impl, TRUE);
- priv->browse_files_model =
+ priv->browse_files_model =
_gtk_file_system_model_new_for_directory (priv->current_folder,
- MODEL_ATTRIBUTES,
- file_system_model_set,
- impl,
- MODEL_COLUMN_TYPES);
+ MODEL_ATTRIBUTES,
+ file_system_model_set,
+ impl,
+ MODEL_COLUMN_TYPES);
_gtk_file_system_model_set_show_hidden (priv->browse_files_model, priv->show_hidden);
set_sort_column (impl);
priv->list_sort_ascending = TRUE;
g_signal_connect (priv->browse_files_model, "sort-column-changed",
- G_CALLBACK (list_sort_column_changed_cb), impl);
+ G_CALLBACK (list_sort_column_changed_cb), impl);
load_setup_timer (impl); /* This changes the state to LOAD_PRELOAD */
g_signal_connect (priv->browse_files_model, "finished-loading",
- G_CALLBACK (browse_files_model_finished_loading_cb), impl);
+ G_CALLBACK (browse_files_model_finished_loading_cb), impl);
_gtk_file_system_model_set_filter (priv->browse_files_model, priv->current_filter);
static gint
compare_utf8_filenames (const gchar *a,
- const gchar *b)
+ const gchar *b)
{
gchar *a_folded, *b_folded;
gint retval;
static void
update_chooser_entry_selected_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
struct update_chooser_entry_selected_foreach_closure *closure;
if (closure.num_selected == 0)
{
if (priv->operation_mode == OPERATION_MODE_RECENT)
- _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), NULL);
+ _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), NULL);
else
- goto maybe_clear_entry;
+ goto maybe_clear_entry;
}
else if (closure.num_selected == 1)
{
if (priv->operation_mode == OPERATION_MODE_BROWSE)
{
- GFileInfo *info;
- gboolean change_entry;
-
- info = _gtk_file_system_model_get_info (priv->browse_files_model, &closure.first_selected_iter);
-
- /* If the cursor moved to the row of the newly created folder,
- * retrieving info will return NULL.
- */
- if (!info)
- return;
-
- g_free (priv->browse_files_last_selected_name);
- priv->browse_files_last_selected_name =
- g_strdup (g_file_info_get_display_name (info));
-
- if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
- priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- {
- /* Don't change the name when clicking on a folder... */
- change_entry = (! _gtk_file_info_consider_as_directory (info));
- }
- else
- change_entry = TRUE; /* ... unless we are in SELECT_FOLDER mode */
-
- if (change_entry && !priv->auto_selecting_first_row)
- {
+ GFileInfo *info;
+ gboolean change_entry;
+
+ info = _gtk_file_system_model_get_info (priv->browse_files_model, &closure.first_selected_iter);
+
+ /* If the cursor moved to the row of the newly created folder,
+ * retrieving info will return NULL.
+ */
+ if (!info)
+ return;
+
+ g_free (priv->browse_files_last_selected_name);
+ priv->browse_files_last_selected_name =
+ g_strdup (g_file_info_get_display_name (info));
+
+ if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ {
+ /* Don't change the name when clicking on a folder... */
+ change_entry = !_gtk_file_info_consider_as_directory (info);
+ }
+ else
+ change_entry = TRUE; /* ... unless we are in SELECT_FOLDER mode */
+
+ if (change_entry && !priv->auto_selecting_first_row)
+ {
g_signal_handlers_block_by_func (priv->location_entry, G_CALLBACK (location_entry_changed_cb), impl);
- gtk_entry_set_text (GTK_ENTRY (priv->location_entry), priv->browse_files_last_selected_name);
+ gtk_entry_set_text (GTK_ENTRY (priv->location_entry), priv->browse_files_last_selected_name);
g_signal_handlers_unblock_by_func (priv->location_entry, G_CALLBACK (location_entry_changed_cb), impl);
- if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- _gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (priv->location_entry));
- }
+ if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ _gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (priv->location_entry));
+ }
- return;
+ return;
}
else if (priv->operation_mode == OPERATION_MODE_RECENT
- && priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- GFile *folder;
+ && priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ {
+ GFile *folder;
- /* Set the base folder on the name entry, so it will do completion relative to the correct recent-folder */
+ /* Set the base folder on the name entry, so it will do completion relative to the correct recent-folder */
- gtk_tree_model_get (GTK_TREE_MODEL (priv->recent_model), &closure.first_selected_iter,
- MODEL_COL_FILE, &folder,
- -1);
- _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), folder);
- g_object_unref (folder);
- return;
- }
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->recent_model), &closure.first_selected_iter,
+ MODEL_COL_FILE, &folder,
+ -1);
+ _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), folder);
+ g_object_unref (folder);
+ return;
+ }
}
else
{
static gboolean
gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser,
- GFile *file,
- GError **error)
+ GFile *file,
+ GError **error)
{
return gtk_file_chooser_widget_update_current_folder (chooser, file, FALSE, FALSE, error);
}
static void
update_current_folder_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
- gpointer user_data)
+ GFileInfo *info,
+ const GError *error,
+ gpointer user_data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
struct UpdateCurrentFolderData *data = user_data;
if (!data->original_file)
{
- data->original_file = g_object_ref (data->file);
- data->original_error = g_error_copy (error);
- }
+ data->original_file = g_object_ref (data->file);
+ data->original_error = g_error_copy (error);
+ }
parent_file = g_file_get_parent (data->file);
/* get parent path and try to change the folder to that */
if (parent_file)
{
- g_object_unref (data->file);
- data->file = parent_file;
+ g_object_unref (data->file);
+ data->file = parent_file;
- g_object_unref (cancellable);
+ g_object_unref (cancellable);
- /* restart the update current folder operation */
- priv->reload_state = RELOAD_HAS_FOLDER;
+ /* restart the update current folder operation */
+ priv->reload_state = RELOAD_HAS_FOLDER;
- priv->update_current_folder_cancellable =
- _gtk_file_system_get_info (priv->file_system, data->file,
- "standard::type",
- update_current_folder_get_info_cb,
- data);
+ priv->update_current_folder_cancellable =
+ _gtk_file_system_get_info (priv->file_system, data->file,
+ "standard::type",
+ update_current_folder_get_info_cb,
+ data);
- set_busy_cursor (impl, TRUE);
+ set_busy_cursor (impl, TRUE);
- return;
- }
+ return;
+ }
else
{
/* Error and bail out, ignoring "not found" errors since they're useless:
else
g_error_free (data->original_error);
- g_object_unref (data->original_file);
+ g_object_unref (data->original_file);
- goto out;
- }
+ goto out;
+ }
}
if (data->original_file)
if (priv->current_folder != data->file)
{
if (priv->current_folder)
- g_object_unref (priv->current_folder);
+ g_object_unref (priv->current_folder);
priv->current_folder = g_object_ref (data->file);
}
if (priv->location_entry)
{
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry),
- priv->current_folder);
+ priv->current_folder);
if (data->clear_entry)
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), "");
}
static gboolean
-gtk_file_chooser_widget_update_current_folder (GtkFileChooser *chooser,
- GFile *file,
- gboolean keep_trail,
- gboolean clear_entry,
- GError **error)
+gtk_file_chooser_widget_update_current_folder (GtkFileChooser *chooser,
+ GFile *file,
+ gboolean keep_trail,
+ gboolean clear_entry,
+ GError **error)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
GtkFileChooserWidgetPrivate *priv = impl->priv;
priv->update_current_folder_cancellable =
_gtk_file_system_get_info (priv->file_system, file,
- "standard::type",
- update_current_folder_get_info_cb,
- data);
+ "standard::type",
+ update_current_folder_get_info_cb,
+ data);
set_busy_cursor (impl, TRUE);
g_object_unref (file);
static void
gtk_file_chooser_widget_set_current_name (GtkFileChooser *chooser,
- const gchar *name)
+ const gchar *name)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
GtkFileChooserWidgetPrivate *priv = impl->priv;
g_return_if_fail (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
- priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
pending_select_files_free (impl);
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), name);
GtkFileChooserWidgetPrivate *priv = impl->priv;
g_return_val_if_fail (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
- priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
- NULL);
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
+ NULL);
return g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->location_entry)));
}
static gboolean
gtk_file_chooser_widget_select_file (GtkFileChooser *chooser,
- GFile *file,
- GError **error)
+ GFile *file,
+ GError **error)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
GtkFileChooserWidgetPrivate *priv = impl->priv;
static void
gtk_file_chooser_widget_unselect_file (GtkFileChooser *chooser,
- GFile *file)
+ GFile *file)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
GtkFileChooserWidgetPrivate *priv = impl->priv;
- GtkTreeView *tree_view = GTK_TREE_VIEW (priv->browse_files_tree_view);
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
GtkTreeIter iter;
- if (!priv->browse_files_model)
+ tree_view = GTK_TREE_VIEW (priv->browse_files_tree_view);
+ model = gtk_tree_view_get_model (tree_view);
+ if (!model)
return;
- if (!_gtk_file_system_model_get_iter_for_file (priv->browse_files_model,
- &iter,
- file))
+ if (!_gtk_file_system_model_get_iter_for_file (GTK_FILE_SYSTEM_MODEL (model), &iter, file))
return;
- gtk_tree_selection_unselect_iter (gtk_tree_view_get_selection (tree_view),
- &iter);
+ gtk_tree_selection_unselect_iter (gtk_tree_view_get_selection (tree_view), &iter);
}
static gboolean
-maybe_select (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+maybe_select (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (data);
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkTreeSelection *selection;
gboolean is_sensitive;
gboolean is_folder;
-
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
-
+
gtk_tree_model_get (model, iter,
MODEL_COL_IS_FOLDER, &is_folder,
MODEL_COL_IS_SENSITIVE, &is_sensitive,
gtk_tree_selection_select_iter (selection, iter);
else
gtk_tree_selection_unselect_iter (selection, iter);
-
+
return FALSE;
}
priv->operation_mode == OPERATION_MODE_RECENT)
{
GtkTreeSelection *selection;
-
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
gtk_tree_selection_select_all (selection);
return;
}
if (priv->select_multiple)
- gtk_tree_model_foreach (GTK_TREE_MODEL (priv->browse_files_model),
- maybe_select, impl);
+ gtk_tree_model_foreach (GTK_TREE_MODEL (priv->browse_files_model),
+ maybe_select, impl);
}
static void
pending_select_files_free (impl);
}
-/* Checks whether the filename entry for the Save modes contains a well-formed filename.
+/* Checks whether the filename entry for 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”)
+ * 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
-check_save_entry (GtkFileChooserWidget *impl,
- GFile **file_ret,
- gboolean *is_well_formed_ret,
- gboolean *is_empty_ret,
- gboolean *is_file_part_empty_ret,
- gboolean *is_folder)
+check_save_entry (GtkFileChooserWidget *impl,
+ GFile **file_ret,
+ gboolean *is_well_formed_ret,
+ gboolean *is_empty_ret,
+ gboolean *is_file_part_empty_ret,
+ gboolean *is_folder)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkFileChooserEntry *chooser_entry;
GFile *file;
GError *error;
- 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));
+ 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));
chooser_entry = GTK_FILE_CHOOSER_ENTRY (priv->location_entry);
static void
get_files_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
GtkFileSystemModel *fs_model = GTK_FILE_SYSTEM_MODEL (model);
struct get_files_closure *info = data;
if (priv->operation_mode == OPERATION_MODE_RECENT)
{
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- file_list_seen = TRUE;
- goto file_entry;
- }
+ {
+ file_list_seen = TRUE;
+ goto file_entry;
+ }
else
- return recent_get_selected_files (impl);
+ return recent_get_selected_files (impl);
}
toplevel = get_toplevel (GTK_WIDGET (impl));
* filename entry to see if that is the case.
*/
if (info.result == NULL && priv->location_entry)
- goto file_entry;
+ goto file_entry;
}
else if (priv->location_entry && current_focus == priv->location_entry)
{
check_save_entry (impl, &info.file_from_entry, &is_well_formed, &is_empty, &is_file_part_empty, &is_folder);
if (is_empty)
- goto out;
+ goto out;
if (!is_well_formed)
- return NULL;
+ return NULL;
if (is_file_part_empty && priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- g_object_unref (info.file_from_entry);
- return NULL;
- }
+ {
+ g_object_unref (info.file_from_entry);
+ return NULL;
+ }
if (info.file_from_entry)
info.result = g_slist_prepend (info.result, info.file_from_entry);
- else if (!file_list_seen)
+ else if (!file_list_seen)
goto file_list;
else
return NULL;
/* The focus is on a dialog's action area button or something else */
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- goto file_entry;
+ goto file_entry;
else
- goto file_list;
+ goto file_list;
}
out:
- /* If there's no folder selected, and we're in SELECT_FOLDER mode, then we
- * fall back to the current directory */
+ /* If there's no folder selected, and we're in SELECT_FOLDER mode,
+ * then we fall back to the current directory
+ */
if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER &&
info.result == NULL)
{
/* Shows or hides the filter widgets */
static void
show_filters (GtkFileChooserWidget *impl,
- gboolean show)
+ gboolean show)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
- if (show)
- gtk_widget_show (priv->filter_combo_hbox);
- else
- gtk_widget_hide (priv->filter_combo_hbox);
-
+ gtk_widget_set_visible (priv->filter_combo_hbox, show);
update_extra_and_filters (impl);
}
static void
gtk_file_chooser_widget_add_filter (GtkFileChooser *chooser,
- GtkFileFilter *filter)
+ GtkFileFilter *filter)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
GtkFileChooserWidgetPrivate *priv = impl->priv;
name = gtk_file_filter_get_name (filter);
if (!name)
- name = "Untitled filter"; /* Place-holder, doesn't need to be marked for translation */
+ name = "Untitled filter"; /* Place-holder, doesn't need to be marked for translation */
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->filter_combo), name);
static void
gtk_file_chooser_widget_remove_filter (GtkFileChooser *chooser,
- GtkFileFilter *filter)
+ GtkFileFilter *filter)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
GtkFileChooserWidgetPrivate *priv = impl->priv;
if (filter == priv->current_filter)
{
if (priv->filters)
- set_current_filter (impl, priv->filters->data);
+ set_current_filter (impl, priv->filters->data);
else
- set_current_filter (impl, NULL);
+ set_current_filter (impl, NULL);
}
/* Remove row from the combo box */
static gboolean
gtk_file_chooser_widget_add_shortcut_folder (GtkFileChooser *chooser,
- GFile *file,
- GError **error)
+ GFile *file,
+ GError **error)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
GtkFileChooserWidgetPrivate *priv = impl->priv;
static gboolean
gtk_file_chooser_widget_remove_shortcut_folder (GtkFileChooser *chooser,
- GFile *file,
- GError **error)
+ GFile *file,
+ GError **error)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
GtkFileChooserWidgetPrivate *priv = impl->priv;
static void
gtk_file_chooser_widget_get_default_size (GtkFileChooserEmbed *chooser_embed,
- gint *default_width,
- gint *default_height)
+ gint *default_width,
+ gint *default_height)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser_embed);
GtkFileChooserWidgetPrivate *priv = impl->priv;
gtk_widget_get_visible (priv->preview_widget))
{
gtk_widget_get_preferred_size (priv->preview_box,
- &req, NULL);
+ &req, NULL);
*default_width += PREVIEW_HBOX_SPACING + req.width;
}
gtk_widget_get_visible (priv->extra_widget))
{
gtk_widget_get_preferred_size (priv->extra_align,
- &req, NULL);
+ &req, NULL);
*default_height += gtk_box_get_spacing (GTK_BOX (chooser_embed)) + req.height;
}
}
/* 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)
+switch_folder_foreach_cb (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
struct switch_folder_closure *closure;
*/
static GFileInfo *
get_selected_file_info_from_file_list (GtkFileChooserWidget *impl,
- gboolean *had_selection)
+ gboolean *had_selection)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkTreeSelection *selection;
static void
add_custom_button_to_dialog (GtkDialog *dialog,
- const gchar *mnemonic_label,
- gint response_id)
+ const gchar *mnemonic_label,
+ gint response_id)
{
GtkWidget *button;
*/
static gboolean
confirm_dialog_should_accept_filename (GtkFileChooserWidget *impl,
- const gchar *file_part,
- const gchar *folder_display_name)
+ const gchar *file_part,
+ const gchar *folder_display_name)
{
GtkWindow *toplevel;
GtkWidget *dialog;
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,
- _("A file named “%s” already exists. Do you want to replace it?"),
- file_part);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("A file named “%s” already exists. Do you want to replace it?"),
+ file_part);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("The file already exists in “%s”. Replacing it will "
- "overwrite its contents."),
- folder_display_name);
+ _("The file already exists in “%s”. Replacing it will "
+ "overwrite its contents."),
+ folder_display_name);
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_CANCEL);
add_custom_button_to_dialog (GTK_DIALOG (dialog), _("_Replace"), GTK_RESPONSE_ACCEPT);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
if (gtk_window_has_group (toplevel))
- gtk_window_group_add_window (gtk_window_get_group (toplevel),
- GTK_WINDOW (dialog));
+ gtk_window_group_add_window (gtk_window_get_group (toplevel), GTK_WINDOW (dialog));
response = gtk_dialog_run (GTK_DIALOG (dialog));
gchar *file_part;
};
-/* 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”.
+/* 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 (GtkFileChooserWidget *impl)
static void
confirmation_confirm_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
- gpointer user_data)
+ GFileInfo *info,
+ const GError *error,
+ gpointer user_data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
gboolean should_respond = FALSE;
*/
static gboolean
should_respond_after_confirm_overwrite (GtkFileChooserWidget *impl,
- const gchar *file_part,
- GFile *parent_file)
+ const gchar *file_part,
+ GFile *parent_file)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkFileChooserConfirmation conf;
{
case GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM:
{
- struct GetDisplayNameData *data;
+ struct GetDisplayNameData *data;
- g_assert (file_part != NULL);
+ g_assert (file_part != NULL);
- data = g_new0 (struct GetDisplayNameData, 1);
- data->impl = g_object_ref (impl);
- data->file_part = g_strdup (file_part);
+ data = g_new0 (struct GetDisplayNameData, 1);
+ data->impl = g_object_ref (impl);
+ data->file_part = g_strdup (file_part);
- if (priv->should_respond_get_info_cancellable)
- g_cancellable_cancel (priv->should_respond_get_info_cancellable);
+ if (priv->should_respond_get_info_cancellable)
+ g_cancellable_cancel (priv->should_respond_get_info_cancellable);
- priv->should_respond_get_info_cancellable =
- _gtk_file_system_get_info (priv->file_system, parent_file,
- "standard::display-name",
- confirmation_confirm_get_info_cb,
- data);
- set_busy_cursor (data->impl, TRUE);
- return FALSE;
+ priv->should_respond_get_info_cancellable =
+ _gtk_file_system_get_info (priv->file_system, parent_file,
+ "standard::display-name",
+ confirmation_confirm_get_info_cb,
+ data);
+ set_busy_cursor (data->impl, TRUE);
+ return FALSE;
}
case GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME:
static void
name_entry_get_parent_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
- gpointer user_data)
+ GFileInfo *info,
+ const GError *error,
+ gpointer user_data)
{
gboolean parent_is_folder;
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
if (parent_is_folder)
{
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN)
- {
- 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) */
- }
+ {
+ 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) */
+ }
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
{
if (data->file_exists_and_is_not_folder)
- {
- gboolean retval;
- char *file_part;
+ {
+ gboolean retval;
+ char *file_part;
/* Dup the string because the string may be modified
* depending on what clients do in the confirm-overwrite
* signal and this corrupts the pointer
*/
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);
+ retval = should_respond_after_confirm_overwrite (impl, file_part, data->parent_file);
g_free (file_part);
- if (retval)
- request_response_and_add_to_recent_list (impl);
- }
- else
- request_response_and_add_to_recent_list (impl);
- }
+ if (retval)
+ request_response_and_add_to_recent_list (impl);
+ }
+ else
+ request_response_and_add_to_recent_list (impl);
+ }
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
- || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
{
- GError *mkdir_error = NULL;
+ GError *mkdir_error = NULL;
- /* In both cases (SELECT_FOLDER and CREATE_FOLDER), if you type
- * "/blah/nonexistent" you *will* want a folder created.
- */
+ /* In both cases (SELECT_FOLDER and CREATE_FOLDER), if you type
+ * "/blah/nonexistent" you *will* want a folder created.
+ */
- set_busy_cursor (impl, TRUE);
- g_file_make_directory (data->file, NULL, &mkdir_error);
- set_busy_cursor (impl, FALSE);
+ set_busy_cursor (impl, TRUE);
+ g_file_make_directory (data->file, NULL, &mkdir_error);
+ set_busy_cursor (impl, FALSE);
- if (!mkdir_error)
- request_response_and_add_to_recent_list (impl);
- else
- error_creating_folder_dialog (impl, data->file, mkdir_error);
+ if (!mkdir_error)
+ request_response_and_add_to_recent_list (impl);
+ else
+ error_creating_folder_dialog (impl, data->file, mkdir_error);
}
else
- g_assert_not_reached ();
+ g_assert_not_reached ();
}
else
{
if (info)
- {
- /* The parent exists, but it's not a folder! Someone probably typed existing_file.txt/subfile.txt */
- error_with_file_under_nonfolder (impl, data->parent_file);
- }
+ {
+ /* The parent exists, but it's not a folder!
+ * Someone probably typed existing_file.txt/subfile.txt
+ */
+ error_with_file_under_nonfolder (impl, data->parent_file);
+ }
else
- {
- GError *error_copy;
+ {
+ GError *error_copy;
- /* The parent folder is not readable for some reason */
+ /* The parent folder is not readable for some reason */
- error_copy = g_error_copy (error);
- error_changing_folder_dialog (impl, data->parent_file, error_copy);
- }
+ error_copy = g_error_copy (error);
+ error_changing_folder_dialog (impl, data->parent_file, error_copy);
+ }
}
out:
static void
file_exists_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
- gpointer user_data)
+ GFileInfo *info,
+ const GError *error,
+ gpointer user_data)
{
gboolean data_ownership_taken = FALSE;
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN)
{
if (is_folder)
- change_folder_and_display_error (impl, data->file, TRUE);
+ change_folder_and_display_error (impl, data->file, TRUE);
else
- {
- if (file_exists)
- request_response_and_add_to_recent_list (impl); /* user typed an existing filename; we are done */
- else
- needs_parent_check = TRUE; /* file doesn't exist; see if its parent exists */
- }
+ {
+ if (file_exists)
+ request_response_and_add_to_recent_list (impl); /* user typed an existing filename; we are done */
+ else
+ needs_parent_check = TRUE; /* file doesn't exist; see if its parent exists */
+ }
}
else if (priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
{
* a folder
*/
error_creating_folder_over_existing_file_dialog (impl, data->file,
- g_error_copy (error));
+ g_error_copy (error));
}
else
{
{
if (!file_exists)
{
- needs_parent_check = TRUE;
+ needs_parent_check = TRUE;
}
else
- {
- if (is_folder)
- {
- /* User typed a folder; we are done */
- request_response_and_add_to_recent_list (impl);
- }
- else
- error_selecting_folder_over_existing_file_dialog (impl);
- }
+ {
+ if (is_folder)
+ {
+ /* User typed a folder; we are done */
+ request_response_and_add_to_recent_list (impl);
+ }
+ else
+ error_selecting_folder_over_existing_file_dialog (impl);
+ }
}
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
{
if (is_folder)
- change_folder_and_display_error (impl, data->file, TRUE);
+ change_folder_and_display_error (impl, data->file, TRUE);
else
if (!file_exists && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FILENAME_TOO_LONG))
error_filename_to_long_dialog (data->impl);
g_assert_not_reached();
}
- if (needs_parent_check) {
- /* check that everything up to the last path component exists (i.e. the parent) */
+ if (needs_parent_check)
+ {
+ /* check that everything up to the last path component exists (i.e. the parent) */
- data->file_exists_and_is_not_folder = file_exists && !is_folder;
- data_ownership_taken = TRUE;
+ data->file_exists_and_is_not_folder = file_exists && !is_folder;
+ data_ownership_taken = TRUE;
- if (priv->should_respond_get_info_cancellable)
- g_cancellable_cancel (priv->should_respond_get_info_cancellable);
+ if (priv->should_respond_get_info_cancellable)
+ g_cancellable_cancel (priv->should_respond_get_info_cancellable);
priv->should_respond_get_info_cancellable =
- _gtk_file_system_get_info (priv->file_system,
- data->parent_file,
- "standard::type",
- name_entry_get_parent_info_cb,
- data);
+ _gtk_file_system_get_info (priv->file_system,
+ data->parent_file,
+ "standard::type",
+ name_entry_get_parent_info_cb,
+ data);
set_busy_cursor (impl, TRUE);
}
}
static void
-paste_text_received (GtkClipboard *clipboard,
- const gchar *text,
- GtkFileChooserWidget *impl)
+paste_text_received (GtkClipboard *clipboard,
+ const gchar *text,
+ GtkFileChooserWidget *impl)
{
GFile *file;
location_popup_on_paste_handler (GtkFileChooserWidget *impl)
{
GtkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (impl),
- GDK_SELECTION_CLIPBOARD);
+ GDK_SELECTION_CLIPBOARD);
gtk_clipboard_request_text (clipboard,
- (GtkClipboardTextReceivedFunc) paste_text_received,
- impl);
+ (GtkClipboardTextReceivedFunc) paste_text_received,
+ impl);
}
/* Implementation for GtkFileChooserEmbed::should_respond() */
uri = g_file_get_uri (file);
if (uri)
- {
- gtk_recent_manager_add_item (priv->recent_manager, uri);
- g_free (uri);
- }
+ {
+ gtk_recent_manager_add_item (priv->recent_manager, uri);
+ g_free (uri);
+ }
}
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
* 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 */
+ 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 }
+ /* 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 }
};
int num_selected;
g_assert (priv->action >= GTK_FILE_CHOOSER_ACTION_OPEN && priv->action <= GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
if (priv->operation_mode == OPERATION_MODE_RECENT)
- {
- if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- goto save_entry;
- else
- {
- retval = recent_should_respond (impl);
- goto out;
- }
- }
+ {
+ if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ goto save_entry;
+ else
+ {
+ retval = recent_should_respond (impl);
+ goto out;
+ }
+ }
selection_check (impl, &num_selected, &all_files, &all_folders);
if (num_selected > 2)
- k = 2;
+ k = 2;
else
- k = num_selected;
+ k = num_selected;
action = what_to_do [priv->action] [k];
switch (action)
- {
- case NOOP:
- return FALSE;
-
- case RESPOND:
- retval = TRUE;
- goto out;
-
- case RESPOND_OR_SWITCH:
- g_assert (num_selected == 1);
-
- if (all_folders)
- {
- switch_to_selected_folder (impl);
- return FALSE;
- }
- else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- retval = should_respond_after_confirm_overwrite (impl,
- get_display_name_from_file_list (impl),
- priv->current_folder);
- goto out;
- }
- else
- {
- retval = TRUE;
- goto out;
- }
-
- case ALL_FILES:
- retval = all_files;
- goto out;
-
- case ALL_FOLDERS:
- retval = all_folders;
- goto out;
-
- case SAVE_ENTRY:
- goto save_entry;
-
- default:
- g_assert_not_reached ();
- }
+ {
+ case NOOP:
+ return FALSE;
+
+ case RESPOND:
+ retval = TRUE;
+ goto out;
+
+ case RESPOND_OR_SWITCH:
+ g_assert (num_selected == 1);
+
+ if (all_folders)
+ {
+ switch_to_selected_folder (impl);
+ return FALSE;
+ }
+ else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ {
+ retval = should_respond_after_confirm_overwrite (impl,
+ get_display_name_from_file_list (impl),
+ priv->current_folder);
+ goto out;
+ }
+ else
+ {
+ retval = TRUE;
+ goto out;
+ }
+
+ case ALL_FILES:
+ retval = all_files;
+ goto out;
+
+ case ALL_FOLDERS:
+ retval = all_folders;
+ goto out;
+
+ case SAVE_ENTRY:
+ goto save_entry;
+
+ default:
+ g_assert_not_reached ();
+ }
}
else if ((priv->location_entry != NULL) && (current_focus == priv->location_entry))
{
save_entry:
- 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));
+ 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));
entry = GTK_FILE_CHOOSER_ENTRY (priv->location_entry);
check_save_entry (impl, &file, &is_well_formed, &is_empty, &is_file_part_empty, &is_folder);
if (!is_well_formed)
- {
- if (!is_empty
- && priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
- && priv->operation_mode == OPERATION_MODE_RECENT)
- {
- /* FIXME: ERROR_NO_FOLDER */
+ {
+ if (!is_empty &&
+ priv->action == GTK_FILE_CHOOSER_ACTION_SAVE &&
+ priv->operation_mode == OPERATION_MODE_RECENT)
+ {
+ /* FIXME: 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!
- */
- gtk_widget_grab_focus (priv->browse_files_tree_view);
+ /* 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!
+ */
+ gtk_widget_grab_focus (priv->browse_files_tree_view);
#endif
- }
- /* FIXME: else show an "invalid filename" error as the pathbar mode? */
+ }
+ /* FIXME: else show an "invalid filename" error as the pathbar mode? */
- return FALSE;
- }
+ return FALSE;
+ }
if (is_empty)
{
- if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
- || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- {
- /* FIXME: ERROR_NO_FILENAME */
- gtk_widget_grab_focus (priv->location_entry);
- return FALSE;
- }
+ if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ {
+ /* FIXME: ERROR_NO_FILENAME */
+ gtk_widget_grab_focus (priv->location_entry);
+ return FALSE;
+ }
goto file_list;
}
error = NULL;
if (is_folder)
- {
- if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- change_folder_and_display_error (impl, file, TRUE);
- }
- else if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
- priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- {
- /* The folder already exists, so we do not need to create it.
- * Just respond to terminate the dialog.
- */
- retval = TRUE;
- }
- else
- {
- g_assert_not_reached ();
- }
- }
+ {
+ if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ {
+ change_folder_and_display_error (impl, file, TRUE);
+ }
+ else if (priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ {
+ /* The folder already exists, so we do not need to create it.
+ * Just respond to terminate the dialog.
+ */
+ retval = TRUE;
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+ }
else
- {
- struct FileExistsData *data;
+ {
+ struct FileExistsData *data;
- /* 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).
- */
+ /* 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).
+ */
- data = g_new0 (struct FileExistsData, 1);
- data->impl = g_object_ref (impl);
- data->file = g_object_ref (file);
- data->parent_file = _gtk_file_chooser_entry_get_current_folder (entry);
+ data = g_new0 (struct FileExistsData, 1);
+ data->impl = g_object_ref (impl);
+ data->file = g_object_ref (file);
+ data->parent_file = _gtk_file_chooser_entry_get_current_folder (entry);
- if (priv->file_exists_get_info_cancellable)
- g_cancellable_cancel (priv->file_exists_get_info_cancellable);
+ if (priv->file_exists_get_info_cancellable)
+ g_cancellable_cancel (priv->file_exists_get_info_cancellable);
- priv->file_exists_get_info_cancellable =
- _gtk_file_system_get_info (priv->file_system, file,
- "standard::type",
- file_exists_get_info_cb,
- data);
+ priv->file_exists_get_info_cancellable =
+ _gtk_file_system_get_info (priv->file_system, file,
+ "standard::type",
+ file_exists_get_info_cb,
+ data);
- set_busy_cursor (impl, TRUE);
+ set_busy_cursor (impl, TRUE);
- if (error != NULL)
- g_error_free (error);
- }
+ if (error != NULL)
+ g_error_free (error);
+ }
g_object_unref (file);
}
else if (priv->toplevel_last_focus_widget == priv->browse_files_tree_view)
{
/* The focus is on a dialog's action area button, *and* the widget that
- * was focused immediately before it is the file list.
+ * was focused immediately before it is the file list.
*/
goto file_list;
}
}
else
/* The focus is on a dialog's action area button or something else */
- if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE
- || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
goto save_entry;
else
- goto file_list;
+ goto file_list;
out:
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
if (priv->location_mode == LOCATION_MODE_PATH_BAR
- || priv->operation_mode == OPERATION_MODE_RECENT)
- widget = priv->browse_files_tree_view;
+ || priv->operation_mode == OPERATION_MODE_RECENT)
+ widget = priv->browse_files_tree_view;
else
- widget = priv->location_entry;
+ widget = priv->location_entry;
}
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
- priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
widget = priv->location_entry;
else
{
/* Callback used from gtk_tree_selection_selected_foreach(); gets the selected GFiles */
static void
search_selected_foreach_get_file_cb (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
GSList **list;
GFile *file;
list = data;
gtk_tree_model_get (model, iter, MODEL_COL_FILE, &file, -1);
- *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 */
+ /* The file already has a new ref courtesy of gtk_tree_model_get();
+ * this will be unreffed by the caller
+ */
+ *list = g_slist_prepend (*list, file);
}
/* Constructs a list of the selected paths in search mode */
/* Callback used from GtkSearchEngine when we get new hits */
static void
search_engine_hits_added_cb (GtkSearchEngine *engine,
- GList *hits,
- GtkFileChooserWidget *impl)
+ GList *hits,
+ GtkFileChooserWidget *impl)
{
GList *l, *files, *files_with_info, *infos;
GFile *file;
/* Callback used from GtkSearchEngine when the query is done running */
static void
search_engine_finished_cb (GtkSearchEngine *engine,
- gpointer data)
+ gpointer data)
{
GtkFileChooserWidget *impl;
gtk_stack_set_visible_child_name (GTK_STACK (impl->priv->browse_files_stack), "empty");
}
-/* Displays a generic error when we cannot create a GtkSearchEngine.
- * It would be better if _gtk_search_engine_new() gave us a GError
+/* 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 (GtkFileChooserWidget *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."));
+ _("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)
+ const gchar *message,
+ gpointer data)
{
- GtkFileChooserWidget *impl;
-
- impl = GTK_FILE_CHOOSER_WIDGET (data);
+ GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (data);
search_stop_searching (impl, TRUE);
error_message (impl, _("Could not send the search request"), message);
/* Frees the data in the search_model */
static void
search_clear_model (GtkFileChooserWidget *impl,
- gboolean remove_from_treeview)
+ gboolean remove)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
if (!priv->search_model)
return;
- if (remove_from_treeview &&
- 1)//gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view)) == GTK_TREE_MODEL (priv->search_model))
- {
- g_print ("clear model\n");
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view), NULL);
- }
+ if (remove &&
+ gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view)) == GTK_TREE_MODEL (priv->search_model))
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view), NULL);
g_clear_object (&priv->search_model);
}
g_object_unref (priv->search_query);
priv->search_query = NULL;
}
-
+
if (priv->search_engine)
{
_gtk_search_engine_stop (priv->search_engine);
g_signal_handlers_disconnect_by_data (priv->search_engine, impl);
- g_object_unref (priv->search_engine);
- priv->search_engine = NULL;
+ g_clear_object (&priv->search_engine);
+
set_busy_cursor (impl, FALSE);
gtk_spinner_stop (GTK_SPINNER (priv->search_spinner));
}
priv->search_model = _gtk_file_system_model_new (file_system_model_set,
impl,
- MODEL_COLUMN_TYPES);
+ MODEL_COLUMN_TYPES);
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (priv->search_model),
- search_sort_func,
- impl, NULL);
+ search_sort_func,
+ impl, NULL);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->search_model),
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
GTK_SORT_ASCENDING);
- /* 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
- */
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view),
GTK_TREE_MODEL (priv->search_model));
/* Creates a new query with the specified text and launches it */
static void
search_start_query (GtkFileChooserWidget *impl,
- const gchar *query_text)
+ const gchar *query_text)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GFile *file;
search_stop_searching (impl, FALSE);
search_clear_model (impl, TRUE);
search_setup_model (impl);
+
set_busy_cursor (impl, TRUE);
gtk_spinner_start (GTK_SPINNER (priv->search_spinner));
priv->show_progress_timeout = g_timeout_add (1000, show_spinner, impl);
_gtk_search_engine_set_query (priv->search_engine, priv->search_query);
g_signal_connect (priv->search_engine, "hits-added",
- G_CALLBACK (search_engine_hits_added_cb), impl);
+ G_CALLBACK (search_engine_hits_added_cb), impl);
g_signal_connect (priv->search_engine, "finished",
- G_CALLBACK (search_engine_finished_cb), impl);
+ G_CALLBACK (search_engine_finished_cb), impl);
g_signal_connect (priv->search_engine, "error",
- G_CALLBACK (search_engine_error_cb), impl);
+ G_CALLBACK (search_engine_error_cb), impl);
_gtk_search_engine_start (priv->search_engine);
}
text = gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
/* reset any existing query object */
- if (priv->search_query)
- {
- g_object_unref (priv->search_query);
- priv->search_query = NULL;
- }
-
- if (strlen (text) == 0)
- return;
+ g_set_object (&priv->search_query, NULL);
- search_start_query (impl, text);
+ if (text[0] != '\0')
+ search_start_query (impl, text);
}
static void
/* if there already is a query, restart it */
if (priv->search_query)
{
- gchar *query = gtk_query_get_text (priv->search_query);
+ gchar *query;
+ query = gtk_query_get_text (priv->search_query);
if (query)
{
gtk_entry_set_text (GTK_ENTRY (priv->search_entry), query);
search_start_query (impl, query);
-
g_free (query);
}
else
priv->search_query = NULL;
}
}
-
- /* FMQ: hide the filter combo? */
}
/*
/* Frees the data in the recent_model */
static void
recent_clear_model (GtkFileChooserWidget *impl,
- gboolean remove_from_treeview)
+ gboolean remove)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
if (!priv->recent_model)
return;
- if (remove_from_treeview)
+ if (remove)
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view), NULL);
- g_object_unref (priv->recent_model);
- priv->recent_model = NULL;
+ g_set_object (&priv->recent_model, NULL);
}
/* Stops any ongoing loading of the recent files list; does
priv->recent_model = _gtk_file_system_model_new (file_system_model_set,
impl,
- MODEL_COLUMN_TYPES);
+ MODEL_COLUMN_TYPES);
- _gtk_file_system_model_set_filter (priv->recent_model,
- priv->current_filter);
+ _gtk_file_system_model_set_filter (priv->recent_model, priv->current_filter);
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (priv->recent_model),
recent_sort_func,
impl, NULL);
g_free (load_data);
}
-/* Populates the file system model with the GtkRecentInfo* items in the provided list; frees the items */
+/* Populates the file system model with the GtkRecentInfo* items
+ * in the provided list; frees the items
+ */
static void
-populate_model_with_recent_items (GtkFileChooserWidget *impl, GList *items)
+populate_model_with_recent_items (GtkFileChooserWidget *impl,
+ GList *items)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
gint limit;
GList *l;
- int n;
+ gint n;
limit = DEFAULT_RECENT_FILES_LIMIT;
n++;
if (limit != -1 && n >= limit)
- break;
+ break;
}
g_set_object (&priv->model_for_search, priv->recent_model);
}
static void
-populate_model_with_folders (GtkFileChooserWidget *impl, GList *items)
+populate_model_with_folders (GtkFileChooserWidget *impl,
+ GList *items)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GList *folders;
folders = _gtk_file_chooser_extract_recent_folders (items);
for (l = folders; l; l = l->next)
- {
- GFile *folder = l->data;
+ _gtk_file_system_model_add_and_query_file (priv->recent_model,
+ G_FILE (l->data),
+ MODEL_ATTRIBUTES);
- _gtk_file_system_model_add_and_query_file (priv->recent_model,
- folder,
- MODEL_ATTRIBUTES);
- }
-
- g_list_foreach (folders, (GFunc) g_object_unref, NULL);
- g_list_free (folders);
+ g_list_free_full (folders, g_object_unref);
}
static gboolean
else
populate_model_with_folders (impl, load_data->items);
- g_list_foreach (load_data->items, (GFunc) gtk_recent_info_unref, NULL);
- g_list_free (load_data->items);
+ g_list_free_full (load_data->items, (GDestroyNotify) gtk_recent_info_unref);
load_data->items = NULL;
return FALSE;
static void
recent_selected_foreach_get_file_cb (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
GSList **list;
GFile *file;
return result;
}
-/* Called from ::should_respond(). We return whether there are selected
+/* Called from ::should_respond(). We return whether there are selected
* files in the recent files list.
*/
static gboolean
static void
set_current_filter (GtkFileChooserWidget *impl,
- GtkFileFilter *filter)
+ GtkFileFilter *filter)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
/* NULL filters are allowed to reset to non-filtered status */
filter_index = g_slist_index (priv->filters, filter);
if (priv->filters && filter && filter_index < 0)
- return;
+ return;
if (priv->current_filter)
- g_object_unref (priv->current_filter);
+ g_object_unref (priv->current_filter);
priv->current_filter = filter;
if (priv->current_filter)
- g_object_ref_sink (priv->current_filter);
+ g_object_ref_sink (priv->current_filter);
if (priv->filters)
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->filter_combo), filter_index);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->filter_combo), filter_index);
clear_model_cache (impl, MODEL_COL_IS_SENSITIVE);
set_model_filter (impl, priv->current_filter);
}
static void
-filter_combo_changed (GtkComboBox *combo_box,
- GtkFileChooserWidget *impl)
+filter_combo_changed (GtkComboBox *combo_box,
+ GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
- gint new_index = gtk_combo_box_get_active (combo_box);
- GtkFileFilter *new_filter = g_slist_nth_data (priv->filters, new_index);
+ gint new_index;
+ GtkFileFilter *new_filter;
+ new_index = gtk_combo_box_get_active (combo_box);
+ new_filter = g_slist_nth_data (priv->filters, new_index);
set_current_filter (impl, new_filter);
}
MODEL_COL_FILE, &new_file,
MODEL_COL_NAME, &new_display_name,
-1);
-
+
gtk_tree_path_free (path);
}
else
if (new_file != priv->preview_file &&
!(new_file && priv->preview_file &&
- g_file_equal (new_file, priv->preview_file)))
+ g_file_equal (new_file, priv->preview_file)))
{
if (priv->preview_file)
- {
- g_object_unref (priv->preview_file);
- g_free (priv->preview_display_name);
- }
+ {
+ g_object_unref (priv->preview_file);
+ g_free (priv->preview_display_name);
+ }
if (new_file)
- {
- priv->preview_file = new_file;
- priv->preview_display_name = new_display_name;
- }
+ {
+ priv->preview_file = new_file;
+ priv->preview_display_name = new_display_name;
+ }
else
- {
- priv->preview_file = NULL;
- priv->preview_display_name = NULL;
+ {
+ priv->preview_file = NULL;
+ priv->preview_display_name = NULL;
g_free (new_display_name);
- }
+ }
if (priv->use_preview_label && priv->preview_label)
- gtk_label_set_text (GTK_LABEL (priv->preview_label), priv->preview_display_name);
+ gtk_label_set_text (GTK_LABEL (priv->preview_label), priv->preview_display_name);
g_signal_emit_by_name (impl, "update-preview");
}
}
static gboolean
-list_select_func (GtkTreeSelection *selection,
- GtkTreeModel *model,
- GtkTreePath *path,
- gboolean path_currently_selected,
- gpointer data)
+list_select_func (GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ gpointer data)
{
GtkFileChooserWidget *impl = data;
GtkFileChooserWidgetPrivate *priv = impl->priv;
if (!is_sensitive || !is_folder)
return FALSE;
}
-
+
return TRUE;
}
static void
-list_selection_changed (GtkTreeSelection *selection,
- GtkFileChooserWidget *impl)
+list_selection_changed (GtkTreeSelection *selection,
+ GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
info = get_selected_file_info_from_file_list (impl, &had_selection);
if (!had_selection)
- goto out; /* normal processing */
+ goto out; /* normal processing */
if (!info)
- return; /* We are on the editable row for New Folder */
+ return; /* We are on the editable row for New Folder */
}
out:
/* Callback used when a row in the file list is activated */
static void
-list_row_activated (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- GtkFileChooserWidget *impl)
+list_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GFile *file;
MODEL_COL_IS_FOLDER, &is_folder,
MODEL_COL_IS_SENSITIVE, &is_sensitive,
-1);
-
+
if (is_sensitive && is_folder && file)
{
change_folder_and_display_error (impl, file, FALSE);
}
static void
-path_bar_clicked (GtkPathBar *path_bar,
- GFile *file,
- GFile *child_file,
- gboolean child_is_hidden,
- GtkFileChooserWidget *impl)
+path_bar_clicked (GtkPathBar *path_bar,
+ GFile *file,
+ GFile *child_file,
+ gboolean child_is_hidden,
+ GtkFileChooserWidget *impl)
{
if (child_file)
pending_select_files_add (impl, child_file);
static void
location_set_user_text (GtkFileChooserWidget *impl,
- const gchar *path)
+ const gchar *path)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
static void
location_popup_handler (GtkFileChooserWidget *impl,
- const gchar *path)
+ const gchar *path)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
if (!path)
- return;
+ return;
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY);
location_set_user_text (impl, path);
}
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
- priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
{
gtk_widget_grab_focus (priv->location_entry);
if (path != NULL)
- location_set_user_text (impl, path);
+ location_set_user_text (impl, path);
}
else
g_assert_not_reached ();
{
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 ())) {
+ */
+ name = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
+ if (!g_strcmp0 (name, g_get_home_dir ()))
return;
- }
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), name);
}
static void
quick_bookmark_handler (GtkFileChooserWidget *impl,
- gint bookmark_index)
+ gint bookmark_index)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GFile *file;
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
- g_object_set (impl,
- "show-hidden", !priv->show_hidden,
- NULL);
+ g_object_set (impl, "show-hidden", !priv->show_hidden, NULL);
}
static void
-add_normal_and_shifted_binding (GtkBindingSet *binding_set,
- guint keyval,
- GdkModifierType modifiers,
- const gchar *signal_name)
+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);
+ keyval, modifiers,
+ signal_name, 0);
gtk_binding_entry_add_signal (binding_set,
- keyval, modifiers | GDK_SHIFT_MASK,
- signal_name, 0);
+ keyval, modifiers | GDK_SHIFT_MASK,
+ signal_name, 0);
}
static void
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkBindingSet *binding_set;
- int i;
+ gint i;
gobject_class->finalize = gtk_file_chooser_widget_finalize;
gobject_class->constructed = gtk_file_chooser_widget_constructed;
/**
* GtkFileChooserWidget::location-popup:
- * @widget: the object which received the signal.
- * @path: a string that gets put in the text entry for the file
- * name.
+ * @widget: the object which received the signal
+ * @path: a string that gets put in the text entry for the file name
*
- * The ::location-popup signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::location-popup signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
- * This is used to make the file chooser show a "Location"
- * prompt which the user can use to manually type the name of
- * the file he wishes to select.
+ * This is used to make the file chooser show a "Location" prompt which
+ * the user can use to manually type the name of the file he wishes to select.
*
- * The default bindings for this signal are
- * `Control + L`
- * with a @path string of "" (the empty
- * string). It is also bound to `/` with a
- * @path string of "`/`"
- * (a slash): this lets you type `/` and
- * immediately type a path name. On Unix systems, this is bound to
- * `~` (tilde) with a @path string
- * of "~" itself for access to home directories.
+ * The default bindings for this signal are `Control + L` with a @path string
+ * of "" (the empty string). It is also bound to `/` with a @path string of
+ * "`/`" (a slash): this lets you type `/` and immediately type a path name.
+ * On Unix systems, this is bound to `~` (tilde) with a @path string of "~"
+ * itself for access to home directories.
*/
signals[LOCATION_POPUP] =
g_signal_new_class_handler (I_("location-popup"),
/**
* GtkFileChooserWidget::location-popup-on-paste:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::location-popup-on-paste signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::location-popup-on-paste signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
- * This is used to make the file chooser show a "Location"
- * prompt when the user pastes into a #GtkFileChooserWidget.
+ * This is used to make the file chooser show a "Location" prompt when the user
+ * pastes into a #GtkFileChooserWidget.
*
* The default binding for this signal is `Control + V`.
*/
/**
* GtkFileChooserWidget::location-toggle-popup:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::location-toggle-popup signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::location-toggle-popup signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
- * This is used to toggle the visibility of a "Location"
- * prompt which the user can use to manually type the name of
- * the file he wishes to select.
+ * This is used to toggle the visibility of a "Location" prompt which the user
+ * can use to manually type the name of the file he wishes to select.
*
* The default binding for this signal is `Control + L`.
*/
/**
* GtkFileChooserWidget::up-folder:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::up-folder signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::up-folder signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
- * This is used to make the file chooser go to the parent of
- * the current folder in the file hierarchy.
+ * This is used to make the file chooser go to the parent of the current folder
+ * in the file hierarchy.
*
* The default binding for this signal is `Alt + Up`.
*/
/**
* GtkFileChooserWidget::down-folder:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::down-folder signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::down-folder signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
- * This is used to make the file chooser go to a child of the
- * current folder in the file hierarchy. The subfolder that
- * will be used is displayed in the path bar widget of the file
- * chooser. For example, if the path bar is showing
- * "/foo/bar/baz", with bar currently displayed, then this will cause
- * the file chooser to switch to the "baz" subfolder.
+ * This is used to make the file chooser go to a child of the current folder
+ * in the file hierarchy. The subfolder that will be used is displayed in the
+ * path bar widget of the file chooser. For example, if the path bar is showing
+ * "/foo/bar/baz", with bar currently displayed, then this will cause the file
+ * chooser to switch to the "baz" subfolder.
*
* The default binding for this signal is `Alt + Down`.
*/
/**
* GtkFileChooserWidget::home-folder:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::home-folder signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::home-folder signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
* This is used to make the file chooser show the user's home
/**
* GtkFileChooserWidget::desktop-folder:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::desktop-folder signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::desktop-folder signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
* This is used to make the file chooser show the user's Desktop
/**
* GtkFileChooserWidget::quick-bookmark:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
* @bookmark_index: the number of the bookmark to switch to
*
- * The ::quick-bookmark signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::quick-bookmark signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
- * This is used to make the file chooser switch to the bookmark
- * specified in the @bookmark_index parameter.
- * For example, if you have three bookmarks, you can pass 0, 1, 2 to
- * this signal to switch to each of them, respectively.
+ * This is used to make the file chooser switch to the bookmark specified
+ * in the @bookmark_index parameter. For example, if you have three bookmarks,
+ * you can pass 0, 1, 2 to this signal to switch to each of them, respectively.
*
* The default binding for this signal is `Alt + 1`, `Alt + 2`,
* etc. until `Alt + 0`. Note that in the default binding, that
/**
* GtkFileChooserWidget::show-hidden:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::show-hidden signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::show-hidden signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
* This is used to make the file chooser display hidden files.
/**
* GtkFileChooserWidget::search-shortcut:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::search-shortcut signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::search-shortcut signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
* This is used to make the file chooser show the search entry.
/**
* GtkFileChooserWidget::recent-shortcut:
- * @widget: the object which received the signal.
+ * @widget: the object which received the signal
*
- * The ::recent-shortcut signal is a
- * [keybinding signal][GtkBindingSignal]
+ * The ::recent-shortcut signal is a [keybinding signal][GtkBindingSignal]
* which gets emitted when the user asks for it.
*
* This is used to make the file chooser show the Recent location.
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);
+ GDK_KEY_l, GDK_CONTROL_MASK,
+ "location-toggle-popup",
+ 0);
gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_v, GDK_CONTROL_MASK,
- "location-popup-on-paste",
- 0);
+ 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");
+ GDK_KEY_Up, GDK_MOD1_MASK,
+ "up-folder");
add_normal_and_shifted_binding (binding_set,
- GDK_KEY_KP_Up, GDK_MOD1_MASK,
- "up-folder");
+ GDK_KEY_KP_Up, GDK_MOD1_MASK,
+ "up-folder");
add_normal_and_shifted_binding (binding_set,
- GDK_KEY_Down, GDK_MOD1_MASK,
- "down-folder");
+ GDK_KEY_Down, GDK_MOD1_MASK,
+ "down-folder");
add_normal_and_shifted_binding (binding_set,
- GDK_KEY_KP_Down, GDK_MOD1_MASK,
- "down-folder");
+ 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);
+ 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);
+ 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);
+ GDK_KEY_d, GDK_MOD1_MASK,
+ "desktop-folder",
+ 0);
gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_h, GDK_CONTROL_MASK,
+ GDK_KEY_h, GDK_CONTROL_MASK,
"show-hidden",
0);
gtk_binding_entry_add_signal (binding_set,
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);
+ quick_bookmark_keyvals[i], GDK_MOD1_MASK,
+ "quick-bookmark",
+ 1, G_TYPE_INT, i);
g_object_class_install_property (gobject_class, PROP_SEARCH_MODE,
g_param_spec_boolean ("search-mode",
/* Bind class to template */
gtk_widget_class_set_template_from_resource (widget_class,
- "/org/gtk/libgtk/ui/gtkfilechooserwidget.ui");
+ "/org/gtk/libgtk/ui/gtkfilechooserwidget.ui");
/* A *lot* of widgets that we need to handle .... */
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_hpaned);
/* 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);
+ 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);
+ 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,
g_assert (cells);
cell = cells->data;
g_object_set (G_OBJECT (cell),
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL);
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ NULL);
g_list_free (cells);
priv->bookmarks_manager = _gtk_bookmarks_manager_new (NULL, NULL);
- /* Setup various attributes and callbacks in the UI
+ /* Setup various attributes and callbacks in the UI
* which cannot be done with GtkBuilder.
*/
post_process_ui (impl);
* gtk_file_chooser_widget_new:
* @action: Open or save mode for the widget
*
- * Creates a new #GtkFileChooserWidget. This is a file chooser widget that can
+ * Creates a new #GtkFileChooserWidget. This is a file chooser widget that can
* be embedded in custom windows, and it is the same widget that is used by
* #GtkFileChooserDialog.
*
gtk_file_chooser_widget_new (GtkFileChooserAction action)
{
return g_object_new (GTK_TYPE_FILE_CHOOSER_WIDGET,
- "action", action,
- NULL);
+ "action", action,
+ NULL);
}
-