2003-03-21 20:34:02 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
2003-10-23 00:26:15 +00:00
|
|
|
|
* gtkfilechooserdefault.c: Default implementation of GtkFileChooser
|
2003-03-21 20:34:02 +00:00
|
|
|
|
* Copyright (C) 2003, Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2004-03-06 03:38:59 +00:00
|
|
|
|
#include <config.h>
|
2004-02-23 19:55:49 +00:00
|
|
|
|
#include "gdk/gdkkeysyms.h"
|
2004-08-09 16:59:53 +00:00
|
|
|
|
#include "gtkalias.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkalignment.h"
|
2004-02-23 19:55:49 +00:00
|
|
|
|
#include "gtkbindings.h"
|
2003-10-23 05:10:47 +00:00
|
|
|
|
#include "gtkbutton.h"
|
2004-03-02 02:59:02 +00:00
|
|
|
|
#include "gtkcelllayout.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkcellrendererpixbuf.h"
|
2004-08-07 22:21:25 +00:00
|
|
|
|
#include "gtkcellrenderertext.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkcellrenderertext.h"
|
2004-04-02 00:35:07 +00:00
|
|
|
|
#include "gtkcheckmenuitem.h"
|
2003-10-23 05:10:47 +00:00
|
|
|
|
#include "gtkcombobox.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkentry.h"
|
2004-10-08 03:04:25 +00:00
|
|
|
|
#include "gtkeventbox.h"
|
2004-02-23 19:55:49 +00:00
|
|
|
|
#include "gtkexpander.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkfilechooserdefault.h"
|
2004-02-27 23:51:16 +00:00
|
|
|
|
#include "gtkfilechooserembed.h"
|
2003-03-25 00:11:06 +00:00
|
|
|
|
#include "gtkfilechooserentry.h"
|
2003-03-21 20:34:02 +00:00
|
|
|
|
#include "gtkfilechooserutils.h"
|
|
|
|
|
#include "gtkfilechooser.h"
|
|
|
|
|
#include "gtkfilesystemmodel.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkframe.h"
|
|
|
|
|
#include "gtkhbox.h"
|
|
|
|
|
#include "gtkhpaned.h"
|
2004-03-09 21:22:42 +00:00
|
|
|
|
#include "gtkiconfactory.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkicontheme.h"
|
|
|
|
|
#include "gtkimage.h"
|
2004-07-29 20:53:52 +00:00
|
|
|
|
#include "gtkimagemenuitem.h"
|
2003-11-03 20:24:04 +00:00
|
|
|
|
#include "gtkintl.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtklabel.h"
|
2004-02-23 19:55:49 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkmenuitem.h"
|
2003-11-03 00:50:33 +00:00
|
|
|
|
#include "gtkmessagedialog.h"
|
2004-02-20 23:21:01 +00:00
|
|
|
|
#include "gtkpathbar.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
#include "gtkscrolledwindow.h"
|
2004-07-29 20:53:52 +00:00
|
|
|
|
#include "gtkseparatormenuitem.h"
|
2003-12-01 18:57:17 +00:00
|
|
|
|
#include "gtksizegroup.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtkstock.h"
|
|
|
|
|
#include "gtktable.h"
|
2004-03-11 06:24:15 +00:00
|
|
|
|
#include "gtktreednd.h"
|
|
|
|
|
#include "gtktreeprivate.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtktreeview.h"
|
|
|
|
|
#include "gtktreemodelsort.h"
|
|
|
|
|
#include "gtktreeselection.h"
|
|
|
|
|
#include "gtktreestore.h"
|
2004-09-23 19:39:39 +00:00
|
|
|
|
#include "gtktooltips.h"
|
2003-10-23 04:22:32 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
|
|
|
|
#include "gtkvbox.h"
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2004-02-19 07:43:39 +00:00
|
|
|
|
#if defined (G_OS_UNIX)
|
|
|
|
|
#include "gtkfilesystemunix.h"
|
|
|
|
|
#elif defined (G_OS_WIN32)
|
|
|
|
|
#include "gtkfilesystemwin32.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-08-25 19:10:38 +00:00
|
|
|
|
#include <errno.h>
|
2003-03-24 15:41:40 +00:00
|
|
|
|
#include <string.h>
|
2003-09-09 15:18:29 +00:00
|
|
|
|
#include <time.h>
|
2003-03-24 15:41:40 +00:00
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
typedef struct _GtkFileChooserDefaultClass GtkFileChooserDefaultClass;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
#define GTK_FILE_CHOOSER_DEFAULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_CHOOSER_DEFAULT, GtkFileChooserDefaultClass))
|
|
|
|
|
#define GTK_IS_FILE_CHOOSER_DEFAULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_CHOOSER_DEFAULT))
|
|
|
|
|
#define GTK_FILE_CHOOSER_DEFAULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_CHOOSER_DEFAULT, GtkFileChooserDefaultClass))
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
struct _GtkFileChooserDefaultClass
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
GtkVBoxClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
struct _GtkFileChooserDefault
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
GtkVBox parent_instance;
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GtkFileChooserAction action;
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
GtkFileSystem *file_system;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* Save mode widgets */
|
|
|
|
|
GtkWidget *save_widgets;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkWidget *save_file_name_entry;
|
|
|
|
|
GtkWidget *save_folder_label;
|
|
|
|
|
GtkWidget *save_folder_combo;
|
|
|
|
|
GtkWidget *save_extra_align;
|
|
|
|
|
GtkWidget *save_expander;
|
|
|
|
|
|
|
|
|
|
/* The file browsing widgets */
|
|
|
|
|
GtkWidget *browse_widgets;
|
|
|
|
|
GtkWidget *browse_shortcuts_tree_view;
|
|
|
|
|
GtkWidget *browse_shortcuts_add_button;
|
|
|
|
|
GtkWidget *browse_shortcuts_remove_button;
|
|
|
|
|
GtkWidget *browse_files_tree_view;
|
2004-04-02 00:35:07 +00:00
|
|
|
|
GtkWidget *browse_files_popup_menu;
|
2004-07-29 20:53:52 +00:00
|
|
|
|
GtkWidget *browse_files_popup_menu_add_shortcut_item;
|
2004-04-02 00:35:07 +00:00
|
|
|
|
GtkWidget *browse_files_popup_menu_hidden_files_item;
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkWidget *browse_new_folder_button;
|
|
|
|
|
GtkWidget *browse_path_bar;
|
|
|
|
|
GtkWidget *browse_extra_align;
|
2004-03-02 02:59:02 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkFileSystemModel *browse_files_model;
|
2004-02-29 06:35:15 +00:00
|
|
|
|
|
2004-05-04 17:53:13 +00:00
|
|
|
|
GtkWidget *filter_combo_hbox;
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkWidget *filter_combo;
|
2004-02-29 06:35:15 +00:00
|
|
|
|
GtkWidget *preview_box;
|
|
|
|
|
GtkWidget *preview_label;
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkWidget *preview_widget;
|
|
|
|
|
GtkWidget *extra_widget;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-02-24 00:15:23 +00:00
|
|
|
|
GtkListStore *shortcuts_model;
|
2004-03-02 02:59:02 +00:00
|
|
|
|
GtkTreeModel *shortcuts_filter_model;
|
|
|
|
|
|
2003-03-21 23:59:22 +00:00
|
|
|
|
GtkTreeModelSort *sort_model;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
GtkFileFilter *current_filter;
|
|
|
|
|
GSList *filters;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-09-23 19:39:39 +00:00
|
|
|
|
GtkTooltips *tooltips;
|
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
gboolean has_home;
|
|
|
|
|
gboolean has_desktop;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
|
|
|
|
int num_volumes;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
int num_shortcuts;
|
|
|
|
|
int num_bookmarks;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
gulong volumes_changed_id;
|
|
|
|
|
gulong bookmarks_changed_id;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
|
2004-01-16 03:35:33 +00:00
|
|
|
|
GtkFilePath *current_volume_path;
|
2003-04-04 22:43:12 +00:00
|
|
|
|
GtkFilePath *current_folder;
|
2003-07-23 22:30:32 +00:00
|
|
|
|
GtkFilePath *preview_path;
|
2004-02-29 06:35:15 +00:00
|
|
|
|
char *preview_display_name;
|
2003-03-24 15:41:40 +00:00
|
|
|
|
|
2004-01-17 04:34:49 +00:00
|
|
|
|
GtkTreeViewColumn *list_name_column;
|
|
|
|
|
GtkCellRenderer *list_name_renderer;
|
|
|
|
|
|
2004-06-12 00:49:02 +00:00
|
|
|
|
GSource *edited_idle;
|
|
|
|
|
char *edited_new_text;
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
gulong settings_signal_id;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
int icon_size;
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
gulong toplevel_set_focus_id;
|
|
|
|
|
GtkWidget *toplevel_last_focus_widget;
|
|
|
|
|
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#if 0
|
2004-03-11 06:24:15 +00:00
|
|
|
|
GdkDragContext *shortcuts_drag_context;
|
|
|
|
|
GSource *shortcuts_drag_outside_idle;
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Flags */
|
|
|
|
|
|
2003-10-01 00:53:59 +00:00
|
|
|
|
guint local_only : 1;
|
|
|
|
|
guint preview_widget_active : 1;
|
2004-02-29 06:35:15 +00:00
|
|
|
|
guint use_preview_label : 1;
|
2003-10-01 00:53:59 +00:00
|
|
|
|
guint select_multiple : 1;
|
|
|
|
|
guint show_hidden : 1;
|
2003-10-01 19:42:50 +00:00
|
|
|
|
guint list_sort_ascending : 1;
|
2003-12-02 04:23:06 +00:00
|
|
|
|
guint changing_folder : 1;
|
2004-03-02 02:59:02 +00:00
|
|
|
|
guint shortcuts_current_folder_active : 1;
|
2004-03-15 06:29:33 +00:00
|
|
|
|
|
|
|
|
|
#if 0
|
2004-03-11 06:24:15 +00:00
|
|
|
|
guint shortcuts_drag_outside : 1;
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2003-10-01 00:53:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Signal IDs */
|
|
|
|
|
enum {
|
|
|
|
|
LOCATION_POPUP,
|
|
|
|
|
UP_FOLDER,
|
2004-03-15 02:12:08 +00:00
|
|
|
|
DOWN_FOLDER,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
HOME_FOLDER,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2004-02-25 03:03:11 +00:00
|
|
|
|
/* Column numbers for the shortcuts tree. Keep these in sync with shortcuts_model_create() */
|
2003-10-01 00:53:59 +00:00
|
|
|
|
enum {
|
|
|
|
|
SHORTCUTS_COL_PIXBUF,
|
|
|
|
|
SHORTCUTS_COL_NAME,
|
2004-08-18 16:30:58 +00:00
|
|
|
|
SHORTCUTS_COL_DATA,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME,
|
2004-01-07 17:07:18 +00:00
|
|
|
|
SHORTCUTS_COL_REMOVABLE,
|
2004-02-24 00:15:23 +00:00
|
|
|
|
SHORTCUTS_COL_PIXBUF_VISIBLE,
|
2003-10-01 00:53:59 +00:00
|
|
|
|
SHORTCUTS_COL_NUM_COLUMNS
|
2003-03-21 20:34:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-10-01 19:42:50 +00:00
|
|
|
|
/* Column numbers for the file list */
|
|
|
|
|
enum {
|
|
|
|
|
FILE_LIST_COL_NAME,
|
|
|
|
|
FILE_LIST_COL_SIZE,
|
|
|
|
|
FILE_LIST_COL_MTIME,
|
|
|
|
|
FILE_LIST_COL_NUM_COLUMNS
|
|
|
|
|
};
|
|
|
|
|
|
2003-12-01 15:33:37 +00:00
|
|
|
|
/* Identifiers for target types */
|
|
|
|
|
enum {
|
2004-03-11 06:24:15 +00:00
|
|
|
|
GTK_TREE_MODEL_ROW,
|
2003-12-01 15:33:37 +00:00
|
|
|
|
TEXT_URI_LIST
|
|
|
|
|
};
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
/* Target types for dragging from the shortcuts list */
|
|
|
|
|
static GtkTargetEntry shortcuts_source_targets[] = {
|
|
|
|
|
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const int num_shortcuts_source_targets = (sizeof (shortcuts_source_targets)
|
|
|
|
|
/ sizeof (shortcuts_source_targets[0]));
|
|
|
|
|
|
|
|
|
|
/* Target types for dropping into the shortcuts list */
|
|
|
|
|
static GtkTargetEntry shortcuts_dest_targets[] = {
|
|
|
|
|
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW },
|
2003-12-01 15:33:37 +00:00
|
|
|
|
{ "text/uri-list", 0, TEXT_URI_LIST }
|
|
|
|
|
};
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
static const int num_shortcuts_dest_targets = (sizeof (shortcuts_dest_targets)
|
|
|
|
|
/ sizeof (shortcuts_dest_targets[0]));
|
|
|
|
|
|
|
|
|
|
/* Target types for DnD from the file list */
|
|
|
|
|
static GtkTargetEntry file_list_source_targets[] = {
|
|
|
|
|
{ "text/uri-list", 0, TEXT_URI_LIST }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const int num_file_list_source_targets = (sizeof (file_list_source_targets)
|
|
|
|
|
/ sizeof (file_list_source_targets[0]));
|
2003-12-01 15:33:37 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
/* Interesting places in the shortcuts bar */
|
|
|
|
|
typedef enum {
|
|
|
|
|
SHORTCUTS_HOME,
|
|
|
|
|
SHORTCUTS_DESKTOP,
|
|
|
|
|
SHORTCUTS_VOLUMES,
|
|
|
|
|
SHORTCUTS_SHORTCUTS,
|
2004-03-02 02:59:02 +00:00
|
|
|
|
SHORTCUTS_BOOKMARKS_SEPARATOR,
|
|
|
|
|
SHORTCUTS_BOOKMARKS,
|
|
|
|
|
SHORTCUTS_CURRENT_FOLDER_SEPARATOR,
|
|
|
|
|
SHORTCUTS_CURRENT_FOLDER
|
2003-12-17 05:55:16 +00:00
|
|
|
|
} ShortcutsIndex;
|
|
|
|
|
|
2004-03-09 21:22:42 +00:00
|
|
|
|
/* Icon size for if we can't get it from the theme */
|
|
|
|
|
#define FALLBACK_ICON_SIZE 20
|
|
|
|
|
|
2004-02-29 07:55:24 +00:00
|
|
|
|
#define PREVIEW_HBOX_SPACING 12
|
|
|
|
|
#define NUM_LINES 40
|
|
|
|
|
#define NUM_CHARS 60
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class);
|
|
|
|
|
static void gtk_file_chooser_default_iface_init (GtkFileChooserIface *iface);
|
|
|
|
|
static void gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface);
|
|
|
|
|
static void gtk_file_chooser_default_init (GtkFileChooserDefault *impl);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
|
|
|
|
|
static GObject* gtk_file_chooser_default_constructor (GType type,
|
|
|
|
|
guint n_construct_properties,
|
|
|
|
|
GObjectConstructParam *construct_params);
|
|
|
|
|
static void gtk_file_chooser_default_finalize (GObject *object);
|
|
|
|
|
static void gtk_file_chooser_default_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_file_chooser_default_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
static void gtk_file_chooser_default_dispose (GObject *object);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void gtk_file_chooser_default_show_all (GtkWidget *widget);
|
2004-07-29 01:26:51 +00:00
|
|
|
|
static void gtk_file_chooser_default_hierarchy_changed (GtkWidget *widget,
|
|
|
|
|
GtkWidget *previous_toplevel);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void gtk_file_chooser_default_style_set (GtkWidget *widget,
|
|
|
|
|
GtkStyle *previous_style);
|
|
|
|
|
static void gtk_file_chooser_default_screen_changed (GtkWidget *widget,
|
|
|
|
|
GdkScreen *previous_screen);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
static gboolean gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError **error);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static GtkFilePath * gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser);
|
|
|
|
|
static void gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
const gchar *name);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
static gboolean gtk_file_chooser_default_select_path (GtkFileChooser *chooser,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError **error);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void gtk_file_chooser_default_unselect_path (GtkFileChooser *chooser,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
const GtkFilePath *path);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void gtk_file_chooser_default_select_all (GtkFileChooser *chooser);
|
|
|
|
|
static void gtk_file_chooser_default_unselect_all (GtkFileChooser *chooser);
|
|
|
|
|
static GSList * gtk_file_chooser_default_get_paths (GtkFileChooser *chooser);
|
|
|
|
|
static GtkFilePath * gtk_file_chooser_default_get_preview_path (GtkFileChooser *chooser);
|
|
|
|
|
static GtkFileSystem *gtk_file_chooser_default_get_file_system (GtkFileChooser *chooser);
|
|
|
|
|
static void gtk_file_chooser_default_add_filter (GtkFileChooser *chooser,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
GtkFileFilter *filter);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void gtk_file_chooser_default_remove_filter (GtkFileChooser *chooser,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
GtkFileFilter *filter);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static GSList * gtk_file_chooser_default_list_filters (GtkFileChooser *chooser);
|
|
|
|
|
static gboolean gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError **error);
|
|
|
|
|
static gboolean gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser *chooser,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError **error);
|
|
|
|
|
static GSList * gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void gtk_file_chooser_default_get_default_size (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
|
gint *default_width,
|
|
|
|
|
gint *default_height);
|
|
|
|
|
static void gtk_file_chooser_default_get_resizable_hints (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
|
gboolean *resize_horizontally,
|
|
|
|
|
gboolean *resize_vertically);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
static gboolean gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed);
|
2004-03-08 22:21:47 +00:00
|
|
|
|
static void gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed);
|
2003-10-23 00:26:15 +00:00
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
static void location_popup_handler (GtkFileChooserDefault *impl);
|
|
|
|
|
static void up_folder_handler (GtkFileChooserDefault *impl);
|
2004-03-15 02:12:08 +00:00
|
|
|
|
static void down_folder_handler (GtkFileChooserDefault *impl);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
static void home_folder_handler (GtkFileChooserDefault *impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
static void update_appearance (GtkFileChooserDefault *impl);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void set_current_filter (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkFileFilter *filter);
|
|
|
|
|
static void check_preview_change (GtkFileChooserDefault *impl);
|
|
|
|
|
|
2003-10-23 05:10:47 +00:00
|
|
|
|
static void filter_combo_changed (GtkComboBox *combo_box,
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl);
|
2003-12-10 03:46:30 +00:00
|
|
|
|
static void shortcuts_row_activated_cb (GtkTreeView *tree_view,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
2004-04-29 23:13:50 +00:00
|
|
|
|
|
|
|
|
|
static gboolean shortcuts_key_press_event_cb (GtkWidget *widget,
|
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
|
|
|
|
|
2003-11-01 20:17:37 +00:00
|
|
|
|
static gboolean shortcuts_select_func (GtkTreeSelection *selection,
|
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
2004-02-23 20:24:01 +00:00
|
|
|
|
gboolean path_currently_selected,
|
2003-11-01 20:17:37 +00:00
|
|
|
|
gpointer data);
|
2004-07-29 01:26:51 +00:00
|
|
|
|
static void shortcuts_activate_iter (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkTreeIter *iter);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
static int shortcuts_get_index (GtkFileChooserDefault *impl,
|
|
|
|
|
ShortcutsIndex where);
|
2004-03-02 05:27:51 +00:00
|
|
|
|
static int shortcut_find_position (GtkFileChooserDefault *impl,
|
|
|
|
|
const GtkFilePath *path);
|
2003-11-01 20:17:37 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
static void bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl);
|
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static void list_selection_changed (GtkTreeSelection *tree_selection,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
|
|
|
|
static void list_row_activated (GtkTreeView *tree_view,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-02-23 07:11:31 +00:00
|
|
|
|
static void path_bar_clicked (GtkPathBar *path_bar,
|
2004-02-23 20:24:01 +00:00
|
|
|
|
GtkFilePath *file_path,
|
2004-04-02 00:35:07 +00:00
|
|
|
|
gboolean child_is_hidden,
|
2004-02-23 07:11:31 +00:00
|
|
|
|
GtkFileChooserDefault *impl);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-01-06 04:18:42 +00:00
|
|
|
|
static void add_bookmark_button_clicked_cb (GtkButton *button,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
|
|
|
|
static void remove_bookmark_button_clicked_cb (GtkButton *button,
|
|
|
|
|
GtkFileChooserDefault *impl);
|
|
|
|
|
|
2003-07-16 21:07:38 +00:00
|
|
|
|
static void list_icon_data_func (GtkTreeViewColumn *tree_column,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
static void list_name_data_func (GtkTreeViewColumn *tree_column,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data);
|
2003-09-09 15:18:29 +00:00
|
|
|
|
#if 0
|
2003-03-26 17:09:26 +00:00
|
|
|
|
static void list_size_data_func (GtkTreeViewColumn *tree_column,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data);
|
2003-09-09 15:18:29 +00:00
|
|
|
|
#endif
|
|
|
|
|
static void list_mtime_data_func (GtkTreeViewColumn *tree_column,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
|
2004-09-20 23:47:38 +00:00
|
|
|
|
static const GtkFileInfo *get_list_file_info (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkTreeIter *iter);
|
|
|
|
|
|
2003-07-16 21:07:38 +00:00
|
|
|
|
static GObjectClass *parent_class;
|
2003-03-26 17:09:26 +00:00
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Drag and drop interface declarations */
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
GtkTreeModelFilter parent;
|
|
|
|
|
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
} ShortcutsModelFilter;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
GtkTreeModelFilterClass parent_class;
|
|
|
|
|
} ShortcutsModelFilterClass;
|
|
|
|
|
|
2004-08-12 21:09:03 +00:00
|
|
|
|
#define SHORTCUTS_MODEL_FILTER_TYPE (_shortcuts_model_filter_get_type ())
|
2004-03-11 06:24:15 +00:00
|
|
|
|
#define SHORTCUTS_MODEL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHORTCUTS_MODEL_FILTER_TYPE, ShortcutsModelFilter))
|
|
|
|
|
|
|
|
|
|
static void shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface);
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (ShortcutsModelFilter,
|
2004-08-12 21:09:03 +00:00
|
|
|
|
_shortcuts_model_filter,
|
2004-03-11 06:24:15 +00:00
|
|
|
|
GTK_TYPE_TREE_MODEL_FILTER,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE,
|
|
|
|
|
shortcuts_model_filter_drag_source_iface_init));
|
|
|
|
|
|
|
|
|
|
static GtkTreeModel *shortcuts_model_filter_new (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkTreeModel *child_model,
|
|
|
|
|
GtkTreePath *root);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
GType
|
2003-10-23 00:26:15 +00:00
|
|
|
|
_gtk_file_chooser_default_get_type (void)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static GType file_chooser_default_type = 0;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
if (!file_chooser_default_type)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
static const GTypeInfo file_chooser_default_info =
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
sizeof (GtkFileChooserDefaultClass),
|
2003-03-21 20:34:02 +00:00
|
|
|
|
NULL, /* base_init */
|
|
|
|
|
NULL, /* base_finalize */
|
2003-10-23 00:26:15 +00:00
|
|
|
|
(GClassInitFunc) gtk_file_chooser_default_class_init,
|
2003-03-21 20:34:02 +00:00
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
|
NULL, /* class_data */
|
2003-10-23 00:26:15 +00:00
|
|
|
|
sizeof (GtkFileChooserDefault),
|
2003-03-21 20:34:02 +00:00
|
|
|
|
0, /* n_preallocs */
|
2003-10-23 00:26:15 +00:00
|
|
|
|
(GInstanceInitFunc) gtk_file_chooser_default_init,
|
2003-03-21 20:34:02 +00:00
|
|
|
|
};
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static const GInterfaceInfo file_chooser_info =
|
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
(GInterfaceInitFunc) gtk_file_chooser_default_iface_init, /* interface_init */
|
2003-03-21 20:34:02 +00:00
|
|
|
|
NULL, /* interface_finalize */
|
|
|
|
|
NULL /* interface_data */
|
|
|
|
|
};
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static const GInterfaceInfo file_chooser_embed_info =
|
|
|
|
|
{
|
|
|
|
|
(GInterfaceInitFunc) gtk_file_chooser_embed_default_iface_init, /* interface_init */
|
|
|
|
|
NULL, /* interface_finalize */
|
|
|
|
|
NULL /* interface_data */
|
|
|
|
|
};
|
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
file_chooser_default_type = g_type_register_static (GTK_TYPE_VBOX, "GtkFileChooserDefault",
|
|
|
|
|
&file_chooser_default_info, 0);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
g_type_add_interface_static (file_chooser_default_type,
|
2003-03-21 20:34:02 +00:00
|
|
|
|
GTK_TYPE_FILE_CHOOSER,
|
|
|
|
|
&file_chooser_info);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
g_type_add_interface_static (file_chooser_default_type,
|
|
|
|
|
GTK_TYPE_FILE_CHOOSER_EMBED,
|
|
|
|
|
&file_chooser_embed_info);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
return file_chooser_default_type;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GtkBindingSet *binding_set;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-07-16 21:07:38 +00:00
|
|
|
|
parent_class = g_type_class_peek_parent (class);
|
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gobject_class->finalize = gtk_file_chooser_default_finalize;
|
|
|
|
|
gobject_class->constructor = gtk_file_chooser_default_constructor;
|
|
|
|
|
gobject_class->set_property = gtk_file_chooser_default_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_file_chooser_default_get_property;
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gobject_class->dispose = gtk_file_chooser_default_dispose;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-10-23 00:26:15 +00:00
|
|
|
|
widget_class->show_all = gtk_file_chooser_default_show_all;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
widget_class->hierarchy_changed = gtk_file_chooser_default_hierarchy_changed;
|
2004-02-27 23:51:16 +00:00
|
|
|
|
widget_class->style_set = gtk_file_chooser_default_style_set;
|
|
|
|
|
widget_class->screen_changed = gtk_file_chooser_default_screen_changed;
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
signals[LOCATION_POPUP] =
|
|
|
|
|
_gtk_binding_signal_new ("location-popup",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (location_popup_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
signals[UP_FOLDER] =
|
|
|
|
|
_gtk_binding_signal_new ("up-folder",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (up_folder_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2004-03-15 02:12:08 +00:00
|
|
|
|
signals[DOWN_FOLDER] =
|
|
|
|
|
_gtk_binding_signal_new ("down-folder",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (down_folder_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
signals[HOME_FOLDER] =
|
|
|
|
|
_gtk_binding_signal_new ("home-folder",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (home_folder_handler),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
_gtk_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
|
|
binding_set = gtk_binding_set_by_class (class);
|
|
|
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_l, GDK_CONTROL_MASK,
|
|
|
|
|
"location-popup",
|
|
|
|
|
0);
|
|
|
|
|
|
2004-08-25 19:10:38 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_slash, 0,
|
|
|
|
|
"location-popup",
|
|
|
|
|
0);
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
2004-02-23 22:07:55 +00:00
|
|
|
|
GDK_Up, GDK_MOD1_MASK,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
"up-folder",
|
|
|
|
|
0);
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
2004-02-23 22:07:55 +00:00
|
|
|
|
GDK_KP_Up, GDK_MOD1_MASK,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
"up-folder",
|
|
|
|
|
0);
|
|
|
|
|
|
2004-03-15 02:12:08 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_Down, GDK_MOD1_MASK,
|
|
|
|
|
"down-folder",
|
|
|
|
|
0);
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
|
|
|
|
GDK_KP_Down, GDK_MOD1_MASK,
|
|
|
|
|
"down-folder",
|
|
|
|
|
0);
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
2004-02-23 22:07:55 +00:00
|
|
|
|
GDK_Home, GDK_MOD1_MASK,
|
|
|
|
|
"home-folder",
|
2004-02-23 19:55:49 +00:00
|
|
|
|
0);
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set,
|
2004-02-23 22:07:55 +00:00
|
|
|
|
GDK_KP_Home, GDK_MOD1_MASK,
|
|
|
|
|
"home-folder",
|
2004-02-23 19:55:49 +00:00
|
|
|
|
0);
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
_gtk_file_chooser_install_properties (gobject_class);
|
2004-03-03 00:38:19 +00:00
|
|
|
|
|
2004-03-01 19:40:47 +00:00
|
|
|
|
gtk_settings_install_property (g_param_spec_string ("gtk-file-chooser-backend",
|
|
|
|
|
P_("Default file chooser backend"),
|
|
|
|
|
P_("Name of the GtkFileChooser backend to use by default"),
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE));
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_iface_init (GtkFileChooserIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->select_path = gtk_file_chooser_default_select_path;
|
|
|
|
|
iface->unselect_path = gtk_file_chooser_default_unselect_path;
|
|
|
|
|
iface->select_all = gtk_file_chooser_default_select_all;
|
|
|
|
|
iface->unselect_all = gtk_file_chooser_default_unselect_all;
|
|
|
|
|
iface->get_paths = gtk_file_chooser_default_get_paths;
|
|
|
|
|
iface->get_preview_path = gtk_file_chooser_default_get_preview_path;
|
|
|
|
|
iface->get_file_system = gtk_file_chooser_default_get_file_system;
|
|
|
|
|
iface->set_current_folder = gtk_file_chooser_default_set_current_folder;
|
|
|
|
|
iface->get_current_folder = gtk_file_chooser_default_get_current_folder;
|
|
|
|
|
iface->set_current_name = gtk_file_chooser_default_set_current_name;
|
|
|
|
|
iface->add_filter = gtk_file_chooser_default_add_filter;
|
|
|
|
|
iface->remove_filter = gtk_file_chooser_default_remove_filter;
|
|
|
|
|
iface->list_filters = gtk_file_chooser_default_list_filters;
|
|
|
|
|
iface->add_shortcut_folder = gtk_file_chooser_default_add_shortcut_folder;
|
|
|
|
|
iface->remove_shortcut_folder = gtk_file_chooser_default_remove_shortcut_folder;
|
|
|
|
|
iface->list_shortcut_folders = gtk_file_chooser_default_list_shortcut_folders;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_default_size = gtk_file_chooser_default_get_default_size;
|
|
|
|
|
iface->get_resizable_hints = gtk_file_chooser_default_get_resizable_hints;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
iface->should_respond = gtk_file_chooser_default_should_respond;
|
2004-03-08 22:21:47 +00:00
|
|
|
|
iface->initial_focus = gtk_file_chooser_default_initial_focus;
|
2004-02-27 23:51:16 +00:00
|
|
|
|
}
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-03-26 17:09:26 +00:00
|
|
|
|
impl->local_only = TRUE;
|
|
|
|
|
impl->preview_widget_active = TRUE;
|
2004-02-29 06:35:15 +00:00
|
|
|
|
impl->use_preview_label = TRUE;
|
2003-03-26 17:09:26 +00:00
|
|
|
|
impl->select_multiple = FALSE;
|
|
|
|
|
impl->show_hidden = FALSE;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
impl->icon_size = FALLBACK_ICON_SIZE;
|
2003-03-26 17:09:26 +00:00
|
|
|
|
|
2004-03-07 21:26:32 +00:00
|
|
|
|
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (impl), TRUE);
|
2003-11-03 00:50:33 +00:00
|
|
|
|
gtk_box_set_spacing (GTK_BOX (impl), 12);
|
2004-09-23 19:39:39 +00:00
|
|
|
|
|
|
|
|
|
impl->tooltips = gtk_tooltips_new ();
|
|
|
|
|
g_object_ref (impl->tooltips);
|
|
|
|
|
gtk_object_sink (GTK_OBJECT (impl->tooltips));
|
2003-03-26 17:09:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
/* Frees the data columns for the specified iter in the shortcuts model*/
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_free_row_data (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
|
{
|
|
|
|
|
gpointer col_data;
|
|
|
|
|
gboolean is_volume;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), iter,
|
|
|
|
|
SHORTCUTS_COL_DATA, &col_data,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, &is_volume,
|
|
|
|
|
-1);
|
|
|
|
|
if (!col_data)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (is_volume)
|
|
|
|
|
{
|
|
|
|
|
GtkFileSystemVolume *volume;
|
|
|
|
|
|
|
|
|
|
volume = col_data;
|
|
|
|
|
gtk_file_system_volume_free (impl->file_system, volume);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkFilePath *path;
|
|
|
|
|
|
|
|
|
|
path = col_data;
|
|
|
|
|
gtk_file_path_free (path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Frees all the data columns in the shortcuts model */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_free (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
|
|
if (!impl->shortcuts_model)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
shortcuts_free_row_data (impl, &iter);
|
|
|
|
|
}
|
|
|
|
|
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter));
|
|
|
|
|
|
|
|
|
|
g_object_unref (impl->shortcuts_model);
|
|
|
|
|
impl->shortcuts_model = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-26 17:09:26 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_finalize (GObject *object)
|
2003-03-26 17:09:26 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
|
2004-02-10 19:48:38 +00:00
|
|
|
|
GSList *l;
|
2003-03-26 17:09:26 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (impl->shortcuts_filter_model)
|
|
|
|
|
g_object_unref (impl->shortcuts_filter_model);
|
|
|
|
|
|
|
|
|
|
shortcuts_free (impl);
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
g_signal_handler_disconnect (impl->file_system, impl->volumes_changed_id);
|
|
|
|
|
impl->volumes_changed_id = 0;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
g_signal_handler_disconnect (impl->file_system, impl->bookmarks_changed_id);
|
|
|
|
|
impl->bookmarks_changed_id = 0;
|
2003-03-26 17:09:26 +00:00
|
|
|
|
g_object_unref (impl->file_system);
|
|
|
|
|
|
2004-02-10 19:48:38 +00:00
|
|
|
|
for (l = impl->filters; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GtkFileFilter *filter;
|
|
|
|
|
|
|
|
|
|
filter = GTK_FILE_FILTER (l->data);
|
|
|
|
|
g_object_unref (filter);
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (impl->filters);
|
|
|
|
|
|
|
|
|
|
if (impl->current_filter)
|
|
|
|
|
g_object_unref (impl->current_filter);
|
2004-01-22 02:39:31 +00:00
|
|
|
|
|
|
|
|
|
if (impl->current_volume_path)
|
|
|
|
|
gtk_file_path_free (impl->current_volume_path);
|
|
|
|
|
|
|
|
|
|
if (impl->current_folder)
|
|
|
|
|
gtk_file_path_free (impl->current_folder);
|
|
|
|
|
|
|
|
|
|
if (impl->preview_path)
|
|
|
|
|
gtk_file_path_free (impl->preview_path);
|
|
|
|
|
|
2004-03-05 07:58:36 +00:00
|
|
|
|
/* Free all the Models we have */
|
|
|
|
|
if (impl->browse_files_model)
|
|
|
|
|
g_object_unref (impl->browse_files_model);
|
|
|
|
|
|
|
|
|
|
if (impl->sort_model)
|
|
|
|
|
g_object_unref (impl->sort_model);
|
|
|
|
|
|
2004-02-29 06:35:15 +00:00
|
|
|
|
g_free (impl->preview_display_name);
|
|
|
|
|
|
2004-06-12 00:49:02 +00:00
|
|
|
|
g_free (impl->edited_new_text);
|
|
|
|
|
|
2003-03-26 17:09:26 +00:00
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Shows an error dialog set as transient for the specified window */
|
2003-11-03 00:50:33 +00:00
|
|
|
|
static void
|
2004-02-23 19:55:49 +00:00
|
|
|
|
error_message_with_parent (GtkWindow *parent,
|
|
|
|
|
const char *msg)
|
2003-11-03 00:50:33 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
dialog = gtk_message_dialog_new (parent,
|
2003-11-03 00:50:33 +00:00
|
|
|
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
|
GTK_MESSAGE_ERROR,
|
2004-03-11 18:48:46 +00:00
|
|
|
|
GTK_BUTTONS_OK,
|
2003-11-04 01:56:56 +00:00
|
|
|
|
"%s",
|
|
|
|
|
msg);
|
2003-11-03 00:50:33 +00:00
|
|
|
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
/* Returns a toplevel GtkWindow, or NULL if none */
|
|
|
|
|
static GtkWindow *
|
|
|
|
|
get_toplevel (GtkWidget *widget)
|
2004-03-19 19:41:06 +00:00
|
|
|
|
{
|
2004-03-19 21:16:24 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
toplevel = gtk_widget_get_toplevel (widget);
|
2004-03-19 21:16:24 +00:00
|
|
|
|
if (!GTK_WIDGET_TOPLEVEL (toplevel))
|
2004-03-29 19:52:16 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
else
|
|
|
|
|
return GTK_WINDOW (toplevel);
|
|
|
|
|
}
|
2004-03-19 21:16:24 +00:00
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
/* Shows an error dialog for the file chooser */
|
|
|
|
|
static void
|
|
|
|
|
error_message (GtkFileChooserDefault *impl,
|
|
|
|
|
const char *msg)
|
|
|
|
|
{
|
|
|
|
|
error_message_with_parent (get_toplevel (GTK_WIDGET (impl)), msg);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-04 01:56:56 +00:00
|
|
|
|
/* Shows a simple error dialog relative to a path. Frees the GError as well. */
|
|
|
|
|
static void
|
|
|
|
|
error_dialog (GtkFileChooserDefault *impl,
|
|
|
|
|
const char *msg,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
2004-03-14 19:47:20 +00:00
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
|
{
|
|
|
|
|
char *uri = gtk_file_system_path_to_uri (impl->file_system, path);
|
2004-03-14 19:50:11 +00:00
|
|
|
|
char *text = g_strdup_printf (msg,
|
|
|
|
|
uri,
|
|
|
|
|
error->message);
|
2004-03-14 19:47:20 +00:00
|
|
|
|
error_message (impl, text);
|
|
|
|
|
g_free (text);
|
|
|
|
|
g_free (uri);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2003-11-04 01:56:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-01 15:33:37 +00:00
|
|
|
|
/* Displays an error message about not being able to get information for a file.
|
|
|
|
|
* Frees the GError as well.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
error_getting_info_dialog (GtkFileChooserDefault *impl,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Could not retrieve information about %s:\n%s"),
|
|
|
|
|
path, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Shows an error dialog about not being able to add a bookmark */
|
|
|
|
|
static void
|
|
|
|
|
error_could_not_add_bookmark_dialog (GtkFileChooserDefault *impl,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Could not add a bookmark for %s:\n%s"),
|
|
|
|
|
path, error);
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-17 04:34:49 +00:00
|
|
|
|
/* Shows an error dialog about not being able to compose a filename */
|
|
|
|
|
static void
|
|
|
|
|
error_building_filename_dialog (GtkFileChooserDefault *impl,
|
|
|
|
|
const GtkFilePath *base_path,
|
|
|
|
|
const char *file_part,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
2004-03-07 22:49:44 +00:00
|
|
|
|
char *uri;
|
2004-01-17 04:34:49 +00:00
|
|
|
|
char *msg;
|
|
|
|
|
|
2004-03-07 22:49:44 +00:00
|
|
|
|
uri = gtk_file_system_path_to_uri (impl->file_system, base_path);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
msg = g_strdup_printf (_("Could not build file name from '%s' and '%s':\n%s"),
|
2004-03-07 22:49:44 +00:00
|
|
|
|
uri, file_part,
|
2004-01-17 04:34:49 +00:00
|
|
|
|
error->message);
|
|
|
|
|
error_message (impl, msg);
|
2004-03-07 22:49:44 +00:00
|
|
|
|
g_free (uri);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
g_free (msg);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
/* Shows an error dialog when we cannot switch to a folder */
|
|
|
|
|
static void
|
|
|
|
|
error_changing_folder_dialog (GtkFileChooserDefault *impl,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Could not change the current folder to %s:\n%s"),
|
|
|
|
|
path,
|
|
|
|
|
error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Changes folders, displaying an error dialog if this fails */
|
|
|
|
|
static gboolean
|
|
|
|
|
change_folder_and_display_error (GtkFileChooserDefault *impl,
|
|
|
|
|
const GtkFilePath *path)
|
|
|
|
|
{
|
|
|
|
|
GError *error;
|
|
|
|
|
gboolean result;
|
2004-07-09 00:53:48 +00:00
|
|
|
|
GtkFilePath *path_copy;
|
|
|
|
|
|
|
|
|
|
/* We copy the path because of this case:
|
|
|
|
|
*
|
|
|
|
|
* list_row_activated()
|
|
|
|
|
* fetches path from model; path belongs to the model (*)
|
|
|
|
|
* calls change_folder_and_display_error()
|
|
|
|
|
* calls _gtk_file_chooser_set_current_folder_path()
|
|
|
|
|
* changing folders fails, sets model to NULL, thus freeing the path in (*)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
path_copy = gtk_file_path_copy (path);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
|
|
|
|
error = NULL;
|
2004-07-09 00:53:48 +00:00
|
|
|
|
result = _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path_copy, &error);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
|
|
|
|
if (!result)
|
2004-07-09 00:53:48 +00:00
|
|
|
|
error_changing_folder_dialog (impl, path_copy, error);
|
|
|
|
|
|
|
|
|
|
gtk_file_path_free (path_copy);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
update_preview_widget_visibility (GtkFileChooserDefault *impl)
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
2004-02-29 06:35:15 +00:00
|
|
|
|
if (impl->use_preview_label)
|
|
|
|
|
{
|
|
|
|
|
if (!impl->preview_label)
|
|
|
|
|
{
|
|
|
|
|
impl->preview_label = gtk_label_new (impl->preview_display_name);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_label, FALSE, FALSE, 0);
|
|
|
|
|
gtk_box_reorder_child (GTK_BOX (impl->preview_box), impl->preview_label, 0);
|
|
|
|
|
gtk_widget_show (impl->preview_label);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (impl->preview_label)
|
2004-02-29 07:55:24 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_destroy (impl->preview_label);
|
|
|
|
|
impl->preview_label = NULL;
|
|
|
|
|
}
|
2004-02-29 06:35:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
if (impl->preview_widget_active && impl->preview_widget)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
gtk_widget_show (impl->preview_box);
|
2003-07-23 22:30:32 +00:00
|
|
|
|
else
|
2004-02-29 06:35:15 +00:00
|
|
|
|
gtk_widget_hide (impl->preview_box);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (impl, "default-size-changed");
|
2003-07-23 22:30:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-26 17:09:26 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
set_preview_widget (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkWidget *preview_widget)
|
2003-03-26 17:09:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (preview_widget == impl->preview_widget)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (impl->preview_widget)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (impl->preview_box),
|
2003-09-03 05:52:35 +00:00
|
|
|
|
impl->preview_widget);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
|
|
|
|
|
impl->preview_widget = preview_widget;
|
|
|
|
|
if (impl->preview_widget)
|
|
|
|
|
{
|
2004-03-05 08:37:11 +00:00
|
|
|
|
gtk_widget_show (impl->preview_widget);
|
2004-02-29 06:35:15 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_widget, TRUE, TRUE, 0);
|
|
|
|
|
gtk_box_reorder_child (GTK_BOX (impl->preview_box),
|
|
|
|
|
impl->preview_widget,
|
|
|
|
|
(impl->use_preview_label && impl->preview_label) ? 1 : 0);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
}
|
2003-07-23 22:30:32 +00:00
|
|
|
|
|
|
|
|
|
update_preview_widget_visibility (impl);
|
2003-03-26 17:09:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-09 21:22:42 +00:00
|
|
|
|
/* Re-reads all the icons for the shortcuts, used when the theme changes */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_reload_icons (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
gpointer data;
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gboolean is_volume;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
gboolean pixbuf_visible;
|
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
|
2004-08-18 16:30:58 +00:00
|
|
|
|
SHORTCUTS_COL_DATA, &data,
|
2004-08-18 23:18:15 +00:00
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, &is_volume,
|
2004-03-09 21:22:42 +00:00
|
|
|
|
SHORTCUTS_COL_PIXBUF_VISIBLE, &pixbuf_visible,
|
|
|
|
|
-1);
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (pixbuf_visible && data)
|
2004-03-09 21:22:42 +00:00
|
|
|
|
{
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (is_volume)
|
|
|
|
|
{
|
|
|
|
|
GtkFileSystemVolume *volume;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
volume = data;
|
|
|
|
|
pixbuf = gtk_file_system_volume_render_icon (impl->file_system, volume, GTK_WIDGET (impl),
|
|
|
|
|
impl->icon_size, NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const GtkFilePath *path;
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
path = data;
|
|
|
|
|
pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
|
|
|
|
|
impl->icon_size, NULL);
|
|
|
|
|
}
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gtk_list_store_set (impl->shortcuts_model, &iter,
|
|
|
|
|
SHORTCUTS_COL_PIXBUF, pixbuf,
|
|
|
|
|
-1);
|
|
|
|
|
if (pixbuf)
|
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
}
|
2004-03-09 21:22:42 +00:00
|
|
|
|
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model),&iter));
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-15 06:51:58 +00:00
|
|
|
|
/* If a shortcut corresponds to the current folder, selects it */
|
2003-11-03 18:46:18 +00:00
|
|
|
|
static void
|
2004-03-15 06:51:58 +00:00
|
|
|
|
shortcuts_find_current_folder (GtkFileChooserDefault *impl)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
2003-10-08 04:14:55 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
2004-03-15 06:51:58 +00:00
|
|
|
|
int pos;
|
|
|
|
|
GtkTreePath *path;
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
|
2004-03-15 06:51:58 +00:00
|
|
|
|
|
|
|
|
|
pos = shortcut_find_position (impl, impl->current_folder);
|
|
|
|
|
if (pos == -1)
|
|
|
|
|
{
|
|
|
|
|
gtk_tree_selection_unselect_all (selection);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_indices (pos, -1);
|
|
|
|
|
gtk_tree_selection_select_path (selection, path);
|
|
|
|
|
gtk_tree_path_free (path);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convenience function to get the display name and icon info for a path */
|
|
|
|
|
static GtkFileInfo *
|
2004-03-08 22:53:35 +00:00
|
|
|
|
get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean name_only, GError **error)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
|
|
|
|
GtkFilePath *parent_path;
|
|
|
|
|
GtkFileFolder *parent_folder;
|
|
|
|
|
GtkFileInfo *info;
|
|
|
|
|
|
2004-03-11 21:23:16 +00:00
|
|
|
|
info = NULL;
|
|
|
|
|
|
2003-10-01 00:53:59 +00:00
|
|
|
|
if (!gtk_file_system_get_parent (file_system, path, &parent_path, error))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2004-03-09 19:47:09 +00:00
|
|
|
|
parent_folder = gtk_file_system_get_folder (file_system, parent_path ? parent_path : path,
|
2003-12-01 15:33:37 +00:00
|
|
|
|
GTK_FILE_INFO_DISPLAY_NAME
|
2004-03-08 22:53:35 +00:00
|
|
|
|
| (name_only ? 0 : GTK_FILE_INFO_IS_FOLDER),
|
2003-10-01 00:53:59 +00:00
|
|
|
|
error);
|
2004-03-11 21:23:16 +00:00
|
|
|
|
if (!parent_folder)
|
2004-03-15 05:42:51 +00:00
|
|
|
|
goto out;
|
2004-03-11 21:23:16 +00:00
|
|
|
|
|
2004-03-15 05:42:51 +00:00
|
|
|
|
info = gtk_file_folder_get_info (parent_folder, parent_path ? path : NULL, error);
|
2004-03-11 21:23:16 +00:00
|
|
|
|
g_object_unref (parent_folder);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-03-15 05:42:51 +00:00
|
|
|
|
out:
|
|
|
|
|
|
|
|
|
|
gtk_file_path_free (parent_path);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-25 16:59:57 +00:00
|
|
|
|
/* Returns whether a path is a folder */
|
|
|
|
|
static gboolean
|
|
|
|
|
check_is_folder (GtkFileSystem *file_system, const GtkFilePath *path, GError **error)
|
|
|
|
|
{
|
|
|
|
|
GtkFileInfo *info;
|
|
|
|
|
gboolean is_folder;
|
|
|
|
|
|
|
|
|
|
/* Use get_file_info() rather than trying get_folder() and checking
|
|
|
|
|
* for an error directly because older versions of the gnome-vfs
|
|
|
|
|
* backend don't return an error immediately. This way is also
|
|
|
|
|
* more efficient if we already have the parent folder.
|
|
|
|
|
*/
|
|
|
|
|
info = get_file_info (file_system, path, FALSE, error);
|
|
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
is_folder = gtk_file_info_get_is_folder (info);
|
|
|
|
|
|
|
|
|
|
if (!is_folder)
|
2004-10-07 05:03:19 +00:00
|
|
|
|
g_set_error (error,
|
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
|
GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
|
|
|
|
|
"%s: %s",
|
|
|
|
|
gtk_file_info_get_display_name (info),
|
|
|
|
|
g_strerror (ENOTDIR));
|
|
|
|
|
|
|
|
|
|
gtk_file_info_free (info);
|
2004-08-25 16:59:57 +00:00
|
|
|
|
|
2004-10-07 05:03:19 +00:00
|
|
|
|
return is_folder;
|
2004-08-25 16:59:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
/* Inserts a path in the shortcuts tree, making a copy of it; alternatively,
|
|
|
|
|
* inserts a volume. A position of -1 indicates the end of the tree.
|
2003-10-08 04:14:55 +00:00
|
|
|
|
*/
|
2003-10-18 04:29:40 +00:00
|
|
|
|
static gboolean
|
2003-10-23 00:26:15 +00:00
|
|
|
|
shortcuts_insert_path (GtkFileChooserDefault *impl,
|
|
|
|
|
int pos,
|
2003-12-17 05:55:16 +00:00
|
|
|
|
gboolean is_volume,
|
|
|
|
|
GtkFileSystemVolume *volume,
|
2003-10-23 00:26:15 +00:00
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
const char *label,
|
2004-01-07 17:07:18 +00:00
|
|
|
|
gboolean removable,
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GError **error)
|
2003-10-08 04:14:55 +00:00
|
|
|
|
{
|
2003-12-17 05:55:16 +00:00
|
|
|
|
char *label_copy;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
GdkPixbuf *pixbuf;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
gpointer data;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
if (is_volume)
|
|
|
|
|
{
|
|
|
|
|
data = volume;
|
|
|
|
|
label_copy = gtk_file_system_volume_get_display_name (impl->file_system, volume);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
pixbuf = gtk_file_system_volume_render_icon (impl->file_system, volume, GTK_WIDGET (impl),
|
|
|
|
|
impl->icon_size, NULL);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
2003-10-08 04:14:55 +00:00
|
|
|
|
else
|
2003-12-17 05:55:16 +00:00
|
|
|
|
{
|
2004-03-15 02:09:22 +00:00
|
|
|
|
if (!check_is_folder (impl->file_system, path, error))
|
2004-03-11 21:23:16 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
if (label)
|
|
|
|
|
label_copy = g_strdup (label);
|
|
|
|
|
else
|
2004-03-15 02:09:22 +00:00
|
|
|
|
{
|
|
|
|
|
GtkFileInfo *info = get_file_info (impl->file_system, path, TRUE, error);
|
2004-03-11 21:23:16 +00:00
|
|
|
|
|
2004-03-15 02:09:22 +00:00
|
|
|
|
if (!info)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
label_copy = g_strdup (gtk_file_info_get_display_name (info));
|
|
|
|
|
gtk_file_info_free (info);
|
|
|
|
|
}
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2004-03-08 22:53:35 +00:00
|
|
|
|
data = gtk_file_path_copy (path);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
|
|
|
|
|
impl->icon_size, NULL);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-24 00:15:23 +00:00
|
|
|
|
if (pos == -1)
|
|
|
|
|
gtk_list_store_append (impl->shortcuts_model, &iter);
|
|
|
|
|
else
|
|
|
|
|
gtk_list_store_insert (impl->shortcuts_model, &iter, pos);
|
2003-10-08 04:14:55 +00:00
|
|
|
|
|
2004-02-24 00:15:23 +00:00
|
|
|
|
gtk_list_store_set (impl->shortcuts_model, &iter,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
SHORTCUTS_COL_PIXBUF, pixbuf,
|
2004-02-24 00:15:23 +00:00
|
|
|
|
SHORTCUTS_COL_PIXBUF_VISIBLE, TRUE,
|
2003-12-17 05:55:16 +00:00
|
|
|
|
SHORTCUTS_COL_NAME, label_copy,
|
2004-08-18 16:30:58 +00:00
|
|
|
|
SHORTCUTS_COL_DATA, data,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, is_volume,
|
2004-01-07 17:07:18 +00:00
|
|
|
|
SHORTCUTS_COL_REMOVABLE, removable,
|
2003-10-08 04:14:55 +00:00
|
|
|
|
-1);
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
g_free (label_copy);
|
2003-10-21 01:06:30 +00:00
|
|
|
|
|
2003-10-08 04:14:55 +00:00
|
|
|
|
if (pixbuf)
|
|
|
|
|
g_object_unref (pixbuf);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-01 00:53:59 +00:00
|
|
|
|
/* Appends an item for the user's home directory to the shortcuts model */
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
shortcuts_append_home (GtkFileChooserDefault *impl)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
|
|
|
|
const char *home;
|
|
|
|
|
GtkFilePath *home_path;
|
2003-11-04 01:56:56 +00:00
|
|
|
|
GError *error;
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
|
|
|
|
home = g_get_home_dir ();
|
2004-08-14 16:47:48 +00:00
|
|
|
|
if (home == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-10-01 00:53:59 +00:00
|
|
|
|
home_path = gtk_file_system_filename_to_path (impl->file_system, home);
|
|
|
|
|
|
2003-11-04 01:56:56 +00:00
|
|
|
|
error = NULL;
|
2004-01-07 17:07:18 +00:00
|
|
|
|
impl->has_home = shortcuts_insert_path (impl, -1, FALSE, NULL, home_path, _("Home"), FALSE, &error);
|
2003-11-04 01:56:56 +00:00
|
|
|
|
if (!impl->has_home)
|
|
|
|
|
error_getting_info_dialog (impl, home_path, error);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
|
|
|
|
gtk_file_path_free (home_path);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
/* Appends the ~/Desktop directory to the shortcuts model */
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
shortcuts_append_desktop (GtkFileChooserDefault *impl)
|
2003-10-18 04:29:40 +00:00
|
|
|
|
{
|
2004-08-14 16:47:48 +00:00
|
|
|
|
const char *home;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
char *name;
|
|
|
|
|
GtkFilePath *path;
|
|
|
|
|
|
2004-08-14 16:47:48 +00:00
|
|
|
|
home = g_get_home_dir ();
|
|
|
|
|
if (home == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
name = g_build_filename (home, "Desktop", NULL);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
path = gtk_file_system_filename_to_path (impl->file_system, name);
|
|
|
|
|
g_free (name);
|
|
|
|
|
|
2004-02-24 10:11:47 +00:00
|
|
|
|
impl->has_desktop = shortcuts_insert_path (impl, -1, FALSE, NULL, path, _("Desktop"), FALSE, NULL);
|
2003-11-19 22:38:31 +00:00
|
|
|
|
/* We do not actually pop up an error dialog if there is no desktop directory
|
|
|
|
|
* because some people may really not want to have one.
|
|
|
|
|
*/
|
2003-11-04 01:56:56 +00:00
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
gtk_file_path_free (path);
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-04 01:56:56 +00:00
|
|
|
|
/* Appends a list of GtkFilePath to the shortcuts model; returns how many were inserted */
|
|
|
|
|
static int
|
|
|
|
|
shortcuts_append_paths (GtkFileChooserDefault *impl,
|
2003-12-17 05:55:16 +00:00
|
|
|
|
GSList *paths)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
2004-03-05 06:51:22 +00:00
|
|
|
|
int start_row;
|
2003-11-04 01:56:56 +00:00
|
|
|
|
int num_inserted;
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-03-05 06:51:22 +00:00
|
|
|
|
/* As there is no separator now, we want to start there.
|
|
|
|
|
*/
|
|
|
|
|
start_row = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
|
2003-11-04 01:56:56 +00:00
|
|
|
|
num_inserted = 0;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
|
2003-11-04 01:56:56 +00:00
|
|
|
|
for (; paths; paths = paths->next)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
2003-10-08 04:14:55 +00:00
|
|
|
|
GtkFilePath *path;
|
2003-11-04 01:56:56 +00:00
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
|
|
path = paths->data;
|
|
|
|
|
error = NULL;
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-03-15 06:09:40 +00:00
|
|
|
|
if (impl->local_only &&
|
|
|
|
|
!gtk_file_system_path_is_local (impl->file_system, path))
|
|
|
|
|
continue;
|
|
|
|
|
|
2004-01-06 05:13:31 +00:00
|
|
|
|
/* NULL GError, but we don't really want to show error boxes here */
|
2004-03-05 06:51:22 +00:00
|
|
|
|
if (shortcuts_insert_path (impl, start_row + num_inserted, FALSE, NULL, path, NULL, TRUE, NULL))
|
2003-11-04 01:56:56 +00:00
|
|
|
|
num_inserted++;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2003-11-04 01:56:56 +00:00
|
|
|
|
return num_inserted;
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
/* Returns the index for the corresponding item in the shortcuts bar */
|
|
|
|
|
static int
|
|
|
|
|
shortcuts_get_index (GtkFileChooserDefault *impl,
|
|
|
|
|
ShortcutsIndex where)
|
2003-11-04 01:56:56 +00:00
|
|
|
|
{
|
2003-12-17 05:55:16 +00:00
|
|
|
|
int n;
|
|
|
|
|
|
|
|
|
|
n = 0;
|
2003-11-04 01:56:56 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
if (where == SHORTCUTS_HOME)
|
|
|
|
|
goto out;
|
2004-01-20 02:44:58 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
n += impl->has_home ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
if (where == SHORTCUTS_DESKTOP)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
n += impl->has_desktop ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
if (where == SHORTCUTS_VOLUMES)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
n += impl->num_volumes;
|
|
|
|
|
|
|
|
|
|
if (where == SHORTCUTS_SHORTCUTS)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
n += impl->num_shortcuts;
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
if (where == SHORTCUTS_BOOKMARKS_SEPARATOR)
|
2003-12-17 05:55:16 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
2004-02-24 10:11:47 +00:00
|
|
|
|
/* If there are no bookmarks there won't be a separator */
|
2004-03-01 18:24:06 +00:00
|
|
|
|
n += (impl->num_bookmarks > 0) ? 1 : 0;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
|
|
|
|
if (where == SHORTCUTS_BOOKMARKS)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
n += impl->num_bookmarks;
|
|
|
|
|
|
|
|
|
|
if (where == SHORTCUTS_CURRENT_FOLDER_SEPARATOR)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
n += 1;
|
|
|
|
|
|
|
|
|
|
if (where == SHORTCUTS_CURRENT_FOLDER)
|
|
|
|
|
goto out;
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
|
|
out:
|
2003-11-04 01:56:56 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
return n;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
/* Removes the specified number of rows from the shortcuts list */
|
2003-10-15 03:06:55 +00:00
|
|
|
|
static void
|
2003-12-17 05:55:16 +00:00
|
|
|
|
shortcuts_remove_rows (GtkFileChooserDefault *impl,
|
2004-08-18 16:30:58 +00:00
|
|
|
|
int start_row,
|
|
|
|
|
int n_rows)
|
2003-10-15 03:06:55 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreePath *path;
|
2004-09-20 23:47:38 +00:00
|
|
|
|
gchar *text;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
path = gtk_tree_path_new_from_indices (start_row, -1);
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
for (; n_rows; n_rows--)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->shortcuts_model), &iter, path))
|
|
|
|
|
g_assert_not_reached ();
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-09-20 23:47:38 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
|
|
|
|
|
SHORTCUTS_COL_NAME, &text, -1);
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcuts_free_row_data (impl, &iter);
|
2004-02-24 00:15:23 +00:00
|
|
|
|
gtk_list_store_remove (impl->shortcuts_model, &iter);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
gtk_tree_path_free (path);
|
2003-10-15 03:06:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
/* Adds all the file system volumes to the shortcuts model */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_add_volumes (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
int start_row;
|
|
|
|
|
GSList *list, *l;
|
|
|
|
|
int n;
|
2004-03-15 16:27:45 +00:00
|
|
|
|
gboolean old_changing_folders;
|
|
|
|
|
|
|
|
|
|
old_changing_folders = impl->changing_folder;
|
|
|
|
|
impl->changing_folder = TRUE;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
|
|
|
|
start_row = shortcuts_get_index (impl, SHORTCUTS_VOLUMES);
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcuts_remove_rows (impl, start_row, impl->num_volumes);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
impl->num_volumes = 0;
|
|
|
|
|
|
|
|
|
|
list = gtk_file_system_list_volumes (impl->file_system);
|
|
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
|
|
|
|
|
|
for (l = list; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GtkFileSystemVolume *volume;
|
|
|
|
|
|
|
|
|
|
volume = l->data;
|
2004-03-15 23:15:31 +00:00
|
|
|
|
|
2004-03-15 06:09:40 +00:00
|
|
|
|
if (impl->local_only)
|
|
|
|
|
{
|
|
|
|
|
GtkFilePath *base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
|
|
|
|
|
gboolean is_local = gtk_file_system_path_is_local (impl->file_system, base_path);
|
|
|
|
|
gtk_file_path_free (base_path);
|
|
|
|
|
|
|
|
|
|
if (!is_local)
|
2004-03-17 21:52:29 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_file_system_volume_free (impl->file_system, volume);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2004-03-15 06:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-17 21:52:29 +00:00
|
|
|
|
if (shortcuts_insert_path (impl, start_row + n, TRUE, volume, NULL, NULL, FALSE, NULL))
|
|
|
|
|
n++;
|
|
|
|
|
else
|
|
|
|
|
gtk_file_system_volume_free (impl->file_system, volume);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl->num_volumes = n;
|
2004-02-06 16:21:39 +00:00
|
|
|
|
g_slist_free (list);
|
2004-03-05 06:51:22 +00:00
|
|
|
|
|
|
|
|
|
if (impl->shortcuts_filter_model)
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
|
2004-03-15 16:27:45 +00:00
|
|
|
|
|
|
|
|
|
impl->changing_folder = old_changing_folders;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
/* Inserts a separator node in the shortcuts list */
|
2004-02-24 11:48:13 +00:00
|
|
|
|
static void
|
2004-03-02 02:59:02 +00:00
|
|
|
|
shortcuts_insert_separator (GtkFileChooserDefault *impl,
|
|
|
|
|
ShortcutsIndex where)
|
2004-02-24 11:48:13 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
g_assert (where == SHORTCUTS_BOOKMARKS_SEPARATOR || where == SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
|
|
|
|
|
|
2004-02-24 11:48:13 +00:00
|
|
|
|
gtk_list_store_insert (impl->shortcuts_model, &iter,
|
2004-03-02 02:59:02 +00:00
|
|
|
|
shortcuts_get_index (impl, where));
|
2004-02-24 11:48:13 +00:00
|
|
|
|
gtk_list_store_set (impl->shortcuts_model, &iter,
|
|
|
|
|
SHORTCUTS_COL_PIXBUF, NULL,
|
|
|
|
|
SHORTCUTS_COL_PIXBUF_VISIBLE, FALSE,
|
|
|
|
|
SHORTCUTS_COL_NAME, NULL,
|
2004-08-18 16:30:58 +00:00
|
|
|
|
SHORTCUTS_COL_DATA, NULL,
|
2004-02-24 11:48:13 +00:00
|
|
|
|
-1);
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
/* Updates the list of bookmarks */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
|
2003-10-08 04:14:55 +00:00
|
|
|
|
{
|
2003-11-04 01:56:56 +00:00
|
|
|
|
GSList *bookmarks;
|
2004-03-15 16:27:45 +00:00
|
|
|
|
gboolean old_changing_folders;
|
|
|
|
|
|
|
|
|
|
old_changing_folders = impl->changing_folder;
|
|
|
|
|
impl->changing_folder = TRUE;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
|
2004-02-24 10:11:47 +00:00
|
|
|
|
if (impl->num_bookmarks > 0)
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcuts_remove_rows (impl,
|
|
|
|
|
shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR),
|
|
|
|
|
impl->num_bookmarks + 1);
|
2004-02-29 06:35:15 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
bookmarks = gtk_file_system_list_bookmarks (impl->file_system);
|
|
|
|
|
impl->num_bookmarks = shortcuts_append_paths (impl, bookmarks);
|
|
|
|
|
gtk_file_paths_free (bookmarks);
|
2004-02-24 10:11:47 +00:00
|
|
|
|
|
|
|
|
|
if (impl->num_bookmarks > 0)
|
|
|
|
|
{
|
2004-03-02 02:59:02 +00:00
|
|
|
|
shortcuts_insert_separator (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
|
2004-02-24 10:11:47 +00:00
|
|
|
|
}
|
2004-03-05 06:51:22 +00:00
|
|
|
|
if (impl->shortcuts_filter_model)
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
|
2004-03-15 16:27:45 +00:00
|
|
|
|
|
|
|
|
|
impl->changing_folder = old_changing_folders;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
/* Appends a separator and a row to the shortcuts list for the current folder */
|
2003-10-01 00:53:59 +00:00
|
|
|
|
static void
|
2004-03-02 02:59:02 +00:00
|
|
|
|
shortcuts_add_current_folder (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
int pos;
|
2004-03-02 20:05:08 +00:00
|
|
|
|
gboolean success;
|
2004-03-02 02:59:02 +00:00
|
|
|
|
|
2004-03-02 05:27:51 +00:00
|
|
|
|
g_assert (!impl->shortcuts_current_folder_active);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
|
2004-03-02 20:05:08 +00:00
|
|
|
|
success = TRUE;
|
|
|
|
|
|
2004-03-02 05:27:51 +00:00
|
|
|
|
pos = shortcut_find_position (impl, impl->current_folder);
|
|
|
|
|
if (pos == -1)
|
|
|
|
|
{
|
|
|
|
|
GtkFileSystemVolume *volume;
|
|
|
|
|
GtkFilePath *base_path;
|
|
|
|
|
|
|
|
|
|
/* Separator */
|
|
|
|
|
|
|
|
|
|
shortcuts_insert_separator (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
|
|
|
|
|
|
|
|
|
|
/* Item */
|
|
|
|
|
|
|
|
|
|
pos = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER);
|
|
|
|
|
|
|
|
|
|
volume = gtk_file_system_get_volume_for_path (impl->file_system, impl->current_folder);
|
2004-03-05 07:46:06 +00:00
|
|
|
|
if (volume)
|
|
|
|
|
base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
|
|
|
|
|
else
|
|
|
|
|
base_path = NULL;
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
2004-03-05 07:46:06 +00:00
|
|
|
|
if (base_path &&
|
|
|
|
|
strcmp (gtk_file_path_get_string (base_path), gtk_file_path_get_string (impl->current_folder)) == 0)
|
2004-03-02 05:27:51 +00:00
|
|
|
|
{
|
2004-03-02 20:05:08 +00:00
|
|
|
|
success = shortcuts_insert_path (impl, pos, TRUE, volume, NULL, NULL, FALSE, NULL);
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (!success)
|
|
|
|
|
gtk_file_system_volume_free (impl->file_system, volume);
|
2004-03-02 05:27:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2004-08-18 16:30:58 +00:00
|
|
|
|
success = shortcuts_insert_path (impl, pos, FALSE, NULL, impl->current_folder, NULL, FALSE, NULL);
|
2004-03-02 05:27:51 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (base_path)
|
|
|
|
|
gtk_file_path_free (base_path);
|
2004-03-02 05:27:51 +00:00
|
|
|
|
|
2004-03-02 20:05:08 +00:00
|
|
|
|
if (!success)
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcuts_remove_rows (impl, pos - 1, 1); /* remove the separator */
|
2004-03-02 20:05:08 +00:00
|
|
|
|
|
|
|
|
|
impl->shortcuts_current_folder_active = success;
|
2004-03-02 05:27:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-02 20:05:08 +00:00
|
|
|
|
if (success)
|
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo), pos);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Updates the current folder row in the shortcuts model */
|
|
|
|
|
static void
|
2004-03-02 05:27:51 +00:00
|
|
|
|
shortcuts_update_current_folder (GtkFileChooserDefault *impl)
|
2004-03-02 02:59:02 +00:00
|
|
|
|
{
|
|
|
|
|
int pos;
|
|
|
|
|
|
2004-03-02 05:27:51 +00:00
|
|
|
|
pos = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
|
2004-03-02 05:27:51 +00:00
|
|
|
|
if (impl->shortcuts_current_folder_active)
|
|
|
|
|
{
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcuts_remove_rows (impl, pos, 2);
|
2004-03-02 05:27:51 +00:00
|
|
|
|
impl->shortcuts_current_folder_active = FALSE;
|
|
|
|
|
}
|
2004-03-02 02:59:02 +00:00
|
|
|
|
|
|
|
|
|
shortcuts_add_current_folder (impl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Filter function used for the shortcuts filter model */
|
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_filter_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path (model, iter);
|
|
|
|
|
if (!path)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
pos = *gtk_tree_path_get_indices (path);
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
|
|
return (pos < shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Creates the list model for shortcuts */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_model_create (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2003-10-09 01:12:24 +00:00
|
|
|
|
/* Keep this order in sync with the SHORCUTS_COL_* enum values */
|
2004-02-24 00:15:23 +00:00
|
|
|
|
impl->shortcuts_model = gtk_list_store_new (SHORTCUTS_COL_NUM_COLUMNS,
|
2003-10-01 00:53:59 +00:00
|
|
|
|
GDK_TYPE_PIXBUF, /* pixbuf */
|
|
|
|
|
G_TYPE_STRING, /* name */
|
2004-01-07 17:07:18 +00:00
|
|
|
|
G_TYPE_POINTER, /* path or volume */
|
2004-08-18 16:30:58 +00:00
|
|
|
|
G_TYPE_BOOLEAN, /* is the previous column a volume? */
|
2004-02-24 00:15:23 +00:00
|
|
|
|
G_TYPE_BOOLEAN, /* removable */
|
|
|
|
|
G_TYPE_BOOLEAN); /* pixbuf cell visibility */
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2003-10-08 04:14:55 +00:00
|
|
|
|
if (impl->file_system)
|
|
|
|
|
{
|
|
|
|
|
shortcuts_append_home (impl);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
shortcuts_append_desktop (impl);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
shortcuts_add_volumes (impl);
|
2004-02-24 10:11:47 +00:00
|
|
|
|
shortcuts_add_bookmarks (impl);
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
impl->shortcuts_filter_model = shortcuts_model_filter_new (impl,
|
|
|
|
|
GTK_TREE_MODEL (impl->shortcuts_model),
|
|
|
|
|
NULL);
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
|
|
|
|
|
shortcuts_filter_cb,
|
|
|
|
|
impl,
|
|
|
|
|
NULL);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-05-04 17:53:13 +00:00
|
|
|
|
/* Callback used when the "New Folder" button is clicked */
|
2004-01-17 04:34:49 +00:00
|
|
|
|
static void
|
|
|
|
|
new_folder_button_clicked (GtkButton *button,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
if (!impl->browse_files_model)
|
|
|
|
|
return; /* FIXME: this sucks. Disable the New Folder button or something. */
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
_gtk_file_system_model_add_editable (impl->browse_files_model, &iter);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->browse_files_model), &iter);
|
2004-03-05 23:02:01 +00:00
|
|
|
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (impl->browse_files_tree_view),
|
|
|
|
|
path, impl->list_name_column,
|
|
|
|
|
FALSE, 0.0, 0.0);
|
|
|
|
|
|
|
|
|
|
g_object_set (impl->list_name_renderer, "editable", TRUE, NULL);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view),
|
2004-01-17 04:34:49 +00:00
|
|
|
|
path,
|
|
|
|
|
impl->list_name_column,
|
|
|
|
|
TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-12 00:49:02 +00:00
|
|
|
|
/* Idle handler for creating a new folder after editing its name cell, or for
|
|
|
|
|
* canceling the editing.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
edited_idle_cb (GtkFileChooserDefault *impl)
|
2004-01-17 04:34:49 +00:00
|
|
|
|
{
|
2004-06-12 00:49:02 +00:00
|
|
|
|
g_source_destroy (impl->edited_idle);
|
|
|
|
|
impl->edited_idle = NULL;
|
2004-01-17 04:34:49 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
_gtk_file_system_model_remove_editable (impl->browse_files_model);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
g_object_set (impl->list_name_renderer, "editable", FALSE, NULL);
|
|
|
|
|
|
2004-06-12 00:49:02 +00:00
|
|
|
|
if (impl->edited_new_text) /* not cancelled? */
|
2004-01-17 04:34:49 +00:00
|
|
|
|
{
|
2004-06-12 00:49:02 +00:00
|
|
|
|
GError *error;
|
|
|
|
|
GtkFilePath *file_path;
|
|
|
|
|
|
|
|
|
|
error = NULL;
|
|
|
|
|
file_path = gtk_file_system_make_path (impl->file_system, impl->current_folder, impl->edited_new_text,
|
|
|
|
|
&error);
|
|
|
|
|
if (file_path)
|
|
|
|
|
{
|
|
|
|
|
error = NULL;
|
|
|
|
|
if (gtk_file_system_create_folder (impl->file_system, file_path, &error))
|
|
|
|
|
change_folder_and_display_error (impl, file_path);
|
|
|
|
|
else
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Could not create folder %s:\n%s"),
|
|
|
|
|
file_path, error);
|
|
|
|
|
|
|
|
|
|
gtk_file_path_free (file_path);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error_building_filename_dialog (impl, impl->current_folder, impl->edited_new_text, error);
|
|
|
|
|
|
|
|
|
|
g_free (impl->edited_new_text);
|
|
|
|
|
impl->edited_new_text = NULL;
|
2004-01-17 04:34:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-06-12 00:49:02 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
queue_edited_idle (GtkFileChooserDefault *impl,
|
|
|
|
|
const gchar *new_text)
|
|
|
|
|
{
|
|
|
|
|
/* We create the folder in an idle handler so that we don't modify the tree
|
|
|
|
|
* just now.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
g_assert (!impl->edited_idle);
|
|
|
|
|
g_assert (!impl->edited_new_text);
|
|
|
|
|
|
|
|
|
|
impl->edited_idle = g_idle_source_new ();
|
|
|
|
|
g_source_set_closure (impl->edited_idle,
|
|
|
|
|
g_cclosure_new_object (G_CALLBACK (edited_idle_cb),
|
|
|
|
|
G_OBJECT (impl)));
|
|
|
|
|
g_source_attach (impl->edited_idle, NULL);
|
|
|
|
|
|
|
|
|
|
if (new_text)
|
|
|
|
|
impl->edited_new_text = g_strdup (new_text);
|
|
|
|
|
}
|
2004-01-17 04:34:49 +00:00
|
|
|
|
|
2004-06-12 00:49:02 +00:00
|
|
|
|
/* Callback used from the text cell renderer when the new folder is named */
|
|
|
|
|
static void
|
|
|
|
|
renderer_edited_cb (GtkCellRendererText *cell_renderer_text,
|
|
|
|
|
const gchar *path,
|
|
|
|
|
const gchar *new_text,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-10-08 17:09:18 +00:00
|
|
|
|
/* work around bug #154921 */
|
|
|
|
|
g_object_set (cell_renderer_text,
|
|
|
|
|
"mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
|
|
|
|
|
queue_edited_idle (impl, new_text);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used from the text cell renderer when the new folder edition gets
|
|
|
|
|
* canceled.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
renderer_editing_canceled_cb (GtkCellRendererText *cell_renderer_text,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-10-08 17:09:18 +00:00
|
|
|
|
/* work around bug #154921 */
|
|
|
|
|
g_object_set (cell_renderer_text,
|
|
|
|
|
"mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
|
|
|
|
|
queue_edited_idle (impl, NULL);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-06 04:18:42 +00:00
|
|
|
|
/* Creates the widgets for the filter combo box */
|
|
|
|
|
static GtkWidget *
|
|
|
|
|
filter_create (GtkFileChooserDefault *impl)
|
2003-11-03 00:50:33 +00:00
|
|
|
|
{
|
2004-01-06 04:18:42 +00:00
|
|
|
|
impl->filter_combo = gtk_combo_box_new_text ();
|
|
|
|
|
g_signal_connect (impl->filter_combo, "changed",
|
|
|
|
|
G_CALLBACK (filter_combo_changed), impl);
|
2003-11-03 18:46:18 +00:00
|
|
|
|
|
2004-01-06 04:18:42 +00:00
|
|
|
|
return impl->filter_combo;
|
2003-11-03 00:50:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-10 20:49:44 +00:00
|
|
|
|
static GtkWidget *
|
2004-02-19 03:22:22 +00:00
|
|
|
|
button_new (GtkFileChooserDefault *impl,
|
|
|
|
|
const char *text,
|
|
|
|
|
const char *stock_id,
|
|
|
|
|
gboolean sensitive,
|
|
|
|
|
gboolean show,
|
|
|
|
|
GCallback callback)
|
2003-12-10 20:49:44 +00:00
|
|
|
|
{
|
2004-01-06 04:18:42 +00:00
|
|
|
|
GtkWidget *button;
|
2003-12-10 20:49:44 +00:00
|
|
|
|
GtkWidget *hbox;
|
2004-01-06 04:18:42 +00:00
|
|
|
|
GtkWidget *widget;
|
2004-02-23 22:56:55 +00:00
|
|
|
|
GtkWidget *align;
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2004-01-06 04:18:42 +00:00
|
|
|
|
button = gtk_button_new ();
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 2);
|
2004-02-23 22:56:55 +00:00
|
|
|
|
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2004-02-23 22:56:55 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), align);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), hbox);
|
2004-01-06 04:18:42 +00:00
|
|
|
|
widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
|
2004-02-23 22:56:55 +00:00
|
|
|
|
|
2004-01-06 04:18:42 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2004-02-24 02:09:20 +00:00
|
|
|
|
widget = gtk_label_new_with_mnemonic (text);
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (button));
|
2004-01-06 04:18:42 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2004-01-06 04:18:42 +00:00
|
|
|
|
gtk_widget_set_sensitive (button, sensitive);
|
|
|
|
|
g_signal_connect (button, "clicked", callback, impl);
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2004-02-23 22:56:55 +00:00
|
|
|
|
gtk_widget_show_all (align);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
|
|
|
|
|
if (show)
|
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
2004-01-06 04:18:42 +00:00
|
|
|
|
return button;
|
2003-12-10 20:49:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-02 05:27:51 +00:00
|
|
|
|
/* Looks for a path among the shortcuts; returns its index or -1 if it doesn't exist */
|
|
|
|
|
static int
|
|
|
|
|
shortcut_find_position (GtkFileChooserDefault *impl,
|
|
|
|
|
const GtkFilePath *path)
|
2004-02-24 03:37:32 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
2004-03-02 02:59:02 +00:00
|
|
|
|
int i;
|
|
|
|
|
int current_folder_separator_idx;
|
|
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
|
2004-03-02 05:27:51 +00:00
|
|
|
|
return -1;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
current_folder_separator_idx = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < current_folder_separator_idx; i++)
|
2004-02-24 03:37:32 +00:00
|
|
|
|
{
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gpointer col_data;
|
|
|
|
|
gboolean is_volume;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
|
|
|
|
|
SHORTCUTS_COL_DATA, &col_data,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, &is_volume,
|
|
|
|
|
-1);
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (col_data)
|
2004-02-24 03:37:32 +00:00
|
|
|
|
{
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (is_volume)
|
|
|
|
|
{
|
|
|
|
|
GtkFileSystemVolume *volume;
|
|
|
|
|
GtkFilePath *base_path;
|
|
|
|
|
gboolean exists;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
volume = col_data;
|
|
|
|
|
base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
exists = strcmp (gtk_file_path_get_string (path),
|
|
|
|
|
gtk_file_path_get_string (base_path)) == 0;
|
|
|
|
|
g_free (base_path);
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (exists)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkFilePath *model_path;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
model_path = col_data;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (model_path && gtk_file_path_compare (model_path, path) == 0)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
2004-02-24 03:37:32 +00:00
|
|
|
|
}
|
2004-03-02 02:59:02 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
|
2004-02-24 03:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-02 05:27:51 +00:00
|
|
|
|
return -1;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-01 15:33:37 +00:00
|
|
|
|
/* Tries to add a bookmark from a path name */
|
2004-03-11 06:24:15 +00:00
|
|
|
|
static gboolean
|
2003-12-01 15:33:37 +00:00
|
|
|
|
shortcuts_add_bookmark_from_path (GtkFileChooserDefault *impl,
|
2004-03-11 06:24:15 +00:00
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
int pos)
|
2003-10-08 04:14:55 +00:00
|
|
|
|
{
|
2003-11-04 01:56:56 +00:00
|
|
|
|
GError *error;
|
|
|
|
|
|
2004-03-02 05:27:51 +00:00
|
|
|
|
if (shortcut_find_position (impl, path) != -1)
|
2004-03-11 06:24:15 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2004-03-17 15:34:21 +00:00
|
|
|
|
/* FIXME: this check really belongs in gtk_file_system_insert_bookmark. */
|
2003-11-04 01:56:56 +00:00
|
|
|
|
error = NULL;
|
2004-03-17 15:34:21 +00:00
|
|
|
|
if (!check_is_folder (impl->file_system, path, &error))
|
2003-12-01 15:33:37 +00:00
|
|
|
|
{
|
2004-03-17 15:34:21 +00:00
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Could not add bookmark for %s because it is not a folder."),
|
|
|
|
|
path,
|
|
|
|
|
error);
|
|
|
|
|
return FALSE;
|
2003-12-01 15:33:37 +00:00
|
|
|
|
}
|
2004-03-17 15:34:21 +00:00
|
|
|
|
|
|
|
|
|
error = NULL;
|
|
|
|
|
if (!gtk_file_system_insert_bookmark (impl->file_system, path, pos, &error))
|
2003-12-01 15:33:37 +00:00
|
|
|
|
{
|
2004-03-17 15:34:21 +00:00
|
|
|
|
error_could_not_add_bookmark_dialog (impl, path, error);
|
|
|
|
|
return FALSE;
|
2003-12-01 15:33:37 +00:00
|
|
|
|
}
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
2004-03-17 15:34:21 +00:00
|
|
|
|
return TRUE;
|
2003-12-01 15:33:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-24 03:37:32 +00:00
|
|
|
|
static void
|
|
|
|
|
add_bookmark_foreach_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
GtkFileSystemModel *fs_model;
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
const GtkFilePath *file_path;
|
|
|
|
|
|
2004-03-07 04:41:36 +00:00
|
|
|
|
impl = (GtkFileChooserDefault *) data;
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
2004-03-07 04:41:36 +00:00
|
|
|
|
fs_model = impl->browse_files_model;
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, iter);
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
file_path = _gtk_file_system_model_get_path (fs_model, &child_iter);
|
2004-03-11 06:24:15 +00:00
|
|
|
|
shortcuts_add_bookmark_from_path (impl, file_path, -1);
|
2004-02-24 03:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
/* Adds a bookmark from the currently selected item in the file list */
|
2003-12-01 15:33:37 +00:00
|
|
|
|
static void
|
2004-07-29 20:53:52 +00:00
|
|
|
|
bookmarks_add_selected_folder (GtkFileChooserDefault *impl)
|
2003-12-01 15:33:37 +00:00
|
|
|
|
{
|
2004-02-24 03:37:32 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
2004-03-07 04:41:36 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
2004-02-24 03:37:32 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_tree_selection_count_selected_rows (selection) == 0)
|
2004-03-11 06:24:15 +00:00
|
|
|
|
shortcuts_add_bookmark_from_path (impl, impl->current_folder, -1);
|
2004-02-24 03:37:32 +00:00
|
|
|
|
else
|
|
|
|
|
gtk_tree_selection_selected_foreach (selection,
|
|
|
|
|
add_bookmark_foreach_cb,
|
|
|
|
|
impl);
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
/* Callback used when the "Add bookmark" button is clicked */
|
|
|
|
|
static void
|
|
|
|
|
add_bookmark_button_clicked_cb (GtkButton *button,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
bookmarks_add_selected_folder (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
/* Returns TRUE plus an iter in the shortcuts_model if a row is selected;
|
|
|
|
|
* returns FALSE if no shortcut is selected.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_get_selected (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
GtkTreeIter parent_iter;
|
|
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
|
|
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected (selection, NULL, &parent_iter))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
|
|
|
|
|
iter,
|
|
|
|
|
&parent_iter);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-29 23:13:50 +00:00
|
|
|
|
/* Removes the selected bookmarks */
|
2003-10-15 03:06:55 +00:00
|
|
|
|
static void
|
2004-04-29 23:13:50 +00:00
|
|
|
|
remove_selected_bookmarks (GtkFileChooserDefault *impl)
|
2003-10-15 03:06:55 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gpointer col_data;
|
|
|
|
|
gboolean is_volume;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
GtkFilePath *path;
|
2004-01-07 17:07:18 +00:00
|
|
|
|
gboolean removable;
|
2003-11-04 01:56:56 +00:00
|
|
|
|
GError *error;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
if (!shortcuts_get_selected (impl, &iter))
|
2004-04-29 23:13:50 +00:00
|
|
|
|
return;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
|
2004-08-18 16:30:58 +00:00
|
|
|
|
SHORTCUTS_COL_DATA, &col_data,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, &is_volume,
|
|
|
|
|
SHORTCUTS_COL_REMOVABLE, &removable,
|
|
|
|
|
-1);
|
|
|
|
|
g_assert (col_data != NULL);
|
|
|
|
|
g_assert (!is_volume);
|
|
|
|
|
|
2004-04-29 23:13:50 +00:00
|
|
|
|
if (!removable)
|
|
|
|
|
return;
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
path = col_data;
|
|
|
|
|
|
2004-04-29 23:13:50 +00:00
|
|
|
|
error = NULL;
|
|
|
|
|
if (!gtk_file_system_remove_bookmark (impl->file_system, path, &error))
|
|
|
|
|
{
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Could not remove bookmark for %s:\n%s"),
|
|
|
|
|
path,
|
|
|
|
|
error);
|
2004-01-07 17:07:18 +00:00
|
|
|
|
}
|
2003-10-15 03:06:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-04-29 23:13:50 +00:00
|
|
|
|
/* Callback used when the "Remove bookmark" button is clicked */
|
|
|
|
|
static void
|
|
|
|
|
remove_bookmark_button_clicked_cb (GtkButton *button,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
remove_selected_bookmarks (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
struct selection_check_closure {
|
2004-02-24 03:37:32 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
2004-07-29 20:53:52 +00:00
|
|
|
|
int num_selected;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
gboolean all_files;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
gboolean all_folders;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Used from gtk_tree_selection_selected_foreach() */
|
2003-10-15 03:06:55 +00:00
|
|
|
|
static void
|
2004-03-05 00:10:59 +00:00
|
|
|
|
selection_check_foreach_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2003-10-15 03:06:55 +00:00
|
|
|
|
{
|
2004-03-05 00:10:59 +00:00
|
|
|
|
struct selection_check_closure *closure;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
const GtkFileInfo *info;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
gboolean is_folder;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-02-24 03:37:32 +00:00
|
|
|
|
closure = data;
|
2004-07-29 20:53:52 +00:00
|
|
|
|
closure->num_selected++;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-02-24 03:37:32 +00:00
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
info = _gtk_file_system_model_get_info (closure->impl->browse_files_model, &child_iter);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
is_folder = gtk_file_info_get_is_folder (info);
|
|
|
|
|
|
2004-09-22 19:32:13 +00:00
|
|
|
|
closure->all_folders = closure->all_folders && is_folder;
|
|
|
|
|
closure->all_files = closure->all_files && !is_folder;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
}
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
/* Checks whether the selected items in the file list are all files or all folders */
|
|
|
|
|
static void
|
|
|
|
|
selection_check (GtkFileChooserDefault *impl,
|
2004-09-23 19:39:39 +00:00
|
|
|
|
gint *num_selected,
|
2004-03-05 00:10:59 +00:00
|
|
|
|
gboolean *all_files,
|
|
|
|
|
gboolean *all_folders)
|
2004-02-24 03:37:32 +00:00
|
|
|
|
{
|
2004-03-05 00:10:59 +00:00
|
|
|
|
struct selection_check_closure closure;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
closure.impl = impl;
|
|
|
|
|
closure.num_selected = 0;
|
|
|
|
|
closure.all_files = TRUE;
|
|
|
|
|
closure.all_folders = TRUE;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
|
|
|
|
gtk_tree_selection_selected_foreach (selection,
|
|
|
|
|
selection_check_foreach_cb,
|
|
|
|
|
&closure);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
g_assert (closure.num_selected == 0 || !(closure.all_files && closure.all_folders));
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
if (num_selected)
|
|
|
|
|
*num_selected = closure.num_selected;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
if (all_files)
|
|
|
|
|
*all_files = closure.all_files;
|
|
|
|
|
|
|
|
|
|
if (all_folders)
|
|
|
|
|
*all_folders = closure.all_folders;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
}
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
struct get_selected_path_closure {
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
const GtkFilePath *path;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_selected_path_foreach_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
struct get_selected_path_closure *closure;
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
|
|
|
|
|
closure = data;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
|
|
|
|
|
closure->path = _gtk_file_system_model_get_path (closure->impl->browse_files_model, &child_iter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns a selected path from the file list */
|
|
|
|
|
static const GtkFilePath *
|
|
|
|
|
get_selected_path (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
struct get_selected_path_closure closure;
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
|
|
|
|
closure.impl = impl;
|
|
|
|
|
closure.path = NULL;
|
|
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
|
|
|
|
gtk_tree_selection_selected_foreach (selection,
|
|
|
|
|
get_selected_path_foreach_cb,
|
|
|
|
|
&closure);
|
|
|
|
|
|
|
|
|
|
return closure.path;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-23 19:39:39 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
gchar *tip;
|
|
|
|
|
} UpdateTooltipData;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_tooltip (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
UpdateTooltipData *udata = data;
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
const GtkFileInfo *info;
|
|
|
|
|
|
|
|
|
|
if (udata->tip == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (udata->impl->sort_model,
|
|
|
|
|
&child_iter,
|
|
|
|
|
iter);
|
|
|
|
|
|
|
|
|
|
info = _gtk_file_system_model_get_info (udata->impl->browse_files_model, &child_iter);
|
|
|
|
|
udata->tip = g_strdup_printf (_("Add the folder '%s' to the bookmarks"),
|
|
|
|
|
gtk_file_info_get_display_name (info));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-02-24 03:37:32 +00:00
|
|
|
|
/* Sensitize the "add bookmark" button if all the selected items are folders, or
|
|
|
|
|
* if there are no selected items *and* the current folder is not in the
|
|
|
|
|
* bookmarks list. De-sensitize the button otherwise.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-09-23 19:39:39 +00:00
|
|
|
|
gint num_selected;
|
2004-07-29 20:53:52 +00:00
|
|
|
|
gboolean all_folders;
|
2004-02-24 03:37:32 +00:00
|
|
|
|
gboolean active;
|
2004-09-23 19:39:39 +00:00
|
|
|
|
gchar *tip;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
selection_check (impl, &num_selected, NULL, &all_folders);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
if (num_selected == 0)
|
2004-03-02 05:27:51 +00:00
|
|
|
|
active = (shortcut_find_position (impl, impl->current_folder) == -1);
|
2004-07-29 20:53:52 +00:00
|
|
|
|
else if (num_selected == 1)
|
2004-03-05 00:10:59 +00:00
|
|
|
|
{
|
2004-07-29 20:53:52 +00:00
|
|
|
|
const GtkFilePath *path;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
path = get_selected_path (impl);
|
|
|
|
|
active = all_folders && (shortcut_find_position (impl, path) == -1);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
2004-07-29 20:53:52 +00:00
|
|
|
|
else
|
|
|
|
|
active = all_folders;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_widget_set_sensitive (impl->browse_shortcuts_add_button, active);
|
2004-07-29 20:53:52 +00:00
|
|
|
|
|
|
|
|
|
if (impl->browse_files_popup_menu_add_shortcut_item)
|
|
|
|
|
gtk_widget_set_sensitive (impl->browse_files_popup_menu_add_shortcut_item,
|
|
|
|
|
(num_selected == 0) ? FALSE : active);
|
2004-09-23 19:39:39 +00:00
|
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
|
{
|
|
|
|
|
if (num_selected == 0)
|
|
|
|
|
tip = g_strdup_printf (_("Add the current folder to the bookmarks"));
|
|
|
|
|
else if (num_selected > 1)
|
|
|
|
|
tip = g_strdup_printf (_("Add the selected folders to the bookmarks"));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
UpdateTooltipData data;
|
|
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
|
|
|
|
data.impl = impl;
|
|
|
|
|
data.tip = NULL;
|
|
|
|
|
gtk_tree_selection_selected_foreach (selection, update_tooltip, &data);
|
|
|
|
|
tip = data.tip;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_add_button, tip, NULL);
|
|
|
|
|
g_free (tip);
|
|
|
|
|
}
|
2003-10-15 03:06:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sets the sensitivity of the "remove bookmark" button depending on whether a
|
|
|
|
|
* bookmark row is selected in the shortcuts tree.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
bookmarks_check_remove_sensitivity (GtkFileChooserDefault *impl)
|
2003-10-15 03:06:55 +00:00
|
|
|
|
{
|
2004-01-07 17:07:18 +00:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gboolean removable = FALSE;
|
2004-09-26 05:39:34 +00:00
|
|
|
|
gchar *name = NULL;
|
2004-09-23 19:39:39 +00:00
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
if (shortcuts_get_selected (impl, &iter))
|
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
|
2004-01-07 17:07:18 +00:00
|
|
|
|
SHORTCUTS_COL_REMOVABLE, &removable,
|
2004-09-23 19:39:39 +00:00
|
|
|
|
SHORTCUTS_COL_NAME, &name,
|
2004-01-07 17:07:18 +00:00
|
|
|
|
-1);
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_widget_set_sensitive (impl->browse_shortcuts_remove_button, removable);
|
2004-09-23 19:39:39 +00:00
|
|
|
|
|
|
|
|
|
if (removable)
|
|
|
|
|
{
|
|
|
|
|
gchar *tip;
|
|
|
|
|
|
|
|
|
|
tip = g_strdup_printf (_("Remove the bookmark '%s'"), name);
|
|
|
|
|
gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_remove_button,
|
|
|
|
|
tip, NULL);
|
|
|
|
|
g_free (tip);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (name);
|
2003-10-15 03:06:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
/* GtkWidget::drag-begin handler for the shortcuts list. */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_drag_begin_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#if 0
|
2004-03-11 06:24:15 +00:00
|
|
|
|
impl->shortcuts_drag_context = g_object_ref (context);
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2004-03-11 06:24:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#if 0
|
2004-03-11 06:24:15 +00:00
|
|
|
|
/* Removes the idle handler for outside drags */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_cancel_drag_outside_idle (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
if (!impl->shortcuts_drag_outside_idle)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_source_destroy (impl->shortcuts_drag_outside_idle);
|
|
|
|
|
impl->shortcuts_drag_outside_idle = NULL;
|
|
|
|
|
}
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
|
|
|
|
/* GtkWidget::drag-end handler for the shortcuts list. */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_drag_end_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#if 0
|
2004-03-11 06:24:15 +00:00
|
|
|
|
g_object_unref (impl->shortcuts_drag_context);
|
|
|
|
|
|
|
|
|
|
shortcuts_cancel_drag_outside_idle (impl);
|
|
|
|
|
|
|
|
|
|
if (!impl->shortcuts_drag_outside)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_button_clicked (GTK_BUTTON (impl->browse_shortcuts_remove_button));
|
|
|
|
|
|
|
|
|
|
impl->shortcuts_drag_outside = FALSE;
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2004-03-11 06:24:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* GtkWidget::drag-data-delete handler for the shortcuts list. */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_drag_data_delete_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-data-delete");
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#if 0
|
2004-03-11 06:24:15 +00:00
|
|
|
|
/* Creates a suitable drag cursor to indicate that the selected bookmark will be
|
|
|
|
|
* deleted or not.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_drag_set_delete_cursor (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean delete)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeView *tree_view;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
GtkTreeIter iter;
|
2004-03-11 06:24:15 +00:00
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
GdkPixmap *row_pixmap;
|
|
|
|
|
GdkBitmap *mask;
|
|
|
|
|
int row_pixmap_y;
|
|
|
|
|
int cell_y;
|
|
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (impl->browse_shortcuts_tree_view);
|
|
|
|
|
|
|
|
|
|
/* Find the selected path and get its drag pixmap */
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
if (!shortcuts_get_selected (impl, &iter))
|
2004-03-11 06:24:15 +00:00
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
|
|
|
|
row_pixmap = gtk_tree_view_create_row_drag_icon (tree_view, path);
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
|
|
mask = NULL;
|
|
|
|
|
row_pixmap_y = 0;
|
|
|
|
|
|
|
|
|
|
if (delete)
|
|
|
|
|
{
|
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
|
|
pixbuf = gtk_widget_render_icon (impl->browse_shortcuts_tree_view,
|
|
|
|
|
GTK_STOCK_DELETE,
|
|
|
|
|
GTK_ICON_SIZE_DND,
|
|
|
|
|
NULL);
|
|
|
|
|
if (pixbuf)
|
|
|
|
|
{
|
|
|
|
|
GdkPixmap *composite;
|
|
|
|
|
int row_pixmap_width, row_pixmap_height;
|
|
|
|
|
int pixbuf_width, pixbuf_height;
|
|
|
|
|
int composite_width, composite_height;
|
2004-03-12 00:03:48 +00:00
|
|
|
|
int pixbuf_x, pixbuf_y;
|
2004-03-11 06:24:15 +00:00
|
|
|
|
GdkGC *gc, *mask_gc;
|
|
|
|
|
GdkColor color;
|
|
|
|
|
GdkBitmap *pixbuf_mask;
|
|
|
|
|
|
|
|
|
|
/* Create pixmap and mask for composite image */
|
|
|
|
|
|
|
|
|
|
gdk_drawable_get_size (row_pixmap, &row_pixmap_width, &row_pixmap_height);
|
|
|
|
|
pixbuf_width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
|
pixbuf_height = gdk_pixbuf_get_height (pixbuf);
|
|
|
|
|
|
|
|
|
|
composite_width = MAX (row_pixmap_width, pixbuf_width);
|
|
|
|
|
composite_height = MAX (row_pixmap_height, pixbuf_height);
|
|
|
|
|
|
|
|
|
|
row_pixmap_y = (composite_height - row_pixmap_height) / 2;
|
2004-03-12 00:03:48 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_direction (impl->browse_shortcuts_tree_view) == GTK_TEXT_DIR_RTL)
|
|
|
|
|
pixbuf_x = 0;
|
|
|
|
|
else
|
|
|
|
|
pixbuf_x = composite_width - pixbuf_width;
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
pixbuf_y = (composite_height - pixbuf_height) / 2;
|
|
|
|
|
|
|
|
|
|
composite = gdk_pixmap_new (row_pixmap, composite_width, composite_height, -1);
|
|
|
|
|
gc = gdk_gc_new (composite);
|
|
|
|
|
|
|
|
|
|
mask = gdk_pixmap_new (row_pixmap, composite_width, composite_height, 1);
|
|
|
|
|
mask_gc = gdk_gc_new (mask);
|
|
|
|
|
color.pixel = 0;
|
|
|
|
|
gdk_gc_set_foreground (mask_gc, &color);
|
|
|
|
|
gdk_draw_rectangle (mask, mask_gc, TRUE, 0, 0, composite_width, composite_height);
|
|
|
|
|
|
|
|
|
|
color.red = 0xffff;
|
|
|
|
|
color.green = 0xffff;
|
|
|
|
|
color.blue = 0xffff;
|
|
|
|
|
gdk_gc_set_rgb_fg_color (gc, &color);
|
|
|
|
|
gdk_draw_rectangle (composite, gc, TRUE, 0, 0, composite_width, composite_height);
|
|
|
|
|
|
|
|
|
|
/* Composite the row pixmap and the pixbuf */
|
|
|
|
|
|
|
|
|
|
gdk_pixbuf_render_pixmap_and_mask_for_colormap
|
|
|
|
|
(pixbuf,
|
|
|
|
|
gtk_widget_get_colormap (impl->browse_shortcuts_tree_view),
|
|
|
|
|
NULL, &pixbuf_mask, 128);
|
|
|
|
|
gdk_draw_drawable (mask, mask_gc, pixbuf_mask,
|
|
|
|
|
0, 0,
|
2004-03-12 00:03:48 +00:00
|
|
|
|
pixbuf_x, pixbuf_y,
|
2004-03-11 06:24:15 +00:00
|
|
|
|
pixbuf_width, pixbuf_height);
|
|
|
|
|
g_object_unref (pixbuf_mask);
|
|
|
|
|
|
|
|
|
|
gdk_draw_drawable (composite, gc, row_pixmap,
|
|
|
|
|
0, 0,
|
|
|
|
|
0, row_pixmap_y,
|
|
|
|
|
row_pixmap_width, row_pixmap_height);
|
|
|
|
|
color.pixel = 1;
|
|
|
|
|
gdk_gc_set_foreground (mask_gc, &color);
|
|
|
|
|
gdk_draw_rectangle (mask, mask_gc, TRUE, 0, row_pixmap_y, row_pixmap_width, row_pixmap_height);
|
|
|
|
|
|
|
|
|
|
gdk_draw_pixbuf (composite, gc, pixbuf,
|
|
|
|
|
0, 0,
|
2004-03-12 00:03:48 +00:00
|
|
|
|
pixbuf_x, pixbuf_y,
|
2004-03-11 06:24:15 +00:00
|
|
|
|
pixbuf_width, pixbuf_height,
|
|
|
|
|
GDK_RGB_DITHER_MAX,
|
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
g_object_unref (row_pixmap);
|
|
|
|
|
|
|
|
|
|
row_pixmap = composite;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The hotspot offsets here are copied from gtk_tree_view_drag_begin(), ugh */
|
|
|
|
|
|
|
|
|
|
gtk_tree_view_get_path_at_pos (tree_view,
|
|
|
|
|
tree_view->priv->press_start_x,
|
|
|
|
|
tree_view->priv->press_start_y,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
&cell_y);
|
|
|
|
|
|
|
|
|
|
gtk_drag_set_icon_pixmap (impl->shortcuts_drag_context,
|
|
|
|
|
gdk_drawable_get_colormap (row_pixmap),
|
|
|
|
|
row_pixmap,
|
|
|
|
|
mask,
|
|
|
|
|
tree_view->priv->press_start_x + 1,
|
|
|
|
|
row_pixmap_y + cell_y + 1);
|
|
|
|
|
|
|
|
|
|
g_object_unref (row_pixmap);
|
|
|
|
|
if (mask)
|
|
|
|
|
g_object_unref (mask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We set the delete cursor and the shortcuts_drag_outside flag in an idle
|
|
|
|
|
* handler so that we can tell apart the drag_leave event that comes right
|
|
|
|
|
* before a drag_drop, from a normal drag_leave. We don't want to set the
|
|
|
|
|
* cursor nor the flag in the latter case.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_drag_outside_idle_cb (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
shortcuts_drag_set_delete_cursor (impl, TRUE);
|
|
|
|
|
impl->shortcuts_drag_outside = TRUE;
|
|
|
|
|
|
|
|
|
|
shortcuts_cancel_drag_outside_idle (impl);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2004-03-15 02:09:22 +00:00
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
/* GtkWidget::drag-leave handler for the shortcuts list. We unhighlight the
|
|
|
|
|
* drop position.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_drag_leave_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
guint time_,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#if 0
|
2004-03-12 00:03:48 +00:00
|
|
|
|
if (gtk_drag_get_source_widget (context) == widget && !impl->shortcuts_drag_outside_idle)
|
2004-03-11 06:24:15 +00:00
|
|
|
|
{
|
|
|
|
|
impl->shortcuts_drag_outside_idle = g_idle_source_new ();
|
|
|
|
|
g_source_set_closure (impl->shortcuts_drag_outside_idle,
|
|
|
|
|
g_cclosure_new_object (G_CALLBACK (shortcuts_drag_outside_idle_cb),
|
|
|
|
|
G_OBJECT (impl)));
|
|
|
|
|
g_source_attach (impl->shortcuts_drag_outside_idle, NULL);
|
|
|
|
|
}
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
|
|
|
|
gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
|
|
|
|
|
NULL,
|
|
|
|
|
GTK_TREE_VIEW_DROP_BEFORE);
|
|
|
|
|
|
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-leave");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Computes the appropriate row and position for dropping */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_compute_drop_position (GtkFileChooserDefault *impl,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
GtkTreePath **path,
|
|
|
|
|
GtkTreeViewDropPosition *pos)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeView *tree_view;
|
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
|
int cell_y;
|
|
|
|
|
GdkRectangle cell;
|
|
|
|
|
int row;
|
|
|
|
|
int bookmarks_index;
|
|
|
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (impl->browse_shortcuts_tree_view);
|
|
|
|
|
|
|
|
|
|
bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
|
|
|
|
|
|
|
|
|
|
if (!gtk_tree_view_get_path_at_pos (tree_view,
|
|
|
|
|
x,
|
|
|
|
|
y - TREE_VIEW_HEADER_HEIGHT (tree_view),
|
|
|
|
|
path,
|
|
|
|
|
&column,
|
|
|
|
|
NULL,
|
|
|
|
|
&cell_y))
|
|
|
|
|
{
|
|
|
|
|
row = bookmarks_index + impl->num_bookmarks - 1;
|
|
|
|
|
*path = gtk_tree_path_new_from_indices (row, -1);
|
|
|
|
|
*pos = GTK_TREE_VIEW_DROP_AFTER;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
row = *gtk_tree_path_get_indices (*path);
|
|
|
|
|
gtk_tree_view_get_background_area (tree_view, *path, column, &cell);
|
|
|
|
|
gtk_tree_path_free (*path);
|
|
|
|
|
|
|
|
|
|
if (row < bookmarks_index)
|
|
|
|
|
{
|
|
|
|
|
row = bookmarks_index;
|
|
|
|
|
*pos = GTK_TREE_VIEW_DROP_BEFORE;
|
|
|
|
|
}
|
|
|
|
|
else if (row > bookmarks_index + impl->num_bookmarks - 1)
|
|
|
|
|
{
|
|
|
|
|
row = bookmarks_index + impl->num_bookmarks - 1;
|
|
|
|
|
*pos = GTK_TREE_VIEW_DROP_AFTER;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (cell_y < cell.height / 2)
|
|
|
|
|
*pos = GTK_TREE_VIEW_DROP_BEFORE;
|
|
|
|
|
else
|
|
|
|
|
*pos = GTK_TREE_VIEW_DROP_AFTER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*path = gtk_tree_path_new_from_indices (row, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* GtkWidget::drag-motion handler for the shortcuts list. We basically
|
|
|
|
|
* implement the destination side of DnD by hand, due to limitations in
|
|
|
|
|
* GtkTreeView's DnD API.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_drag_motion_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
guint time_,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
GtkTreeViewDropPosition pos;
|
|
|
|
|
GdkDragAction action;
|
|
|
|
|
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#if 0
|
2004-03-12 00:03:48 +00:00
|
|
|
|
if (gtk_drag_get_source_widget (context) == widget)
|
2004-03-11 06:24:15 +00:00
|
|
|
|
{
|
2004-03-12 00:03:48 +00:00
|
|
|
|
shortcuts_cancel_drag_outside_idle (impl);
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
2004-03-12 00:03:48 +00:00
|
|
|
|
if (impl->shortcuts_drag_outside)
|
|
|
|
|
{
|
|
|
|
|
shortcuts_drag_set_delete_cursor (impl, FALSE);
|
|
|
|
|
impl->shortcuts_drag_outside = FALSE;
|
|
|
|
|
}
|
2004-03-11 06:24:15 +00:00
|
|
|
|
}
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
|
|
|
|
if (context->suggested_action == GDK_ACTION_COPY || (context->actions & GDK_ACTION_COPY) != 0)
|
|
|
|
|
action = GDK_ACTION_COPY;
|
|
|
|
|
else if (context->suggested_action == GDK_ACTION_MOVE || (context->actions & GDK_ACTION_MOVE) != 0)
|
|
|
|
|
action = GDK_ACTION_MOVE;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
action = 0;
|
2004-03-11 18:13:51 +00:00
|
|
|
|
goto out;
|
2004-03-11 06:24:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shortcuts_compute_drop_position (impl, x, y, &path, &pos);
|
|
|
|
|
gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), path, pos);
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-motion");
|
|
|
|
|
|
|
|
|
|
if (action != 0)
|
|
|
|
|
{
|
|
|
|
|
gdk_drag_status (context, action, time_);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* GtkWidget::drag-drop handler for the shortcuts list. */
|
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_drag_drop_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
guint time_,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#if 0
|
2004-03-11 06:24:15 +00:00
|
|
|
|
shortcuts_cancel_drag_outside_idle (impl);
|
2004-03-15 06:29:33 +00:00
|
|
|
|
#endif
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-drop");
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-15 19:17:50 +00:00
|
|
|
|
/* Converts raw selection data from text/uri-list to a list of strings. */
|
2003-12-01 15:33:37 +00:00
|
|
|
|
static GSList *
|
|
|
|
|
split_uris (const char *data)
|
|
|
|
|
{
|
|
|
|
|
GSList *uris;
|
2004-04-15 19:17:50 +00:00
|
|
|
|
const char *p, *q;
|
2003-12-01 15:33:37 +00:00
|
|
|
|
|
|
|
|
|
uris = NULL;
|
|
|
|
|
|
2004-04-15 19:17:50 +00:00
|
|
|
|
p = data;
|
2003-12-01 15:33:37 +00:00
|
|
|
|
|
2004-04-15 19:17:50 +00:00
|
|
|
|
/* We don't actually try to validate the URI according to RFC
|
|
|
|
|
* 2396, or even check for allowed characters - we just ignore
|
|
|
|
|
* comments and trim whitespace off the ends. We also
|
|
|
|
|
* allow LF delimination as well as the specified CRLF.
|
|
|
|
|
*
|
|
|
|
|
* We do allow comments like specified in RFC 2483.
|
|
|
|
|
*/
|
|
|
|
|
while (p)
|
|
|
|
|
{
|
|
|
|
|
if (*p != '#')
|
|
|
|
|
{
|
|
|
|
|
while (g_ascii_isspace (*p))
|
|
|
|
|
p++;
|
2003-12-01 15:33:37 +00:00
|
|
|
|
|
2004-04-15 19:17:50 +00:00
|
|
|
|
q = p;
|
|
|
|
|
while (*q && (*q != '\n') && (*q != '\r'))
|
|
|
|
|
q++;
|
2003-12-01 15:33:37 +00:00
|
|
|
|
|
2004-04-15 19:17:50 +00:00
|
|
|
|
if (q > p)
|
|
|
|
|
{
|
|
|
|
|
q--;
|
|
|
|
|
while (q > p && g_ascii_isspace (*q))
|
|
|
|
|
q--;
|
|
|
|
|
|
|
|
|
|
if (q > p)
|
|
|
|
|
uris = g_slist_prepend (uris, g_strndup (p, q - p + 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
p = strchr (p, '\n');
|
|
|
|
|
if (p)
|
|
|
|
|
p++;
|
|
|
|
|
}
|
2003-12-01 15:33:37 +00:00
|
|
|
|
|
|
|
|
|
uris = g_slist_reverse (uris);
|
|
|
|
|
return uris;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
/* Parses a "text/uri-list" string and inserts its URIs as bookmarks */
|
2003-12-01 15:33:37 +00:00
|
|
|
|
static void
|
2004-03-11 06:24:15 +00:00
|
|
|
|
shortcuts_drop_uris (GtkFileChooserDefault *impl,
|
|
|
|
|
const char *data,
|
|
|
|
|
int position)
|
2003-12-01 15:33:37 +00:00
|
|
|
|
{
|
|
|
|
|
GSList *uris, *l;
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
uris = split_uris (data);
|
2003-12-01 15:33:37 +00:00
|
|
|
|
|
|
|
|
|
for (l = uris; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
char *uri;
|
|
|
|
|
GtkFilePath *path;
|
|
|
|
|
|
|
|
|
|
uri = l->data;
|
|
|
|
|
path = gtk_file_system_uri_to_path (impl->file_system, uri);
|
|
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
|
{
|
2004-03-11 06:24:15 +00:00
|
|
|
|
if (shortcuts_add_bookmark_from_path (impl, path, position))
|
|
|
|
|
position++;
|
|
|
|
|
|
2003-12-01 15:33:37 +00:00
|
|
|
|
gtk_file_path_free (path);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *msg;
|
|
|
|
|
|
|
|
|
|
msg = g_strdup_printf (_("Could not add a bookmark for %s because it is an invalid path name."),
|
|
|
|
|
uri);
|
|
|
|
|
error_message (impl, msg);
|
|
|
|
|
g_free (msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_slist_free (uris);
|
2004-03-11 06:24:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reorders the selected bookmark to the specified position */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_reorder (GtkFileChooserDefault *impl,
|
|
|
|
|
int new_position)
|
|
|
|
|
{
|
2004-07-29 01:26:51 +00:00
|
|
|
|
GtkTreeIter iter;
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gpointer col_data;
|
|
|
|
|
gboolean is_volume;
|
2004-03-11 06:24:15 +00:00
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
int old_position;
|
|
|
|
|
int bookmarks_index;
|
|
|
|
|
const GtkFilePath *file_path;
|
|
|
|
|
GtkFilePath *file_path_copy;
|
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
|
|
/* Get the selected path */
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
if (!shortcuts_get_selected (impl, &iter))
|
2004-03-11 06:24:15 +00:00
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
|
2004-03-11 06:24:15 +00:00
|
|
|
|
old_position = *gtk_tree_path_get_indices (path);
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
|
|
bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
|
|
|
|
|
old_position -= bookmarks_index;
|
|
|
|
|
g_assert (old_position >= 0 && old_position < impl->num_bookmarks);
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
|
2004-08-18 16:30:58 +00:00
|
|
|
|
SHORTCUTS_COL_DATA, &col_data,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, &is_volume,
|
2004-03-11 06:24:15 +00:00
|
|
|
|
-1);
|
2004-08-18 16:30:58 +00:00
|
|
|
|
g_assert (col_data != NULL);
|
|
|
|
|
g_assert (!is_volume);
|
|
|
|
|
|
|
|
|
|
file_path = col_data;
|
2004-03-11 06:24:15 +00:00
|
|
|
|
file_path_copy = gtk_file_path_copy (file_path); /* removal below will free file_path, so we need a copy */
|
|
|
|
|
|
|
|
|
|
/* Remove the path from the old position and insert it in the new one */
|
|
|
|
|
|
|
|
|
|
if (new_position > old_position)
|
|
|
|
|
new_position--;
|
|
|
|
|
|
|
|
|
|
if (old_position == new_position)
|
2004-08-18 16:30:58 +00:00
|
|
|
|
goto out;
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
|
|
|
|
error = NULL;
|
|
|
|
|
if (gtk_file_system_remove_bookmark (impl->file_system, file_path_copy, &error))
|
|
|
|
|
shortcuts_add_bookmark_from_path (impl, file_path_copy, new_position);
|
|
|
|
|
else
|
|
|
|
|
error_could_not_add_bookmark_dialog (impl, file_path_copy, error);
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
out:
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
gtk_file_path_free (file_path_copy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used when we get the drag data for the bookmarks list. We add the
|
|
|
|
|
* received URIs as bookmarks if they are folders.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_drag_data_received_cb (GtkWidget *widget,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
|
guint info,
|
|
|
|
|
guint time_,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
GtkTreePath *tree_path;
|
|
|
|
|
GtkTreeViewDropPosition tree_pos;
|
|
|
|
|
int position;
|
|
|
|
|
int bookmarks_index;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
|
|
|
|
|
/* Compute position */
|
|
|
|
|
|
|
|
|
|
bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
|
|
|
|
|
|
|
|
|
|
shortcuts_compute_drop_position (impl, x, y, &tree_path, &tree_pos);
|
|
|
|
|
position = *gtk_tree_path_get_indices (tree_path);
|
|
|
|
|
gtk_tree_path_free (tree_path);
|
|
|
|
|
|
|
|
|
|
if (tree_pos == GTK_TREE_VIEW_DROP_AFTER)
|
|
|
|
|
position++;
|
|
|
|
|
|
|
|
|
|
g_assert (position >= bookmarks_index);
|
|
|
|
|
position -= bookmarks_index;
|
|
|
|
|
|
|
|
|
|
if (selection_data->target == gdk_atom_intern ("text/uri-list", FALSE))
|
|
|
|
|
shortcuts_drop_uris (impl, selection_data->data, position);
|
|
|
|
|
else if (selection_data->target == gdk_atom_intern ("GTK_TREE_MODEL_ROW", FALSE))
|
|
|
|
|
shortcuts_reorder (impl, position);
|
2004-03-09 19:10:20 +00:00
|
|
|
|
|
|
|
|
|
g_signal_stop_emission_by_name (widget, "drag-data-received");
|
2003-12-01 15:33:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-10 03:46:30 +00:00
|
|
|
|
/* Callback used when the selection in the shortcuts tree changes */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_selection_changed_cb (GtkTreeSelection *selection,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
bookmarks_check_remove_sensitivity (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-07 22:21:25 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_row_separator_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
gint column = GPOINTER_TO_INT (data);
|
|
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter, column, &text, -1);
|
|
|
|
|
|
|
|
|
|
if (!text)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-25 19:10:38 +00:00
|
|
|
|
/* Since GtkTreeView has a keybinding attached to '/', we need to catch
|
|
|
|
|
* keypresses before the TreeView gets them.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
tree_view_keybinding_cb (GtkWidget *tree_view,
|
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
if (event->keyval == GDK_slash &&
|
|
|
|
|
! (event->state & gtk_accelerator_get_default_mod_mask ()))
|
|
|
|
|
{
|
|
|
|
|
location_popup_handler (impl);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-01 00:53:59 +00:00
|
|
|
|
/* Creates the widgets for the shortcuts and bookmarks tree */
|
|
|
|
|
static GtkWidget *
|
2004-02-25 03:03:11 +00:00
|
|
|
|
shortcuts_list_create (GtkFileChooserDefault *impl)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
2004-03-10 03:43:58 +00:00
|
|
|
|
GtkWidget *swin;
|
2003-10-01 00:53:59 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
|
GtkCellRenderer *renderer;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
|
2003-10-01 00:53:59 +00:00
|
|
|
|
/* Scrolled window */
|
|
|
|
|
|
2004-03-10 03:43:58 +00:00
|
|
|
|
swin = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
|
2003-10-01 00:53:59 +00:00
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
2004-03-10 03:43:58 +00:00
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
|
2003-10-01 00:53:59 +00:00
|
|
|
|
GTK_SHADOW_IN);
|
2004-03-10 03:43:58 +00:00
|
|
|
|
gtk_widget_show (swin);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
|
|
|
|
/* Tree */
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
impl->browse_shortcuts_tree_view = gtk_tree_view_new ();
|
2004-08-26 00:20:25 +00:00
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event",
|
|
|
|
|
G_CALLBACK (tree_view_keybinding_cb), impl);
|
2004-07-14 17:08:40 +00:00
|
|
|
|
atk_object_set_name (gtk_widget_get_accessible (impl->browse_shortcuts_tree_view), _("Shortcuts"));
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), FALSE);
|
2004-02-29 06:35:15 +00:00
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), impl->shortcuts_filter_model);
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
|
|
|
|
|
GDK_BUTTON1_MASK,
|
|
|
|
|
shortcuts_source_targets,
|
|
|
|
|
num_shortcuts_source_targets,
|
|
|
|
|
GDK_ACTION_MOVE);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_drag_dest_set (impl->browse_shortcuts_tree_view,
|
2003-12-01 15:33:37 +00:00
|
|
|
|
GTK_DEST_DEFAULT_ALL,
|
2004-03-11 06:24:15 +00:00
|
|
|
|
shortcuts_dest_targets,
|
|
|
|
|
num_shortcuts_dest_targets,
|
|
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
2003-12-01 15:33:37 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
|
2003-11-03 00:50:33 +00:00
|
|
|
|
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
|
2003-11-01 20:17:37 +00:00
|
|
|
|
gtk_tree_selection_set_select_function (selection,
|
|
|
|
|
shortcuts_select_func,
|
|
|
|
|
impl, NULL);
|
2003-12-10 03:46:30 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect (selection, "changed",
|
|
|
|
|
G_CALLBACK (shortcuts_selection_changed_cb), impl);
|
2004-01-20 02:44:58 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "row-activated",
|
2003-12-10 03:46:30 +00:00
|
|
|
|
G_CALLBACK (shortcuts_row_activated_cb), impl);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-04-29 23:13:50 +00:00
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event",
|
|
|
|
|
G_CALLBACK (shortcuts_key_press_event_cb), impl);
|
|
|
|
|
|
2004-03-11 06:24:15 +00:00
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-begin",
|
|
|
|
|
G_CALLBACK (shortcuts_drag_begin_cb), impl);
|
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-end",
|
|
|
|
|
G_CALLBACK (shortcuts_drag_end_cb), impl);
|
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-data-delete",
|
|
|
|
|
G_CALLBACK (shortcuts_drag_data_delete_cb), impl);
|
|
|
|
|
|
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-leave",
|
|
|
|
|
G_CALLBACK (shortcuts_drag_leave_cb), impl);
|
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-motion",
|
|
|
|
|
G_CALLBACK (shortcuts_drag_motion_cb), impl);
|
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-drop",
|
|
|
|
|
G_CALLBACK (shortcuts_drag_drop_cb), impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-data-received",
|
2003-12-01 15:33:37 +00:00
|
|
|
|
G_CALLBACK (shortcuts_drag_data_received_cb), impl);
|
|
|
|
|
|
2004-03-10 03:43:58 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (swin), impl->browse_shortcuts_tree_view);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_widget_show (impl->browse_shortcuts_tree_view);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
|
|
|
|
/* Column */
|
|
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new ();
|
2003-11-03 20:24:04 +00:00
|
|
|
|
gtk_tree_view_column_set_title (column, _("Folder"));
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new ();
|
2003-10-08 04:14:55 +00:00
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer, FALSE);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
gtk_tree_view_column_set_attributes (column, renderer,
|
2003-10-09 01:12:24 +00:00
|
|
|
|
"pixbuf", SHORTCUTS_COL_PIXBUF,
|
2004-02-24 00:15:23 +00:00
|
|
|
|
"visible", SHORTCUTS_COL_PIXBUF_VISIBLE,
|
2003-10-01 00:53:59 +00:00
|
|
|
|
NULL);
|
|
|
|
|
|
2004-08-07 22:21:25 +00:00
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2003-10-01 00:53:59 +00:00
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer, TRUE);
|
|
|
|
|
gtk_tree_view_column_set_attributes (column, renderer,
|
2003-10-09 01:12:24 +00:00
|
|
|
|
"text", SHORTCUTS_COL_NAME,
|
2003-10-01 00:53:59 +00:00
|
|
|
|
NULL);
|
|
|
|
|
|
2004-08-07 22:21:25 +00:00
|
|
|
|
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
|
|
|
|
|
shortcuts_row_separator_func,
|
|
|
|
|
GINT_TO_POINTER (SHORTCUTS_COL_NAME),
|
|
|
|
|
NULL);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), column);
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-03-10 03:43:58 +00:00
|
|
|
|
return swin;
|
2003-12-01 18:57:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-19 03:22:22 +00:00
|
|
|
|
/* Creates the widgets for the shortcuts/bookmarks pane */
|
|
|
|
|
static GtkWidget *
|
2004-02-23 22:56:55 +00:00
|
|
|
|
shortcuts_pane_create (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkSizeGroup *size_group)
|
2004-02-19 03:22:22 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
GtkWidget *hbox;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 6);
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
|
|
/* Shortcuts tree */
|
|
|
|
|
|
2004-02-25 03:03:11 +00:00
|
|
|
|
widget = shortcuts_list_create (impl);
|
2004-02-19 03:22:22 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
|
|
/* Box for buttons */
|
|
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (TRUE, 6);
|
2004-02-23 22:56:55 +00:00
|
|
|
|
gtk_size_group_add_widget (size_group, hbox);
|
2004-02-19 03:22:22 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
|
|
/* Add bookmark button */
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
impl->browse_shortcuts_add_button = button_new (impl,
|
|
|
|
|
_("_Add"),
|
|
|
|
|
GTK_STOCK_ADD,
|
|
|
|
|
FALSE,
|
|
|
|
|
TRUE,
|
|
|
|
|
G_CALLBACK (add_bookmark_button_clicked_cb));
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), impl->browse_shortcuts_add_button, TRUE, TRUE, 0);
|
2004-09-23 19:39:39 +00:00
|
|
|
|
gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_add_button,
|
|
|
|
|
_("Add the selected folder to the bookmarks"), NULL);
|
2004-02-19 03:22:22 +00:00
|
|
|
|
|
|
|
|
|
/* Remove bookmark button */
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
impl->browse_shortcuts_remove_button = button_new (impl,
|
|
|
|
|
_("_Remove"),
|
|
|
|
|
GTK_STOCK_REMOVE,
|
|
|
|
|
FALSE,
|
|
|
|
|
TRUE,
|
|
|
|
|
G_CALLBACK (remove_bookmark_button_clicked_cb));
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), impl->browse_shortcuts_remove_button, TRUE, TRUE, 0);
|
2004-09-23 19:39:39 +00:00
|
|
|
|
gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_remove_button,
|
|
|
|
|
_("Remove the selected bookmark"), NULL);
|
2004-02-19 03:22:22 +00:00
|
|
|
|
|
|
|
|
|
return vbox;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
/* Handles key press events on the file list, so that we can trap Enter to
|
2004-08-25 19:10:38 +00:00
|
|
|
|
* activate the default button on our own. Also, checks to see if '/' has been
|
|
|
|
|
* pressed. See comment by tree_view_keybinding_cb() for more details.
|
2004-04-02 00:35:07 +00:00
|
|
|
|
*/
|
2004-03-07 19:38:49 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
trap_activate_cb (GtkWidget *widget,
|
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
|
|
|
|
impl = (GtkFileChooserDefault *) data;
|
2004-08-25 19:10:38 +00:00
|
|
|
|
|
|
|
|
|
if (event->keyval == GDK_slash &&
|
|
|
|
|
! (event->state & gtk_accelerator_get_default_mod_mask ()))
|
|
|
|
|
{
|
|
|
|
|
location_popup_handler (impl);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-03-07 19:38:49 +00:00
|
|
|
|
|
|
|
|
|
if (event->keyval == GDK_Return
|
|
|
|
|
|| event->keyval == GDK_ISO_Enter
|
|
|
|
|
|| event->keyval == GDK_KP_Enter
|
|
|
|
|
|| event->keyval == GDK_space)
|
|
|
|
|
{
|
2004-03-29 19:52:16 +00:00
|
|
|
|
GtkWindow *window;
|
2004-03-07 19:38:49 +00:00
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
window = get_toplevel (widget);
|
|
|
|
|
if (window
|
|
|
|
|
&& widget != window->default_widget
|
|
|
|
|
&& !(widget == window->focus_widget &&
|
|
|
|
|
(!window->default_widget || !GTK_WIDGET_SENSITIVE (window->default_widget))))
|
2004-05-31 18:29:02 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_window_activate_default (window);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-03-07 19:38:49 +00:00
|
|
|
|
}
|
2004-05-31 18:29:02 +00:00
|
|
|
|
|
2004-03-07 19:38:49 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
/* Callback used when the file list's popup menu is detached */
|
|
|
|
|
static void
|
|
|
|
|
popup_menu_detach_cb (GtkWidget *attach_widget,
|
|
|
|
|
GtkMenu *menu)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
|
|
|
|
impl = g_object_get_data (G_OBJECT (attach_widget), "GtkFileChooserDefault");
|
|
|
|
|
g_assert (GTK_IS_FILE_CHOOSER_DEFAULT (impl));
|
|
|
|
|
|
|
|
|
|
impl->browse_files_popup_menu = NULL;
|
2004-07-29 20:53:52 +00:00
|
|
|
|
impl->browse_files_popup_menu_add_shortcut_item = NULL;
|
2004-04-02 00:35:07 +00:00
|
|
|
|
impl->browse_files_popup_menu_hidden_files_item = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-29 20:53:52 +00:00
|
|
|
|
/* Callback used when the "Add to Shortcuts" menu item is activated */
|
|
|
|
|
static void
|
|
|
|
|
add_to_shortcuts_cb (GtkMenuItem *item,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
bookmarks_add_selected_folder (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
/* Callback used when the "Show Hidden Files" menu item is toggled */
|
|
|
|
|
static void
|
|
|
|
|
show_hidden_toggled_cb (GtkCheckMenuItem *item,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
g_object_set (impl,
|
|
|
|
|
"show-hidden", gtk_check_menu_item_get_active (item),
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Constructs the popup menu for the file list if needed */
|
|
|
|
|
static void
|
|
|
|
|
file_list_build_popup_menu (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-07-29 20:53:52 +00:00
|
|
|
|
GtkWidget *item;
|
|
|
|
|
|
|
|
|
|
if (impl->browse_files_popup_menu)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
impl->browse_files_popup_menu = gtk_menu_new ();
|
|
|
|
|
gtk_menu_attach_to_widget (GTK_MENU (impl->browse_files_popup_menu),
|
|
|
|
|
impl->browse_files_tree_view,
|
|
|
|
|
popup_menu_detach_cb);
|
|
|
|
|
|
|
|
|
|
item = gtk_image_menu_item_new_with_mnemonic (_("_Add to Shortcuts"));
|
|
|
|
|
impl->browse_files_popup_menu_add_shortcut_item = item;
|
|
|
|
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
|
|
|
|
|
gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
|
|
|
|
|
gtk_widget_set_sensitive (item, FALSE);
|
|
|
|
|
g_signal_connect (item, "activate",
|
|
|
|
|
G_CALLBACK (add_to_shortcuts_cb), impl);
|
|
|
|
|
gtk_widget_show (item);
|
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
|
|
|
|
|
|
|
|
|
item = gtk_separator_menu_item_new ();
|
|
|
|
|
gtk_widget_show (item);
|
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
|
|
|
|
|
|
|
|
|
item = gtk_check_menu_item_new_with_mnemonic (_("Show _Hidden Files"));
|
|
|
|
|
impl->browse_files_popup_menu_hidden_files_item = item;
|
|
|
|
|
g_signal_connect (item, "toggled",
|
|
|
|
|
G_CALLBACK (show_hidden_toggled_cb), impl);
|
|
|
|
|
gtk_widget_show (item);
|
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Updates the popup menu for the file list, creating it if necessary */
|
|
|
|
|
static void
|
|
|
|
|
file_list_update_popup_menu (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
file_list_build_popup_menu (impl);
|
|
|
|
|
|
|
|
|
|
/* The sensitivity of the Add to Shortcuts item is set in
|
|
|
|
|
* bookmarks_check_add_sensitivity()
|
|
|
|
|
*/
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (impl->browse_files_popup_menu_hidden_files_item,
|
|
|
|
|
G_CALLBACK (show_hidden_toggled_cb), impl);
|
|
|
|
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_hidden_files_item),
|
|
|
|
|
impl->show_hidden);
|
|
|
|
|
g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_hidden_files_item,
|
|
|
|
|
G_CALLBACK (show_hidden_toggled_cb), impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-06 06:02:57 +00:00
|
|
|
|
static void
|
|
|
|
|
popup_position_func (GtkMenu *menu,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *y,
|
|
|
|
|
gboolean *push_in,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (user_data);
|
|
|
|
|
GdkScreen *screen = gtk_widget_get_screen (widget);
|
|
|
|
|
GtkRequisition req;
|
|
|
|
|
gint monitor_num;
|
|
|
|
|
GdkRectangle monitor;
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
2004-07-06 06:02:57 +00:00
|
|
|
|
g_return_if_fail (GTK_WIDGET_REALIZED (widget));
|
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
gdk_window_get_origin (widget->window, x, y);
|
2004-07-06 06:02:57 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_size_request (GTK_WIDGET (menu), &req);
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
2004-07-06 06:02:57 +00:00
|
|
|
|
*x += (widget->allocation.width - req.width) / 2;
|
|
|
|
|
*y += (widget->allocation.height - req.height) / 2;
|
|
|
|
|
|
|
|
|
|
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
|
|
|
|
|
gtk_menu_set_monitor (menu, monitor_num);
|
|
|
|
|
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
|
|
|
|
|
|
|
|
|
|
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
|
|
|
|
|
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
|
|
|
|
|
|
|
|
|
|
*push_in = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
static void
|
|
|
|
|
file_list_popup_menu (GtkFileChooserDefault *impl,
|
|
|
|
|
GdkEventButton *event)
|
|
|
|
|
{
|
2004-07-29 20:53:52 +00:00
|
|
|
|
file_list_update_popup_menu (impl);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
if (event)
|
2004-07-06 06:02:57 +00:00
|
|
|
|
gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
|
|
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
|
event->button, event->time);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-07-06 06:02:57 +00:00
|
|
|
|
gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
|
2004-07-09 00:53:48 +00:00
|
|
|
|
NULL, NULL,
|
2004-07-06 06:02:57 +00:00
|
|
|
|
popup_position_func, impl->browse_files_tree_view,
|
|
|
|
|
0, GDK_CURRENT_TIME);
|
2004-07-09 00:53:48 +00:00
|
|
|
|
gtk_menu_shell_select_first (GTK_MENU_SHELL (impl->browse_files_popup_menu),
|
2004-07-06 06:02:57 +00:00
|
|
|
|
FALSE);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used for the GtkWidget::popup-menu signal of the file list */
|
|
|
|
|
static gboolean
|
|
|
|
|
list_popup_menu_cb (GtkWidget *widget,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
file_list_popup_menu (impl, NULL);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used when a button is pressed on the file list. We trap button 3 to
|
|
|
|
|
* bring up a popup menu.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
list_button_press_event_cb (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
if (event->button != 3)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
file_list_popup_menu (impl, event);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-03-07 19:38:49 +00:00
|
|
|
|
|
2003-10-13 02:31:09 +00:00
|
|
|
|
/* Creates the widgets for the file list */
|
2003-09-06 00:50:33 +00:00
|
|
|
|
static GtkWidget *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
create_file_list (GtkFileChooserDefault *impl)
|
2003-09-06 00:50:33 +00:00
|
|
|
|
{
|
2004-03-07 04:41:36 +00:00
|
|
|
|
GtkWidget *swin;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
|
|
/* Scrolled window */
|
|
|
|
|
|
2004-03-07 04:41:36 +00:00
|
|
|
|
swin = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
|
2003-03-21 20:34:02 +00:00
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
2004-03-07 04:41:36 +00:00
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
|
2003-03-25 00:11:06 +00:00
|
|
|
|
GTK_SHADOW_IN);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
|
|
|
|
/* Tree/list view */
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
impl->browse_files_tree_view = gtk_tree_view_new ();
|
2004-04-02 00:35:07 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (impl->browse_files_tree_view), "GtkFileChooserDefault", impl);
|
2004-07-14 17:08:40 +00:00
|
|
|
|
atk_object_set_name (gtk_widget_get_accessible (impl->browse_files_tree_view), _("Files"));
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (impl->browse_files_tree_view), TRUE);
|
2004-03-07 04:41:36 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (swin), impl->browse_files_tree_view);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
g_signal_connect (impl->browse_files_tree_view, "row-activated",
|
2003-09-11 00:33:28 +00:00
|
|
|
|
G_CALLBACK (list_row_activated), impl);
|
2004-03-07 19:38:49 +00:00
|
|
|
|
g_signal_connect (impl->browse_files_tree_view, "key-press-event",
|
|
|
|
|
G_CALLBACK (trap_activate_cb), impl);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
g_signal_connect (impl->browse_files_tree_view, "popup-menu",
|
|
|
|
|
G_CALLBACK (list_popup_menu_cb), impl);
|
|
|
|
|
g_signal_connect (impl->browse_files_tree_view, "button-press-event",
|
|
|
|
|
G_CALLBACK (list_button_press_event_cb), impl);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
|
|
|
|
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->browse_files_tree_view),
|
2004-02-25 03:03:11 +00:00
|
|
|
|
GDK_BUTTON1_MASK,
|
2004-03-11 06:24:15 +00:00
|
|
|
|
file_list_source_targets,
|
|
|
|
|
num_file_list_source_targets,
|
2004-02-25 03:03:11 +00:00
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
g_signal_connect (selection, "changed",
|
|
|
|
|
G_CALLBACK (list_selection_changed), impl);
|
2003-03-25 00:11:06 +00:00
|
|
|
|
|
2003-09-06 00:50:33 +00:00
|
|
|
|
/* Filename column */
|
|
|
|
|
|
2004-01-17 04:34:49 +00:00
|
|
|
|
impl->list_name_column = gtk_tree_view_column_new ();
|
2004-02-07 17:28:36 +00:00
|
|
|
|
gtk_tree_view_column_set_expand (impl->list_name_column, TRUE);
|
2004-07-22 05:45:19 +00:00
|
|
|
|
gtk_tree_view_column_set_resizable (impl->list_name_column, TRUE);
|
2004-02-29 02:59:05 +00:00
|
|
|
|
gtk_tree_view_column_set_title (impl->list_name_column, _("Name"));
|
2004-01-17 04:34:49 +00:00
|
|
|
|
gtk_tree_view_column_set_sort_column_id (impl->list_name_column, FILE_LIST_COL_NAME);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new ();
|
2004-02-07 17:28:36 +00:00
|
|
|
|
gtk_tree_view_column_pack_start (impl->list_name_column, renderer, FALSE);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
gtk_tree_view_column_set_cell_data_func (impl->list_name_column, renderer,
|
2003-09-06 00:50:33 +00:00
|
|
|
|
list_icon_data_func, impl, NULL);
|
|
|
|
|
|
2004-01-17 04:34:49 +00:00
|
|
|
|
impl->list_name_renderer = gtk_cell_renderer_text_new ();
|
2004-07-22 05:45:19 +00:00
|
|
|
|
g_object_set (impl->list_name_renderer,
|
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
|
NULL);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
g_signal_connect (impl->list_name_renderer, "edited",
|
|
|
|
|
G_CALLBACK (renderer_edited_cb), impl);
|
|
|
|
|
g_signal_connect (impl->list_name_renderer, "editing-canceled",
|
|
|
|
|
G_CALLBACK (renderer_editing_canceled_cb), impl);
|
|
|
|
|
gtk_tree_view_column_pack_start (impl->list_name_column, impl->list_name_renderer, TRUE);
|
|
|
|
|
gtk_tree_view_column_set_cell_data_func (impl->list_name_column, impl->list_name_renderer,
|
2003-09-06 00:50:33 +00:00
|
|
|
|
list_name_data_func, impl, NULL);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_files_tree_view), impl->list_name_column);
|
2003-09-09 15:18:29 +00:00
|
|
|
|
#if 0
|
2003-09-06 00:50:33 +00:00
|
|
|
|
/* Size column */
|
|
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new ();
|
2003-11-03 20:24:04 +00:00
|
|
|
|
gtk_tree_view_column_set_title (column, _("Size"));
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer, TRUE);
|
|
|
|
|
gtk_tree_view_column_set_cell_data_func (column, renderer,
|
|
|
|
|
list_size_data_func, impl, NULL);
|
2003-10-01 19:42:50 +00:00
|
|
|
|
gtk_tree_view_column_set_sort_column_id (column, FILE_LIST_COL_SIZE);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_files_tree_view), column);
|
2003-09-09 15:18:29 +00:00
|
|
|
|
#endif
|
|
|
|
|
/* Modification time column */
|
|
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new ();
|
2004-07-22 05:45:19 +00:00
|
|
|
|
gtk_tree_view_column_set_resizable (column, TRUE);
|
2003-11-03 20:24:04 +00:00
|
|
|
|
gtk_tree_view_column_set_title (column, _("Modified"));
|
2003-09-09 15:18:29 +00:00
|
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer, TRUE);
|
|
|
|
|
gtk_tree_view_column_set_cell_data_func (column, renderer,
|
|
|
|
|
list_mtime_data_func, impl, NULL);
|
2003-10-01 19:42:50 +00:00
|
|
|
|
gtk_tree_view_column_set_sort_column_id (column, FILE_LIST_COL_MTIME);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_files_tree_view), column);
|
2004-03-07 04:41:36 +00:00
|
|
|
|
gtk_widget_show_all (swin);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-03-07 04:41:36 +00:00
|
|
|
|
return swin;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-08 09:56:34 +00:00
|
|
|
|
static GtkWidget *
|
|
|
|
|
create_path_bar (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *path_bar;
|
|
|
|
|
|
|
|
|
|
path_bar = g_object_new (GTK_TYPE_PATH_BAR, NULL);
|
|
|
|
|
_gtk_path_bar_set_file_system (GTK_PATH_BAR (path_bar), impl->file_system);
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
2004-03-08 09:56:34 +00:00
|
|
|
|
return path_bar;
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-19 03:22:22 +00:00
|
|
|
|
/* Creates the widgets for the files/folders pane */
|
|
|
|
|
static GtkWidget *
|
2004-02-23 22:56:55 +00:00
|
|
|
|
file_pane_create (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkSizeGroup *size_group)
|
2004-02-19 03:22:22 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
GtkWidget *hbox;
|
2004-09-23 19:39:39 +00:00
|
|
|
|
GtkWidget *ebox;
|
2004-02-19 03:22:22 +00:00
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 6);
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
2004-02-23 07:11:31 +00:00
|
|
|
|
/* The path bar and 'Create Folder' button */
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
|
gtk_widget_show (hbox);
|
2004-03-08 09:56:34 +00:00
|
|
|
|
impl->browse_path_bar = create_path_bar (impl);
|
2004-03-04 06:47:54 +00:00
|
|
|
|
g_signal_connect (impl->browse_path_bar, "path-clicked", G_CALLBACK (path_bar_clicked), impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_widget_show_all (impl->browse_path_bar);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), impl->browse_path_bar, TRUE, TRUE, 0);
|
2004-02-23 07:11:31 +00:00
|
|
|
|
|
|
|
|
|
/* Create Folder */
|
2004-04-06 02:52:08 +00:00
|
|
|
|
impl->browse_new_folder_button = gtk_button_new_with_mnemonic (_("Create Fo_lder"));
|
2004-02-25 08:55:48 +00:00
|
|
|
|
g_signal_connect (impl->browse_new_folder_button, "clicked",
|
2004-02-23 07:11:31 +00:00
|
|
|
|
G_CALLBACK (new_folder_button_clicked), impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), impl->browse_new_folder_button, FALSE, FALSE, 0);
|
2004-02-23 07:11:31 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
2004-02-19 03:22:22 +00:00
|
|
|
|
|
|
|
|
|
/* Box for lists and preview */
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
hbox = gtk_hbox_new (FALSE, PREVIEW_HBOX_SPACING);
|
2004-02-19 03:22:22 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
|
|
/* File list */
|
|
|
|
|
|
|
|
|
|
widget = create_file_list (impl);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
|
|
/* Preview */
|
|
|
|
|
|
2004-02-29 06:35:15 +00:00
|
|
|
|
impl->preview_box = gtk_vbox_new (FALSE, 12);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), impl->preview_box, FALSE, FALSE, 0);
|
|
|
|
|
/* Don't show preview box initially */
|
2004-02-19 03:22:22 +00:00
|
|
|
|
|
2004-05-04 17:53:13 +00:00
|
|
|
|
/* Filter combo */
|
|
|
|
|
|
|
|
|
|
impl->filter_combo_hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
|
|
|
|
|
|
widget = filter_create (impl);
|
2004-09-23 19:39:39 +00:00
|
|
|
|
ebox = gtk_event_box_new ();
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (ebox), widget);
|
|
|
|
|
gtk_widget_show (ebox);
|
|
|
|
|
/* We need enter/leave to do tooltips */
|
|
|
|
|
gtk_widget_add_events (ebox, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
|
|
|
|
|
gtk_tooltips_set_tip (impl->tooltips, ebox,
|
|
|
|
|
_("Select which types of files are shown"), NULL);
|
|
|
|
|
|
|
|
|
|
|
2004-05-04 17:53:13 +00:00
|
|
|
|
gtk_widget_show (widget);
|
2004-09-23 19:39:39 +00:00
|
|
|
|
gtk_box_pack_end (GTK_BOX (impl->filter_combo_hbox), ebox, FALSE, FALSE, 0);
|
2004-05-04 17:53:13 +00:00
|
|
|
|
|
|
|
|
|
gtk_size_group_add_widget (size_group, impl->filter_combo_hbox);
|
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), impl->filter_combo_hbox, FALSE, FALSE, 0);
|
2003-03-25 00:11:06 +00:00
|
|
|
|
|
2004-02-23 22:56:55 +00:00
|
|
|
|
return vbox;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
/* Callback used when the "Browse for more folders" expander is toggled */
|
|
|
|
|
static void
|
2004-02-24 20:30:54 +00:00
|
|
|
|
expander_changed_cb (GtkExpander *expander,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2004-02-23 19:55:49 +00:00
|
|
|
|
{
|
2004-02-25 21:05:30 +00:00
|
|
|
|
update_appearance (impl);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
/* Callback used when the selection changes in the save folder combo box */
|
|
|
|
|
static void
|
|
|
|
|
save_folder_combo_changed_cb (GtkComboBox *combo,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-07-29 01:26:51 +00:00
|
|
|
|
GtkTreeIter iter;
|
2004-03-02 02:59:02 +00:00
|
|
|
|
|
2004-03-03 21:09:46 +00:00
|
|
|
|
if (impl->changing_folder)
|
|
|
|
|
return;
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
if (gtk_combo_box_get_active_iter (combo, &iter))
|
|
|
|
|
shortcuts_activate_iter (impl, &iter);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Creates the combo box with the save folders */
|
|
|
|
|
static GtkWidget *
|
|
|
|
|
save_folder_combo_create (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *combo;
|
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
|
|
|
|
|
|
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (impl->shortcuts_model));
|
|
|
|
|
gtk_widget_show (combo);
|
|
|
|
|
|
|
|
|
|
cell = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, FALSE);
|
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
|
|
|
|
|
"pixbuf", SHORTCUTS_COL_PIXBUF,
|
|
|
|
|
"visible", SHORTCUTS_COL_PIXBUF_VISIBLE,
|
2004-05-27 13:40:36 +00:00
|
|
|
|
"sensitive", SHORTCUTS_COL_PIXBUF_VISIBLE,
|
2004-03-02 02:59:02 +00:00
|
|
|
|
NULL);
|
|
|
|
|
|
2004-08-07 22:21:25 +00:00
|
|
|
|
cell = gtk_cell_renderer_text_new ();
|
2004-03-02 02:59:02 +00:00
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
|
|
|
|
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
|
|
|
|
|
"text", SHORTCUTS_COL_NAME,
|
2004-05-27 13:40:36 +00:00
|
|
|
|
"sensitive", SHORTCUTS_COL_PIXBUF_VISIBLE,
|
2004-03-02 02:59:02 +00:00
|
|
|
|
NULL);
|
|
|
|
|
|
2004-08-07 22:21:25 +00:00
|
|
|
|
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
|
|
|
|
|
shortcuts_row_separator_func,
|
|
|
|
|
GINT_TO_POINTER (SHORTCUTS_COL_NAME),
|
|
|
|
|
NULL);
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
|
G_CALLBACK (save_folder_combo_changed_cb), impl);
|
|
|
|
|
|
|
|
|
|
return combo;
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Creates the widgets specific to Save mode */
|
|
|
|
|
static GtkWidget *
|
|
|
|
|
save_widgets_create (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkWidget *vbox;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GtkWidget *table;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
GtkWidget *alignment;
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
|
|
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (table);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 12);
|
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
|
|
|
|
|
|
/* Name entry */
|
|
|
|
|
|
|
|
|
|
widget = gtk_label_new_with_mnemonic (_("_Name:"));
|
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
|
0, 1, 0, 1,
|
|
|
|
|
GTK_FILL, GTK_FILL,
|
|
|
|
|
0, 0);
|
2004-01-06 04:18:42 +00:00
|
|
|
|
gtk_widget_show (widget);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
impl->save_file_name_entry = _gtk_file_chooser_entry_new (TRUE);
|
2004-08-06 19:25:25 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
|
|
|
|
|
impl->file_system);
|
2004-03-01 21:52:04 +00:00
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (impl->save_file_name_entry), 45);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (impl->save_file_name_entry), TRUE);
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table), impl->save_file_name_entry,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
1, 2, 0, 1,
|
|
|
|
|
GTK_EXPAND | GTK_FILL, 0,
|
|
|
|
|
0, 0);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_widget_show (impl->save_file_name_entry);
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (widget), impl->save_file_name_entry);
|
2004-01-06 04:18:42 +00:00
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Folder combo */
|
2004-03-08 20:06:50 +00:00
|
|
|
|
impl->save_folder_label = gtk_label_new (NULL);
|
2004-02-24 20:30:54 +00:00
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (impl->save_folder_label), 0.0, 0.5);
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table), impl->save_folder_label,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
0, 1, 1, 2,
|
|
|
|
|
GTK_FILL, GTK_FILL,
|
|
|
|
|
0, 0);
|
2004-02-24 20:30:54 +00:00
|
|
|
|
gtk_widget_show (impl->save_folder_label);
|
2003-03-25 00:11:06 +00:00
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
impl->save_folder_combo = save_folder_combo_create (impl);
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table), impl->save_folder_combo,
|
|
|
|
|
1, 2, 1, 2,
|
|
|
|
|
GTK_EXPAND | GTK_FILL, GTK_FILL,
|
|
|
|
|
0, 0);
|
2004-03-02 20:09:20 +00:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (impl->save_folder_label), impl->save_folder_combo);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* custom widget */
|
|
|
|
|
impl->save_extra_align = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), impl->save_extra_align, FALSE, FALSE, 0);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* Expander */
|
2004-02-23 19:55:49 +00:00
|
|
|
|
alignment = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
impl->save_expander = gtk_expander_new_with_mnemonic (_("_Browse for other folders"));
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), impl->save_expander);
|
|
|
|
|
g_signal_connect (impl->save_expander, "notify::expanded",
|
2004-02-24 20:30:54 +00:00
|
|
|
|
G_CALLBACK (expander_changed_cb),
|
2004-02-23 19:55:49 +00:00
|
|
|
|
impl);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_widget_show_all (alignment);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-02-29 06:35:15 +00:00
|
|
|
|
return vbox;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Creates the main hpaned with the widgets shared by Open and Save mode */
|
|
|
|
|
static GtkWidget *
|
2004-02-25 08:55:48 +00:00
|
|
|
|
browse_widgets_create (GtkFileChooserDefault *impl)
|
2003-09-06 00:50:33 +00:00
|
|
|
|
{
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkWidget *vbox;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
GtkWidget *hpaned;
|
|
|
|
|
GtkWidget *widget;
|
2004-02-23 22:56:55 +00:00
|
|
|
|
GtkSizeGroup *size_group;
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* size group is used by the [+][-] buttons and the filter combo */
|
2004-02-23 22:56:55 +00:00
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
vbox = gtk_vbox_new (FALSE, 12);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
|
|
|
|
/* Paned widget */
|
|
|
|
|
hpaned = gtk_hpaned_new ();
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_widget_show (hpaned);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
gtk_paned_set_position (GTK_PANED (hpaned), 200); /* FIXME: this sucks */
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2004-02-23 22:56:55 +00:00
|
|
|
|
widget = shortcuts_pane_create (impl, size_group);
|
2004-01-06 04:18:42 +00:00
|
|
|
|
gtk_paned_pack1 (GTK_PANED (hpaned), widget, FALSE, FALSE);
|
2004-02-23 22:56:55 +00:00
|
|
|
|
widget = file_pane_create (impl, size_group);
|
2004-02-19 03:22:22 +00:00
|
|
|
|
gtk_paned_pack2 (GTK_PANED (hpaned), widget, TRUE, FALSE);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-03-15 02:09:22 +00:00
|
|
|
|
g_object_unref (size_group);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* Alignment to hold custom widget */
|
|
|
|
|
impl->browse_extra_align = gtk_alignment_new (0.0, .5, 1.0, 1.0);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), impl->browse_extra_align, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
|
|
return vbox;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GObject*
|
|
|
|
|
gtk_file_chooser_default_constructor (GType type,
|
|
|
|
|
guint n_construct_properties,
|
|
|
|
|
GObjectConstructParam *construct_params)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
GObject *object;
|
|
|
|
|
|
|
|
|
|
object = parent_class->constructor (type,
|
|
|
|
|
n_construct_properties,
|
|
|
|
|
construct_params);
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (object);
|
|
|
|
|
|
|
|
|
|
g_assert (impl->file_system);
|
|
|
|
|
|
|
|
|
|
gtk_widget_push_composite_child ();
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
/* Shortcuts model */
|
|
|
|
|
|
|
|
|
|
shortcuts_model_create (impl);
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
/* Widgets for Save mode */
|
|
|
|
|
impl->save_widgets = save_widgets_create (impl);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (impl), impl->save_widgets, FALSE, FALSE, 0);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* The browse widgets */
|
|
|
|
|
impl->browse_widgets = browse_widgets_create (impl);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (impl), impl->browse_widgets, TRUE, TRUE, 0);
|
2004-01-20 02:44:58 +00:00
|
|
|
|
|
2003-09-06 00:50:33 +00:00
|
|
|
|
gtk_widget_pop_composite_child ();
|
2004-02-25 08:55:48 +00:00
|
|
|
|
update_appearance (impl);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-03-26 17:09:26 +00:00
|
|
|
|
return object;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-03 05:52:35 +00:00
|
|
|
|
/* Sets the extra_widget by packing it in the appropriate place */
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
set_extra_widget (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkWidget *extra_widget)
|
2003-09-03 05:52:35 +00:00
|
|
|
|
{
|
2004-02-25 08:55:48 +00:00
|
|
|
|
if (extra_widget)
|
|
|
|
|
{
|
|
|
|
|
g_object_ref (extra_widget);
|
|
|
|
|
/* FIXME: is this right ? */
|
|
|
|
|
gtk_widget_show (extra_widget);
|
|
|
|
|
}
|
2003-09-03 05:52:35 +00:00
|
|
|
|
|
|
|
|
|
if (impl->extra_widget)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
g_object_unref (impl->extra_widget);
|
2003-09-03 05:52:35 +00:00
|
|
|
|
|
|
|
|
|
impl->extra_widget = extra_widget;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-15 06:09:40 +00:00
|
|
|
|
static void
|
|
|
|
|
set_local_only (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean local_only)
|
|
|
|
|
{
|
|
|
|
|
if (local_only != impl->local_only)
|
|
|
|
|
{
|
|
|
|
|
impl->local_only = local_only;
|
|
|
|
|
|
|
|
|
|
if (impl->shortcuts_model && impl->file_system)
|
|
|
|
|
{
|
|
|
|
|
shortcuts_add_volumes (impl);
|
|
|
|
|
shortcuts_add_bookmarks (impl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (local_only &&
|
|
|
|
|
!gtk_file_system_path_is_local (impl->file_system, impl->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.
|
|
|
|
|
*/
|
|
|
|
|
const gchar *home = g_get_home_dir ();
|
2004-08-14 16:47:48 +00:00
|
|
|
|
GtkFilePath *home_path;
|
|
|
|
|
|
|
|
|
|
if (home == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
home_path = gtk_file_system_filename_to_path (impl->file_system, home);
|
2004-03-15 06:09:40 +00:00
|
|
|
|
|
|
|
|
|
_gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), home_path, NULL);
|
|
|
|
|
|
|
|
|
|
gtk_file_path_free (home_path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
static void
|
|
|
|
|
volumes_changed_cb (GtkFileSystem *file_system,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
shortcuts_add_volumes (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 04:14:55 +00:00
|
|
|
|
/* Callback used when the set of bookmarks changes in the file system */
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
bookmarks_changed_cb (GtkFileSystem *file_system,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-10-08 04:14:55 +00:00
|
|
|
|
{
|
2003-12-17 05:55:16 +00:00
|
|
|
|
shortcuts_add_bookmarks (impl);
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
|
|
|
|
bookmarks_check_add_sensitivity (impl);
|
|
|
|
|
bookmarks_check_remove_sensitivity (impl);
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-20 02:44:58 +00:00
|
|
|
|
/* Sets the file chooser to multiple selection mode */
|
|
|
|
|
static void
|
2004-01-23 20:15:05 +00:00
|
|
|
|
set_select_multiple (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean select_multiple,
|
|
|
|
|
gboolean property_notify)
|
2004-01-20 02:44:58 +00:00
|
|
|
|
{
|
2004-01-23 20:15:05 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
GtkSelectionMode mode;
|
|
|
|
|
|
|
|
|
|
if (select_multiple == impl->select_multiple)
|
|
|
|
|
return;
|
2004-01-20 02:44:58 +00:00
|
|
|
|
|
2004-01-23 20:15:05 +00:00
|
|
|
|
mode = select_multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_BROWSE;
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
2004-01-23 20:15:05 +00:00
|
|
|
|
gtk_tree_selection_set_mode (selection, mode);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
impl->select_multiple = select_multiple;
|
2004-01-23 20:15:05 +00:00
|
|
|
|
g_object_notify (G_OBJECT (impl), "select-multiple");
|
|
|
|
|
|
2004-01-20 02:44:58 +00:00
|
|
|
|
check_preview_change (impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-19 07:43:39 +00:00
|
|
|
|
static void
|
|
|
|
|
set_file_system_backend (GtkFileChooserDefault *impl,
|
|
|
|
|
const char *backend)
|
|
|
|
|
{
|
|
|
|
|
if (impl->file_system)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handler_disconnect (impl->file_system, impl->volumes_changed_id);
|
|
|
|
|
impl->volumes_changed_id = 0;
|
|
|
|
|
g_signal_handler_disconnect (impl->file_system, impl->bookmarks_changed_id);
|
|
|
|
|
impl->bookmarks_changed_id = 0;
|
|
|
|
|
g_object_unref (impl->file_system);
|
|
|
|
|
}
|
2004-02-29 06:35:15 +00:00
|
|
|
|
|
2004-02-19 07:43:39 +00:00
|
|
|
|
impl->file_system = NULL;
|
|
|
|
|
if (backend)
|
|
|
|
|
impl->file_system = _gtk_file_system_create (backend);
|
2004-03-01 19:40:47 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkSettings *settings = gtk_settings_get_default ();
|
|
|
|
|
gchar *default_backend = NULL;
|
2004-03-03 00:38:19 +00:00
|
|
|
|
|
2004-03-01 19:40:47 +00:00
|
|
|
|
g_object_get (settings, "gtk-file-chooser-backend", &default_backend, NULL);
|
|
|
|
|
if (default_backend)
|
|
|
|
|
{
|
|
|
|
|
impl->file_system = _gtk_file_system_create (default_backend);
|
|
|
|
|
g_free (default_backend);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-02-29 06:35:15 +00:00
|
|
|
|
|
2004-02-19 07:43:39 +00:00
|
|
|
|
if (!impl->file_system)
|
|
|
|
|
{
|
|
|
|
|
#if defined (G_OS_UNIX)
|
|
|
|
|
impl->file_system = gtk_file_system_unix_new ();
|
|
|
|
|
#elif defined (G_OS_WIN32)
|
|
|
|
|
impl->file_system = gtk_file_system_win32_new ();
|
|
|
|
|
#else
|
|
|
|
|
#error "No default filesystem implementation on the platform"
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2004-02-29 06:35:15 +00:00
|
|
|
|
|
2004-02-19 07:43:39 +00:00
|
|
|
|
if (impl->file_system)
|
|
|
|
|
{
|
|
|
|
|
impl->volumes_changed_id = g_signal_connect (impl->file_system, "volumes-changed",
|
|
|
|
|
G_CALLBACK (volumes_changed_cb),
|
|
|
|
|
impl);
|
|
|
|
|
impl->bookmarks_changed_id = g_signal_connect (impl->file_system, "bookmarks-changed",
|
|
|
|
|
G_CALLBACK (bookmarks_changed_cb),
|
|
|
|
|
impl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* This function is basically a do_all function.
|
2004-02-29 06:35:15 +00:00
|
|
|
|
*
|
2004-02-25 08:55:48 +00:00
|
|
|
|
* It sets the visibility on all the widgets based on the current state, and
|
|
|
|
|
* moves the custom_widget if needed.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
update_appearance (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
2004-02-26 23:35:05 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
2004-03-08 20:06:50 +00:00
|
|
|
|
const char *text;
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_widget_show (impl->save_widgets);
|
|
|
|
|
|
2004-03-08 20:06:50 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
|
|
|
|
text = _("Save in _folder:");
|
|
|
|
|
else
|
|
|
|
|
text = _("Create in _folder:");
|
|
|
|
|
|
|
|
|
|
gtk_label_set_text_with_mnemonic (GTK_LABEL (impl->save_folder_label), text);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
if (gtk_expander_get_expanded (GTK_EXPANDER (impl->save_expander)))
|
2004-02-25 21:05:30 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_sensitive (impl->save_folder_label, FALSE);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
gtk_widget_set_sensitive (impl->save_folder_combo, FALSE);
|
2004-02-25 21:05:30 +00:00
|
|
|
|
gtk_widget_show (impl->browse_widgets);
|
|
|
|
|
}
|
2004-02-25 08:55:48 +00:00
|
|
|
|
else
|
2004-02-25 21:05:30 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_sensitive (impl->save_folder_label, TRUE);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
gtk_widget_set_sensitive (impl->save_folder_combo, TRUE);
|
2004-02-25 21:05:30 +00:00
|
|
|
|
gtk_widget_hide (impl->browse_widgets);
|
|
|
|
|
}
|
2004-02-25 08:55:48 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_show (impl->browse_new_folder_button);
|
|
|
|
|
|
|
|
|
|
if (impl->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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-02-26 23:35:05 +00:00
|
|
|
|
else if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
|
|
|
|
impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_hide (impl->save_widgets);
|
|
|
|
|
gtk_widget_show (impl->browse_widgets);
|
|
|
|
|
}
|
2004-02-26 23:35:05 +00:00
|
|
|
|
/* FIXME: */
|
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
|
|
|
|
|
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
2004-03-07 04:41:36 +00:00
|
|
|
|
if (impl->browse_files_model)
|
|
|
|
|
_gtk_file_system_model_set_show_files (impl->browse_files_model, FALSE);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-03-07 04:41:36 +00:00
|
|
|
|
if (impl->browse_files_model)
|
|
|
|
|
_gtk_file_system_model_set_show_files (impl->browse_files_model, TRUE);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-15 23:15:31 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
2004-03-04 21:29:51 +00:00
|
|
|
|
gtk_widget_hide (impl->browse_new_folder_button);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_show (impl->browse_new_folder_button);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
if (impl->extra_widget)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *align;
|
|
|
|
|
GtkWidget *unused_align;
|
|
|
|
|
|
2004-03-08 20:06:50 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
|
|
|
|
align = impl->save_extra_align;
|
|
|
|
|
unused_align = impl->browse_extra_align;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
align = impl->browse_extra_align;
|
|
|
|
|
unused_align = impl->save_extra_align;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We own a ref on extra_widget, so it's safe to do this */
|
|
|
|
|
child = GTK_BIN (unused_align)->child;
|
|
|
|
|
if (child)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (unused_align), child);
|
|
|
|
|
|
|
|
|
|
child = GTK_BIN (align)->child;
|
|
|
|
|
if (child && child != impl->extra_widget)
|
|
|
|
|
{
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (align), child);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), impl->extra_widget);
|
|
|
|
|
}
|
|
|
|
|
else if (child == NULL)
|
|
|
|
|
{
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (align), impl->extra_widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_show (align);
|
|
|
|
|
gtk_widget_hide (unused_align);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
child = GTK_BIN (impl->browse_extra_align)->child;
|
|
|
|
|
if (child)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (impl->browse_extra_align), child);
|
|
|
|
|
|
|
|
|
|
child = GTK_BIN (impl->save_extra_align)->child;
|
|
|
|
|
if (child)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (impl->save_extra_align), child);
|
|
|
|
|
|
|
|
|
|
gtk_widget_hide (impl->save_extra_align);
|
|
|
|
|
gtk_widget_hide (impl->browse_extra_align);
|
|
|
|
|
}
|
2004-02-29 07:55:24 +00:00
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
g_signal_emit_by_name (impl, "default-size-changed");
|
2004-02-25 08:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_ACTION:
|
2004-02-25 08:55:48 +00:00
|
|
|
|
{
|
|
|
|
|
GtkFileChooserAction action = g_value_get_enum (value);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
if (action != impl->action)
|
|
|
|
|
{
|
|
|
|
|
if (action == GTK_FILE_CHOOSER_ACTION_SAVE && impl->select_multiple)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Multiple selection mode is not allowed in Save mode");
|
|
|
|
|
set_select_multiple (impl, FALSE, TRUE);
|
|
|
|
|
}
|
|
|
|
|
impl->action = action;
|
|
|
|
|
update_appearance (impl);
|
|
|
|
|
}
|
2004-09-17 18:13:26 +00:00
|
|
|
|
|
|
|
|
|
if (impl->save_file_name_entry)
|
|
|
|
|
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
|
|
|
|
|
action);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
}
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2004-02-19 07:43:39 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM_BACKEND:
|
|
|
|
|
set_file_system_backend (impl, g_value_get_string (value));
|
2003-03-26 17:09:26 +00:00
|
|
|
|
break;
|
2003-07-23 15:31:10 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILTER:
|
|
|
|
|
set_current_filter (impl, g_value_get_object (value));
|
|
|
|
|
break;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
|
2004-03-15 06:09:40 +00:00
|
|
|
|
set_local_only (impl, g_value_get_boolean (value));
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
|
|
|
|
|
set_preview_widget (impl, g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
|
|
|
|
|
impl->preview_widget_active = g_value_get_boolean (value);
|
2003-07-23 22:30:32 +00:00
|
|
|
|
update_preview_widget_visibility (impl);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
break;
|
2004-02-29 06:35:15 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
|
|
|
|
|
impl->use_preview_label = g_value_get_boolean (value);
|
|
|
|
|
update_preview_widget_visibility (impl);
|
|
|
|
|
break;
|
2003-09-03 05:52:35 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
|
|
|
|
|
set_extra_widget (impl, g_value_get_object (value));
|
2004-02-25 08:55:48 +00:00
|
|
|
|
update_appearance (impl);
|
2003-09-03 05:52:35 +00:00
|
|
|
|
break;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
|
|
|
|
|
{
|
|
|
|
|
gboolean select_multiple = g_value_get_boolean (value);
|
2004-01-16 05:12:21 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE && select_multiple)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("Multiple selection mode is not allowed in Save mode");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-23 20:15:05 +00:00
|
|
|
|
set_select_multiple (impl, select_multiple, FALSE);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
|
|
|
|
|
{
|
|
|
|
|
gboolean show_hidden = g_value_get_boolean (value);
|
|
|
|
|
if (show_hidden != impl->show_hidden)
|
|
|
|
|
{
|
|
|
|
|
impl->show_hidden = show_hidden;
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
|
|
|
|
if (impl->browse_files_model)
|
|
|
|
|
_gtk_file_system_model_set_show_hidden (impl->browse_files_model, show_hidden);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
break;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_ACTION:
|
|
|
|
|
g_value_set_enum (value, impl->action);
|
|
|
|
|
break;
|
2003-07-23 15:31:10 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_FILTER:
|
|
|
|
|
g_value_set_object (value, impl->current_filter);
|
|
|
|
|
break;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
|
|
|
|
|
g_value_set_boolean (value, impl->local_only);
|
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
|
|
|
|
|
g_value_set_object (value, impl->preview_widget);
|
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
|
|
|
|
|
g_value_set_boolean (value, impl->preview_widget_active);
|
|
|
|
|
break;
|
2004-02-29 06:35:15 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
|
|
|
|
|
g_value_set_boolean (value, impl->use_preview_label);
|
|
|
|
|
break;
|
2003-09-03 05:52:35 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
|
|
|
|
|
g_value_set_object (value, impl->extra_widget);
|
|
|
|
|
break;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
|
|
|
|
|
g_value_set_boolean (value, impl->select_multiple);
|
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
|
|
|
|
|
g_value_set_boolean (value, impl->show_hidden);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
break;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-11 20:03:38 +00:00
|
|
|
|
/* Removes the settings signal handler. It's safe to call multiple times */
|
|
|
|
|
static void
|
|
|
|
|
remove_settings_signal (GtkFileChooserDefault *impl,
|
|
|
|
|
GdkScreen *screen)
|
|
|
|
|
{
|
|
|
|
|
if (impl->settings_signal_id)
|
|
|
|
|
{
|
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
|
|
|
|
|
settings = gtk_settings_get_for_screen (screen);
|
|
|
|
|
g_signal_handler_disconnect (settings,
|
|
|
|
|
impl->settings_signal_id);
|
|
|
|
|
impl->settings_signal_id = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-02-25 08:55:48 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = (GtkFileChooserDefault *) object;
|
|
|
|
|
|
|
|
|
|
if (impl->extra_widget)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (impl->extra_widget);
|
|
|
|
|
impl->extra_widget = NULL;
|
|
|
|
|
}
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-03-11 20:03:38 +00:00
|
|
|
|
remove_settings_signal (impl, gtk_widget_get_screen (GTK_WIDGET (impl)));
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
/* We override show-all since we have internal widgets that
|
|
|
|
|
* shouldn't be shown when you call show_all(), like the filter
|
2003-10-23 05:10:47 +00:00
|
|
|
|
* combo box.
|
2003-07-23 15:31:10 +00:00
|
|
|
|
*/
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_show_all (GtkWidget *widget)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2004-03-05 09:49:00 +00:00
|
|
|
|
GtkFileChooserDefault *impl = (GtkFileChooserDefault *) widget;
|
2004-03-05 08:37:11 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
gtk_widget_show (widget);
|
2004-03-05 08:37:11 +00:00
|
|
|
|
|
|
|
|
|
if (impl->extra_widget)
|
|
|
|
|
gtk_widget_show_all (impl->extra_widget);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
/* Handler for GtkWindow::set-focus; this is where we save the last-focused
|
|
|
|
|
* widget on our toplevel. See gtk_file_chooser_default_hierarchy_changed()
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
toplevel_set_focus_cb (GtkWindow *window,
|
|
|
|
|
GtkWidget *focus,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
impl->toplevel_last_focus_widget = gtk_window_get_focus (window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We monitor the focus widget on our toplevel to be able to know which widget
|
|
|
|
|
* was last focused at the time our "should_respond" method gets called.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_hierarchy_changed (GtkWidget *widget,
|
|
|
|
|
GtkWidget *previous_toplevel)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
|
|
|
|
|
if (previous_toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_assert (impl->toplevel_set_focus_id != 0);
|
|
|
|
|
g_signal_handler_disconnect (previous_toplevel, impl->toplevel_set_focus_id);
|
|
|
|
|
impl->toplevel_set_focus_id = 0;
|
|
|
|
|
impl->toplevel_last_focus_widget = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_assert (impl->toplevel_set_focus_id == 0);
|
|
|
|
|
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (widget);
|
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
|
|
|
|
{
|
|
|
|
|
impl->toplevel_set_focus_id = g_signal_connect (toplevel, "set-focus",
|
|
|
|
|
G_CALLBACK (toplevel_set_focus_cb), impl);
|
|
|
|
|
impl->toplevel_last_focus_widget = gtk_window_get_focus (GTK_WINDOW (toplevel));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-09 21:22:42 +00:00
|
|
|
|
/* Changes the icons wherever it is needed */
|
|
|
|
|
static void
|
|
|
|
|
change_icon_theme (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
|
|
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
|
|
|
|
|
|
|
|
|
|
if (gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_SMALL_TOOLBAR, &width, &height))
|
|
|
|
|
impl->icon_size = MAX (width, height);
|
|
|
|
|
else
|
|
|
|
|
impl->icon_size = FALLBACK_ICON_SIZE;
|
|
|
|
|
|
|
|
|
|
shortcuts_reload_icons (impl);
|
|
|
|
|
gtk_widget_queue_resize (impl->browse_files_tree_view);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used when a GtkSettings value changes */
|
|
|
|
|
static void
|
|
|
|
|
settings_notify_cb (GObject *object,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
|
|
name = g_param_spec_get_name (pspec);
|
|
|
|
|
|
|
|
|
|
if (strcmp (name, "gtk-icon-theme-name") == 0
|
|
|
|
|
|| strcmp (name, "gtk-icon-sizes") == 0)
|
|
|
|
|
change_icon_theme (impl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Installs a signal handler for GtkSettings so that we can monitor changes in
|
|
|
|
|
* the icon theme.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
check_icon_theme (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
|
|
|
|
|
if (impl->settings_signal_id)
|
|
|
|
|
return;
|
|
|
|
|
|
2004-03-17 15:34:21 +00:00
|
|
|
|
if (gtk_widget_has_screen (GTK_WIDGET (impl)))
|
|
|
|
|
{
|
|
|
|
|
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
|
|
|
|
|
impl->settings_signal_id = g_signal_connect (settings, "notify",
|
|
|
|
|
G_CALLBACK (settings_notify_cb), impl);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-03-17 15:34:21 +00:00
|
|
|
|
change_icon_theme (impl);
|
|
|
|
|
}
|
2004-03-09 21:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
static void
|
2004-08-13 18:09:29 +00:00
|
|
|
|
gtk_file_chooser_default_style_set (GtkWidget *widget,
|
|
|
|
|
GtkStyle *previous_style)
|
2004-02-27 23:51:16 +00:00
|
|
|
|
{
|
2004-03-09 21:22:42 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
|
2004-02-29 07:55:24 +00:00
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->style_set)
|
2004-02-27 23:51:16 +00:00
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
|
|
|
|
|
|
2004-08-13 18:09:29 +00:00
|
|
|
|
if (gtk_widget_has_screen (GTK_WIDGET (impl)))
|
|
|
|
|
change_icon_theme (impl);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
g_signal_emit_by_name (widget, "default-size-changed");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_screen_changed (GtkWidget *widget,
|
|
|
|
|
GdkScreen *previous_screen)
|
|
|
|
|
{
|
2004-03-09 21:22:42 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->screen_changed)
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, previous_screen);
|
|
|
|
|
|
2004-03-11 20:03:38 +00:00
|
|
|
|
remove_settings_signal (impl, previous_screen);
|
2004-03-09 21:22:42 +00:00
|
|
|
|
check_icon_theme (impl);
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
g_signal_emit_by_name (widget, "default-size-changed");
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-13 02:31:09 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
list_model_filter_func (GtkFileSystemModel *model,
|
|
|
|
|
GtkFilePath *path,
|
|
|
|
|
const GtkFileInfo *file_info,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = user_data;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
GtkFileFilterInfo filter_info;
|
|
|
|
|
GtkFileFilterFlags needed;
|
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
|
|
if (!impl->current_filter)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-11-19 22:38:31 +00:00
|
|
|
|
if (gtk_file_info_get_is_folder (file_info))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-10-13 02:31:09 +00:00
|
|
|
|
filter_info.contains = GTK_FILE_FILTER_DISPLAY_NAME | GTK_FILE_FILTER_MIME_TYPE;
|
|
|
|
|
|
|
|
|
|
needed = gtk_file_filter_get_needed (impl->current_filter);
|
|
|
|
|
|
|
|
|
|
filter_info.display_name = gtk_file_info_get_display_name (file_info);
|
|
|
|
|
filter_info.mime_type = gtk_file_info_get_mime_type (file_info);
|
|
|
|
|
|
|
|
|
|
if (needed & GTK_FILE_FILTER_FILENAME)
|
|
|
|
|
{
|
|
|
|
|
filter_info.filename = gtk_file_system_path_to_filename (impl->file_system, path);
|
|
|
|
|
if (filter_info.filename)
|
|
|
|
|
filter_info.contains |= GTK_FILE_FILTER_FILENAME;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
filter_info.filename = NULL;
|
|
|
|
|
|
|
|
|
|
if (needed & GTK_FILE_FILTER_URI)
|
|
|
|
|
{
|
|
|
|
|
filter_info.uri = gtk_file_system_path_to_uri (impl->file_system, path);
|
2004-03-01 18:24:06 +00:00
|
|
|
|
if (filter_info.uri)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
filter_info.contains |= GTK_FILE_FILTER_URI;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
filter_info.uri = NULL;
|
|
|
|
|
|
|
|
|
|
result = gtk_file_filter_filter (impl->current_filter, &filter_info);
|
|
|
|
|
|
|
|
|
|
if (filter_info.filename)
|
|
|
|
|
g_free ((gchar *)filter_info.filename);
|
|
|
|
|
if (filter_info.uri)
|
|
|
|
|
g_free ((gchar *)filter_info.uri);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
install_list_model_filter (GtkFileChooserDefault *impl)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
2004-07-09 00:53:48 +00:00
|
|
|
|
g_assert (impl->browse_files_model != NULL);
|
|
|
|
|
|
2003-10-13 02:31:09 +00:00
|
|
|
|
if (impl->current_filter)
|
2004-02-25 08:55:48 +00:00
|
|
|
|
_gtk_file_system_model_set_filter (impl->browse_files_model,
|
2003-10-13 02:31:09 +00:00
|
|
|
|
list_model_filter_func,
|
|
|
|
|
impl);
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-17 04:34:49 +00:00
|
|
|
|
#define COMPARE_DIRECTORIES \
|
|
|
|
|
GtkFileChooserDefault *impl = user_data; \
|
2004-02-25 08:55:48 +00:00
|
|
|
|
const GtkFileInfo *info_a = _gtk_file_system_model_get_info (impl->browse_files_model, a); \
|
|
|
|
|
const GtkFileInfo *info_b = _gtk_file_system_model_get_info (impl->browse_files_model, b); \
|
2004-01-17 04:34:49 +00:00
|
|
|
|
gboolean dir_a, dir_b; \
|
|
|
|
|
\
|
|
|
|
|
if (info_a) \
|
|
|
|
|
dir_a = gtk_file_info_get_is_folder (info_a); \
|
|
|
|
|
else \
|
|
|
|
|
return impl->list_sort_ascending ? -1 : 1; \
|
|
|
|
|
\
|
|
|
|
|
if (info_b) \
|
|
|
|
|
dir_b = gtk_file_info_get_is_folder (info_b); \
|
|
|
|
|
else \
|
|
|
|
|
return impl->list_sort_ascending ? 1 : -1; \
|
|
|
|
|
\
|
|
|
|
|
if (dir_a != dir_b) \
|
2003-10-13 02:31:09 +00:00
|
|
|
|
return impl->list_sort_ascending ? (dir_a ? -1 : 1) : (dir_a ? 1 : -1) /* Directories *always* go first */
|
|
|
|
|
|
|
|
|
|
/* Sort callback for the filename column */
|
|
|
|
|
static gint
|
|
|
|
|
name_sort_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *a,
|
|
|
|
|
GtkTreeIter *b,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
COMPARE_DIRECTORIES;
|
|
|
|
|
else
|
|
|
|
|
return strcmp (gtk_file_info_get_display_key (info_a), gtk_file_info_get_display_key (info_b));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sort callback for the size column */
|
|
|
|
|
static gint
|
|
|
|
|
size_sort_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *a,
|
|
|
|
|
GtkTreeIter *b,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
COMPARE_DIRECTORIES;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gint64 size_a = gtk_file_info_get_size (info_a);
|
|
|
|
|
gint64 size_b = gtk_file_info_get_size (info_b);
|
|
|
|
|
|
|
|
|
|
return size_a > size_b ? -1 : (size_a == size_b ? 0 : 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sort callback for the mtime column */
|
|
|
|
|
static gint
|
|
|
|
|
mtime_sort_func (GtkTreeModel *model,
|
|
|
|
|
GtkTreeIter *a,
|
|
|
|
|
GtkTreeIter *b,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
COMPARE_DIRECTORIES;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkFileTime ta = gtk_file_info_get_modification_time (info_a);
|
|
|
|
|
GtkFileTime tb = gtk_file_info_get_modification_time (info_b);
|
|
|
|
|
|
|
|
|
|
return ta > tb ? -1 : (ta == tb ? 0 : 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used when the sort column changes. We cache the sort order for use
|
|
|
|
|
* in name_sort_func().
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
list_sort_column_changed_cb (GtkTreeSortable *sortable,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
|
|
|
|
GtkSortType sort_type;
|
|
|
|
|
|
|
|
|
|
if (gtk_tree_sortable_get_sort_column_id (sortable, NULL, &sort_type))
|
|
|
|
|
impl->list_sort_ascending = (sort_type == GTK_SORT_ASCENDING);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
static void
|
|
|
|
|
set_busy_cursor (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean busy)
|
|
|
|
|
{
|
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (impl));
|
|
|
|
|
if (!toplevel || !GTK_WIDGET_REALIZED (toplevel))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
display = gtk_widget_get_display (GTK_WIDGET (toplevel));
|
|
|
|
|
|
|
|
|
|
if (busy)
|
|
|
|
|
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
|
|
|
|
|
else
|
|
|
|
|
cursor = NULL;
|
|
|
|
|
|
|
|
|
|
gdk_window_set_cursor (GTK_WIDGET (toplevel)->window, cursor);
|
|
|
|
|
gdk_display_flush (display);
|
|
|
|
|
|
|
|
|
|
if (cursor)
|
|
|
|
|
gdk_cursor_unref (cursor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback used when the file system model finishes loading */
|
|
|
|
|
static void
|
|
|
|
|
browse_files_model_finished_loading_cb (GtkFileSystemModel *model,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
set_busy_cursor (impl, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-13 02:31:09 +00:00
|
|
|
|
/* Gets rid of the old list model and creates a new one for the current folder */
|
2004-07-09 00:53:48 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
set_list_model (GtkFileChooserDefault *impl,
|
|
|
|
|
GError **error)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
2004-02-25 08:55:48 +00:00
|
|
|
|
if (impl->browse_files_model)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
2004-02-25 08:55:48 +00:00
|
|
|
|
g_object_unref (impl->browse_files_model);
|
2004-07-09 00:53:48 +00:00
|
|
|
|
impl->browse_files_model = NULL;
|
|
|
|
|
|
2003-10-13 02:31:09 +00:00
|
|
|
|
g_object_unref (impl->sort_model);
|
2004-07-09 00:53:48 +00:00
|
|
|
|
impl->sort_model = NULL;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
set_busy_cursor (impl, TRUE);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
impl->browse_files_model = _gtk_file_system_model_new (impl->file_system,
|
2004-03-07 04:41:36 +00:00
|
|
|
|
impl->current_folder, 0,
|
2004-07-09 00:53:48 +00:00
|
|
|
|
GTK_FILE_INFO_ALL,
|
|
|
|
|
error);
|
|
|
|
|
if (!impl->browse_files_model)
|
|
|
|
|
{
|
|
|
|
|
set_busy_cursor (impl, FALSE);
|
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view), NULL);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
g_signal_connect (impl->browse_files_model, "finished-loading",
|
|
|
|
|
G_CALLBACK (browse_files_model_finished_loading_cb), impl);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
_gtk_file_system_model_set_show_hidden (impl->browse_files_model, impl->show_hidden);
|
2004-03-07 04:41:36 +00:00
|
|
|
|
switch (impl->action)
|
|
|
|
|
{
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_OPEN:
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_SAVE:
|
|
|
|
|
_gtk_file_system_model_set_show_files (impl->browse_files_model, TRUE);
|
|
|
|
|
break;
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
|
|
|
|
|
case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
|
|
|
|
|
_gtk_file_system_model_set_show_files (impl->browse_files_model, FALSE);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
2003-10-13 02:31:09 +00:00
|
|
|
|
install_list_model_filter (impl);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
impl->sort_model = (GtkTreeModelSort *)gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (impl->browse_files_model));
|
2003-10-13 02:31:09 +00:00
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_NAME, name_sort_func, impl, NULL);
|
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_SIZE, size_sort_func, impl, NULL);
|
|
|
|
|
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_MTIME, mtime_sort_func, impl, NULL);
|
|
|
|
|
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (impl->sort_model), NULL, NULL, NULL);
|
|
|
|
|
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_NAME, GTK_SORT_ASCENDING);
|
|
|
|
|
impl->list_sort_ascending = TRUE;
|
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
g_signal_connect (impl->sort_model, "sort-column-changed",
|
2003-10-13 02:31:09 +00:00
|
|
|
|
G_CALLBACK (list_sort_column_changed_cb), impl);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view),
|
2003-10-13 02:31:09 +00:00
|
|
|
|
GTK_TREE_MODEL (impl->sort_model));
|
2004-02-25 08:55:48 +00:00
|
|
|
|
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
|
|
|
|
gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->browse_files_tree_view),
|
2003-10-13 02:31:09 +00:00
|
|
|
|
GTK_FILE_SYSTEM_MODEL_DISPLAY_NAME);
|
2004-07-09 00:53:48 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
update_chooser_entry (GtkFileChooserDefault *impl)
|
2003-10-13 02:31:09 +00:00
|
|
|
|
{
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
2003-10-13 02:31:09 +00:00
|
|
|
|
const GtkFileInfo *info;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
if (impl->action != GTK_FILE_CHOOSER_ACTION_SAVE)
|
|
|
|
|
return;
|
|
|
|
|
|
2004-02-24 20:30:54 +00:00
|
|
|
|
g_assert (!impl->select_multiple);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
|
2003-10-13 02:31:09 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
|
|
|
|
|
&child_iter,
|
|
|
|
|
&iter);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
|
2003-10-13 02:31:09 +00:00
|
|
|
|
|
2004-02-10 18:29:11 +00:00
|
|
|
|
if (!gtk_file_info_get_is_folder (info))
|
2004-08-06 19:25:25 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
|
|
|
|
|
gtk_file_info_get_display_name (info));
|
2003-10-13 02:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
static gboolean
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
|
2004-03-05 20:47:05 +00:00
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError **error)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2004-07-09 00:53:48 +00:00
|
|
|
|
gboolean result;
|
2003-03-25 00:11:06 +00:00
|
|
|
|
|
2004-03-15 06:09:40 +00:00
|
|
|
|
if (impl->local_only &&
|
|
|
|
|
!gtk_file_system_path_is_local (impl->file_system, path))
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
|
GTK_FILE_SYSTEM_ERROR_FAILED,
|
2004-06-12 02:08:45 +00:00
|
|
|
|
_("Cannot change to folder because it is not local"));
|
2004-03-15 23:15:31 +00:00
|
|
|
|
|
2004-03-15 06:09:40 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-19 20:18:09 +00:00
|
|
|
|
/* Test validity of path here. */
|
|
|
|
|
if (!check_is_folder (impl->file_system, path, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2004-03-08 22:53:35 +00:00
|
|
|
|
if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, error))
|
|
|
|
|
return FALSE;
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
2004-03-03 00:38:19 +00:00
|
|
|
|
if (impl->current_folder != path)
|
|
|
|
|
{
|
|
|
|
|
if (impl->current_folder)
|
|
|
|
|
gtk_file_path_free (impl->current_folder);
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
2004-03-03 00:38:19 +00:00
|
|
|
|
impl->current_folder = gtk_file_path_copy (path);
|
|
|
|
|
}
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2004-03-08 22:53:35 +00:00
|
|
|
|
/* Update the widgets that may trigger a folder change themselves. */
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
|
|
|
|
if (!impl->changing_folder)
|
|
|
|
|
{
|
|
|
|
|
impl->changing_folder = TRUE;
|
2004-03-02 20:05:08 +00:00
|
|
|
|
|
|
|
|
|
shortcuts_update_current_folder (impl);
|
|
|
|
|
|
2003-12-02 04:23:06 +00:00
|
|
|
|
impl->changing_folder = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-06 19:25:25 +00:00
|
|
|
|
/* Set the folder on the save entry */
|
|
|
|
|
|
|
|
|
|
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
|
|
|
|
|
impl->current_folder);
|
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
/* Create a new list model. This is slightly evil; we store the result value
|
|
|
|
|
* but perform more actions rather than returning immediately even if it
|
|
|
|
|
* generates an error.
|
|
|
|
|
*/
|
|
|
|
|
result = set_list_model (impl, error);
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
|
|
|
|
/* Refresh controls */
|
|
|
|
|
|
2004-03-15 06:51:58 +00:00
|
|
|
|
shortcuts_find_current_folder (impl);
|
2003-12-02 04:23:06 +00:00
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (impl, "current-folder-changed", 0);
|
|
|
|
|
|
|
|
|
|
check_preview_change (impl);
|
|
|
|
|
bookmarks_check_add_sensitivity (impl);
|
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (impl, "selection-changed", 0);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
return result;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-04 22:43:12 +00:00
|
|
|
|
static GtkFilePath *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-04-04 22:43:12 +00:00
|
|
|
|
return gtk_file_path_copy (impl->current_folder);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 19:18:36 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser,
|
|
|
|
|
const gchar *name)
|
2003-07-11 19:18:36 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-07-11 19:18:36 +00:00
|
|
|
|
|
2004-03-15 19:23:54 +00:00
|
|
|
|
g_return_if_fail (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-08-06 19:25:25 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry), name);
|
2003-07-11 19:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 23:59:22 +00:00
|
|
|
|
static void
|
|
|
|
|
select_func (GtkFileSystemModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = user_data;
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkTreeView *tree_view = GTK_TREE_VIEW (impl->browse_files_tree_view);
|
2003-03-21 23:59:22 +00:00
|
|
|
|
GtkTreePath *sorted_path;
|
|
|
|
|
|
|
|
|
|
sorted_path = gtk_tree_model_sort_convert_child_path_to_path (impl->sort_model, path);
|
|
|
|
|
gtk_tree_view_set_cursor (tree_view, sorted_path, NULL, FALSE);
|
2004-09-17 19:05:45 +00:00
|
|
|
|
gtk_tree_view_scroll_to_cell (tree_view, sorted_path, NULL, FALSE, 0.0, 0.0);
|
2003-03-21 23:59:22 +00:00
|
|
|
|
gtk_tree_path_free (sorted_path);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
static gboolean
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_select_path (GtkFileChooser *chooser,
|
2004-03-05 20:47:05 +00:00
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError **error)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-04-04 22:43:12 +00:00
|
|
|
|
GtkFilePath *parent_path;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-03-06 03:38:59 +00:00
|
|
|
|
if (!gtk_file_system_get_parent (impl->file_system, path, &parent_path, error))
|
|
|
|
|
return FALSE;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-04-04 22:43:12 +00:00
|
|
|
|
if (!parent_path)
|
2004-03-05 20:47:05 +00:00
|
|
|
|
return _gtk_file_chooser_set_current_folder_path (chooser, path, error);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-03-05 20:47:05 +00:00
|
|
|
|
gboolean result;
|
2004-04-02 00:35:07 +00:00
|
|
|
|
GtkFileFolder *folder;
|
|
|
|
|
GtkFileInfo *info;
|
|
|
|
|
gboolean is_hidden;
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
|
|
|
|
result = _gtk_file_chooser_set_current_folder_path (chooser, parent_path, error);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
{
|
|
|
|
|
gtk_file_path_free (parent_path);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
folder = gtk_file_system_get_folder (impl->file_system, parent_path, GTK_FILE_INFO_IS_HIDDEN, error);
|
2003-04-04 22:43:12 +00:00
|
|
|
|
gtk_file_path_free (parent_path);
|
2004-04-02 00:35:07 +00:00
|
|
|
|
|
|
|
|
|
if (!folder)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
info = gtk_file_folder_get_info (folder, path, error);
|
|
|
|
|
g_object_unref (folder);
|
|
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
is_hidden = gtk_file_info_get_is_hidden (info);
|
|
|
|
|
gtk_file_info_free (info);
|
|
|
|
|
|
|
|
|
|
if (is_hidden)
|
|
|
|
|
g_object_set (impl, "show-hidden", TRUE, NULL);
|
|
|
|
|
|
|
|
|
|
result = _gtk_file_system_model_path_do (impl->browse_files_model, path,
|
|
|
|
|
select_func, impl);
|
|
|
|
|
if (!result)
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GTK_FILE_CHOOSER_ERROR,
|
|
|
|
|
GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
|
|
|
|
|
_("Could not find the path"));
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
2004-03-05 20:47:05 +00:00
|
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
unselect_func (GtkFileSystemModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = user_data;
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkTreeView *tree_view = GTK_TREE_VIEW (impl->browse_files_tree_view);
|
2003-03-21 23:59:22 +00:00
|
|
|
|
GtkTreePath *sorted_path;
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2003-03-21 23:59:22 +00:00
|
|
|
|
sorted_path = gtk_tree_model_sort_convert_child_path_to_path (impl->sort_model,
|
|
|
|
|
path);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
gtk_tree_selection_unselect_path (gtk_tree_view_get_selection (tree_view),
|
2003-03-21 23:59:22 +00:00
|
|
|
|
sorted_path);
|
|
|
|
|
gtk_tree_path_free (sorted_path);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_unselect_path (GtkFileChooser *chooser,
|
|
|
|
|
const GtkFilePath *path)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
if (!impl->browse_files_model)
|
|
|
|
|
return;
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
_gtk_file_system_model_path_do (impl->browse_files_model, path,
|
2004-04-02 00:35:07 +00:00
|
|
|
|
unselect_func, impl);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-09-20 23:47:38 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
maybe_select (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
const GtkFileInfo *info;
|
|
|
|
|
gboolean is_folder;
|
|
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
|
|
|
|
|
|
|
|
|
info = get_list_file_info (impl, iter);
|
|
|
|
|
is_folder = gtk_file_info_get_is_folder (info);
|
|
|
|
|
|
|
|
|
|
if ((is_folder && impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) ||
|
|
|
|
|
(!is_folder && impl->action == GTK_FILE_CHOOSER_ACTION_OPEN))
|
|
|
|
|
gtk_tree_selection_select_iter (selection, iter);
|
|
|
|
|
else
|
|
|
|
|
gtk_tree_selection_unselect_iter (selection, iter);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_select_all (GtkFileChooser *chooser)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
if (impl->select_multiple)
|
2004-09-20 23:47:38 +00:00
|
|
|
|
gtk_tree_model_foreach (impl->sort_model, maybe_select, impl);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_unselect_all (GtkFileChooser *chooser)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
gtk_tree_selection_unselect_all (selection);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
/* Checks whether the filename entry for the Save modes contains a valid filename */
|
|
|
|
|
static GtkFilePath *
|
|
|
|
|
check_save_entry (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean *is_valid,
|
|
|
|
|
gboolean *is_empty)
|
|
|
|
|
{
|
2004-08-06 19:25:25 +00:00
|
|
|
|
GtkFileChooserEntry *chooser_entry;
|
|
|
|
|
const GtkFilePath *current_folder;
|
|
|
|
|
const char *file_part;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
GtkFilePath *path;
|
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
|
|
g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
|
|
|
|
|
|
2004-08-06 19:25:25 +00:00
|
|
|
|
chooser_entry = GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry);
|
|
|
|
|
|
|
|
|
|
current_folder = _gtk_file_chooser_entry_get_current_folder (chooser_entry);
|
|
|
|
|
file_part = _gtk_file_chooser_entry_get_file_part (chooser_entry);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-08-06 19:25:25 +00:00
|
|
|
|
if (!file_part || file_part[0] == '\0')
|
2004-03-05 00:10:59 +00:00
|
|
|
|
{
|
|
|
|
|
*is_valid = FALSE;
|
|
|
|
|
*is_empty = TRUE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*is_empty = FALSE;
|
|
|
|
|
|
|
|
|
|
error = NULL;
|
2004-08-06 19:25:25 +00:00
|
|
|
|
path = gtk_file_system_make_path (impl->file_system, current_folder, file_part, &error);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
|
|
|
|
if (!path)
|
|
|
|
|
{
|
2004-08-06 19:25:25 +00:00
|
|
|
|
error_building_filename_dialog (impl, current_folder, file_part, error);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
*is_valid = FALSE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*is_valid = TRUE;
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-08 23:38:57 +00:00
|
|
|
|
struct get_paths_closure {
|
|
|
|
|
GtkFileChooserDefault *impl;
|
2004-02-09 20:31:38 +00:00
|
|
|
|
GSList *result;
|
|
|
|
|
GtkFilePath *path_from_entry;
|
2003-12-08 23:38:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2003-04-04 22:43:12 +00:00
|
|
|
|
get_paths_foreach (GtkTreeModel *model,
|
2004-01-16 05:12:21 +00:00
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-12-08 23:38:57 +00:00
|
|
|
|
struct get_paths_closure *info;
|
2004-01-16 05:12:21 +00:00
|
|
|
|
const GtkFilePath *file_path;
|
|
|
|
|
GtkFileSystemModel *fs_model;
|
|
|
|
|
GtkTreeIter sel_iter;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-12-08 23:38:57 +00:00
|
|
|
|
info = data;
|
2004-03-07 04:41:36 +00:00
|
|
|
|
fs_model = info->impl->browse_files_model;
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (info->impl->sort_model, &sel_iter, iter);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
|
file_path = _gtk_file_system_model_get_path (fs_model, &sel_iter);
|
2004-03-15 23:15:31 +00:00
|
|
|
|
if (!file_path)
|
|
|
|
|
return; /* We are on the editable row */
|
2004-02-09 20:31:38 +00:00
|
|
|
|
|
|
|
|
|
if (!info->path_from_entry
|
|
|
|
|
|| gtk_file_path_compare (info->path_from_entry, file_path) != 0)
|
|
|
|
|
info->result = g_slist_prepend (info->result, gtk_file_path_copy (file_path));
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_get_paths (GtkFileChooser *chooser)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-12-08 23:38:57 +00:00
|
|
|
|
struct get_paths_closure info;
|
|
|
|
|
|
2004-02-09 20:31:38 +00:00
|
|
|
|
info.impl = impl;
|
|
|
|
|
info.result = NULL;
|
|
|
|
|
info.path_from_entry = NULL;
|
2003-12-08 23:38:57 +00:00
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-02-09 20:31:38 +00:00
|
|
|
|
{
|
2004-03-05 00:10:59 +00:00
|
|
|
|
gboolean is_valid, is_empty;
|
2004-01-16 05:12:21 +00:00
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
info.path_from_entry = check_save_entry (impl, &is_valid, &is_empty);
|
|
|
|
|
if (!is_valid && !is_empty)
|
|
|
|
|
return NULL;
|
2003-12-08 23:38:57 +00:00
|
|
|
|
}
|
2003-03-24 15:41:40 +00:00
|
|
|
|
|
2004-02-09 20:31:38 +00:00
|
|
|
|
if (!info.path_from_entry || impl->select_multiple)
|
2004-01-16 05:12:21 +00:00
|
|
|
|
{
|
2004-02-09 20:31:38 +00:00
|
|
|
|
GtkTreeSelection *selection;
|
2003-03-24 15:41:40 +00:00
|
|
|
|
|
2004-03-07 04:41:36 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
2004-03-05 00:10:59 +00:00
|
|
|
|
gtk_tree_selection_selected_foreach (selection, get_paths_foreach, &info);
|
2004-01-16 05:12:21 +00:00
|
|
|
|
}
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-02-09 20:31:38 +00:00
|
|
|
|
if (info.path_from_entry)
|
|
|
|
|
info.result = g_slist_prepend (info.result, info.path_from_entry);
|
2003-12-08 23:38:57 +00:00
|
|
|
|
|
2004-03-07 08:15:09 +00:00
|
|
|
|
/* If there's no folder selected, and we're in SELECT_FOLDER mode, then we
|
|
|
|
|
* fall back to the current directory */
|
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER &&
|
|
|
|
|
info.result == NULL)
|
|
|
|
|
{
|
|
|
|
|
info.result = g_slist_prepend (info.result, gtk_file_path_copy (impl->current_folder));
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
return g_slist_reverse (info.result);
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
static GtkFilePath *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_get_preview_path (GtkFileChooser *chooser)
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
if (impl->preview_path)
|
|
|
|
|
return gtk_file_path_copy (impl->preview_path);
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-04 22:43:12 +00:00
|
|
|
|
static GtkFileSystem *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_get_file_system (GtkFileChooser *chooser)
|
2003-04-04 22:43:12 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-04-04 22:43:12 +00:00
|
|
|
|
|
|
|
|
|
return impl->file_system;
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-10 20:49:44 +00:00
|
|
|
|
/* Shows or hides the filter widgets */
|
|
|
|
|
static void
|
2004-05-04 17:53:13 +00:00
|
|
|
|
show_filters (GtkFileChooserDefault *impl,
|
|
|
|
|
gboolean show)
|
2003-12-10 20:49:44 +00:00
|
|
|
|
{
|
|
|
|
|
if (show)
|
2004-05-04 17:53:13 +00:00
|
|
|
|
gtk_widget_show (impl->filter_combo_hbox);
|
2003-12-10 20:49:44 +00:00
|
|
|
|
else
|
2004-05-04 17:53:13 +00:00
|
|
|
|
gtk_widget_hide (impl->filter_combo_hbox);
|
2004-01-20 02:44:58 +00:00
|
|
|
|
}
|
2003-12-10 20:49:44 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_add_filter (GtkFileChooser *chooser,
|
|
|
|
|
GtkFileFilter *filter)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
|
|
if (g_slist_find (impl->filters, filter))
|
|
|
|
|
{
|
|
|
|
|
g_warning ("gtk_file_chooser_add_filter() called on filter already in list\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_ref (filter);
|
|
|
|
|
gtk_object_sink (GTK_OBJECT (filter));
|
|
|
|
|
impl->filters = g_slist_append (impl->filters, filter);
|
|
|
|
|
|
|
|
|
|
name = gtk_file_filter_get_name (filter);
|
|
|
|
|
if (!name)
|
|
|
|
|
name = "Untitled filter"; /* Place-holder, doesn't need to be marked for translation */
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-10-23 05:10:47 +00:00
|
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (impl->filter_combo), name);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
|
|
|
|
if (!g_slist_find (impl->filters, impl->current_filter))
|
|
|
|
|
set_current_filter (impl, filter);
|
|
|
|
|
|
2004-05-04 17:53:13 +00:00
|
|
|
|
show_filters (impl, TRUE);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_remove_filter (GtkFileChooser *chooser,
|
|
|
|
|
GtkFileFilter *filter)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-10-23 05:10:47 +00:00
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gint filter_index;
|
|
|
|
|
|
|
|
|
|
filter_index = g_slist_index (impl->filters, filter);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-10-28 14:13:01 +00:00
|
|
|
|
if (filter_index < 0)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
|
|
|
|
g_warning ("gtk_file_chooser_remove_filter() called on filter not in list\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl->filters = g_slist_remove (impl->filters, filter);
|
|
|
|
|
|
|
|
|
|
if (filter == impl->current_filter)
|
|
|
|
|
{
|
|
|
|
|
if (impl->filters)
|
|
|
|
|
set_current_filter (impl, impl->filters->data);
|
|
|
|
|
else
|
|
|
|
|
set_current_filter (impl, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-23 05:10:47 +00:00
|
|
|
|
/* Remove row from the combo box */
|
|
|
|
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (impl->filter_combo));
|
|
|
|
|
gtk_tree_model_iter_nth_child (model, &iter, NULL, filter_index);
|
|
|
|
|
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
|
2004-01-20 02:44:58 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
g_object_unref (filter);
|
|
|
|
|
|
|
|
|
|
if (!impl->filters)
|
2004-05-04 17:53:13 +00:00
|
|
|
|
show_filters (impl, FALSE);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_list_filters (GtkFileChooser *chooser)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
|
|
|
|
return g_slist_copy (impl->filters);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
/* Returns the position in the shortcuts tree where the nth specified shortcut would appear */
|
|
|
|
|
static int
|
2003-10-23 00:26:15 +00:00
|
|
|
|
shortcuts_get_pos_for_shortcut_folder (GtkFileChooserDefault *impl,
|
|
|
|
|
int pos)
|
2003-10-18 04:29:40 +00:00
|
|
|
|
{
|
2003-12-17 05:55:16 +00:00
|
|
|
|
return pos + shortcuts_get_index (impl, SHORTCUTS_SHORTCUTS);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError **error)
|
2003-10-08 04:14:55 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
gboolean result;
|
|
|
|
|
int pos;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
|
2004-03-15 02:09:22 +00:00
|
|
|
|
/* Test validity of path here. */
|
|
|
|
|
if (!check_is_folder (impl->file_system, path, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
pos = shortcuts_get_pos_for_shortcut_folder (impl, impl->num_shortcuts);
|
2003-10-08 04:14:55 +00:00
|
|
|
|
|
2004-01-07 17:07:18 +00:00
|
|
|
|
result = shortcuts_insert_path (impl, pos, FALSE, NULL, path, NULL, FALSE, error);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
impl->num_shortcuts++;
|
|
|
|
|
|
2004-03-05 06:51:22 +00:00
|
|
|
|
if (impl->shortcuts_filter_model)
|
|
|
|
|
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
|
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser *chooser,
|
|
|
|
|
const GtkFilePath *path,
|
|
|
|
|
GError **error)
|
2003-10-18 04:29:40 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
int pos;
|
|
|
|
|
GtkTreeIter iter;
|
2004-03-07 22:49:44 +00:00
|
|
|
|
char *uri;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (impl->num_shortcuts == 0)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
pos = shortcuts_get_pos_for_shortcut_folder (impl, 0);
|
|
|
|
|
if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < impl->num_shortcuts; i++)
|
|
|
|
|
{
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gpointer col_data;
|
|
|
|
|
gboolean is_volume;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
GtkFilePath *shortcut;
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
|
|
|
|
|
SHORTCUTS_COL_DATA, &col_data,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, &is_volume,
|
|
|
|
|
-1);
|
|
|
|
|
g_assert (col_data != NULL);
|
|
|
|
|
g_assert (!is_volume);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcut = col_data;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
if (gtk_file_path_compare (shortcut, path) == 0)
|
|
|
|
|
{
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcuts_remove_rows (impl, pos + i, 1);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
impl->num_shortcuts--;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
2004-03-07 22:49:44 +00:00
|
|
|
|
uri = gtk_file_system_path_to_uri (impl->file_system, path);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
g_set_error (error,
|
|
|
|
|
GTK_FILE_CHOOSER_ERROR,
|
|
|
|
|
GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
|
2003-11-03 20:24:04 +00:00
|
|
|
|
_("shortcut %s does not exist"),
|
2004-03-07 22:49:44 +00:00
|
|
|
|
uri);
|
|
|
|
|
g_free (uri);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser)
|
2003-10-08 04:14:55 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
int pos;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
int i;
|
|
|
|
|
GSList *list;
|
|
|
|
|
|
2004-03-01 18:24:06 +00:00
|
|
|
|
if (impl->num_shortcuts == 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
pos = shortcuts_get_pos_for_shortcut_folder (impl, 0);
|
|
|
|
|
if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
|
|
list = NULL;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < impl->num_shortcuts; i++)
|
|
|
|
|
{
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gpointer col_data;
|
|
|
|
|
gboolean is_volume;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
GtkFilePath *shortcut;
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
|
|
|
|
|
SHORTCUTS_COL_DATA, &col_data,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, &is_volume,
|
|
|
|
|
-1);
|
|
|
|
|
g_assert (col_data != NULL);
|
|
|
|
|
g_assert (!is_volume);
|
2003-10-18 04:29:40 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcut = col_data;
|
2003-10-18 04:29:40 +00:00
|
|
|
|
list = g_slist_prepend (list, gtk_file_path_copy (shortcut));
|
|
|
|
|
|
2004-03-01 18:24:06 +00:00
|
|
|
|
if (i != impl->num_shortcuts - 1)
|
|
|
|
|
{
|
|
|
|
|
if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
2003-10-18 04:29:40 +00:00
|
|
|
|
}
|
2003-10-08 04:14:55 +00:00
|
|
|
|
|
2003-10-18 04:29:40 +00:00
|
|
|
|
return g_slist_reverse (list);
|
2003-10-08 04:14:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-27 23:51:16 +00:00
|
|
|
|
/* Guesses a size based upon font sizes */
|
|
|
|
|
static void
|
|
|
|
|
find_good_size_from_style (GtkWidget *widget,
|
|
|
|
|
gint *width,
|
|
|
|
|
gint *height)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
gint default_width, default_height;
|
|
|
|
|
int font_size;
|
|
|
|
|
GtkRequisition req;
|
|
|
|
|
GtkRequisition preview_req;
|
|
|
|
|
|
|
|
|
|
g_assert (widget->style != NULL);
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (widget);
|
|
|
|
|
|
|
|
|
|
font_size = pango_font_description_get_size (widget->style->font_desc);
|
|
|
|
|
font_size = PANGO_PIXELS (font_size);
|
|
|
|
|
|
|
|
|
|
default_width = font_size * NUM_CHARS;
|
|
|
|
|
default_height = font_size * NUM_LINES;
|
|
|
|
|
|
|
|
|
|
/* Use at least the requisition size not including the preview widget */
|
|
|
|
|
gtk_widget_size_request (widget, &req);
|
|
|
|
|
|
|
|
|
|
if (impl->preview_widget_active && impl->preview_widget)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
gtk_widget_size_request (impl->preview_box, &preview_req);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
else
|
|
|
|
|
preview_req.width = 0;
|
|
|
|
|
|
|
|
|
|
default_width = MAX (default_width, (req.width - (preview_req.width + PREVIEW_HBOX_SPACING)));
|
|
|
|
|
default_height = MAX (default_height, req.height);
|
|
|
|
|
|
|
|
|
|
*width = default_width;
|
|
|
|
|
*height = default_height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_get_default_size (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
|
gint *default_width,
|
|
|
|
|
gint *default_height)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
|
|
|
|
|
|
|
|
|
|
find_good_size_from_style (GTK_WIDGET (chooser_embed), default_width, default_height);
|
|
|
|
|
|
|
|
|
|
if (impl->preview_widget_active && impl->preview_widget)
|
2004-02-29 07:55:24 +00:00
|
|
|
|
*default_width += impl->preview_box->requisition.width + PREVIEW_HBOX_SPACING;
|
2004-02-27 23:51:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_get_resizable_hints (GtkFileChooserEmbed *chooser_embed,
|
|
|
|
|
gboolean *resize_horizontally,
|
|
|
|
|
gboolean *resize_vertically)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
|
2004-03-02 20:09:20 +00:00
|
|
|
|
g_return_if_fail (resize_horizontally != NULL);
|
|
|
|
|
g_return_if_fail (resize_vertically != NULL);
|
2004-03-03 00:38:19 +00:00
|
|
|
|
|
2004-03-02 20:09:20 +00:00
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
|
2004-02-27 23:51:16 +00:00
|
|
|
|
|
2004-03-02 20:24:27 +00:00
|
|
|
|
*resize_horizontally = TRUE;
|
|
|
|
|
*resize_vertically = TRUE;
|
2004-03-03 00:38:19 +00:00
|
|
|
|
|
2004-03-02 20:09:20 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
|
|
|
|
|
impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-02-27 23:51:16 +00:00
|
|
|
|
{
|
2004-03-02 20:09:20 +00:00
|
|
|
|
if (! gtk_expander_get_expanded (GTK_EXPANDER (impl->save_expander)))
|
2004-02-27 23:51:16 +00:00
|
|
|
|
{
|
2004-03-02 20:09:20 +00:00
|
|
|
|
*resize_horizontally = FALSE;
|
2004-03-02 20:24:27 +00:00
|
|
|
|
*resize_vertically = FALSE;
|
2004-02-27 23:51:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
struct switch_folder_closure {
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
const GtkFilePath *path;
|
|
|
|
|
int num_selected;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Used from gtk_tree_selection_selected_foreach() in switch_to_selected_folder() */
|
|
|
|
|
static void
|
|
|
|
|
switch_folder_foreach_cb (GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
struct switch_folder_closure *closure;
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
|
|
|
|
|
closure = data;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
|
|
|
|
|
|
|
|
|
|
closure->path = _gtk_file_system_model_get_path (closure->impl->browse_files_model, &child_iter);
|
|
|
|
|
closure->num_selected++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Changes to the selected folder in the list view */
|
|
|
|
|
static void
|
|
|
|
|
switch_to_selected_folder (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
struct switch_folder_closure closure;
|
|
|
|
|
|
|
|
|
|
/* We do this with foreach() rather than get_selected() as we may be in
|
|
|
|
|
* multiple selection mode
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
closure.impl = impl;
|
|
|
|
|
closure.path = NULL;
|
|
|
|
|
closure.num_selected = 0;
|
|
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
|
|
|
|
gtk_tree_selection_selected_foreach (selection, switch_folder_foreach_cb, &closure);
|
|
|
|
|
|
|
|
|
|
g_assert (closure.path && closure.num_selected == 1);
|
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
change_folder_and_display_error (impl, closure.path);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation for GtkFileChooserEmbed::should_respond() */
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
2004-08-12 03:07:01 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
GtkWidget *current_focus;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
|
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (impl));
|
|
|
|
|
g_assert (GTK_IS_WINDOW (toplevel));
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
current_focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2004-09-22 20:17:53 +00:00
|
|
|
|
if (current_focus == impl->browse_files_tree_view)
|
2004-08-12 03:07:01 +00:00
|
|
|
|
{
|
|
|
|
|
int num_selected;
|
|
|
|
|
gboolean all_files, all_folders;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
file_list:
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
selection_check (impl, &num_selected, &all_files, &all_folders);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-09-22 20:17:53 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
|
|
|
{
|
|
|
|
|
if (num_selected != 1)
|
|
|
|
|
return TRUE; /* zero means current folder; more than one means use the whole selection */
|
|
|
|
|
else if (current_focus != impl->browse_files_tree_view)
|
|
|
|
|
{
|
|
|
|
|
/* a single folder is selected and a button was clicked */
|
|
|
|
|
switch_to_selected_folder (impl);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-08-12 03:07:01 +00:00
|
|
|
|
if (num_selected == 0)
|
2004-03-05 00:10:59 +00:00
|
|
|
|
{
|
2004-08-12 03:07:01 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
|
|
|
|
goto save_entry; /* it makes sense to use the typed name */
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
if (num_selected == 1 && all_folders)
|
|
|
|
|
{
|
|
|
|
|
switch_to_selected_folder (impl);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return all_files;
|
|
|
|
|
}
|
|
|
|
|
else if (current_focus == impl->save_file_name_entry)
|
2004-03-07 08:15:09 +00:00
|
|
|
|
{
|
2004-08-12 03:07:01 +00:00
|
|
|
|
GtkFilePath *path;
|
|
|
|
|
gboolean is_valid, is_empty;
|
|
|
|
|
gboolean is_folder;
|
|
|
|
|
gboolean retval;
|
2004-09-17 18:13:26 +00:00
|
|
|
|
GtkFileChooserEntry *entry;
|
2004-07-29 01:26:51 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
save_entry:
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-09-17 18:13:26 +00:00
|
|
|
|
entry = GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry);
|
2004-08-12 03:07:01 +00:00
|
|
|
|
path = check_save_entry (impl, &is_valid, &is_empty);
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-09-17 18:13:26 +00:00
|
|
|
|
if (!is_empty && !is_valid)
|
2004-08-12 03:07:01 +00:00
|
|
|
|
return FALSE;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
|
2004-09-17 18:13:26 +00:00
|
|
|
|
if (is_empty)
|
|
|
|
|
path = gtk_file_path_copy (_gtk_file_chooser_entry_get_current_folder (entry));
|
|
|
|
|
|
2004-08-12 03:07:01 +00:00
|
|
|
|
is_folder = check_is_folder (impl->file_system, path, NULL);
|
|
|
|
|
if (is_folder)
|
2004-03-05 00:10:59 +00:00
|
|
|
|
{
|
2004-09-17 18:13:26 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_file_part (entry, "");
|
2004-08-12 03:07:01 +00:00
|
|
|
|
change_folder_and_display_error (impl, path);
|
|
|
|
|
retval = FALSE;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2004-08-12 03:07:01 +00:00
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
gtk_file_path_free (path);
|
|
|
|
|
return retval;
|
2004-03-05 00:10:59 +00:00
|
|
|
|
}
|
2004-08-12 03:07:01 +00:00
|
|
|
|
else if (impl->toplevel_last_focus_widget == impl->browse_shortcuts_tree_view)
|
|
|
|
|
{
|
|
|
|
|
/* The focus is on a dialog's action area button, *and* the widget that
|
|
|
|
|
* was focused immediately before it is the shortcuts list. Switch to the
|
|
|
|
|
* selected shortcut and tell the caller not to respond.
|
|
|
|
|
*/
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
|
|
if (shortcuts_get_selected (impl, &iter))
|
2004-09-17 18:13:26 +00:00
|
|
|
|
{
|
|
|
|
|
shortcuts_activate_iter (impl, &iter);
|
|
|
|
|
|
|
|
|
|
gtk_widget_grab_focus (impl->browse_files_tree_view);
|
|
|
|
|
}
|
2004-08-12 03:07:01 +00:00
|
|
|
|
else
|
|
|
|
|
goto file_list;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-09-17 18:13:26 +00:00
|
|
|
|
else if (impl->toplevel_last_focus_widget == impl->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.
|
|
|
|
|
*/
|
|
|
|
|
goto file_list;
|
|
|
|
|
}
|
2004-08-12 03:07:01 +00:00
|
|
|
|
else
|
2004-09-17 18:13:26 +00:00
|
|
|
|
/* The focus is on a dialog's action area button or something else */
|
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
|
|
|
|
goto save_entry;
|
|
|
|
|
else
|
|
|
|
|
goto file_list;
|
|
|
|
|
|
2004-03-05 00:10:59 +00:00
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-08 22:21:47 +00:00
|
|
|
|
/* Implementation for GtkFileChooserEmbed::initial_focus() */
|
|
|
|
|
static void
|
|
|
|
|
gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl;
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
|
|
impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
|
|
|
|
|
|
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2004-03-08 23:16:03 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_indices (0, -1);
|
|
|
|
|
gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), path, NULL, FALSE);
|
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
|
|
widget = impl->browse_files_tree_view;
|
|
|
|
|
}
|
2004-03-08 22:21:47 +00:00
|
|
|
|
else if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
|
|
|
|
widget = impl->save_file_name_entry;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
widget = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_grab_focus (widget);
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
set_current_filter (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkFileFilter *filter)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
|
|
|
|
if (impl->current_filter != filter)
|
|
|
|
|
{
|
2003-10-23 05:10:47 +00:00
|
|
|
|
int filter_index;
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
|
|
|
|
/* If we have filters, new filter must be one of them
|
|
|
|
|
*/
|
2003-10-23 05:10:47 +00:00
|
|
|
|
filter_index = g_slist_index (impl->filters, filter);
|
|
|
|
|
if (impl->filters && filter_index < 0)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
return;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
if (impl->current_filter)
|
|
|
|
|
g_object_unref (impl->current_filter);
|
|
|
|
|
impl->current_filter = filter;
|
|
|
|
|
if (impl->current_filter)
|
|
|
|
|
{
|
|
|
|
|
g_object_ref (impl->current_filter);
|
|
|
|
|
gtk_object_sink (GTK_OBJECT (filter));
|
|
|
|
|
}
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-07-23 15:31:10 +00:00
|
|
|
|
if (impl->filters)
|
2003-10-23 05:10:47 +00:00
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (impl->filter_combo),
|
|
|
|
|
filter_index);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
2004-07-09 00:53:48 +00:00
|
|
|
|
if (impl->browse_files_model)
|
|
|
|
|
install_list_model_filter (impl);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (impl), "filter");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-10-23 05:10:47 +00:00
|
|
|
|
filter_combo_changed (GtkComboBox *combo_box,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-07-23 15:31:10 +00:00
|
|
|
|
{
|
2003-10-23 05:10:47 +00:00
|
|
|
|
gint new_index = gtk_combo_box_get_active (combo_box);
|
2003-07-23 15:31:10 +00:00
|
|
|
|
GtkFileFilter *new_filter = g_slist_nth_data (impl->filters, new_index);
|
|
|
|
|
|
|
|
|
|
set_current_filter (impl, new_filter);
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
check_preview_change (GtkFileChooserDefault *impl)
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
2004-03-25 21:52:04 +00:00
|
|
|
|
GtkTreePath *cursor_path;
|
|
|
|
|
const GtkFilePath *new_path;
|
|
|
|
|
const GtkFileInfo *new_info;
|
2003-07-23 22:30:32 +00:00
|
|
|
|
|
2004-03-25 21:52:04 +00:00
|
|
|
|
gtk_tree_view_get_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), &cursor_path, NULL);
|
2004-07-09 00:53:48 +00:00
|
|
|
|
if (cursor_path && impl->sort_model)
|
2003-07-23 22:30:32 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
2004-03-25 21:52:04 +00:00
|
|
|
|
GtkTreeIter child_iter;
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-03-25 21:52:04 +00:00
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->sort_model), &iter, cursor_path);
|
|
|
|
|
gtk_tree_path_free (cursor_path);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-03-25 21:52:04 +00:00
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &iter);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2004-03-25 21:52:04 +00:00
|
|
|
|
new_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
|
|
|
|
|
new_info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
new_path = NULL;
|
|
|
|
|
new_info = NULL;
|
2003-07-23 22:30:32 +00:00
|
|
|
|
}
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
if (new_path != impl->preview_path &&
|
|
|
|
|
!(new_path && impl->preview_path &&
|
|
|
|
|
gtk_file_path_compare (new_path, impl->preview_path) == 0))
|
|
|
|
|
{
|
|
|
|
|
if (impl->preview_path)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_file_path_free (impl->preview_path);
|
|
|
|
|
g_free (impl->preview_display_name);
|
|
|
|
|
}
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
if (new_path)
|
2004-02-29 06:35:15 +00:00
|
|
|
|
{
|
|
|
|
|
impl->preview_path = gtk_file_path_copy (new_path);
|
|
|
|
|
impl->preview_display_name = g_strdup (gtk_file_info_get_display_name (new_info));
|
|
|
|
|
}
|
2003-07-23 22:30:32 +00:00
|
|
|
|
else
|
2004-02-29 06:35:15 +00:00
|
|
|
|
{
|
|
|
|
|
impl->preview_path = NULL;
|
|
|
|
|
impl->preview_display_name = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (impl->use_preview_label && impl->preview_label)
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (impl->preview_label), impl->preview_display_name);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-07-23 22:30:32 +00:00
|
|
|
|
g_signal_emit_by_name (impl, "update-preview");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
/* Activates a volume by mounting it if necessary and then switching to its
|
|
|
|
|
* base path.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_activate_volume (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkFileSystemVolume *volume)
|
|
|
|
|
{
|
|
|
|
|
GtkFilePath *path;
|
|
|
|
|
|
2004-07-13 18:25:48 +00:00
|
|
|
|
/* We ref the file chooser since volume_mount() may run a main loop, and the
|
|
|
|
|
* user could close the file chooser window in the meantime.
|
|
|
|
|
*/
|
|
|
|
|
g_object_ref (impl);
|
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
if (!gtk_file_system_volume_get_is_mounted (impl->file_system, volume))
|
|
|
|
|
{
|
|
|
|
|
GError *error;
|
2004-07-13 18:25:48 +00:00
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
|
|
set_busy_cursor (impl, TRUE);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
|
|
|
|
error = NULL;
|
2004-07-13 18:25:48 +00:00
|
|
|
|
result = gtk_file_system_volume_mount (impl->file_system, volume, &error);
|
|
|
|
|
|
|
|
|
|
if (!result)
|
2003-12-17 05:55:16 +00:00
|
|
|
|
{
|
|
|
|
|
char *msg;
|
|
|
|
|
|
|
|
|
|
msg = g_strdup_printf ("Could not mount %s:\n%s",
|
|
|
|
|
gtk_file_system_volume_get_display_name (impl->file_system, volume),
|
|
|
|
|
error->message);
|
|
|
|
|
error_message (impl, msg);
|
|
|
|
|
g_free (msg);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2004-07-13 18:25:48 +00:00
|
|
|
|
|
|
|
|
|
set_busy_cursor (impl, FALSE);
|
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
goto out;
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
change_folder_and_display_error (impl, path);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
gtk_file_path_free (path);
|
2004-07-13 18:25:48 +00:00
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
|
|
g_object_unref (impl);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-29 01:26:51 +00:00
|
|
|
|
/* Opens the folder or volume at the specified iter in the shortcuts model */
|
2003-10-01 00:53:59 +00:00
|
|
|
|
static void
|
2004-07-29 01:26:51 +00:00
|
|
|
|
shortcuts_activate_iter (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkTreeIter *iter)
|
2003-10-01 00:53:59 +00:00
|
|
|
|
{
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gpointer col_data;
|
|
|
|
|
gboolean is_volume;
|
2003-10-15 03:06:55 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), iter,
|
|
|
|
|
SHORTCUTS_COL_DATA, &col_data,
|
|
|
|
|
SHORTCUTS_COL_IS_VOLUME, &is_volume,
|
|
|
|
|
-1);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (!col_data)
|
2004-09-20 23:47:38 +00:00
|
|
|
|
return; /* We are on a separator */
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
if (is_volume)
|
2003-10-09 01:12:24 +00:00
|
|
|
|
{
|
2003-12-17 05:55:16 +00:00
|
|
|
|
GtkFileSystemVolume *volume;
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
volume = col_data;
|
2004-09-17 18:13:26 +00:00
|
|
|
|
|
2003-12-17 05:55:16 +00:00
|
|
|
|
shortcuts_activate_volume (impl, volume);
|
2003-10-09 01:12:24 +00:00
|
|
|
|
}
|
2003-12-17 05:55:16 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2004-03-05 20:47:05 +00:00
|
|
|
|
const GtkFilePath *file_path;
|
2003-10-01 00:53:59 +00:00
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
file_path = col_data;
|
2004-03-05 20:47:05 +00:00
|
|
|
|
change_folder_and_display_error (impl, file_path);
|
2003-12-17 05:55:16 +00:00
|
|
|
|
}
|
2003-10-01 00:53:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
/* Callback used when a row in the shortcuts list is activated */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_row_activated_cb (GtkTreeView *tree_view,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter (impl->shortcuts_filter_model, &iter, path))
|
|
|
|
|
return;
|
|
|
|
|
|
2004-03-02 03:06:07 +00:00
|
|
|
|
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
|
2004-03-02 02:59:02 +00:00
|
|
|
|
&child_iter,
|
|
|
|
|
&iter);
|
2004-07-29 01:26:51 +00:00
|
|
|
|
shortcuts_activate_iter (impl, &child_iter);
|
2004-09-17 18:13:26 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_grab_focus (impl->browse_files_tree_view);
|
2004-03-02 02:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-04-29 23:13:50 +00:00
|
|
|
|
/* Handler for GtkWidget::key-press-event on the shortcuts list */
|
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_key_press_event_cb (GtkWidget *widget,
|
|
|
|
|
GdkEventKey *event,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
guint modifiers;
|
|
|
|
|
|
|
|
|
|
modifiers = gtk_accelerator_get_default_mod_mask ();
|
|
|
|
|
|
|
|
|
|
if ((event->keyval == GDK_BackSpace
|
|
|
|
|
|| event->keyval == GDK_Delete
|
|
|
|
|
|| event->keyval == GDK_KP_Delete)
|
|
|
|
|
&& (event->state & modifiers) == 0)
|
|
|
|
|
{
|
|
|
|
|
remove_selected_bookmarks (impl);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-01 20:17:37 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_select_func (GtkTreeSelection *selection,
|
|
|
|
|
GtkTreeModel *model,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkFileChooserDefault *impl = data;
|
|
|
|
|
|
2004-03-02 02:59:02 +00:00
|
|
|
|
return (*gtk_tree_path_get_indices (path) != shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR));
|
2003-11-01 20:17:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
list_selection_changed (GtkTreeSelection *selection,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2004-01-23 20:15:05 +00:00
|
|
|
|
/* See if we are in the new folder editable row for Save mode */
|
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
2004-01-17 04:34:49 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
GtkTreeIter iter, child_iter;
|
|
|
|
|
const GtkFileInfo *info;
|
|
|
|
|
|
2004-01-23 20:15:05 +00:00
|
|
|
|
g_assert (!impl->select_multiple);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
|
2004-01-17 04:34:49 +00:00
|
|
|
|
if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
|
|
|
|
|
&child_iter,
|
|
|
|
|
&iter);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
if (!info)
|
|
|
|
|
return; /* We are on the editable row for New Folder */
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 00:11:06 +00:00
|
|
|
|
update_chooser_entry (impl);
|
2003-07-23 22:30:32 +00:00
|
|
|
|
check_preview_change (impl);
|
2004-02-24 03:37:32 +00:00
|
|
|
|
bookmarks_check_add_sensitivity (impl);
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-07-11 19:18:36 +00:00
|
|
|
|
g_signal_emit_by_name (impl, "selection-changed", 0);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-11 00:33:28 +00:00
|
|
|
|
/* Callback used when a row in the file list is activated */
|
|
|
|
|
static void
|
2003-10-23 00:26:15 +00:00
|
|
|
|
list_row_activated (GtkTreeView *tree_view,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
|
GtkFileChooserDefault *impl)
|
2003-09-11 00:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter iter, child_iter;
|
|
|
|
|
const GtkFileInfo *info;
|
|
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->sort_model), &iter, path))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &iter);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
|
2003-09-11 00:33:28 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_file_info_get_is_folder (info))
|
|
|
|
|
{
|
|
|
|
|
const GtkFilePath *file_path;
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
file_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
change_folder_and_display_error (impl, file_path);
|
2003-09-11 00:33:28 +00:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (impl, "file-activated");
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-23 07:11:31 +00:00
|
|
|
|
static void
|
|
|
|
|
path_bar_clicked (GtkPathBar *path_bar,
|
2004-02-23 20:24:01 +00:00
|
|
|
|
GtkFilePath *file_path,
|
2004-04-02 00:35:07 +00:00
|
|
|
|
gboolean child_is_hidden,
|
2004-02-23 07:11:31 +00:00
|
|
|
|
GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-04-02 00:35:07 +00:00
|
|
|
|
if (!change_folder_and_display_error (impl, file_path))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Say we have "/foo/bar/[.baz]" and the user clicks on "bar". We should then
|
|
|
|
|
* show hidden files so that ".baz" appears in the file list, as it will still
|
|
|
|
|
* be shown in the path bar: "/foo/[bar]/.baz"
|
|
|
|
|
*/
|
|
|
|
|
if (child_is_hidden)
|
|
|
|
|
g_object_set (impl, "show-hidden", TRUE, NULL);
|
2004-02-23 07:11:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-16 21:07:38 +00:00
|
|
|
|
static const GtkFileInfo *
|
2003-10-23 00:26:15 +00:00
|
|
|
|
get_list_file_info (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkTreeIter *iter)
|
2003-03-21 23:59:22 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
|
|
|
|
|
&child_iter,
|
|
|
|
|
iter);
|
|
|
|
|
|
2004-02-25 08:55:48 +00:00
|
|
|
|
return _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
|
2003-03-21 23:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-16 21:07:38 +00:00
|
|
|
|
static void
|
|
|
|
|
list_icon_data_func (GtkTreeViewColumn *tree_column,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = data;
|
2003-11-19 17:03:32 +00:00
|
|
|
|
GtkTreeIter child_iter;
|
|
|
|
|
const GtkFilePath *path;
|
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
|
|
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
|
|
|
|
|
&child_iter,
|
|
|
|
|
iter);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
if (!path)
|
|
|
|
|
return;
|
2003-11-19 17:03:32 +00:00
|
|
|
|
|
|
|
|
|
/* FIXME: NULL GError */
|
2004-03-09 21:22:42 +00:00
|
|
|
|
pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
|
|
|
|
|
impl->icon_size, NULL);
|
2003-11-19 17:03:32 +00:00
|
|
|
|
g_object_set (cell,
|
|
|
|
|
"pixbuf", pixbuf,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
if (pixbuf)
|
|
|
|
|
g_object_unref (pixbuf);
|
2003-07-16 21:07:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 23:59:22 +00:00
|
|
|
|
static void
|
|
|
|
|
list_name_data_func (GtkTreeViewColumn *tree_column,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = data;
|
2003-03-21 23:59:22 +00:00
|
|
|
|
const GtkFileInfo *info = get_list_file_info (impl, iter);
|
|
|
|
|
|
2003-09-09 17:50:23 +00:00
|
|
|
|
if (!info)
|
2004-01-17 04:34:49 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_set (cell,
|
|
|
|
|
"text", _("Type name of new folder"),
|
|
|
|
|
NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-09-09 17:50:23 +00:00
|
|
|
|
|
2004-02-29 02:16:58 +00:00
|
|
|
|
g_object_set (cell,
|
|
|
|
|
"text", gtk_file_info_get_display_name (info),
|
|
|
|
|
NULL);
|
2003-03-21 23:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-09 15:18:29 +00:00
|
|
|
|
#if 0
|
2003-03-21 23:59:22 +00:00
|
|
|
|
static void
|
|
|
|
|
list_size_data_func (GtkTreeViewColumn *tree_column,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl = data;
|
2003-03-21 23:59:22 +00:00
|
|
|
|
const GtkFileInfo *info = get_list_file_info (impl, iter);
|
2004-01-17 04:34:49 +00:00
|
|
|
|
gint64 size;
|
2003-09-09 17:50:23 +00:00
|
|
|
|
gchar *str;
|
2003-03-21 23:59:22 +00:00
|
|
|
|
|
2003-09-09 17:50:23 +00:00
|
|
|
|
if (!info || gtk_file_info_get_is_folder (info))
|
|
|
|
|
return;
|
2003-03-21 23:59:22 +00:00
|
|
|
|
|
2004-01-17 04:34:49 +00:00
|
|
|
|
size = gtk_file_info_get_size (info);
|
|
|
|
|
|
2003-09-09 17:50:23 +00:00
|
|
|
|
if (size < (gint64)1024)
|
2003-12-31 16:02:22 +00:00
|
|
|
|
str = g_strdup_printf (ngettext ("%d byte", "%d bytes", (gint)size), (gint)size);
|
2003-09-09 17:50:23 +00:00
|
|
|
|
else if (size < (gint64)1024*1024)
|
2003-11-03 20:24:04 +00:00
|
|
|
|
str = g_strdup_printf (_("%.1f K"), size / (1024.));
|
2003-09-09 17:50:23 +00:00
|
|
|
|
else if (size < (gint64)1024*1024*1024)
|
2003-11-03 20:24:04 +00:00
|
|
|
|
str = g_strdup_printf (_("%.1f M"), size / (1024.*1024.));
|
2003-09-09 17:50:23 +00:00
|
|
|
|
else
|
2003-11-03 20:24:04 +00:00
|
|
|
|
str = g_strdup_printf (_("%.1f G"), size / (1024.*1024.*1024.));
|
2003-09-06 00:50:33 +00:00
|
|
|
|
|
2003-09-09 17:50:23 +00:00
|
|
|
|
g_object_set (cell,
|
|
|
|
|
"text", str,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
g_free (str);
|
2003-09-09 15:18:29 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Tree column data callback for the file list; fetches the mtime of a file */
|
|
|
|
|
static void
|
|
|
|
|
list_mtime_data_func (GtkTreeViewColumn *tree_column,
|
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
GtkFileChooserDefault *impl;
|
2003-09-09 15:18:29 +00:00
|
|
|
|
const GtkFileInfo *info;
|
2003-12-19 17:38:54 +00:00
|
|
|
|
GtkFileTime time_mtime, time_now;
|
|
|
|
|
GDate mtime, now;
|
|
|
|
|
int days_diff;
|
2003-09-09 15:18:29 +00:00
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
|
|
impl = data;
|
|
|
|
|
|
|
|
|
|
info = get_list_file_info (impl, iter);
|
|
|
|
|
if (!info)
|
2004-01-17 04:34:49 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_set (cell,
|
|
|
|
|
"text", "",
|
|
|
|
|
NULL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-09-09 15:18:29 +00:00
|
|
|
|
|
2003-12-19 17:38:54 +00:00
|
|
|
|
time_mtime = gtk_file_info_get_modification_time (info);
|
|
|
|
|
g_date_set_time (&mtime, (GTime) time_mtime);
|
2003-09-09 15:18:29 +00:00
|
|
|
|
|
2003-12-19 17:38:54 +00:00
|
|
|
|
time_now = (GTime ) time (NULL);
|
|
|
|
|
g_date_set_time (&now, (GTime) time_now);
|
2003-09-09 15:18:29 +00:00
|
|
|
|
|
2003-12-19 17:38:54 +00:00
|
|
|
|
days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
|
|
|
|
|
|
|
|
|
|
if (days_diff == 0)
|
2003-11-03 20:24:04 +00:00
|
|
|
|
strcpy (buf, _("Today"));
|
2003-12-19 17:38:54 +00:00
|
|
|
|
else if (days_diff == 1)
|
|
|
|
|
strcpy (buf, _("Yesterday"));
|
2003-09-09 15:18:29 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2003-12-19 17:38:54 +00:00
|
|
|
|
char *format;
|
2003-09-09 15:18:29 +00:00
|
|
|
|
|
2003-12-19 17:38:54 +00:00
|
|
|
|
if (days_diff > 1 && days_diff < 7)
|
|
|
|
|
format = "%A"; /* Days from last week */
|
|
|
|
|
else
|
2004-03-10 18:35:07 +00:00
|
|
|
|
format = "%x"; /* Any other date */
|
2003-09-09 15:18:29 +00:00
|
|
|
|
|
2003-12-19 17:38:54 +00:00
|
|
|
|
if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
|
|
|
|
|
strcpy (buf, _("Unknown"));
|
2003-09-09 15:18:29 +00:00
|
|
|
|
}
|
2003-03-21 23:59:22 +00:00
|
|
|
|
|
2004-02-29 02:16:58 +00:00
|
|
|
|
g_object_set (cell,
|
|
|
|
|
"text", buf,
|
|
|
|
|
NULL);
|
2003-03-21 23:59:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-21 20:34:02 +00:00
|
|
|
|
GtkWidget *
|
2004-02-19 07:43:39 +00:00
|
|
|
|
_gtk_file_chooser_default_new (const char *file_system)
|
2003-03-21 20:34:02 +00:00
|
|
|
|
{
|
2003-10-23 00:26:15 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_FILE_CHOOSER_DEFAULT,
|
2004-02-19 07:43:39 +00:00
|
|
|
|
"file-system-backend", file_system,
|
2003-03-26 17:09:26 +00:00
|
|
|
|
NULL);
|
2003-03-21 20:34:02 +00:00
|
|
|
|
}
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
|
location_entry_create (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
|
2004-08-17 16:06:39 +00:00
|
|
|
|
entry = _gtk_file_chooser_entry_new (TRUE);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
/* Pick a good width for the entry */
|
2004-03-11 06:08:28 +00:00
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (entry), 30);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
|
|
|
|
_gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (entry), impl->file_system);
|
|
|
|
|
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (entry), impl->current_folder);
|
2004-09-17 18:13:26 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (entry), impl->action);
|
2004-03-25 21:36:02 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2004-08-26 00:20:25 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (entry), "");
|
2004-03-25 21:36:02 +00:00
|
|
|
|
else if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
2004-08-26 00:20:25 +00:00
|
|
|
|
_gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (entry),
|
2004-08-25 19:10:38 +00:00
|
|
|
|
gtk_entry_get_text (GTK_ENTRY (impl->save_file_name_entry)));
|
2004-03-25 21:36:02 +00:00
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
return GTK_WIDGET (entry);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-08 20:06:50 +00:00
|
|
|
|
static gboolean
|
2004-02-23 19:55:49 +00:00
|
|
|
|
update_from_entry (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkWindow *parent,
|
|
|
|
|
GtkFileChooserEntry *chooser_entry)
|
|
|
|
|
{
|
|
|
|
|
const GtkFilePath *folder_path;
|
|
|
|
|
const char *file_part;
|
|
|
|
|
|
|
|
|
|
folder_path = _gtk_file_chooser_entry_get_current_folder (chooser_entry);
|
|
|
|
|
file_part = _gtk_file_chooser_entry_get_file_part (chooser_entry);
|
|
|
|
|
|
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN && !folder_path)
|
|
|
|
|
{
|
|
|
|
|
error_message_with_parent (parent,
|
|
|
|
|
_("Cannot change to the folder you specified as it is an invalid path."));
|
2004-03-08 20:06:50 +00:00
|
|
|
|
return FALSE;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file_part[0] == '\0')
|
2004-03-08 20:06:50 +00:00
|
|
|
|
return change_folder_and_display_error (impl, folder_path);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GtkFileFolder *folder = NULL;
|
|
|
|
|
GtkFilePath *subfolder_path = NULL;
|
|
|
|
|
GtkFileInfo *info = NULL;
|
|
|
|
|
GError *error;
|
2004-03-08 20:06:50 +00:00
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
|
|
result = FALSE;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
|
|
|
|
/* If the file part is non-empty, we need to figure out if it refers to a
|
|
|
|
|
* folder within folder. We could optimize the case here where the folder
|
|
|
|
|
* is already loaded for one of our tree models.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
error = NULL;
|
|
|
|
|
folder = gtk_file_system_get_folder (impl->file_system, folder_path, GTK_FILE_INFO_IS_FOLDER, &error);
|
|
|
|
|
|
|
|
|
|
if (!folder)
|
|
|
|
|
{
|
|
|
|
|
error_getting_info_dialog (impl, folder_path, error);
|
2004-03-08 20:06:50 +00:00
|
|
|
|
goto out;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error = NULL;
|
|
|
|
|
subfolder_path = gtk_file_system_make_path (impl->file_system, folder_path, file_part, &error);
|
|
|
|
|
|
|
|
|
|
if (!subfolder_path)
|
|
|
|
|
{
|
|
|
|
|
char *msg;
|
2004-03-07 22:49:44 +00:00
|
|
|
|
char *uri;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-03-07 22:49:44 +00:00
|
|
|
|
uri = gtk_file_system_path_to_uri (impl->file_system, folder_path);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
msg = g_strdup_printf (_("Could not build file name from '%s' and '%s':\n%s"),
|
2004-03-07 22:49:44 +00:00
|
|
|
|
uri, file_part,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
error->message);
|
|
|
|
|
error_message (impl, msg);
|
2004-03-07 22:49:44 +00:00
|
|
|
|
g_free (uri);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
g_free (msg);
|
2004-03-08 20:06:50 +00:00
|
|
|
|
goto out;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error = NULL;
|
|
|
|
|
info = gtk_file_folder_get_info (folder, subfolder_path, &error);
|
|
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
|
{
|
2004-03-15 19:23:54 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
|
|
|
|
{
|
|
|
|
|
if (!change_folder_and_display_error (impl, folder_path))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
gtk_file_chooser_default_set_current_name (GTK_FILE_CHOOSER (impl), file_part);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error_getting_info_dialog (impl, subfolder_path, error);
|
|
|
|
|
|
2004-03-08 20:06:50 +00:00
|
|
|
|
goto out;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gtk_file_info_get_is_folder (info))
|
2004-03-08 20:06:50 +00:00
|
|
|
|
result = change_folder_and_display_error (impl, subfolder_path);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
else
|
2004-03-05 20:47:05 +00:00
|
|
|
|
{
|
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
|
|
error = NULL;
|
2004-03-08 20:06:50 +00:00
|
|
|
|
result = _gtk_file_chooser_select_path (GTK_FILE_CHOOSER (impl), subfolder_path, &error);
|
|
|
|
|
if (!result)
|
|
|
|
|
error_dialog (impl,
|
|
|
|
|
_("Could not select %s:\n%s"),
|
|
|
|
|
subfolder_path, error);
|
2004-03-05 20:47:05 +00:00
|
|
|
|
}
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-03-08 20:06:50 +00:00
|
|
|
|
out:
|
|
|
|
|
|
|
|
|
|
if (folder)
|
|
|
|
|
g_object_unref (folder);
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
gtk_file_path_free (subfolder_path);
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
|
gtk_file_info_free (info);
|
|
|
|
|
|
|
|
|
|
return result;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
location_popup_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *dialog;
|
2004-03-29 19:52:16 +00:00
|
|
|
|
GtkWindow *toplevel;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GtkWidget *hbox;
|
|
|
|
|
GtkWidget *label;
|
|
|
|
|
GtkWidget *entry;
|
2004-03-08 20:06:50 +00:00
|
|
|
|
gboolean refocus;
|
2004-06-23 00:28:47 +00:00
|
|
|
|
const char *title;
|
|
|
|
|
const char *accept_stock;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
|
|
|
|
/* Create dialog */
|
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (impl));
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-03-15 18:12:51 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
|
|
|
{
|
|
|
|
|
title = _("Open Location");
|
2004-06-23 00:28:47 +00:00
|
|
|
|
accept_stock = GTK_STOCK_OPEN;
|
2004-03-15 18:12:51 +00:00
|
|
|
|
}
|
2004-03-15 23:15:31 +00:00
|
|
|
|
else
|
2004-03-15 18:12:51 +00:00
|
|
|
|
{
|
|
|
|
|
g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
|
2004-04-06 03:15:21 +00:00
|
|
|
|
title = _("Save in Location");
|
2004-06-23 00:28:47 +00:00
|
|
|
|
accept_stock = GTK_STOCK_SAVE;
|
2004-03-15 18:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dialog = gtk_dialog_new_with_buttons (title,
|
2004-03-29 19:52:16 +00:00
|
|
|
|
toplevel,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
|
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
2004-06-23 00:28:47 +00:00
|
|
|
|
accept_stock, GTK_RESPONSE_ACCEPT,
|
2004-02-23 19:55:49 +00:00
|
|
|
|
NULL);
|
2004-02-24 06:47:51 +00:00
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1);
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
|
|
|
|
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
|
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
|
2004-02-24 06:47:51 +00:00
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Location:"));
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
|
|
entry = location_entry_create (impl);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
|
|
|
|
|
|
|
|
|
|
/* Run */
|
|
|
|
|
|
|
|
|
|
gtk_widget_show_all (dialog);
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
|
|
|
|
refocus = TRUE;
|
|
|
|
|
|
2004-02-23 19:55:49 +00:00
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
2004-03-08 20:06:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (update_from_entry (impl, GTK_WINDOW (dialog), GTK_FILE_CHOOSER_ENTRY (entry)))
|
|
|
|
|
{
|
2004-03-15 14:10:45 +00:00
|
|
|
|
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_grab_focus (impl->browse_files_tree_view);
|
|
|
|
|
}
|
2004-03-15 23:15:31 +00:00
|
|
|
|
else
|
2004-03-15 14:10:45 +00:00
|
|
|
|
{
|
2004-03-15 18:12:51 +00:00
|
|
|
|
g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
|
|
|
|
|
|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
|
2004-03-15 14:10:45 +00:00
|
|
|
|
gtk_widget_grab_focus (impl->save_file_name_entry);
|
|
|
|
|
}
|
2004-03-08 20:06:50 +00:00
|
|
|
|
refocus = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (refocus)
|
|
|
|
|
{
|
2004-03-29 19:52:16 +00:00
|
|
|
|
GtkWindow *toplevel;
|
2004-03-08 20:06:50 +00:00
|
|
|
|
|
2004-03-29 19:52:16 +00:00
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (impl));
|
|
|
|
|
if (toplevel && toplevel->focus_widget)
|
|
|
|
|
gtk_widget_grab_focus (toplevel->focus_widget);
|
2004-03-08 20:06:50 +00:00
|
|
|
|
}
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handler for the "up-folder" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
up_folder_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-03-15 02:12:08 +00:00
|
|
|
|
_gtk_path_bar_up (GTK_PATH_BAR (impl->browse_path_bar));
|
|
|
|
|
}
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-03-15 02:12:08 +00:00
|
|
|
|
/* Handler for the "down-folder" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
down_folder_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
|
|
|
|
_gtk_path_bar_down (GTK_PATH_BAR (impl->browse_path_bar));
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handler for the "home-folder" keybinding signal */
|
|
|
|
|
static void
|
|
|
|
|
home_folder_handler (GtkFileChooserDefault *impl)
|
|
|
|
|
{
|
2004-03-05 20:47:05 +00:00
|
|
|
|
int pos;
|
|
|
|
|
GtkTreeIter iter;
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
if (!impl->has_home)
|
|
|
|
|
return; /* Should we put up an error dialog? */
|
2004-02-23 19:55:49 +00:00
|
|
|
|
|
2004-03-05 20:47:05 +00:00
|
|
|
|
pos = shortcuts_get_index (impl, SHORTCUTS_HOME);
|
|
|
|
|
if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
2004-08-18 16:30:58 +00:00
|
|
|
|
shortcuts_activate_iter (impl, &iter);
|
2004-02-23 19:55:49 +00:00
|
|
|
|
}
|
2004-03-11 06:24:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Drag and drop interfaces */
|
|
|
|
|
|
|
|
|
|
static void
|
2004-08-12 21:09:03 +00:00
|
|
|
|
_shortcuts_model_filter_class_init (ShortcutsModelFilterClass *class)
|
2004-03-11 06:24:15 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-08-12 21:09:03 +00:00
|
|
|
|
_shortcuts_model_filter_init (ShortcutsModelFilter *model)
|
2004-03-11 06:24:15 +00:00
|
|
|
|
{
|
|
|
|
|
model->impl = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* GtkTreeDragSource::row_draggable implementation for the shortcuts filter model */
|
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_model_filter_row_draggable (GtkTreeDragSource *drag_source,
|
|
|
|
|
GtkTreePath *path)
|
|
|
|
|
{
|
|
|
|
|
ShortcutsModelFilter *model;
|
|
|
|
|
int pos;
|
|
|
|
|
int bookmarks_pos;
|
|
|
|
|
|
|
|
|
|
model = SHORTCUTS_MODEL_FILTER (drag_source);
|
|
|
|
|
|
|
|
|
|
pos = *gtk_tree_path_get_indices (path);
|
|
|
|
|
bookmarks_pos = shortcuts_get_index (model->impl, SHORTCUTS_BOOKMARKS);
|
|
|
|
|
|
|
|
|
|
return (pos >= bookmarks_pos && pos < bookmarks_pos + model->impl->num_bookmarks);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* GtkTreeDragSource::drag_data_get implementation for the shortcuts filter model */
|
|
|
|
|
static gboolean
|
|
|
|
|
shortcuts_model_filter_drag_data_get (GtkTreeDragSource *drag_source,
|
|
|
|
|
GtkTreePath *path,
|
|
|
|
|
GtkSelectionData *selection_data)
|
|
|
|
|
{
|
|
|
|
|
ShortcutsModelFilter *model;
|
|
|
|
|
|
|
|
|
|
model = SHORTCUTS_MODEL_FILTER (drag_source);
|
|
|
|
|
|
|
|
|
|
/* FIXME */
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fill the GtkTreeDragSourceIface vtable */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->row_draggable = shortcuts_model_filter_row_draggable;
|
|
|
|
|
iface->drag_data_get = shortcuts_model_filter_drag_data_get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/* Fill the GtkTreeDragDestIface vtable */
|
|
|
|
|
static void
|
|
|
|
|
shortcuts_model_filter_drag_dest_iface_init (GtkTreeDragDestIface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->drag_data_received = shortcuts_model_filter_drag_data_received;
|
|
|
|
|
iface->row_drop_possible = shortcuts_model_filter_row_drop_possible;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static GtkTreeModel *
|
|
|
|
|
shortcuts_model_filter_new (GtkFileChooserDefault *impl,
|
|
|
|
|
GtkTreeModel *child_model,
|
|
|
|
|
GtkTreePath *root)
|
|
|
|
|
{
|
|
|
|
|
ShortcutsModelFilter *model;
|
|
|
|
|
|
|
|
|
|
model = g_object_new (SHORTCUTS_MODEL_FILTER_TYPE,
|
|
|
|
|
"child_model", child_model,
|
|
|
|
|
"virtual_root", root,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
model->impl = impl;
|
|
|
|
|
|
|
|
|
|
return GTK_TREE_MODEL (model);
|
|
|
|
|
}
|