2011-11-07 13:46:58 -06:00
|
|
|
/*
|
2016-10-06 14:17:48 -05:00
|
|
|
* xed-file-browser-widget.c - Xed plugin providing easy file access
|
2011-11-07 13:46:58 -06:00
|
|
|
* from the sidepanel
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-11-18 19:54:49 -06:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-11-07 13:46:58 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <glib/gi18n-lib.h>
|
2013-10-30 10:20:47 -05:00
|
|
|
#include <gtk/gtk.h>
|
2011-11-07 13:46:58 -06:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2015-08-03 10:04:03 -05:00
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
#include <xed/xed-utils.h>
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
#include "xed-file-browser-utils.h"
|
|
|
|
#include "xed-file-browser-error.h"
|
|
|
|
#include "xed-file-browser-widget.h"
|
|
|
|
#include "xed-file-browser-view.h"
|
|
|
|
#include "xed-file-browser-store.h"
|
|
|
|
#include "xed-file-bookmarks-store.h"
|
|
|
|
#include "xed-file-browser-marshal.h"
|
|
|
|
#include "xed-file-browser-enum-types.h"
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
#define XED_FILE_BROWSER_WIDGET_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
|
2017-01-09 13:57:48 -06:00
|
|
|
XED_TYPE_FILE_BROWSER_WIDGET, \
|
|
|
|
XedFileBrowserWidgetPrivate))
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
#define XML_UI_FILE "xed-file-browser-widget-ui.xml"
|
|
|
|
#define LOCATION_DATA_KEY "xed-file-browser-widget-location"
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
enum
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
BOOKMARKS_ID,
|
|
|
|
SEPARATOR_CUSTOM_ID,
|
|
|
|
SEPARATOR_ID,
|
|
|
|
PATH_ID,
|
|
|
|
NUM_DEFAULT_IDS
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
enum
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
COLUMN_INDENT,
|
|
|
|
COLUMN_ICON,
|
|
|
|
COLUMN_NAME,
|
|
|
|
COLUMN_FILE,
|
|
|
|
COLUMN_ID,
|
|
|
|
N_COLUMNS
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Properties */
|
2016-10-06 14:17:48 -05:00
|
|
|
enum
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_FILTER_PATTERN,
|
|
|
|
PROP_ENABLE_DELETE
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Signals */
|
2016-10-06 14:17:48 -05:00
|
|
|
enum
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
URI_ACTIVATED,
|
|
|
|
ERROR,
|
|
|
|
CONFIRM_DELETE,
|
|
|
|
CONFIRM_NO_TRASH,
|
|
|
|
NUM_SIGNALS
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[NUM_SIGNALS] = { 0 };
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
typedef struct _SignalNode
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GObject *object;
|
|
|
|
gulong id;
|
2011-11-07 13:46:58 -06:00
|
|
|
} SignalNode;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gulong id;
|
|
|
|
XedFileBrowserWidgetFilterFunc func;
|
|
|
|
gpointer user_data;
|
|
|
|
GDestroyNotify destroy_notify;
|
2011-11-07 13:46:58 -06:00
|
|
|
} FilterFunc;
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
typedef struct
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GFile *root;
|
|
|
|
GFile *virtual_root;
|
2011-11-07 13:46:58 -06:00
|
|
|
} Location;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar *name;
|
|
|
|
GdkPixbuf *icon;
|
2011-11-07 13:46:58 -06:00
|
|
|
} NameIcon;
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
struct _XedFileBrowserWidgetPrivate
|
|
|
|
{
|
|
|
|
XedFileBrowserView *treeview;
|
|
|
|
XedFileBrowserStore *file_store;
|
|
|
|
XedFileBookmarksStore *bookmarks_store;
|
|
|
|
|
|
|
|
GHashTable *bookmarks_hash;
|
|
|
|
|
|
|
|
GtkWidget *combo;
|
|
|
|
GtkTreeStore *combo_model;
|
|
|
|
|
|
|
|
GtkWidget *filter_expander;
|
|
|
|
GtkWidget *filter_entry;
|
|
|
|
|
|
|
|
GtkUIManager *manager;
|
|
|
|
GtkActionGroup *action_group;
|
|
|
|
GtkActionGroup *action_group_selection;
|
|
|
|
GtkActionGroup *action_group_file_selection;
|
|
|
|
GtkActionGroup *action_group_single_selection;
|
|
|
|
GtkActionGroup *action_group_single_most_selection;
|
|
|
|
GtkActionGroup *action_group_sensitive;
|
|
|
|
GtkActionGroup *bookmark_action_group;
|
|
|
|
|
|
|
|
GSList *signal_pool;
|
|
|
|
|
|
|
|
GSList *filter_funcs;
|
|
|
|
gulong filter_id;
|
|
|
|
gulong glob_filter_id;
|
|
|
|
GPatternSpec *filter_pattern;
|
|
|
|
gchar *filter_pattern_str;
|
|
|
|
|
|
|
|
GList *locations;
|
|
|
|
GList *current_location;
|
|
|
|
gboolean changing_location;
|
|
|
|
GtkWidget *location_previous_menu;
|
|
|
|
GtkWidget *location_next_menu;
|
|
|
|
GtkWidget *current_location_menu_item;
|
|
|
|
|
|
|
|
gboolean enable_delete;
|
|
|
|
|
|
|
|
GCancellable *cancellable;
|
|
|
|
|
|
|
|
GdkCursor *busy_cursor;
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static void set_enable_delete (XedFileBrowserWidget *obj,
|
|
|
|
gboolean enable);
|
|
|
|
static void on_model_set (GObject * gobject,
|
|
|
|
GParamSpec * arg1,
|
|
|
|
XedFileBrowserWidget * obj);
|
2016-02-04 03:20:42 -06:00
|
|
|
static void on_treeview_error (XedFileBrowserView * tree_view,
|
2016-10-06 14:17:48 -05:00
|
|
|
guint code,
|
|
|
|
gchar * message,
|
|
|
|
XedFileBrowserWidget * obj);
|
|
|
|
static void on_file_store_error (XedFileBrowserStore * store,
|
|
|
|
guint code,
|
|
|
|
gchar * message,
|
|
|
|
XedFileBrowserWidget * obj);
|
|
|
|
static gboolean on_file_store_no_trash (XedFileBrowserStore * store,
|
|
|
|
GList * files,
|
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_combo_changed (GtkComboBox * combo,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2016-02-04 03:20:42 -06:00
|
|
|
static gboolean on_treeview_popup_menu (XedFileBrowserView * treeview,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2016-02-04 03:20:42 -06:00
|
|
|
static gboolean on_treeview_button_press_event (XedFileBrowserView * treeview,
|
2016-10-06 14:17:48 -05:00
|
|
|
GdkEventButton * event,
|
|
|
|
XedFileBrowserWidget * obj);
|
|
|
|
static gboolean on_treeview_key_press_event (XedFileBrowserView * treeview,
|
|
|
|
GdkEventKey * event,
|
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_selection_changed (GtkTreeSelection * selection,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
static void on_virtual_root_changed (XedFileBrowserStore * model,
|
2016-10-06 14:17:48 -05:00
|
|
|
GParamSpec *param,
|
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
static gboolean on_entry_filter_activate (XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_location_jump_activate (GtkMenuItem * item,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
|
|
|
static void on_bookmarks_row_changed (GtkTreeModel * model,
|
2011-11-07 13:46:58 -06:00
|
|
|
GtkTreePath * path,
|
|
|
|
GtkTreeIter * iter,
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserWidget * obj);
|
2016-10-06 14:17:48 -05:00
|
|
|
static void on_bookmarks_row_deleted (GtkTreeModel * model,
|
2011-11-07 13:46:58 -06:00
|
|
|
GtkTreePath * path,
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserWidget * obj);
|
2016-10-06 14:17:48 -05:00
|
|
|
static void on_filter_mode_changed (XedFileBrowserStore * model,
|
2011-11-07 13:46:58 -06:00
|
|
|
GParamSpec * param,
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_directory_previous (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_directory_next (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_directory_up (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_directory_new (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_file_open (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_file_new (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_file_rename (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_file_delete (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_file_move_to_trash (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_directory_refresh (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_directory_open (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_filter_hidden (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_filter_binary (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
static void on_action_bookmark_open (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-12-26 15:25:50 -06:00
|
|
|
G_DEFINE_DYNAMIC_TYPE (XedFileBrowserWidget, xed_file_browser_widget,
|
2016-10-06 14:17:48 -05:00
|
|
|
GTK_TYPE_BOX)
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
static void
|
|
|
|
free_name_icon (gpointer data)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
NameIcon * item;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (data == NULL)
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
item = (NameIcon *)(data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (item->name);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (item->icon)
|
|
|
|
g_object_unref (item->icon);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (item);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static FilterFunc *
|
2016-02-04 03:20:42 -06:00
|
|
|
filter_func_new (XedFileBrowserWidget * obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidgetFilterFunc func,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify notify)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
FilterFunc *result;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
result = g_new (FilterFunc, 1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
result->id = ++obj->priv->filter_id;
|
|
|
|
result->func = func;
|
|
|
|
result->user_data = user_data;
|
|
|
|
result->destroy_notify = notify;
|
|
|
|
return result;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
location_free (Location * loc)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (loc->root)
|
|
|
|
g_object_unref (loc->root);
|
|
|
|
|
|
|
|
if (loc->virtual_root)
|
|
|
|
g_object_unref (loc->virtual_root);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (loc);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
combo_find_by_id (XedFileBrowserWidget * obj, guint id,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter * iter)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
guint checkid;
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL (obj->priv->combo_model);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (iter == NULL)
|
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (gtk_tree_model_get_iter_first (model, iter)) {
|
|
|
|
do {
|
|
|
|
gtk_tree_model_get (model, iter, COLUMN_ID,
|
|
|
|
&checkid, -1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (checkid == id)
|
|
|
|
return TRUE;
|
|
|
|
} while (gtk_tree_model_iter_next (model, iter));
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
remove_path_items (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter iter;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
while (combo_find_by_id (obj, PATH_ID, &iter))
|
|
|
|
gtk_tree_store_remove (obj->priv->combo_model, &iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
cancel_async_operation (XedFileBrowserWidget *widget)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!widget->priv->cancellable)
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_cancellable_cancel (widget->priv->cancellable);
|
|
|
|
g_object_unref (widget->priv->cancellable);
|
|
|
|
|
|
|
|
widget->priv->cancellable = NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_finalize (GObject * object)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget *obj = XED_FILE_BROWSER_WIDGET (object);
|
|
|
|
GList *loc;
|
|
|
|
|
|
|
|
remove_path_items (obj);
|
|
|
|
xed_file_browser_store_set_filter_func (obj->priv->file_store,
|
|
|
|
NULL, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_unref (obj->priv->manager);
|
|
|
|
g_object_unref (obj->priv->file_store);
|
|
|
|
g_object_unref (obj->priv->bookmarks_store);
|
|
|
|
g_object_unref (obj->priv->combo_model);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_slist_foreach (obj->priv->filter_funcs, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free (obj->priv->filter_funcs);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
for (loc = obj->priv->locations; loc; loc = loc->next)
|
|
|
|
location_free ((Location *) (loc->data));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (obj->priv->current_location_menu_item)
|
|
|
|
g_object_unref (obj->priv->current_location_menu_item);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_list_free (obj->priv->locations);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_hash_table_destroy (obj->priv->bookmarks_hash);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
cancel_async_operation (obj);
|
2015-11-19 18:46:26 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_unref (obj->priv->busy_cursor);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
G_OBJECT_CLASS (xed_file_browser_widget_parent_class)->finalize (object);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_get_property (GObject *object,
|
2016-10-06 14:17:48 -05:00
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget *obj = XED_FILE_BROWSER_WIDGET (object);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_FILTER_PATTERN:
|
|
|
|
g_value_set_string (value, obj->priv->filter_pattern_str);
|
|
|
|
break;
|
|
|
|
case PROP_ENABLE_DELETE:
|
|
|
|
g_value_set_boolean (value, obj->priv->enable_delete);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_set_property (GObject *object,
|
2016-10-06 14:17:48 -05:00
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget *obj = XED_FILE_BROWSER_WIDGET (object);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_FILTER_PATTERN:
|
|
|
|
xed_file_browser_widget_set_filter_pattern (obj,
|
|
|
|
g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_ENABLE_DELETE:
|
|
|
|
set_enable_delete (obj, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_class_init (XedFileBrowserWidgetClass * klass)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = xed_file_browser_widget_finalize;
|
|
|
|
|
|
|
|
object_class->get_property = xed_file_browser_widget_get_property;
|
|
|
|
object_class->set_property = xed_file_browser_widget_set_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_FILTER_PATTERN,
|
|
|
|
g_param_spec_string ("filter-pattern",
|
|
|
|
"Filter Pattern",
|
|
|
|
"The filter pattern",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (object_class, PROP_ENABLE_DELETE,
|
|
|
|
g_param_spec_boolean ("enable-delete",
|
|
|
|
"Enable delete",
|
|
|
|
"Enable permanently deleting items",
|
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
|
|
|
|
|
|
|
signals[URI_ACTIVATED] =
|
|
|
|
g_signal_new ("uri-activated",
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (XedFileBrowserWidgetClass,
|
|
|
|
uri_activated), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
signals[ERROR] =
|
|
|
|
g_signal_new ("error", G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (XedFileBrowserWidgetClass,
|
|
|
|
error), NULL, NULL,
|
|
|
|
xed_file_browser_marshal_VOID__UINT_STRING,
|
|
|
|
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
|
|
|
|
|
|
|
|
signals[CONFIRM_DELETE] =
|
|
|
|
g_signal_new ("confirm-delete", G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (XedFileBrowserWidgetClass,
|
|
|
|
confirm_delete),
|
|
|
|
g_signal_accumulator_true_handled,
|
|
|
|
NULL,
|
|
|
|
xed_file_browser_marshal_BOOL__OBJECT_POINTER,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
2,
|
|
|
|
G_TYPE_OBJECT,
|
|
|
|
G_TYPE_POINTER);
|
|
|
|
|
|
|
|
signals[CONFIRM_NO_TRASH] =
|
|
|
|
g_signal_new ("confirm-no-trash", G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (XedFileBrowserWidgetClass,
|
|
|
|
confirm_no_trash),
|
|
|
|
g_signal_accumulator_true_handled,
|
|
|
|
NULL,
|
|
|
|
xed_file_browser_marshal_BOOL__POINTER,
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
1,
|
|
|
|
G_TYPE_POINTER);
|
|
|
|
|
|
|
|
g_type_class_add_private (object_class,
|
|
|
|
sizeof (XedFileBrowserWidgetPrivate));
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:25:50 -06:00
|
|
|
static void
|
|
|
|
xed_file_browser_widget_class_finalize (XedFileBrowserWidgetClass *klass)
|
|
|
|
{
|
|
|
|
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE */
|
|
|
|
}
|
|
|
|
|
2011-11-07 13:46:58 -06:00
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
add_signal (XedFileBrowserWidget * obj, gpointer object, gulong id)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
SignalNode *node = g_new (SignalNode, 1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
node->object = G_OBJECT (object);
|
|
|
|
node->id = id;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->signal_pool =
|
|
|
|
g_slist_prepend (obj->priv->signal_pool, node);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
clear_signals (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GSList *item;
|
|
|
|
SignalNode *node;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
for (item = obj->priv->signal_pool; item; item = item->next) {
|
|
|
|
node = (SignalNode *) (item->data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_signal_handler_disconnect (node->object, node->id);
|
|
|
|
g_free (item->data);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_slist_free (obj->priv->signal_pool);
|
|
|
|
obj->priv->signal_pool = NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
separator_func (GtkTreeModel * model, GtkTreeIter * iter, gpointer data)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
guint id;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_model_get (model, iter, COLUMN_ID, &id, -1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return (id == SEPARATOR_ID);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
get_from_bookmark_file (XedFileBrowserWidget * obj, GFile * file,
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar ** name, GdkPixbuf ** icon)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gpointer data;
|
|
|
|
NameIcon * item;
|
|
|
|
|
|
|
|
data = g_hash_table_lookup (obj->priv->bookmarks_hash, file);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (data == NULL)
|
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
item = (NameIcon *)data;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
*name = g_strdup (item->name);
|
|
|
|
*icon = item->icon;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (item->icon != NULL)
|
|
|
|
{
|
|
|
|
g_object_ref (item->icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-06 14:17:48 -05:00
|
|
|
insert_path_item (XedFileBrowserWidget * obj,
|
2011-11-07 13:46:58 -06:00
|
|
|
GFile * file,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter * after,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
guint indent)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar * unescape;
|
|
|
|
GdkPixbuf * icon = NULL;
|
|
|
|
|
|
|
|
/* Try to get the icon and name from the bookmarks hash */
|
|
|
|
if (!get_from_bookmark_file (obj, file, &unescape, &icon)) {
|
|
|
|
/* It's not a bookmark, fetch the name and the icon ourselves */
|
|
|
|
unescape = xed_file_browser_utils_file_basename (file);
|
|
|
|
|
|
|
|
/* Get the icon */
|
|
|
|
icon = xed_file_browser_utils_pixbuf_from_file (file, GTK_ICON_SIZE_MENU);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_store_insert_after (obj->priv->combo_model, iter, NULL,
|
|
|
|
after);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_store_set (obj->priv->combo_model,
|
|
|
|
iter,
|
|
|
|
COLUMN_INDENT, indent,
|
|
|
|
COLUMN_ICON, icon,
|
|
|
|
COLUMN_NAME, unescape,
|
|
|
|
COLUMN_FILE, file,
|
|
|
|
COLUMN_ID, PATH_ID,
|
|
|
|
-1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (icon)
|
|
|
|
g_object_unref (icon);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (unescape);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
insert_separator_item (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter iter;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_store_insert (obj->priv->combo_model, &iter, NULL, 1);
|
|
|
|
gtk_tree_store_set (obj->priv->combo_model, &iter,
|
|
|
|
COLUMN_ICON, NULL,
|
|
|
|
COLUMN_NAME, NULL,
|
|
|
|
COLUMN_ID, SEPARATOR_ID, -1);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
combo_set_active_by_id (XedFileBrowserWidget * obj, guint id)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter iter;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (combo_find_by_id (obj, id, &iter))
|
|
|
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX
|
|
|
|
(obj->priv->combo), &iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
|
|
|
uri_num_parents (GFile * from, GFile * to)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
/* Determine the number of 'levels' to get from #from to #to. */
|
|
|
|
guint parents = 0;
|
|
|
|
GFile * parent;
|
|
|
|
|
|
|
|
if (from == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
g_object_ref (from);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
while ((parent = g_file_get_parent (from)) && !(to && g_file_equal (from, to))) {
|
|
|
|
g_object_unref (from);
|
|
|
|
from = parent;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
++parents;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (from);
|
|
|
|
return parents;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
insert_location_path (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
Location *loc;
|
|
|
|
GFile *current = NULL;
|
|
|
|
GFile * tmp;
|
|
|
|
GtkTreeIter separator;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
guint indent;
|
|
|
|
|
|
|
|
if (!obj->priv->current_location) {
|
|
|
|
g_message ("insert_location_path: no current location");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
loc = (Location *) (obj->priv->current_location->data);
|
|
|
|
|
|
|
|
current = loc->virtual_root;
|
|
|
|
combo_find_by_id (obj, SEPARATOR_ID, &separator);
|
|
|
|
|
|
|
|
indent = uri_num_parents (loc->virtual_root, loc->root);
|
|
|
|
|
|
|
|
while (current != NULL) {
|
|
|
|
insert_path_item (obj, current, &separator, &iter, indent--);
|
|
|
|
|
|
|
|
if (current == loc->virtual_root) {
|
|
|
|
g_signal_handlers_block_by_func (obj->priv->combo,
|
|
|
|
on_combo_changed,
|
|
|
|
obj);
|
|
|
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX
|
|
|
|
(obj->priv->combo),
|
|
|
|
&iter);
|
|
|
|
g_signal_handlers_unblock_by_func (obj->priv->
|
|
|
|
combo,
|
|
|
|
on_combo_changed,
|
|
|
|
obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_file_equal (current, loc->root) || !xed_utils_file_has_parent (current)) {
|
|
|
|
if (current != loc->virtual_root)
|
|
|
|
g_object_unref (current);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = g_file_get_parent (current);
|
|
|
|
|
|
|
|
if (current != loc->virtual_root)
|
|
|
|
g_object_unref (current);
|
|
|
|
|
|
|
|
current = tmp;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
check_current_item (XedFileBrowserWidget * obj, gboolean show_path)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter separator;
|
|
|
|
gboolean has_sep;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
remove_path_items (obj);
|
|
|
|
has_sep = combo_find_by_id (obj, SEPARATOR_ID, &separator);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (show_path) {
|
|
|
|
if (!has_sep)
|
|
|
|
insert_separator_item (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
insert_location_path (obj);
|
|
|
|
} else if (has_sep)
|
|
|
|
gtk_tree_store_remove (obj->priv->combo_model, &separator);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
fill_combo_model (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeStore *store = obj->priv->combo_model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GdkPixbuf *icon;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
icon = xed_file_browser_utils_pixbuf_from_theme (GTK_STOCK_HOME, GTK_ICON_SIZE_MENU);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_store_append (store, &iter, NULL);
|
|
|
|
gtk_tree_store_set (store, &iter,
|
|
|
|
COLUMN_ICON, icon,
|
|
|
|
COLUMN_NAME, _("Bookmarks"),
|
|
|
|
COLUMN_ID, BOOKMARKS_ID, -1);
|
|
|
|
g_object_unref (icon);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (obj->priv->combo),
|
|
|
|
separator_func, obj, NULL);
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (obj->priv->combo), 0);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-06 14:17:48 -05:00
|
|
|
indent_cell_data_func (GtkCellLayout * cell_layout,
|
2011-11-07 13:46:58 -06:00
|
|
|
GtkCellRenderer * cell,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel * model,
|
|
|
|
GtkTreeIter * iter,
|
2011-11-07 13:46:58 -06:00
|
|
|
gpointer data)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar * indent;
|
|
|
|
guint num;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter, COLUMN_INDENT, &num, -1);
|
|
|
|
|
|
|
|
if (num == 0)
|
|
|
|
g_object_set (cell, "text", "", NULL);
|
|
|
|
else {
|
|
|
|
indent = g_strnfill (num * 2, ' ');
|
|
|
|
|
|
|
|
g_object_set (cell, "text", indent, NULL);
|
|
|
|
g_free (indent);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
create_combo (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkCellRenderer *renderer;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->combo_model = gtk_tree_store_new (N_COLUMNS,
|
|
|
|
G_TYPE_UINT,
|
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_FILE,
|
|
|
|
G_TYPE_UINT);
|
|
|
|
obj->priv->combo =
|
|
|
|
gtk_combo_box_new_with_model (GTK_TREE_MODEL
|
|
|
|
(obj->priv->combo_model));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (obj->priv->combo),
|
|
|
|
renderer, FALSE);
|
|
|
|
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT
|
|
|
|
(obj->priv->combo), renderer,
|
|
|
|
indent_cell_data_func, obj, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
renderer = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (obj->priv->combo),
|
|
|
|
renderer, FALSE);
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (obj->priv->combo),
|
|
|
|
renderer, "pixbuf", COLUMN_ICON);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (obj->priv->combo),
|
|
|
|
renderer, TRUE);
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (obj->priv->combo),
|
|
|
|
renderer, "text", COLUMN_NAME);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_set (renderer, "ellipsize-set", TRUE,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_box_pack_start (GTK_BOX (obj), GTK_WIDGET (obj->priv->combo),
|
|
|
|
FALSE, FALSE, 0);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
fill_combo_model (obj);
|
|
|
|
g_signal_connect (obj->priv->combo, "changed",
|
|
|
|
G_CALLBACK (on_combo_changed), obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_widget_show (obj->priv->combo);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static GtkActionEntry toplevel_actions[] =
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
{"FilterMenuAction", NULL, N_("_Filter")}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static const GtkActionEntry tree_actions_selection[] =
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 15:24:36 -05:00
|
|
|
{"FileMoveToTrash", "user-trash", N_("_Move to Trash"), NULL,
|
2017-01-09 13:57:48 -06:00
|
|
|
N_("Move selected file or folder to trash"), G_CALLBACK (on_action_file_move_to_trash)},
|
2016-10-06 15:24:36 -05:00
|
|
|
{"FileDelete", "edit-delete-symbolic", N_("_Delete"), NULL,
|
2017-01-09 13:57:48 -06:00
|
|
|
N_("Delete selected file or folder"), G_CALLBACK (on_action_file_delete)}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static const GtkActionEntry tree_actions_file_selection[] =
|
|
|
|
{
|
2017-01-09 13:57:48 -06:00
|
|
|
{"FileOpen", "document-open-symbolic", N_("_Open"), NULL,
|
|
|
|
N_("Open selected file"), G_CALLBACK (on_action_file_open)}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static const GtkActionEntry tree_actions[] =
|
|
|
|
{
|
2016-10-06 15:24:36 -05:00
|
|
|
{"DirectoryUp", "go-up-symbolic", N_("Up"), NULL,
|
2016-10-06 14:17:48 -05:00
|
|
|
N_("Open the parent folder"), G_CALLBACK (on_action_directory_up)}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static const GtkActionEntry tree_actions_single_most_selection[] =
|
|
|
|
{
|
2016-10-06 15:24:36 -05:00
|
|
|
{"DirectoryNew", "folder-new-symbolic", N_("_New Folder"), NULL,
|
2017-01-09 13:57:48 -06:00
|
|
|
N_("Add new empty folder"), G_CALLBACK (on_action_directory_new)},
|
2016-10-06 15:24:36 -05:00
|
|
|
{"FileNew", "document-new-symbolic", N_("New F_ile"), NULL,
|
2016-10-06 14:17:48 -05:00
|
|
|
N_("Add new empty file"), G_CALLBACK (on_action_file_new)}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static const GtkActionEntry tree_actions_single_selection[] =
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
{"FileRename", NULL, N_("_Rename"), NULL,
|
2017-01-09 13:57:48 -06:00
|
|
|
N_("Rename selected file or folder"), G_CALLBACK (on_action_file_rename)}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static const GtkActionEntry tree_actions_sensitive[] =
|
|
|
|
{
|
2016-10-06 15:24:36 -05:00
|
|
|
{"DirectoryPrevious", "go-previous-symbolic", N_("_Previous Location"), NULL,
|
2017-01-09 13:57:48 -06:00
|
|
|
N_("Go to the previous visited location"), G_CALLBACK (on_action_directory_previous)},
|
2016-10-06 15:24:36 -05:00
|
|
|
{"DirectoryNext", "go-next-symbolic", N_("_Next Location"), NULL,
|
2016-10-06 14:17:48 -05:00
|
|
|
N_("Go to the next visited location"), G_CALLBACK (on_action_directory_next)},
|
2016-10-06 15:24:36 -05:00
|
|
|
{"DirectoryRefresh", "view-refresh-symbolic", N_("Re_fresh View"), NULL,
|
2016-10-06 14:17:48 -05:00
|
|
|
N_("Refresh the view"), G_CALLBACK (on_action_directory_refresh)},
|
2016-10-06 15:24:36 -05:00
|
|
|
{"DirectoryOpen", "folder-open-symbolic", N_("_View Folder"), NULL,
|
2017-01-09 13:57:48 -06:00
|
|
|
N_("View folder in file manager"), G_CALLBACK (on_action_directory_open)}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static const GtkToggleActionEntry tree_actions_toggle[] =
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2017-01-09 13:57:48 -06:00
|
|
|
{"FilterHidden", GTK_STOCK_DIALOG_AUTHENTICATION, N_("Show _Hidden"), NULL,
|
|
|
|
N_("Show hidden files and folders"), G_CALLBACK (on_action_filter_hidden), FALSE},
|
2016-10-06 14:17:48 -05:00
|
|
|
{"FilterBinary", NULL, N_("Show _Binary"), NULL,
|
2017-01-09 13:57:48 -06:00
|
|
|
N_("Show binary files"), G_CALLBACK (on_action_filter_binary), FALSE}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static const GtkActionEntry bookmark_actions[] =
|
|
|
|
{
|
2016-10-06 15:24:36 -05:00
|
|
|
{"BookmarkOpen", "folder-open-symbolic", N_("_View Folder"), NULL,
|
2016-10-06 14:17:48 -05:00
|
|
|
N_("View folder in file manager"), G_CALLBACK (on_action_bookmark_open)}
|
2011-11-07 13:46:58 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
create_toolbar (XedFileBrowserWidget * obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
const gchar *data_dir)
|
|
|
|
{
|
|
|
|
GtkUIManager *manager;
|
|
|
|
GError *error = NULL;
|
|
|
|
GtkActionGroup *action_group;
|
|
|
|
GtkWidget *toolbar;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkAction *action;
|
|
|
|
gchar *ui_file;
|
|
|
|
|
|
|
|
manager = gtk_ui_manager_new ();
|
|
|
|
obj->priv->manager = manager;
|
|
|
|
|
|
|
|
ui_file = g_build_filename (data_dir, XML_UI_FILE, NULL);
|
|
|
|
gtk_ui_manager_add_ui_from_file (manager, ui_file, &error);
|
|
|
|
|
|
|
|
g_free (ui_file);
|
|
|
|
|
|
|
|
if (error != NULL) {
|
|
|
|
g_warning ("Error in adding ui from file %s: %s",
|
|
|
|
XML_UI_FILE, error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("FileBrowserWidgetActionGroupToplevel");
|
|
|
|
gtk_action_group_set_translation_domain (action_group, NULL);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
toplevel_actions,
|
|
|
|
G_N_ELEMENTS (toplevel_actions),
|
|
|
|
obj);
|
|
|
|
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("FileBrowserWidgetActionGroup");
|
|
|
|
gtk_action_group_set_translation_domain (action_group, NULL);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
tree_actions,
|
|
|
|
G_N_ELEMENTS (tree_actions),
|
|
|
|
obj);
|
|
|
|
gtk_action_group_add_toggle_actions (action_group,
|
|
|
|
tree_actions_toggle,
|
|
|
|
G_N_ELEMENTS (tree_actions_toggle),
|
|
|
|
obj);
|
|
|
|
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
|
|
|
obj->priv->action_group = action_group;
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("FileBrowserWidgetSelectionActionGroup");
|
|
|
|
gtk_action_group_set_translation_domain (action_group, NULL);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
tree_actions_selection,
|
|
|
|
G_N_ELEMENTS (tree_actions_selection),
|
|
|
|
obj);
|
|
|
|
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
|
|
|
obj->priv->action_group_selection = action_group;
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("FileBrowserWidgetFileSelectionActionGroup");
|
|
|
|
gtk_action_group_set_translation_domain (action_group, NULL);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
tree_actions_file_selection,
|
|
|
|
G_N_ELEMENTS (tree_actions_file_selection),
|
|
|
|
obj);
|
|
|
|
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
|
|
|
obj->priv->action_group_file_selection = action_group;
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("FileBrowserWidgetSingleSelectionActionGroup");
|
|
|
|
gtk_action_group_set_translation_domain (action_group, NULL);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
tree_actions_single_selection,
|
|
|
|
G_N_ELEMENTS (tree_actions_single_selection),
|
|
|
|
obj);
|
|
|
|
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
|
|
|
obj->priv->action_group_single_selection = action_group;
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("FileBrowserWidgetSingleMostSelectionActionGroup");
|
|
|
|
gtk_action_group_set_translation_domain (action_group, NULL);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
tree_actions_single_most_selection,
|
|
|
|
G_N_ELEMENTS (tree_actions_single_most_selection),
|
|
|
|
obj);
|
|
|
|
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
|
|
|
obj->priv->action_group_single_most_selection = action_group;
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("FileBrowserWidgetSensitiveActionGroup");
|
|
|
|
gtk_action_group_set_translation_domain (action_group, NULL);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
tree_actions_sensitive,
|
|
|
|
G_N_ELEMENTS (tree_actions_sensitive),
|
|
|
|
obj);
|
|
|
|
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
|
|
|
obj->priv->action_group_sensitive = action_group;
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("FileBrowserWidgetBookmarkActionGroup");
|
|
|
|
gtk_action_group_set_translation_domain (action_group, NULL);
|
|
|
|
gtk_action_group_add_actions (action_group,
|
|
|
|
bookmark_actions,
|
|
|
|
G_N_ELEMENTS (bookmark_actions),
|
|
|
|
obj);
|
|
|
|
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
|
|
|
obj->priv->bookmark_action_group = action_group;
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
|
|
|
|
"DirectoryPrevious");
|
|
|
|
gtk_action_set_sensitive (action, FALSE);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
|
|
|
|
"DirectoryNext");
|
|
|
|
gtk_action_set_sensitive (action, FALSE);
|
|
|
|
|
|
|
|
toolbar = gtk_ui_manager_get_widget (manager, "/ToolBar");
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
|
|
|
|
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU);
|
|
|
|
|
|
|
|
/* Previous directory menu tool item */
|
|
|
|
obj->priv->location_previous_menu = gtk_menu_new ();
|
|
|
|
gtk_widget_show (obj->priv->location_previous_menu);
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (gtk_menu_tool_button_new_from_stock (GTK_STOCK_GO_BACK));
|
|
|
|
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (widget),
|
|
|
|
obj->priv->location_previous_menu);
|
|
|
|
|
|
|
|
g_object_set (widget, "label", _("Previous location"), NULL);
|
|
|
|
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (widget),
|
|
|
|
_("Go to previous location"));
|
|
|
|
gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (widget),
|
|
|
|
_("Go to a previously opened location"));
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
|
|
|
|
"DirectoryPrevious");
|
|
|
|
g_object_set (action, "is_important", TRUE, "short_label",
|
|
|
|
_("Previous location"), NULL);
|
|
|
|
gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget), 0);
|
|
|
|
|
|
|
|
/* Next directory menu tool item */
|
|
|
|
obj->priv->location_next_menu = gtk_menu_new ();
|
|
|
|
gtk_widget_show (obj->priv->location_next_menu);
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (gtk_menu_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD));
|
|
|
|
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (widget),
|
|
|
|
obj->priv->location_next_menu);
|
|
|
|
|
|
|
|
g_object_set (widget, "label", _("Next location"), NULL);
|
|
|
|
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (widget),
|
|
|
|
_("Go to next location"));
|
|
|
|
gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (widget),
|
|
|
|
_("Go to a previously opened location"));
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
|
|
|
|
"DirectoryNext");
|
|
|
|
g_object_set (action, "is_important", TRUE, "short_label",
|
|
|
|
_("Previous location"), NULL);
|
|
|
|
gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
|
|
|
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget), 1);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (obj), toolbar, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (toolbar);
|
|
|
|
|
|
|
|
set_enable_delete (obj, obj->priv->enable_delete);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
set_enable_delete (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
gboolean enable)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkAction *action;
|
|
|
|
obj->priv->enable_delete = enable;
|
|
|
|
|
|
|
|
if (obj->priv->action_group_selection == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
action =
|
|
|
|
gtk_action_group_get_action (obj->priv->action_group_selection,
|
|
|
|
"FileDelete");
|
|
|
|
|
|
|
|
g_object_set (action, "visible", enable, "sensitive", enable, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
filter_real (XedFileBrowserStore * model, GtkTreeIter * iter,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GSList *item;
|
|
|
|
FilterFunc *func;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
for (item = obj->priv->filter_funcs; item; item = item->next) {
|
|
|
|
func = (FilterFunc *) (item->data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!func->func (obj, model, iter, func->user_data))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return TRUE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
add_bookmark_hash (XedFileBrowserWidget * obj,
|
2011-11-07 13:46:58 -06:00
|
|
|
GtkTreeIter * iter)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GdkPixbuf * pixbuf;
|
|
|
|
gchar * name;
|
|
|
|
gchar * uri;
|
|
|
|
GFile * file;
|
|
|
|
NameIcon * item;
|
|
|
|
|
|
|
|
model = GTK_TREE_MODEL (obj->priv->bookmarks_store);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
uri = xed_file_bookmarks_store_get_uri (obj->priv->
|
|
|
|
bookmarks_store,
|
|
|
|
iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (uri == NULL)
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
file = g_file_new_for_uri (uri);
|
|
|
|
g_free (uri);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
XED_FILE_BOOKMARKS_STORE_COLUMN_ICON,
|
|
|
|
&pixbuf,
|
|
|
|
XED_FILE_BOOKMARKS_STORE_COLUMN_NAME,
|
|
|
|
&name, -1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
item = g_new (NameIcon, 1);
|
|
|
|
item->name = name;
|
|
|
|
item->icon = pixbuf;
|
|
|
|
|
|
|
|
g_hash_table_insert (obj->priv->bookmarks_hash,
|
|
|
|
file,
|
|
|
|
item);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
init_bookmarks_hash (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
model = GTK_TREE_MODEL (obj->priv->bookmarks_store);
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter_first (model, &iter))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
do {
|
|
|
|
add_bookmark_hash (obj, &iter);
|
|
|
|
} while (gtk_tree_model_iter_next (model, &iter));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_signal_connect (obj->priv->bookmarks_store,
|
|
|
|
"row-changed",
|
|
|
|
G_CALLBACK (on_bookmarks_row_changed),
|
|
|
|
obj);
|
|
|
|
|
|
|
|
g_signal_connect (obj->priv->bookmarks_store,
|
|
|
|
"row-deleted",
|
|
|
|
G_CALLBACK (on_bookmarks_row_deleted),
|
|
|
|
obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-06 14:17:48 -05:00
|
|
|
on_begin_loading (XedFileBrowserStore *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!GDK_IS_WINDOW (gtk_widget_get_window (GTK_WIDGET (obj->priv->treeview))))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (obj)),
|
|
|
|
obj->priv->busy_cursor);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-06 14:17:48 -05:00
|
|
|
on_end_loading (XedFileBrowserStore *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!GDK_IS_WINDOW (gtk_widget_get_window (GTK_WIDGET (obj->priv->treeview))))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (obj)), NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
create_tree (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkWidget *sw;
|
|
|
|
|
|
|
|
obj->priv->file_store = xed_file_browser_store_new (NULL);
|
|
|
|
obj->priv->bookmarks_store = xed_file_bookmarks_store_new ();
|
|
|
|
obj->priv->treeview =
|
|
|
|
XED_FILE_BROWSER_VIEW (xed_file_browser_view_new ());
|
|
|
|
|
|
|
|
xed_file_browser_view_set_restore_expand_state (obj->priv->treeview, TRUE);
|
|
|
|
|
|
|
|
xed_file_browser_store_set_filter_mode (obj->priv->file_store,
|
|
|
|
XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN
|
|
|
|
|
|
|
|
|
XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY);
|
|
|
|
xed_file_browser_store_set_filter_func (obj->priv->file_store,
|
|
|
|
(XedFileBrowserStoreFilterFunc)
|
|
|
|
filter_real, obj);
|
|
|
|
|
|
|
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (sw),
|
|
|
|
GTK_WIDGET (obj->priv->treeview));
|
|
|
|
gtk_box_pack_start (GTK_BOX (obj), sw, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
g_signal_connect (obj->priv->treeview, "notify::model",
|
|
|
|
G_CALLBACK (on_model_set), obj);
|
|
|
|
g_signal_connect (obj->priv->treeview, "error",
|
|
|
|
G_CALLBACK (on_treeview_error), obj);
|
|
|
|
g_signal_connect (obj->priv->treeview, "popup-menu",
|
|
|
|
G_CALLBACK (on_treeview_popup_menu), obj);
|
|
|
|
g_signal_connect (obj->priv->treeview, "button-press-event",
|
|
|
|
G_CALLBACK (on_treeview_button_press_event),
|
|
|
|
obj);
|
|
|
|
g_signal_connect (obj->priv->treeview, "key-press-event",
|
|
|
|
G_CALLBACK (on_treeview_key_press_event), obj);
|
|
|
|
|
|
|
|
g_signal_connect (gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW (obj->priv->treeview)), "changed",
|
|
|
|
G_CALLBACK (on_selection_changed), obj);
|
|
|
|
g_signal_connect (obj->priv->file_store, "notify::filter-mode",
|
|
|
|
G_CALLBACK (on_filter_mode_changed), obj);
|
|
|
|
|
|
|
|
g_signal_connect (obj->priv->file_store, "notify::virtual-root",
|
|
|
|
G_CALLBACK (on_virtual_root_changed), obj);
|
|
|
|
|
|
|
|
g_signal_connect (obj->priv->file_store, "begin-loading",
|
|
|
|
G_CALLBACK (on_begin_loading), obj);
|
|
|
|
|
|
|
|
g_signal_connect (obj->priv->file_store, "end-loading",
|
|
|
|
G_CALLBACK (on_end_loading), obj);
|
|
|
|
|
|
|
|
g_signal_connect (obj->priv->file_store, "error",
|
|
|
|
G_CALLBACK (on_file_store_error), obj);
|
|
|
|
|
|
|
|
init_bookmarks_hash (obj);
|
|
|
|
|
|
|
|
gtk_widget_show (sw);
|
|
|
|
gtk_widget_show (GTK_WIDGET (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
create_filter (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkWidget *expander;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *entry;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
expander = gtk_expander_new_with_mnemonic (_("_Match Filename"));
|
|
|
|
gtk_widget_show (expander);
|
|
|
|
gtk_box_pack_start (GTK_BOX (obj), expander, FALSE, FALSE, 0);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
|
|
|
gtk_widget_show (vbox);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->filter_expander = expander;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
entry = gtk_entry_new ();
|
|
|
|
gtk_widget_show (entry);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->filter_entry = entry;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_signal_connect_swapped (entry, "activate",
|
|
|
|
G_CALLBACK (on_entry_filter_activate),
|
|
|
|
obj);
|
|
|
|
g_signal_connect_swapped (entry, "focus_out_event",
|
|
|
|
G_CALLBACK (on_entry_filter_activate),
|
|
|
|
obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (expander), vbox);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_init (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv = XED_FILE_BROWSER_WIDGET_GET_PRIVATE (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->bookmarks_hash = g_hash_table_new_full (g_file_hash,
|
|
|
|
(GEqualFunc)g_file_equal,
|
|
|
|
g_object_unref,
|
|
|
|
free_name_icon);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_box_set_spacing (GTK_BOX (obj), 3);
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (obj),
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
|
|
|
obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Private */
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
update_sensitivity (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model =
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
GtkAction *action;
|
|
|
|
gint mode;
|
|
|
|
|
|
|
|
if (XED_IS_FILE_BROWSER_STORE (model)) {
|
|
|
|
gtk_action_group_set_sensitive (obj->priv->action_group,
|
|
|
|
TRUE);
|
|
|
|
gtk_action_group_set_sensitive (obj->priv->bookmark_action_group,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
mode =
|
|
|
|
xed_file_browser_store_get_filter_mode
|
|
|
|
(XED_FILE_BROWSER_STORE (model));
|
|
|
|
|
|
|
|
action =
|
|
|
|
gtk_action_group_get_action (obj->priv->action_group,
|
|
|
|
"FilterHidden");
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
|
|
|
|
!(mode &
|
|
|
|
XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN));
|
|
|
|
} else if (XED_IS_FILE_BOOKMARKS_STORE (model)) {
|
|
|
|
gtk_action_group_set_sensitive (obj->priv->action_group,
|
|
|
|
FALSE);
|
|
|
|
gtk_action_group_set_sensitive (obj->priv->bookmark_action_group,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
/* Set the filter toggle to normal up state, just for visual pleasure */
|
|
|
|
action =
|
|
|
|
gtk_action_group_get_action (obj->priv->action_group,
|
|
|
|
"FilterHidden");
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
on_selection_changed (gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW (obj->priv->treeview)), obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_get_first_selected (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter *iter)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GList *rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
if (!rows)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
result = gtk_tree_model_get_iter(model, iter, (GtkTreePath *)(rows->data));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
|
|
|
g_list_free (rows);
|
|
|
|
|
|
|
|
return result;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
popup_menu (XedFileBrowserWidget * obj, GdkEventButton * event, GtkTreeModel * model)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkWidget *menu;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
menu = gtk_ui_manager_get_widget (obj->priv->manager, "/FilePopup");
|
|
|
|
else if (XED_IS_FILE_BOOKMARKS_STORE (model))
|
|
|
|
menu = gtk_ui_manager_get_widget (obj->priv->manager, "/BookmarkPopup");
|
|
|
|
else
|
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_return_val_if_fail (menu != NULL, FALSE);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (event != NULL) {
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (gtk_tree_selection_count_selected_rows (selection) <= 1) {
|
|
|
|
GtkTreePath *path;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (obj->priv->treeview),
|
|
|
|
(gint)event->x, (gint)event->y,
|
|
|
|
&path, NULL, NULL, NULL))
|
|
|
|
{
|
|
|
|
gtk_tree_selection_unselect_all (selection);
|
|
|
|
gtk_tree_selection_select_path (selection, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
|
|
|
|
event->button, event->time);
|
|
|
|
} else {
|
|
|
|
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
|
|
|
|
xed_utils_menu_position_under_tree_view,
|
|
|
|
obj->priv->treeview, 0,
|
|
|
|
gtk_get_current_event_time ());
|
|
|
|
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return TRUE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
filter_glob (XedFileBrowserWidget * obj, XedFileBrowserStore * store,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter * iter, gpointer user_data)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar *name;
|
|
|
|
gboolean result;
|
|
|
|
guint flags;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (obj->priv->filter_pattern == NULL)
|
|
|
|
return TRUE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_NAME, &name,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
|
|
|
|
-1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (FILE_IS_DIR (flags) || FILE_IS_DUMMY (flags))
|
|
|
|
result = TRUE;
|
|
|
|
else
|
|
|
|
result =
|
|
|
|
g_pattern_match_string (obj->priv->filter_pattern,
|
|
|
|
name);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (name);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return result;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
rename_selected_file (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (xed_file_browser_widget_get_first_selected (obj, &iter))
|
|
|
|
xed_file_browser_view_start_rename (obj->priv->treeview,
|
|
|
|
&iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
2016-02-04 03:20:42 -06:00
|
|
|
get_deletable_files (XedFileBrowserWidget *obj) {
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GList *rows;
|
|
|
|
GList *row;
|
|
|
|
GList *paths = NULL;
|
|
|
|
guint flags;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
|
|
|
|
/* Get all selected files */
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
|
|
|
|
|
|
|
for (row = rows; row; row = row->next) {
|
|
|
|
path = (GtkTreePath *)(row->data);
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_FLAGS,
|
|
|
|
&flags, -1);
|
|
|
|
|
|
|
|
if (FILE_IS_DUMMY (flags))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
paths = g_list_append (paths, gtk_tree_path_copy (path));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
|
|
|
g_list_free (rows);
|
|
|
|
|
|
|
|
return paths;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
delete_selected_files (XedFileBrowserWidget * obj, gboolean trash)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
gboolean confirm;
|
|
|
|
XedFileBrowserStoreResult result;
|
|
|
|
GList *rows;
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
rows = get_deletable_files (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!rows)
|
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!trash) {
|
|
|
|
g_signal_emit (obj, signals[CONFIRM_DELETE], 0, model, rows, &confirm);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!confirm)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
result = xed_file_browser_store_delete_all (XED_FILE_BROWSER_STORE (model),
|
|
|
|
rows, trash);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
|
|
|
g_list_free (rows);
|
|
|
|
|
|
|
|
return result == XED_FILE_BROWSER_STORE_RESULT_OK;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-10-06 14:17:48 -05:00
|
|
|
on_file_store_no_trash (XedFileBrowserStore * store,
|
|
|
|
GList * files,
|
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gboolean confirm = FALSE;
|
|
|
|
|
|
|
|
g_signal_emit (obj, signals[CONFIRM_NO_TRASH], 0, files, &confirm);
|
|
|
|
|
|
|
|
return confirm;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static GFile *
|
|
|
|
get_topmost_file (GFile * file)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GFile * tmp;
|
|
|
|
GFile * current;
|
|
|
|
|
|
|
|
current = g_object_ref (file);
|
|
|
|
|
|
|
|
while ((tmp = g_file_get_parent (current)) != NULL) {
|
|
|
|
g_object_unref (current);
|
|
|
|
current = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return current;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
2016-02-04 03:20:42 -06:00
|
|
|
create_goto_menu_item (XedFileBrowserWidget * obj, GList * item,
|
2016-10-06 14:17:48 -05:00
|
|
|
GdkPixbuf * icon)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkWidget *result;
|
|
|
|
GtkWidget *image;
|
|
|
|
gchar *unescape;
|
|
|
|
GdkPixbuf *pixbuf = NULL;
|
|
|
|
Location *loc;
|
|
|
|
|
|
|
|
loc = (Location *) (item->data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!get_from_bookmark_file (obj, loc->virtual_root, &unescape, &pixbuf)) {
|
|
|
|
unescape = xed_file_browser_utils_file_basename (loc->virtual_root);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (icon)
|
|
|
|
pixbuf = g_object_ref (icon);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (pixbuf) {
|
|
|
|
image = gtk_image_new_from_pixbuf (pixbuf);
|
|
|
|
g_object_unref (pixbuf);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_widget_show (image);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
result = gtk_image_menu_item_new_with_label (unescape);
|
|
|
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (result),
|
|
|
|
image);
|
|
|
|
} else {
|
|
|
|
result = gtk_menu_item_new_with_label (unescape);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_set_data (G_OBJECT (result), LOCATION_DATA_KEY, item);
|
|
|
|
g_signal_connect (result, "activate",
|
|
|
|
G_CALLBACK (on_location_jump_activate), obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_widget_show (result);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (unescape);
|
|
|
|
|
|
|
|
return result;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
list_next_iterator (GList * list)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!list)
|
|
|
|
return NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return list->next;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
list_prev_iterator (GList * list)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!list)
|
|
|
|
return NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return list->prev;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
jump_to_location (XedFileBrowserWidget * obj, GList * item,
|
2016-10-06 14:17:48 -05:00
|
|
|
gboolean previous)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
Location *loc;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GList *children;
|
|
|
|
GList *child;
|
|
|
|
GList *(*iter_func) (GList *);
|
|
|
|
GtkWidget *menu_from;
|
|
|
|
GtkWidget *menu_to;
|
|
|
|
gchar *root;
|
|
|
|
gchar *virtual_root;
|
|
|
|
|
|
|
|
if (!obj->priv->locations)
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (previous) {
|
|
|
|
iter_func = list_next_iterator;
|
|
|
|
menu_from = obj->priv->location_previous_menu;
|
|
|
|
menu_to = obj->priv->location_next_menu;
|
|
|
|
} else {
|
|
|
|
iter_func = list_prev_iterator;
|
|
|
|
menu_from = obj->priv->location_next_menu;
|
|
|
|
menu_to = obj->priv->location_previous_menu;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (menu_from));
|
|
|
|
child = children;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
/* This is the menuitem for the current location, which is the first
|
|
|
|
to be added to the menu */
|
|
|
|
widget = obj->priv->current_location_menu_item;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
while (obj->priv->current_location != item) {
|
|
|
|
if (widget) {
|
|
|
|
/* Prepend the menu item to the menu */
|
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu_to),
|
|
|
|
widget);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_unref (widget);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
widget = GTK_WIDGET (child->data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
/* Make sure the widget isn't destroyed when removed */
|
|
|
|
g_object_ref (widget);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (menu_from), widget);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->current_location_menu_item = widget;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (obj->priv->current_location == NULL) {
|
|
|
|
obj->priv->current_location = obj->priv->locations;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (obj->priv->current_location == item)
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
obj->priv->current_location =
|
|
|
|
iter_func (obj->priv->current_location);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
child = child->next;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_list_free (children);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->changing_location = TRUE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_assert (obj->priv->current_location != NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
loc = (Location *) (obj->priv->current_location->data);
|
2013-09-24 18:46:53 -05:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
/* Set the new root + virtual root */
|
|
|
|
root = g_file_get_uri (loc->root);
|
|
|
|
virtual_root = g_file_get_uri (loc->virtual_root);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_widget_set_root_and_virtual_root (obj,
|
|
|
|
root,
|
|
|
|
virtual_root);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (root);
|
|
|
|
g_free (virtual_root);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->changing_location = FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
clear_next_locations (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GList *children;
|
|
|
|
GList *item;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (obj->priv->current_location == NULL)
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
while (obj->priv->current_location->prev) {
|
|
|
|
location_free ((Location *) (obj->priv->current_location->
|
|
|
|
prev->data));
|
|
|
|
obj->priv->locations =
|
|
|
|
g_list_remove_link (obj->priv->locations,
|
|
|
|
obj->priv->current_location->prev);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
children =
|
|
|
|
gtk_container_get_children (GTK_CONTAINER
|
|
|
|
(obj->priv->location_next_menu));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
for (item = children; item; item = item->next) {
|
|
|
|
gtk_container_remove (GTK_CONTAINER
|
|
|
|
(obj->priv->location_next_menu),
|
|
|
|
GTK_WIDGET (item->data));
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_list_free (children);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_action_set_sensitive (gtk_action_group_get_action
|
|
|
|
(obj->priv->action_group_sensitive,
|
|
|
|
"DirectoryNext"), FALSE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-06 14:17:48 -05:00
|
|
|
update_filter_mode (XedFileBrowserWidget * obj,
|
|
|
|
GtkAction * action,
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserStoreFilterMode mode)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gboolean active =
|
|
|
|
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
GtkTreeModel *model =
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
gint now;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (XED_IS_FILE_BROWSER_STORE (model)) {
|
|
|
|
now =
|
|
|
|
xed_file_browser_store_get_filter_mode
|
|
|
|
(XED_FILE_BROWSER_STORE (model));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (active)
|
|
|
|
now &= ~mode;
|
|
|
|
else
|
|
|
|
now |= mode;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_store_set_filter_mode
|
|
|
|
(XED_FILE_BROWSER_STORE (model), now);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
set_filter_pattern_real (XedFileBrowserWidget * obj,
|
2011-11-07 13:46:58 -06:00
|
|
|
gchar const * pattern,
|
|
|
|
gboolean update_entry)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
model =
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
|
|
|
|
if (pattern != NULL && *pattern == '\0')
|
|
|
|
pattern = NULL;
|
|
|
|
|
|
|
|
if (pattern == NULL && obj->priv->filter_pattern_str == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pattern != NULL && obj->priv->filter_pattern_str != NULL &&
|
|
|
|
strcmp (pattern, obj->priv->filter_pattern_str) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Free the old pattern */
|
|
|
|
g_free (obj->priv->filter_pattern_str);
|
|
|
|
obj->priv->filter_pattern_str = g_strdup (pattern);
|
|
|
|
|
|
|
|
if (obj->priv->filter_pattern) {
|
|
|
|
g_pattern_spec_free (obj->priv->filter_pattern);
|
|
|
|
obj->priv->filter_pattern = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pattern == NULL) {
|
|
|
|
if (obj->priv->glob_filter_id != 0) {
|
|
|
|
xed_file_browser_widget_remove_filter (obj,
|
|
|
|
obj->
|
|
|
|
priv->
|
|
|
|
glob_filter_id);
|
|
|
|
obj->priv->glob_filter_id = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
obj->priv->filter_pattern = g_pattern_spec_new (pattern);
|
|
|
|
|
|
|
|
if (obj->priv->glob_filter_id == 0)
|
|
|
|
obj->priv->glob_filter_id =
|
|
|
|
xed_file_browser_widget_add_filter (obj,
|
|
|
|
filter_glob,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update_entry) {
|
|
|
|
if (obj->priv->filter_pattern_str == NULL)
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (obj->priv->filter_entry),
|
|
|
|
"");
|
|
|
|
else {
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (obj->priv->filter_entry),
|
|
|
|
obj->priv->filter_pattern_str);
|
|
|
|
|
|
|
|
gtk_expander_set_expanded (GTK_EXPANDER (obj->priv->filter_expander),
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
xed_file_browser_store_refilter (XED_FILE_BROWSER_STORE
|
|
|
|
(model));
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (obj), "filter-pattern");
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Public */
|
|
|
|
|
|
|
|
GtkWidget *
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_new (const gchar *data_dir)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget *obj =
|
|
|
|
g_object_new (XED_TYPE_FILE_BROWSER_WIDGET, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
create_toolbar (obj, data_dir);
|
|
|
|
create_combo (obj);
|
|
|
|
create_tree (obj);
|
|
|
|
create_filter (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_widget_show_bookmarks (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return GTK_WIDGET (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_show_bookmarks (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
/* Select bookmarks in the combo box */
|
|
|
|
g_signal_handlers_block_by_func (obj->priv->combo,
|
|
|
|
on_combo_changed, obj);
|
|
|
|
combo_set_active_by_id (obj, BOOKMARKS_ID);
|
|
|
|
g_signal_handlers_unblock_by_func (obj->priv->combo,
|
|
|
|
on_combo_changed, obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
check_current_item (obj, FALSE);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_view_set_model (obj->priv->treeview,
|
|
|
|
GTK_TREE_MODEL (obj->priv->
|
|
|
|
bookmarks_store));
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
show_files_real (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
gboolean do_root_changed)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_view_set_model (obj->priv->treeview,
|
|
|
|
GTK_TREE_MODEL (obj->priv->
|
|
|
|
file_store));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (do_root_changed)
|
|
|
|
on_virtual_root_changed (obj->priv->file_store, NULL, obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_show_files (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
show_files_real (obj, TRUE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_set_root_and_virtual_root (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar const *root,
|
|
|
|
gchar const *virtual_root)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserStoreResult result;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!virtual_root)
|
|
|
|
result =
|
|
|
|
xed_file_browser_store_set_root_and_virtual_root
|
|
|
|
(obj->priv->file_store, root, root);
|
|
|
|
else
|
|
|
|
result =
|
|
|
|
xed_file_browser_store_set_root_and_virtual_root
|
|
|
|
(obj->priv->file_store, root, virtual_root);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (result == XED_FILE_BROWSER_STORE_RESULT_NO_CHANGE)
|
|
|
|
show_files_real (obj, TRUE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_set_root (XedFileBrowserWidget * obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar const *root,
|
|
|
|
gboolean virtual_root)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GFile *file;
|
|
|
|
GFile *parent;
|
|
|
|
gchar *str;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!virtual_root) {
|
|
|
|
xed_file_browser_widget_set_root_and_virtual_root (obj,
|
|
|
|
root,
|
|
|
|
NULL);
|
|
|
|
return;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!root)
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
file = g_file_new_for_uri (root);
|
|
|
|
parent = get_topmost_file (file);
|
|
|
|
str = g_file_get_uri (parent);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_widget_set_root_and_virtual_root
|
|
|
|
(obj, str, root);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
g_object_unref (file);
|
|
|
|
g_object_unref (parent);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserStore *
|
|
|
|
xed_file_browser_widget_get_browser_store (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
return obj->priv->file_store;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBookmarksStore *
|
|
|
|
xed_file_browser_widget_get_bookmarks_store (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
return obj->priv->bookmarks_store;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserView *
|
|
|
|
xed_file_browser_widget_get_browser_view (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
return obj->priv->treeview;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkUIManager *
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_get_ui_manager (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
return obj->priv->manager;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_get_filter_entry (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
return obj->priv->filter_entry;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
gulong
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_add_filter (XedFileBrowserWidget * obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidgetFilterFunc func,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify notify)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
FilterFunc *f;
|
|
|
|
GtkTreeModel *model =
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
f = filter_func_new (obj, func, user_data, notify);
|
|
|
|
obj->priv->filter_funcs =
|
|
|
|
g_slist_append (obj->priv->filter_funcs, f);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
xed_file_browser_store_refilter (XED_FILE_BROWSER_STORE
|
|
|
|
(model));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return f->id;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_remove_filter (XedFileBrowserWidget * obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
gulong id)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GSList *item;
|
|
|
|
FilterFunc *func;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
for (item = obj->priv->filter_funcs; item; item = item->next)
|
|
|
|
{
|
|
|
|
func = (FilterFunc *) (item->data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (func->id == id)
|
|
|
|
{
|
|
|
|
if (func->destroy_notify)
|
|
|
|
func->destroy_notify (func->user_data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
obj->priv->filter_funcs =
|
|
|
|
g_slist_remove_link (obj->priv->filter_funcs,
|
|
|
|
item);
|
|
|
|
g_free (func);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_set_filter_pattern (XedFileBrowserWidget * obj,
|
2011-11-07 13:46:58 -06:00
|
|
|
gchar const *pattern)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
set_filter_pattern_real (obj, pattern, TRUE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_widget_get_selected_directory (XedFileBrowserWidget * obj,
|
|
|
|
GtkTreeIter * iter)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model =
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
GtkTreeIter parent;
|
|
|
|
guint flags;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!xed_file_browser_widget_get_first_selected (obj, iter)) {
|
|
|
|
if (!xed_file_browser_store_get_iter_virtual_root
|
|
|
|
(XED_FILE_BROWSER_STORE (model), iter))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
|
|
|
|
-1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!FILE_IS_DIR (flags)) {
|
|
|
|
/* Get the parent, because the selection is a file */
|
|
|
|
gtk_tree_model_iter_parent (model, &parent, iter);
|
|
|
|
*iter = parent;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return TRUE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_get_num_selected_files_or_directories (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
guint *files,
|
|
|
|
guint *dirs)
|
|
|
|
{
|
|
|
|
GList *rows, *row;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
XedFileBrowserStoreFlag flags;
|
|
|
|
guint result = 0;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
|
|
|
|
if (XED_IS_FILE_BOOKMARKS_STORE (model))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
|
|
|
|
|
|
|
for (row = rows; row; row = row->next) {
|
|
|
|
path = (GtkTreePath *)(row->data);
|
|
|
|
|
|
|
|
/* Get iter from path */
|
|
|
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, &iter,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (!FILE_IS_DUMMY (flags)) {
|
|
|
|
if (!FILE_IS_DIR (flags))
|
|
|
|
++(*files);
|
|
|
|
else
|
|
|
|
++(*dirs);
|
|
|
|
|
|
|
|
++result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
|
|
|
g_list_free (rows);
|
|
|
|
|
|
|
|
return result;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget *widget;
|
|
|
|
GCancellable *cancellable;
|
2011-11-07 13:46:58 -06:00
|
|
|
} AsyncData;
|
|
|
|
|
|
|
|
static AsyncData *
|
2016-02-04 03:20:42 -06:00
|
|
|
async_data_new (XedFileBrowserWidget *widget)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
AsyncData *ret;
|
|
|
|
|
|
|
|
ret = g_new (AsyncData, 1);
|
|
|
|
ret->widget = widget;
|
|
|
|
|
|
|
|
cancel_async_operation (widget);
|
|
|
|
widget->priv->cancellable = g_cancellable_new ();
|
|
|
|
|
|
|
|
ret->cancellable = g_object_ref (widget->priv->cancellable);
|
|
|
|
|
|
|
|
return ret;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
async_free (AsyncData *async)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_unref (async->cancellable);
|
|
|
|
g_free (async);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
set_busy (XedFileBrowserWidget *obj, gboolean busy)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GdkWindow *window;
|
|
|
|
|
|
|
|
window = gtk_widget_get_window (GTK_WIDGET (obj->priv->treeview));
|
|
|
|
|
|
|
|
if (!GDK_IS_WINDOW (window))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (busy)
|
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
2015-11-19 18:46:26 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
cursor = gdk_cursor_new (GDK_WATCH);
|
|
|
|
gdk_window_set_cursor (window, cursor);
|
|
|
|
g_object_unref (obj->priv->busy_cursor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdk_window_set_cursor (window, NULL);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:20:42 -06:00
|
|
|
static void try_mount_volume (XedFileBrowserWidget *widget, GVolume *volume);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
activate_mount (XedFileBrowserWidget *widget,
|
2016-10-06 14:17:48 -05:00
|
|
|
GVolume *volume,
|
|
|
|
GMount *mount)
|
|
|
|
{
|
|
|
|
GFile *root;
|
|
|
|
gchar *uri;
|
|
|
|
|
|
|
|
if (!mount)
|
|
|
|
{
|
|
|
|
gchar *message;
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
name = g_volume_get_name (volume);
|
|
|
|
message = g_strdup_printf (_("No mount object for mounted volume: %s"), name);
|
|
|
|
|
|
|
|
g_signal_emit (widget,
|
|
|
|
signals[ERROR],
|
|
|
|
0,
|
|
|
|
XED_FILE_BROWSER_ERROR_SET_ROOT,
|
|
|
|
message);
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
g_free (message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
root = g_mount_get_root (mount);
|
|
|
|
uri = g_file_get_uri (root);
|
|
|
|
|
|
|
|
xed_file_browser_widget_set_root (widget, uri, FALSE);
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
g_object_unref (root);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
try_activate_drive (XedFileBrowserWidget *widget,
|
2016-10-06 14:17:48 -05:00
|
|
|
GDrive *drive)
|
|
|
|
{
|
|
|
|
GList *volumes;
|
|
|
|
GVolume *volume;
|
|
|
|
GMount *mount;
|
|
|
|
|
|
|
|
volumes = g_drive_get_volumes (drive);
|
|
|
|
|
|
|
|
volume = G_VOLUME (volumes->data);
|
|
|
|
mount = g_volume_get_mount (volume);
|
|
|
|
|
|
|
|
if (mount)
|
|
|
|
{
|
|
|
|
/* try set the root of the mount */
|
|
|
|
activate_mount (widget, volume, mount);
|
|
|
|
g_object_unref (mount);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* try to mount it then? */
|
|
|
|
try_mount_volume (widget, volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
|
|
|
|
g_list_free (volumes);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
poll_for_media_cb (GDrive *drive,
|
2016-10-06 14:17:48 -05:00
|
|
|
GAsyncResult *res,
|
|
|
|
AsyncData *async)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
/* check for cancelled state */
|
|
|
|
if (g_cancellable_is_cancelled (async->cancellable))
|
|
|
|
{
|
|
|
|
async_free (async);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* finish poll operation */
|
|
|
|
set_busy (async->widget, FALSE);
|
|
|
|
|
|
|
|
if (g_drive_poll_for_media_finish (drive, res, &error) &&
|
|
|
|
g_drive_has_media (drive) &&
|
|
|
|
g_drive_has_volumes (drive))
|
|
|
|
{
|
|
|
|
try_activate_drive (async->widget, drive);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *message;
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
name = g_drive_get_name (drive);
|
|
|
|
message = g_strdup_printf (_("Could not open media: %s"), name);
|
|
|
|
|
|
|
|
g_signal_emit (async->widget,
|
|
|
|
signals[ERROR],
|
|
|
|
0,
|
|
|
|
XED_FILE_BROWSER_ERROR_SET_ROOT,
|
|
|
|
message);
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
g_free (message);
|
|
|
|
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
async_free (async);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mount_volume_cb (GVolume *volume,
|
2016-10-06 14:17:48 -05:00
|
|
|
GAsyncResult *res,
|
|
|
|
AsyncData *async)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
/* check for cancelled state */
|
|
|
|
if (g_cancellable_is_cancelled (async->cancellable))
|
|
|
|
{
|
|
|
|
async_free (async);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_volume_mount_finish (volume, res, &error))
|
|
|
|
{
|
|
|
|
GMount *mount;
|
|
|
|
|
|
|
|
mount = g_volume_get_mount (volume);
|
|
|
|
activate_mount (async->widget, volume, mount);
|
|
|
|
|
|
|
|
if (mount)
|
|
|
|
g_object_unref (mount);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *message;
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
name = g_volume_get_name (volume);
|
|
|
|
message = g_strdup_printf (_("Could not mount volume: %s"), name);
|
|
|
|
|
|
|
|
g_signal_emit (async->widget,
|
|
|
|
signals[ERROR],
|
|
|
|
0,
|
|
|
|
XED_FILE_BROWSER_ERROR_SET_ROOT,
|
|
|
|
message);
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
g_free (message);
|
|
|
|
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_busy (async->widget, FALSE);
|
|
|
|
async_free (async);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
activate_drive (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter *iter)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GDrive *drive;
|
|
|
|
AsyncData *async;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (obj->priv->bookmarks_store), iter,
|
|
|
|
XED_FILE_BOOKMARKS_STORE_COLUMN_OBJECT,
|
|
|
|
&drive, -1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
/* most common use case is a floppy drive, we'll poll for media and
|
|
|
|
go from there */
|
|
|
|
async = async_data_new (obj);
|
|
|
|
g_drive_poll_for_media (drive,
|
|
|
|
async->cancellable,
|
|
|
|
(GAsyncReadyCallback)poll_for_media_cb,
|
|
|
|
async);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_unref (drive);
|
|
|
|
set_busy (obj, TRUE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static void
|
|
|
|
try_mount_volume (XedFileBrowserWidget *widget,
|
|
|
|
GVolume *volume)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GMountOperation *operation;
|
|
|
|
AsyncData *async;
|
|
|
|
|
|
|
|
operation = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget))));
|
|
|
|
async = async_data_new (widget);
|
|
|
|
|
|
|
|
g_volume_mount (volume,
|
|
|
|
G_MOUNT_MOUNT_NONE,
|
|
|
|
operation,
|
|
|
|
async->cancellable,
|
|
|
|
(GAsyncReadyCallback)mount_volume_cb,
|
|
|
|
async);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_unref (operation);
|
|
|
|
set_busy (widget, TRUE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
activate_volume (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter *iter)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GVolume *volume;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (obj->priv->bookmarks_store), iter,
|
|
|
|
XED_FILE_BOOKMARKS_STORE_COLUMN_OBJECT,
|
|
|
|
&volume, -1);
|
|
|
|
|
|
|
|
/* see if we can mount the volume */
|
|
|
|
try_mount_volume (obj, volume);
|
|
|
|
g_object_unref (volume);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_refresh (XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model =
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
xed_file_browser_store_refresh (XED_FILE_BROWSER_STORE
|
|
|
|
(model));
|
|
|
|
else if (XED_IS_FILE_BOOKMARKS_STORE (model)) {
|
|
|
|
g_hash_table_ref (obj->priv->bookmarks_hash);
|
|
|
|
g_hash_table_destroy (obj->priv->bookmarks_hash);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_bookmarks_store_refresh
|
|
|
|
(XED_FILE_BOOKMARKS_STORE (model));
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_history_back (XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (obj->priv->locations) {
|
|
|
|
if (obj->priv->current_location)
|
|
|
|
jump_to_location (obj,
|
|
|
|
obj->priv->current_location->
|
|
|
|
next, TRUE);
|
|
|
|
else {
|
|
|
|
jump_to_location (obj, obj->priv->locations, TRUE);
|
|
|
|
}
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-04 03:20:42 -06:00
|
|
|
xed_file_browser_widget_history_forward (XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (obj->priv->locations)
|
|
|
|
jump_to_location (obj, obj->priv->current_location->prev,
|
|
|
|
FALSE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
bookmark_open (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
gchar *uri;
|
|
|
|
gint flags;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS,
|
|
|
|
&flags, -1);
|
|
|
|
|
|
|
|
if (flags & XED_FILE_BOOKMARKS_STORE_IS_DRIVE)
|
|
|
|
{
|
|
|
|
/* handle a drive node */
|
|
|
|
xed_file_browser_store_cancel_mount_operation (obj->priv->file_store);
|
|
|
|
activate_drive (obj, iter);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (flags & XED_FILE_BOOKMARKS_STORE_IS_VOLUME)
|
|
|
|
{
|
|
|
|
/* handle a volume node */
|
|
|
|
xed_file_browser_store_cancel_mount_operation (obj->priv->file_store);
|
|
|
|
activate_volume (obj, iter);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uri =
|
|
|
|
xed_file_bookmarks_store_get_uri
|
|
|
|
(XED_FILE_BOOKMARKS_STORE (model), iter);
|
|
|
|
|
|
|
|
if (uri) {
|
|
|
|
/* here we check if the bookmark is a mount point, or if it
|
|
|
|
is a remote bookmark. If that's the case, we will set the
|
|
|
|
root to the uri of the bookmark and not try to set the
|
|
|
|
topmost parent as root (since that may as well not be the
|
|
|
|
mount point anymore) */
|
|
|
|
if ((flags & XED_FILE_BOOKMARKS_STORE_IS_MOUNT) ||
|
|
|
|
(flags & XED_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK)) {
|
|
|
|
xed_file_browser_widget_set_root (obj,
|
|
|
|
uri,
|
|
|
|
FALSE);
|
|
|
|
} else {
|
|
|
|
xed_file_browser_widget_set_root (obj,
|
|
|
|
uri,
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
g_warning ("No uri!");
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (uri);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
file_open (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar *uri;
|
|
|
|
gint flags;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_URI, &uri,
|
|
|
|
-1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!FILE_IS_DIR (flags) && !FILE_IS_DUMMY (flags)) {
|
|
|
|
g_signal_emit (obj, signals[URI_ACTIVATED], 0, uri);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (uri);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
directory_open (XedFileBrowserWidget *obj,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gboolean result = FALSE;
|
|
|
|
GError *error = NULL;
|
|
|
|
gchar *uri = NULL;
|
|
|
|
XedFileBrowserStoreFlag flags;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_URI, &uri,
|
|
|
|
-1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (FILE_IS_DIR (flags)) {
|
|
|
|
result = TRUE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (obj)), uri, GDK_CURRENT_TIME, &error)) {
|
|
|
|
g_signal_emit (obj, signals[ERROR], 0,
|
|
|
|
XED_FILE_BROWSER_ERROR_OPEN_DIRECTORY,
|
|
|
|
error->message);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_error_free (error);
|
|
|
|
error = NULL;
|
|
|
|
}
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_free (uri);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return result;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_bookmark_activated (XedFileBrowserView *tree_view,
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter *iter,
|
|
|
|
XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
bookmark_open (obj, model, iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-06 14:17:48 -05:00
|
|
|
on_file_activated (XedFileBrowserView *tree_view,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
file_open (obj, model, iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-10-06 14:17:48 -05:00
|
|
|
virtual_root_is_root (XedFileBrowserWidget * obj,
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserStore * model)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter root;
|
|
|
|
GtkTreeIter virtual_root;
|
|
|
|
|
|
|
|
if (!xed_file_browser_store_get_iter_root (model, &root))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (!xed_file_browser_store_get_iter_virtual_root (model, &virtual_root))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return xed_file_browser_store_iter_equal (model, &root, &virtual_root);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_virtual_root_changed (XedFileBrowserStore * model,
|
2016-10-06 14:17:48 -05:00
|
|
|
GParamSpec * param,
|
|
|
|
XedFileBrowserWidget * obj)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar *uri;
|
|
|
|
gchar *root_uri;
|
|
|
|
GtkTreeIter root;
|
|
|
|
GtkAction *action;
|
|
|
|
Location *loc;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
if (gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview)) !=
|
|
|
|
GTK_TREE_MODEL (obj->priv->file_store))
|
|
|
|
{
|
|
|
|
show_files_real (obj, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xed_file_browser_store_get_iter_virtual_root (model, &iter)) {
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_URI,
|
|
|
|
&uri, -1);
|
|
|
|
|
|
|
|
if (xed_file_browser_store_get_iter_root (model, &root)) {
|
|
|
|
if (!obj->priv->changing_location) {
|
|
|
|
/* Remove all items from obj->priv->current_location on */
|
|
|
|
if (obj->priv->current_location)
|
|
|
|
clear_next_locations (obj);
|
|
|
|
|
|
|
|
root_uri =
|
|
|
|
xed_file_browser_store_get_root
|
|
|
|
(model);
|
|
|
|
|
|
|
|
loc = g_new (Location, 1);
|
|
|
|
loc->root = g_file_new_for_uri (root_uri);
|
|
|
|
loc->virtual_root = g_file_new_for_uri (uri);
|
|
|
|
g_free (root_uri);
|
|
|
|
|
|
|
|
if (obj->priv->current_location) {
|
|
|
|
/* Add current location to the menu so we can go back
|
|
|
|
to it later */
|
|
|
|
gtk_menu_shell_prepend
|
|
|
|
(GTK_MENU_SHELL
|
|
|
|
(obj->priv->
|
|
|
|
location_previous_menu),
|
|
|
|
obj->priv->
|
|
|
|
current_location_menu_item);
|
|
|
|
}
|
|
|
|
|
|
|
|
obj->priv->locations =
|
|
|
|
g_list_prepend (obj->priv->locations,
|
|
|
|
loc);
|
|
|
|
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (model),
|
|
|
|
&iter,
|
|
|
|
XED_FILE_BROWSER_STORE_COLUMN_ICON,
|
|
|
|
&pixbuf, -1);
|
|
|
|
|
|
|
|
obj->priv->current_location =
|
|
|
|
obj->priv->locations;
|
|
|
|
obj->priv->current_location_menu_item =
|
|
|
|
create_goto_menu_item (obj,
|
|
|
|
obj->priv->
|
|
|
|
current_location,
|
|
|
|
pixbuf);
|
|
|
|
|
|
|
|
g_object_ref_sink (obj->priv->
|
|
|
|
current_location_menu_item);
|
|
|
|
|
|
|
|
if (pixbuf)
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
action =
|
|
|
|
gtk_action_group_get_action (obj->priv->
|
|
|
|
action_group,
|
|
|
|
"DirectoryUp");
|
|
|
|
gtk_action_set_sensitive (action,
|
|
|
|
!virtual_root_is_root (obj, model));
|
|
|
|
|
|
|
|
action =
|
|
|
|
gtk_action_group_get_action (obj->priv->
|
|
|
|
action_group_sensitive,
|
|
|
|
"DirectoryPrevious");
|
|
|
|
gtk_action_set_sensitive (action,
|
|
|
|
obj->priv->
|
|
|
|
current_location != NULL
|
|
|
|
&& obj->priv->
|
|
|
|
current_location->next !=
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
action =
|
|
|
|
gtk_action_group_get_action (obj->priv->
|
|
|
|
action_group_sensitive,
|
|
|
|
"DirectoryNext");
|
|
|
|
gtk_action_set_sensitive (action,
|
|
|
|
obj->priv->
|
|
|
|
current_location != NULL
|
|
|
|
&& obj->priv->
|
|
|
|
current_location->prev !=
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
check_current_item (obj, TRUE);
|
|
|
|
g_free (uri);
|
|
|
|
} else {
|
|
|
|
g_message ("NO!");
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_model_set (GObject * gobject, GParamSpec * arg1,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (gobject));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
clear_signals (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (XED_IS_FILE_BOOKMARKS_STORE (model)) {
|
|
|
|
clear_next_locations (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
/* Add the current location to the back menu */
|
|
|
|
if (obj->priv->current_location) {
|
|
|
|
GtkAction *action;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (obj->priv->location_previous_menu),
|
|
|
|
obj->priv->current_location_menu_item);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_object_unref (obj->priv->current_location_menu_item);
|
|
|
|
obj->priv->current_location = NULL;
|
|
|
|
obj->priv->current_location_menu_item = NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
action = gtk_action_group_get_action (obj->priv->action_group_sensitive,
|
|
|
|
"DirectoryPrevious");
|
|
|
|
gtk_action_set_sensitive (action, TRUE);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_widget_set_sensitive (obj->priv->filter_expander, FALSE);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
add_signal (obj, gobject,
|
|
|
|
g_signal_connect (gobject, "bookmark-activated",
|
|
|
|
G_CALLBACK
|
|
|
|
(on_bookmark_activated), obj));
|
|
|
|
} else if (XED_IS_FILE_BROWSER_STORE (model)) {
|
|
|
|
/* make sure any async operation is cancelled */
|
|
|
|
cancel_async_operation (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
add_signal (obj, gobject,
|
|
|
|
g_signal_connect (gobject, "file-activated",
|
|
|
|
G_CALLBACK
|
|
|
|
(on_file_activated), obj));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
add_signal (obj, model,
|
|
|
|
g_signal_connect (model, "no-trash",
|
|
|
|
G_CALLBACK
|
|
|
|
(on_file_store_no_trash), obj));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_widget_set_sensitive (obj->priv->filter_expander, TRUE);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
update_sensitivity (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_file_store_error (XedFileBrowserStore * store, guint code,
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar * message, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
g_signal_emit (obj, signals[ERROR], 0, code, message);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_treeview_error (XedFileBrowserView * tree_view, guint code,
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar * message, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
g_signal_emit (obj, signals[ERROR], 0, code, message);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_combo_changed (GtkComboBox * combo, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter iter;
|
|
|
|
guint id;
|
|
|
|
gchar * uri;
|
|
|
|
GFile * file;
|
|
|
|
|
|
|
|
if (!gtk_combo_box_get_active_iter (combo, &iter))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (obj->priv->combo_model), &iter,
|
|
|
|
COLUMN_ID, &id, -1);
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case BOOKMARKS_ID:
|
|
|
|
xed_file_browser_widget_show_bookmarks (obj);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PATH_ID:
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL
|
|
|
|
(obj->priv->combo_model), &iter,
|
|
|
|
COLUMN_FILE, &file, -1);
|
|
|
|
|
|
|
|
uri = g_file_get_uri (file);
|
|
|
|
xed_file_browser_store_set_virtual_root_from_string
|
|
|
|
(obj->priv->file_store, uri);
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
g_object_unref (file);
|
|
|
|
break;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
on_treeview_popup_menu (XedFileBrowserView * treeview,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
return popup_menu (obj, NULL, gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)));
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
on_treeview_button_press_event (XedFileBrowserView * treeview,
|
2016-10-06 14:17:48 -05:00
|
|
|
GdkEventButton * event,
|
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
|
|
|
|
return popup_menu (obj, event,
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)));
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
do_change_directory (XedFileBrowserWidget * obj,
|
2011-11-07 13:46:58 -06:00
|
|
|
GdkEventKey * event)
|
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkAction * action = NULL;
|
|
|
|
|
|
|
|
if ((event->state &
|
|
|
|
(~GDK_CONTROL_MASK & ~GDK_SHIFT_MASK & ~GDK_MOD1_MASK)) ==
|
|
|
|
event->state && event->keyval == GDK_KEY_BackSpace)
|
|
|
|
action = gtk_action_group_get_action (obj->priv->
|
|
|
|
action_group_sensitive,
|
|
|
|
"DirectoryPrevious");
|
|
|
|
else if (!((event->state & GDK_MOD1_MASK) &&
|
|
|
|
(event->state & (~GDK_CONTROL_MASK & ~GDK_SHIFT_MASK)) == event->state))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (event->keyval) {
|
|
|
|
case GDK_KEY_Left:
|
|
|
|
action = gtk_action_group_get_action (obj->priv->
|
|
|
|
action_group_sensitive,
|
|
|
|
"DirectoryPrevious");
|
|
|
|
break;
|
|
|
|
case GDK_KEY_Right:
|
|
|
|
action = gtk_action_group_get_action (obj->priv->
|
|
|
|
action_group_sensitive,
|
|
|
|
"DirectoryNext");
|
|
|
|
break;
|
|
|
|
case GDK_KEY_Up:
|
|
|
|
action = gtk_action_group_get_action (obj->priv->
|
|
|
|
action_group,
|
|
|
|
"DirectoryUp");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action != NULL) {
|
|
|
|
gtk_action_activate (action);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
on_treeview_key_press_event (XedFileBrowserView * treeview,
|
2016-10-06 14:17:48 -05:00
|
|
|
GdkEventKey * event,
|
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
guint modifiers;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (do_change_directory (obj, event))
|
|
|
|
return TRUE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BROWSER_STORE
|
|
|
|
(gtk_tree_view_get_model (GTK_TREE_VIEW (treeview))))
|
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
modifiers = gtk_accelerator_get_default_mod_mask ();
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (event->keyval == GDK_KEY_Delete
|
|
|
|
|| event->keyval == GDK_KEY_KP_Delete) {
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if ((event->state & modifiers) == GDK_SHIFT_MASK) {
|
|
|
|
if (obj->priv->enable_delete) {
|
|
|
|
delete_selected_files (obj, FALSE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
} else if ((event->state & modifiers) == 0) {
|
|
|
|
delete_selected_files (obj, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if ((event->keyval == GDK_KEY_F2)
|
|
|
|
&& (event->state & modifiers) == 0) {
|
|
|
|
rename_selected_file (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_selection_changed (GtkTreeSelection * selection,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
guint selected = 0;
|
|
|
|
guint files = 0;
|
|
|
|
guint dirs = 0;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
{
|
|
|
|
selected = xed_file_browser_widget_get_num_selected_files_or_directories (obj,
|
|
|
|
&files,
|
|
|
|
&dirs);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_action_group_set_sensitive (obj->priv->action_group_selection,
|
|
|
|
selected > 0);
|
|
|
|
gtk_action_group_set_sensitive (obj->priv->action_group_file_selection,
|
|
|
|
(selected > 0) && (selected == files));
|
|
|
|
gtk_action_group_set_sensitive (obj->priv->action_group_single_selection,
|
|
|
|
selected == 1);
|
|
|
|
gtk_action_group_set_sensitive (obj->priv->action_group_single_most_selection,
|
|
|
|
selected <= 1);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-04 03:20:42 -06:00
|
|
|
on_entry_filter_activate (XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gchar const *text;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (obj->priv->filter_entry));
|
|
|
|
set_filter_pattern_real (obj, text, FALSE);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
return FALSE;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_location_jump_activate (GtkMenuItem * item,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GList *location;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
location = g_object_get_data (G_OBJECT (item), LOCATION_DATA_KEY);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (obj->priv->current_location) {
|
|
|
|
jump_to_location (obj, location,
|
|
|
|
g_list_position (obj->priv->locations,
|
|
|
|
location) >
|
|
|
|
g_list_position (obj->priv->locations,
|
|
|
|
obj->priv->
|
|
|
|
current_location));
|
|
|
|
} else {
|
|
|
|
jump_to_location (obj, location, TRUE);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-06 14:17:48 -05:00
|
|
|
on_bookmarks_row_changed (GtkTreeModel * model,
|
2011-11-07 13:46:58 -06:00
|
|
|
GtkTreePath * path,
|
|
|
|
GtkTreeIter * iter,
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
add_bookmark_hash (obj, iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-06 14:17:48 -05:00
|
|
|
on_bookmarks_row_deleted (GtkTreeModel * model,
|
2011-11-07 13:46:58 -06:00
|
|
|
GtkTreePath * path,
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserWidget *obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar * uri;
|
|
|
|
GFile * file;
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
uri = xed_file_bookmarks_store_get_uri (obj->priv->bookmarks_store, &iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!uri)
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
file = g_file_new_for_uri (uri);
|
|
|
|
g_hash_table_remove (obj->priv->bookmarks_hash, file);
|
|
|
|
|
|
|
|
g_object_unref (file);
|
|
|
|
g_free (uri);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_filter_mode_changed (XedFileBrowserStore * model,
|
2011-11-07 13:46:58 -06:00
|
|
|
GParamSpec * param,
|
2016-02-04 03:20:42 -06:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
gint mode;
|
|
|
|
GtkToggleAction * action;
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
mode = xed_file_browser_store_get_filter_mode (model);
|
|
|
|
|
|
|
|
action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (obj->priv->action_group,
|
|
|
|
"FilterHidden"));
|
|
|
|
active = !(mode & XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN);
|
|
|
|
|
|
|
|
if (active != gtk_toggle_action_get_active (action))
|
|
|
|
gtk_toggle_action_set_active (action, active);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (obj->priv->action_group,
|
|
|
|
"FilterBinary"));
|
|
|
|
active = !(mode & XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (active != gtk_toggle_action_get_active (action))
|
|
|
|
gtk_toggle_action_set_active (action, active);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_directory_next (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_widget_history_forward (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_action_directory_previous (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_widget_history_back (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
static void
|
2011-11-07 13:46:58 -06:00
|
|
|
on_action_directory_up (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_store_set_virtual_root_up (XED_FILE_BROWSER_STORE (model));
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_directory_new (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter parent;
|
|
|
|
GtkTreeIter iter;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!xed_file_browser_widget_get_selected_directory (obj, &parent))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (xed_file_browser_store_new_directory
|
|
|
|
(XED_FILE_BROWSER_STORE (model), &parent, &iter)) {
|
|
|
|
xed_file_browser_view_start_rename (obj->priv->treeview,
|
|
|
|
&iter);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_file_open (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GList *rows;
|
|
|
|
GList *row;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
for (row = rows; row; row = row->next) {
|
|
|
|
path = (GtkTreePath *)(row->data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
file_open (obj, model, &iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_list_free (rows);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_file_new (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter parent;
|
|
|
|
GtkTreeIter iter;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!xed_file_browser_widget_get_selected_directory (obj, &parent))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (xed_file_browser_store_new_file
|
|
|
|
(XED_FILE_BROWSER_STORE (model), &parent, &iter)) {
|
|
|
|
xed_file_browser_view_start_rename (obj->priv->treeview,
|
|
|
|
&iter);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_file_rename (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
rename_selected_file (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_file_delete (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
delete_selected_files (obj, FALSE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_file_move_to_trash (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
delete_selected_files (obj, TRUE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_action_directory_refresh (GtkAction * action,
|
2016-10-06 14:17:48 -05:00
|
|
|
XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
xed_file_browser_widget_refresh (obj);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_directory_open (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GList *rows;
|
|
|
|
GList *row;
|
|
|
|
gboolean directory_opened = FALSE;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
|
|
|
|
if (!XED_IS_FILE_BROWSER_STORE (model))
|
|
|
|
return;
|
|
|
|
|
|
|
|
rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
for (row = rows; row; row = row->next) {
|
|
|
|
path = (GtkTreePath *)(row->data);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (gtk_tree_model_get_iter (model, &iter, path))
|
|
|
|
directory_opened |= directory_open (obj, model, &iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!directory_opened) {
|
|
|
|
if (xed_file_browser_widget_get_selected_directory (obj, &iter))
|
|
|
|
directory_open (obj, model, &iter);
|
|
|
|
}
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
g_list_free (rows);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_filter_hidden (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
update_filter_mode (obj,
|
|
|
|
action,
|
|
|
|
XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_filter_binary (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
update_filter_mode (obj,
|
|
|
|
action,
|
|
|
|
XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-02-04 03:20:42 -06:00
|
|
|
on_action_bookmark_open (GtkAction * action, XedFileBrowserWidget * obj)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2016-10-06 14:17:48 -05:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (obj->priv->treeview));
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (!XED_IS_FILE_BOOKMARKS_STORE (model))
|
|
|
|
return;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2016-10-06 14:17:48 -05:00
|
|
|
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
|
|
|
|
bookmark_open (obj, model, &iter);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:25:50 -06:00
|
|
|
void
|
|
|
|
_xed_file_browser_widget_register_type (GTypeModule *type_module)
|
|
|
|
{
|
|
|
|
xed_file_browser_widget_register_type (type_module);
|
|
|
|
}
|
|
|
|
|
2011-11-07 13:46:58 -06:00
|
|
|
// ex:ts=8:noet:
|