filebrowser-plugin: Port to libpeas

Adapted from:
3e00f9094c
This commit is contained in:
JosephMcc 2016-12-26 13:25:50 -08:00
parent fdc2da63a9
commit 4cad8ffa7f
10 changed files with 1304 additions and 1151 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* xed-file-bookmarks-store.h - Xed plugin providing easy file access * xed-file-bookmarks-store.h - Xed plugin providing easy file access
* from the sidepanel * from the sidepanel
* *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
@ -25,66 +25,66 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define XED_TYPE_FILE_BOOKMARKS_STORE (xed_file_bookmarks_store_get_type ()) #define XED_TYPE_FILE_BOOKMARKS_STORE (xed_file_bookmarks_store_get_type ())
#define XED_FILE_BOOKMARKS_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BOOKMARKS_STORE, XedFileBookmarksStore)) #define XED_FILE_BOOKMARKS_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BOOKMARKS_STORE, XedFileBookmarksStore))
#define XED_FILE_BOOKMARKS_STORE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BOOKMARKS_STORE, XedFileBookmarksStore const)) #define XED_FILE_BOOKMARKS_STORE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BOOKMARKS_STORE, XedFileBookmarksStore const))
#define XED_FILE_BOOKMARKS_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_FILE_BOOKMARKS_STORE, XedFileBookmarksStoreClass)) #define XED_FILE_BOOKMARKS_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_FILE_BOOKMARKS_STORE, XedFileBookmarksStoreClass))
#define XED_IS_FILE_BOOKMARKS_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_FILE_BOOKMARKS_STORE)) #define XED_IS_FILE_BOOKMARKS_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_FILE_BOOKMARKS_STORE))
#define XED_IS_FILE_BOOKMARKS_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_FILE_BOOKMARKS_STORE)) #define XED_IS_FILE_BOOKMARKS_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_FILE_BOOKMARKS_STORE))
#define XED_FILE_BOOKMARKS_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BOOKMARKS_STORE, XedFileBookmarksStoreClass)) #define XED_FILE_BOOKMARKS_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BOOKMARKS_STORE, XedFileBookmarksStoreClass))
typedef struct _XedFileBookmarksStore XedFileBookmarksStore; typedef struct _XedFileBookmarksStore XedFileBookmarksStore;
typedef struct _XedFileBookmarksStoreClass XedFileBookmarksStoreClass; typedef struct _XedFileBookmarksStoreClass XedFileBookmarksStoreClass;
typedef struct _XedFileBookmarksStorePrivate XedFileBookmarksStorePrivate; typedef struct _XedFileBookmarksStorePrivate XedFileBookmarksStorePrivate;
enum enum
{ {
XED_FILE_BOOKMARKS_STORE_COLUMN_ICON = 0, XED_FILE_BOOKMARKS_STORE_COLUMN_ICON = 0,
XED_FILE_BOOKMARKS_STORE_COLUMN_NAME, XED_FILE_BOOKMARKS_STORE_COLUMN_NAME,
XED_FILE_BOOKMARKS_STORE_COLUMN_OBJECT, XED_FILE_BOOKMARKS_STORE_COLUMN_OBJECT,
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS,
XED_FILE_BOOKMARKS_STORE_N_COLUMNS XED_FILE_BOOKMARKS_STORE_N_COLUMNS
}; };
enum enum
{ {
XED_FILE_BOOKMARKS_STORE_NONE = 0, XED_FILE_BOOKMARKS_STORE_NONE = 0,
XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR = 1 << 0, /* Separator item */ XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR = 1 << 0, /* Separator item */
XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR = 1 << 1, /* Special user dir */ XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR = 1 << 1, /* Special user dir */
XED_FILE_BOOKMARKS_STORE_IS_HOME = 1 << 2, /* The special Home user directory */ XED_FILE_BOOKMARKS_STORE_IS_HOME = 1 << 2, /* The special Home user directory */
XED_FILE_BOOKMARKS_STORE_IS_DESKTOP = 1 << 3, /* The special Desktop user directory */ XED_FILE_BOOKMARKS_STORE_IS_DESKTOP = 1 << 3, /* The special Desktop user directory */
XED_FILE_BOOKMARKS_STORE_IS_DOCUMENTS = 1 << 4, /* The special Documents user directory */ XED_FILE_BOOKMARKS_STORE_IS_DOCUMENTS = 1 << 4, /* The special Documents user directory */
XED_FILE_BOOKMARKS_STORE_IS_FS = 1 << 5, /* A mount object */ XED_FILE_BOOKMARKS_STORE_IS_FS = 1 << 5, /* A mount object */
XED_FILE_BOOKMARKS_STORE_IS_MOUNT = 1 << 6, /* A mount object */ XED_FILE_BOOKMARKS_STORE_IS_MOUNT = 1 << 6, /* A mount object */
XED_FILE_BOOKMARKS_STORE_IS_VOLUME = 1 << 7, /* A volume object */ XED_FILE_BOOKMARKS_STORE_IS_VOLUME = 1 << 7, /* A volume object */
XED_FILE_BOOKMARKS_STORE_IS_DRIVE = 1 << 8, /* A drive object */ XED_FILE_BOOKMARKS_STORE_IS_DRIVE = 1 << 8, /* A drive object */
XED_FILE_BOOKMARKS_STORE_IS_ROOT = 1 << 9, /* The root file system (file:///) */ XED_FILE_BOOKMARKS_STORE_IS_ROOT = 1 << 9, /* The root file system (file:///) */
XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK = 1 << 10, /* A gtk bookmark */ XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK = 1 << 10, /* A gtk bookmark */
XED_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK = 1 << 11, /* A remote gtk bookmark */ XED_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK = 1 << 11, /* A remote gtk bookmark */
XED_FILE_BOOKMARKS_STORE_IS_LOCAL_BOOKMARK = 1 << 12 /* A local gtk bookmark */ XED_FILE_BOOKMARKS_STORE_IS_LOCAL_BOOKMARK = 1 << 12 /* A local gtk bookmark */
}; };
struct _XedFileBookmarksStore struct _XedFileBookmarksStore
{ {
GtkTreeStore parent; GtkTreeStore parent;
XedFileBookmarksStorePrivate *priv; XedFileBookmarksStorePrivate *priv;
}; };
struct _XedFileBookmarksStoreClass struct _XedFileBookmarksStoreClass
{ {
GtkTreeStoreClass parent_class; GtkTreeStoreClass parent_class;
}; };
GType xed_file_bookmarks_store_get_type (void) G_GNUC_CONST; GType xed_file_bookmarks_store_get_type (void) G_GNUC_CONST;
GType xed_file_bookmarks_store_register_type (GTypeModule * module); void _xed_file_bookmarks_store_register_type (GTypeModule * module);
XedFileBookmarksStore *xed_file_bookmarks_store_new (void); XedFileBookmarksStore *xed_file_bookmarks_store_new (void);
gchar *xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model, gchar *xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
GtkTreeIter * iter); GtkTreeIter * iter);
void xed_file_bookmarks_store_refresh (XedFileBookmarksStore * model); void xed_file_bookmarks_store_refresh (XedFileBookmarksStore * model);
G_END_DECLS G_END_DECLS
#endif /* __XED_FILE_BOOKMARKS_STORE_H__ */ #endif /* __XED_FILE_BOOKMARKS_STORE_H__ */
// ex:ts=8:noet: // ex:ts=8:noet:

View File

@ -28,9 +28,11 @@
#include <xed/xed-utils.h> #include <xed/xed-utils.h>
#include <xed/xed-app.h> #include <xed/xed-app.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <xed/xed-window.h>
#include <xed/xed-debug.h> #include <xed/xed-debug.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <string.h> #include <string.h>
#include <libpeas/peas-activatable.h>
#include "xed-file-browser-enum-types.h" #include "xed-file-browser-enum-types.h"
#include "xed-file-browser-plugin.h" #include "xed-file-browser-plugin.h"
@ -39,8 +41,6 @@
#include "xed-file-browser-widget.h" #include "xed-file-browser-widget.h"
#include "xed-file-browser-messages.h" #include "xed-file-browser-messages.h"
#define WINDOW_DATA_KEY "XedFileBrowserPluginWindowData"
#define FILE_BROWSER_SCHEMA "org.x.editor.plugins.filebrowser" #define FILE_BROWSER_SCHEMA "org.x.editor.plugins.filebrowser"
#define FILE_BROWSER_ONLOAD_SCHEMA "org.x.editor.plugins.filebrowser.on-load" #define FILE_BROWSER_ONLOAD_SCHEMA "org.x.editor.plugins.filebrowser.on-load"
@ -48,11 +48,8 @@
struct _XedFileBrowserPluginPrivate struct _XedFileBrowserPluginPrivate
{ {
gpointer *dummy; GtkWidget *window;
};
typedef struct _XedFileBrowserPluginData
{
XedFileBrowserWidget * tree_widget; XedFileBrowserWidget * tree_widget;
gulong merge_id; gulong merge_id;
GtkActionGroup * action_group; GtkActionGroup * action_group;
@ -62,7 +59,13 @@ typedef struct _XedFileBrowserPluginData
GSettings *settings; GSettings *settings;
GSettings *onload_settings; GSettings *onload_settings;
} XedFileBrowserPluginData; };
enum
{
PROP_0,
PROP_OBJECT
};
static void on_uri_activated_cb (XedFileBrowserWidget * widget, static void on_uri_activated_cb (XedFileBrowserWidget * widget,
gchar const *uri, gchar const *uri,
@ -70,67 +73,113 @@ static void on_uri_activated_cb (XedFileBrowserWidget * widget,
static void on_error_cb (XedFileBrowserWidget * widget, static void on_error_cb (XedFileBrowserWidget * widget,
guint code, guint code,
gchar const *message, gchar const *message,
XedWindow * window); XedFileBrowserPluginPrivate * data);
static void on_model_set_cb (XedFileBrowserView * widget, static void on_model_set_cb (XedFileBrowserView * widget,
GParamSpec *arg1, GParamSpec *arg1,
XedWindow * window); XedFileBrowserPluginPrivate * data);
static void on_virtual_root_changed_cb (XedFileBrowserStore * model, static void on_virtual_root_changed_cb (XedFileBrowserStore * model,
GParamSpec * param, GParamSpec * param,
XedWindow * window); XedFileBrowserPluginPrivate * data);
static void on_filter_mode_changed_cb (XedFileBrowserStore * model, static void on_filter_mode_changed_cb (XedFileBrowserStore * model,
GParamSpec * param, GParamSpec * param,
XedWindow * window); XedFileBrowserPluginPrivate * data);
static void on_rename_cb (XedFileBrowserStore * model, static void on_rename_cb (XedFileBrowserStore * model,
const gchar * olduri, const gchar * olduri,
const gchar * newuri, const gchar * newuri,
XedWindow * window); XedWindow * window);
static void on_filter_pattern_changed_cb (XedFileBrowserWidget * widget, static void on_filter_pattern_changed_cb (XedFileBrowserWidget * widget,
GParamSpec * param, GParamSpec * param,
XedWindow * window); XedFileBrowserPluginPrivate * data);
static void on_tab_added_cb (XedWindow * window, static void on_tab_added_cb (XedWindow * window,
XedTab * tab, XedTab * tab,
XedFileBrowserPluginData * data); XedFileBrowserPluginPrivate * data);
static gboolean on_confirm_delete_cb (XedFileBrowserWidget * widget, static gboolean on_confirm_delete_cb (XedFileBrowserWidget * widget,
XedFileBrowserStore * store, XedFileBrowserStore * store,
GList * rows, GList * rows,
XedWindow * window); XedFileBrowserPluginPrivate * data);
static gboolean on_confirm_no_trash_cb (XedFileBrowserWidget * widget, static gboolean on_confirm_no_trash_cb (XedFileBrowserWidget * widget,
GList * files, GList * files,
XedWindow * window); XedWindow * window);
XED_PLUGIN_REGISTER_TYPE_WITH_CODE (XedFileBrowserPlugin, filetree_plugin, \ static void peas_activatable_iface_init (PeasActivatableInterface *iface);
xed_file_browser_enum_and_flag_register_type (type_module); \
xed_file_browser_store_register_type (type_module); \ G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedFileBrowserPlugin,
xed_file_bookmarks_store_register_type (type_module); \ xed_file_browser_plugin,
xed_file_browser_view_register_type (type_module); \ PEAS_TYPE_EXTENSION_BASE,
xed_file_browser_widget_register_type (type_module); \ 0,
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
peas_activatable_iface_init) \
\
xed_file_browser_enum_and_flag_register_type (type_module); \
_xed_file_browser_store_register_type (type_module); \
_xed_file_bookmarks_store_register_type (type_module); \
_xed_file_browser_view_register_type (type_module); \
_xed_file_browser_widget_register_type (type_module);
) )
static void static void
filetree_plugin_init (XedFileBrowserPlugin * plugin) xed_file_browser_plugin_init (XedFileBrowserPlugin * plugin)
{ {
plugin->priv = XED_FILE_BROWSER_PLUGIN_GET_PRIVATE (plugin); plugin->priv = XED_FILE_BROWSER_PLUGIN_GET_PRIVATE (plugin);
} }
static void static void
filetree_plugin_finalize (GObject * object) xed_file_browser_plugin_dispose (GObject * object)
{ {
//XedFileBrowserPlugin * plugin = XED_FILE_BROWSER_PLUGIN (object); XedFileBrowserPlugin *plugin = XED_FILE_BROWSER_PLUGIN (object);
G_OBJECT_CLASS (filetree_plugin_parent_class)->finalize (object); if (plugin->priv->window != NULL)
{
g_object_unref (plugin->priv->window);
plugin->priv->window = NULL;
}
G_OBJECT_CLASS (xed_file_browser_plugin_parent_class)->dispose (object);
} }
static XedFileBrowserPluginData * static void
get_plugin_data (XedWindow * window) xed_file_browser_plugin_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{ {
return (XedFileBrowserPluginData *) (g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY)); XedFileBrowserPlugin *plugin = XED_FILE_BROWSER_PLUGIN (object);
switch (prop_id)
{
case PROP_OBJECT:
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
xed_file_browser_plugin_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
XedFileBrowserPlugin *plugin = XED_FILE_BROWSER_PLUGIN (object);
switch (prop_id)
{
case PROP_OBJECT:
g_value_set_object (value, plugin->priv->window);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} }
static void static void
on_end_loading_cb (XedFileBrowserStore * store, on_end_loading_cb (XedFileBrowserStore * store,
GtkTreeIter * iter, GtkTreeIter * iter,
XedFileBrowserPluginData * data) XedFileBrowserPluginPrivate * data)
{ {
/* Disconnect the signal */ /* Disconnect the signal */
g_signal_handler_disconnect (store, data->end_loading_handle); g_signal_handler_disconnect (store, data->end_loading_handle);
@ -139,7 +188,7 @@ on_end_loading_cb (XedFileBrowserStore * store,
} }
static void static void
prepare_auto_root (XedFileBrowserPluginData *data) prepare_auto_root (XedFileBrowserPluginPrivate *data)
{ {
XedFileBrowserStore *store; XedFileBrowserStore *store;
@ -159,7 +208,7 @@ prepare_auto_root (XedFileBrowserPluginData *data)
} }
static void static void
restore_default_location (XedFileBrowserPluginData *data) restore_default_location (XedFileBrowserPluginPrivate *data)
{ {
gchar * root; gchar * root;
gchar * virtual_root; gchar * virtual_root;
@ -205,7 +254,7 @@ restore_default_location (XedFileBrowserPluginData *data)
} }
static void static void
restore_filter (XedFileBrowserPluginData * data) restore_filter (XedFileBrowserPluginPrivate *data)
{ {
gchar *filter_mode; gchar *filter_mode;
XedFileBrowserStoreFilterMode mode; XedFileBrowserStoreFilterMode mode;
@ -247,7 +296,7 @@ restore_filter (XedFileBrowserPluginData * data)
} }
static void static void
set_root_from_doc (XedFileBrowserPluginData * data, set_root_from_doc (XedFileBrowserPluginPrivate * data,
XedDocument * doc) XedDocument * doc)
{ {
GFile *file; GFile *file;
@ -280,17 +329,13 @@ set_root_from_doc (XedFileBrowserPluginData * data,
static void static void
on_action_set_active_root (GtkAction * action, on_action_set_active_root (GtkAction * action,
XedWindow * window) XedFileBrowserPluginPrivate * data)
{ {
XedFileBrowserPluginData *data; set_root_from_doc (data, xed_window_get_active_document (XED_WINDOW (data->window)));
data = get_plugin_data (window);
set_root_from_doc (data,
xed_window_get_active_document (window));
} }
static gchar * static gchar *
get_terminal (XedFileBrowserPluginData * data) get_terminal (XedFileBrowserPluginPrivate * data)
{ {
// TODO : Identify the DE, find the preferred terminal application (xterminal shouldn't be hardcoded here, it should be set as default in the DE prefs) // TODO : Identify the DE, find the preferred terminal application (xterminal shouldn't be hardcoded here, it should be set as default in the DE prefs)
return g_strdup ("xterminal"); return g_strdup ("xterminal");
@ -298,9 +343,8 @@ get_terminal (XedFileBrowserPluginData * data)
static void static void
on_action_open_terminal (GtkAction * action, on_action_open_terminal (GtkAction * action,
XedWindow * window) XedFileBrowserPluginPrivate * data)
{ {
XedFileBrowserPluginData * data;
gchar * terminal; gchar * terminal;
gchar * wd = NULL; gchar * wd = NULL;
gchar * local; gchar * local;
@ -310,8 +354,6 @@ on_action_open_terminal (GtkAction * action,
GtkTreeIter iter; GtkTreeIter iter;
XedFileBrowserStore * store; XedFileBrowserStore * store;
data = get_plugin_data (window);
/* Get the current directory */ /* Get the current directory */
if (!xed_file_browser_widget_get_selected_directory (data->tree_widget, &iter)) if (!xed_file_browser_widget_get_selected_directory (data->tree_widget, &iter))
return; return;
@ -351,17 +393,14 @@ on_action_open_terminal (GtkAction * action,
static void static void
on_selection_changed_cb (GtkTreeSelection *selection, on_selection_changed_cb (GtkTreeSelection *selection,
XedWindow *window) XedFileBrowserPluginPrivate *data)
{ {
XedFileBrowserPluginData * data;
GtkTreeView * tree_view; GtkTreeView * tree_view;
GtkTreeModel * model; GtkTreeModel * model;
GtkTreeIter iter; GtkTreeIter iter;
gboolean sensitive; gboolean sensitive;
gchar * uri; gchar * uri;
data = get_plugin_data (window);
tree_view = GTK_TREE_VIEW (xed_file_browser_widget_get_browser_view (data->tree_widget)); tree_view = GTK_TREE_VIEW (xed_file_browser_widget_get_browser_view (data->tree_widget));
model = gtk_tree_view_get_model (tree_view); model = gtk_tree_view_get_model (tree_view);
@ -418,14 +457,12 @@ static GtkActionEntry extra_single_selection_actions[] = {
}; };
static void static void
add_popup_ui (XedWindow * window) add_popup_ui (XedFileBrowserPluginPrivate *data)
{ {
XedFileBrowserPluginData * data;
GtkUIManager * manager; GtkUIManager * manager;
GtkActionGroup * action_group; GtkActionGroup * action_group;
GError * error = NULL; GError * error = NULL;
data = get_plugin_data (window);
manager = xed_file_browser_widget_get_ui_manager (data->tree_widget); manager = xed_file_browser_widget_get_ui_manager (data->tree_widget);
action_group = gtk_action_group_new ("FileBrowserPluginExtra"); action_group = gtk_action_group_new ("FileBrowserPluginExtra");
@ -433,7 +470,7 @@ add_popup_ui (XedWindow * window)
gtk_action_group_add_actions (action_group, gtk_action_group_add_actions (action_group,
extra_actions, extra_actions,
G_N_ELEMENTS (extra_actions), G_N_ELEMENTS (extra_actions),
window); data);
gtk_ui_manager_insert_action_group (manager, action_group, 0); gtk_ui_manager_insert_action_group (manager, action_group, 0);
data->action_group = action_group; data->action_group = action_group;
@ -442,7 +479,7 @@ add_popup_ui (XedWindow * window)
gtk_action_group_add_actions (action_group, gtk_action_group_add_actions (action_group,
extra_single_selection_actions, extra_single_selection_actions,
G_N_ELEMENTS (extra_single_selection_actions), G_N_ELEMENTS (extra_single_selection_actions),
window); data);
gtk_ui_manager_insert_action_group (manager, action_group, 0); gtk_ui_manager_insert_action_group (manager, action_group, 0);
data->single_selection_action_group = action_group; data->single_selection_action_group = action_group;
@ -458,12 +495,10 @@ add_popup_ui (XedWindow * window)
} }
static void static void
remove_popup_ui (XedWindow * window) remove_popup_ui (XedFileBrowserPluginPrivate *data)
{ {
XedFileBrowserPluginData * data;
GtkUIManager * manager; GtkUIManager * manager;
data = get_plugin_data (window);
manager = xed_file_browser_widget_get_ui_manager (data->tree_widget); manager = xed_file_browser_widget_get_ui_manager (data->tree_widget);
gtk_ui_manager_remove_ui (manager, data->merge_id); gtk_ui_manager_remove_ui (manager, data->merge_id);
@ -475,14 +510,14 @@ remove_popup_ui (XedWindow * window)
} }
static void static void
impl_updateui (XedPlugin * plugin, XedWindow * window) xed_file_browser_plugin_update_state (PeasActivatable *activatable)
{ {
XedFileBrowserPluginData * data; XedFileBrowserPluginPrivate *data;
XedDocument * doc; XedDocument * doc;
data = get_plugin_data (window); data = XED_FILE_BROWSER_PLUGIN (activatable)->priv;
doc = xed_window_get_active_document (window); doc = xed_window_get_active_document (XED_WINDOW (data->window));
gtk_action_set_sensitive (gtk_action_group_get_action (data->action_group, gtk_action_set_sensitive (gtk_action_group_get_action (data->action_group,
"SetActiveRoot"), "SetActiveRoot"),
@ -491,10 +526,11 @@ impl_updateui (XedPlugin * plugin, XedWindow * window)
} }
static void static void
impl_activate (XedPlugin * plugin, XedWindow * window) xed_file_browser_plugin_activate (PeasActivatable *activatable)
{ {
XedFileBrowserPluginPrivate *data;
XedWindow *window;
XedPanel * panel; XedPanel * panel;
XedFileBrowserPluginData * data;
GtkWidget * image; GtkWidget * image;
GdkPixbuf * pixbuf; GdkPixbuf * pixbuf;
XedFileBrowserStore * store; XedFileBrowserStore * store;
@ -502,9 +538,10 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
GSettingsSchemaSource *schema_source; GSettingsSchemaSource *schema_source;
GSettingsSchema *schema; GSettingsSchema *schema;
data = g_new0 (XedFileBrowserPluginData, 1); data = XED_FILE_BROWSER_PLUGIN (activatable)->priv;
window = XED_WINDOW (data->window);
data_dir = xed_plugin_get_data_dir (plugin); data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (activatable));
data->tree_widget = XED_FILE_BROWSER_WIDGET (xed_file_browser_widget_new (data_dir)); data->tree_widget = XED_FILE_BROWSER_WIDGET (xed_file_browser_widget_new (data_dir));
g_free (data_dir); g_free (data_dir);
@ -516,17 +553,17 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
G_CALLBACK (on_uri_activated_cb), window); G_CALLBACK (on_uri_activated_cb), window);
g_signal_connect (data->tree_widget, g_signal_connect (data->tree_widget,
"error", G_CALLBACK (on_error_cb), window); "error", G_CALLBACK (on_error_cb), data);
g_signal_connect (data->tree_widget, g_signal_connect (data->tree_widget,
"notify::filter-pattern", "notify::filter-pattern",
G_CALLBACK (on_filter_pattern_changed_cb), G_CALLBACK (on_filter_pattern_changed_cb),
window); data);
g_signal_connect (data->tree_widget, g_signal_connect (data->tree_widget,
"confirm-delete", "confirm-delete",
G_CALLBACK (on_confirm_delete_cb), G_CALLBACK (on_confirm_delete_cb),
window); data);
g_signal_connect (data->tree_widget, g_signal_connect (data->tree_widget,
"confirm-no-trash", "confirm-no-trash",
@ -538,7 +575,7 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
(data->tree_widget))), (data->tree_widget))),
"changed", "changed",
G_CALLBACK (on_selection_changed_cb), G_CALLBACK (on_selection_changed_cb),
window); data);
panel = xed_window_get_side_panel (window); panel = xed_window_get_side_panel (window);
pixbuf = xed_file_browser_utils_pixbuf_from_theme("system-file-manager", pixbuf = xed_file_browser_utils_pixbuf_from_theme("system-file-manager",
@ -557,9 +594,8 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
_("File Browser"), _("File Browser"),
image); image);
gtk_widget_show (GTK_WIDGET (data->tree_widget)); gtk_widget_show (GTK_WIDGET (data->tree_widget));
g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, data);
add_popup_ui (window); add_popup_ui (data);
/* Restore filter options */ /* Restore filter options */
restore_filter (data); restore_filter (data);
@ -568,18 +604,18 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
g_signal_connect (xed_file_browser_widget_get_browser_view (data->tree_widget), g_signal_connect (xed_file_browser_widget_get_browser_view (data->tree_widget),
"notify::model", "notify::model",
G_CALLBACK (on_model_set_cb), G_CALLBACK (on_model_set_cb),
window); data);
store = xed_file_browser_widget_get_browser_store (data->tree_widget); store = xed_file_browser_widget_get_browser_store (data->tree_widget);
g_signal_connect (store, g_signal_connect (store,
"notify::virtual-root", "notify::virtual-root",
G_CALLBACK (on_virtual_root_changed_cb), G_CALLBACK (on_virtual_root_changed_cb),
window); data);
g_signal_connect (store, g_signal_connect (store,
"notify::filter-mode", "notify::filter-mode",
G_CALLBACK (on_filter_mode_changed_cb), G_CALLBACK (on_filter_mode_changed_cb),
window); data);
g_signal_connect (store, g_signal_connect (store,
"rename", "rename",
@ -594,16 +630,18 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
/* Register messages on the bus */ /* Register messages on the bus */
xed_file_browser_messages_register (window, data->tree_widget); xed_file_browser_messages_register (window, data->tree_widget);
impl_updateui (plugin, window); xed_file_browser_plugin_update_state (activatable);
} }
static void static void
impl_deactivate (XedPlugin * plugin, XedWindow * window) xed_file_browser_plugin_deactivate (PeasActivatable *activatable)
{ {
XedFileBrowserPluginData * data; XedFileBrowserPluginPrivate *data;
XedWindow *window;
XedPanel * panel; XedPanel * panel;
data = get_plugin_data (window); data = XED_FILE_BROWSER_PLUGIN (activatable)->priv;
window = XED_WINDOW (data->window);
/* Unregister messages from the bus */ /* Unregister messages from the bus */
xed_file_browser_messages_unregister (window); xed_file_browser_messages_unregister (window);
@ -616,31 +654,51 @@ impl_deactivate (XedPlugin * plugin, XedWindow * window)
g_object_unref (data->settings); g_object_unref (data->settings);
g_object_unref (data->onload_settings); g_object_unref (data->onload_settings);
remove_popup_ui (window); remove_popup_ui (data);
panel = xed_window_get_side_panel (window); panel = xed_window_get_side_panel (window);
xed_panel_remove_item (panel, GTK_WIDGET (data->tree_widget)); xed_panel_remove_item (panel, GTK_WIDGET (data->tree_widget));
g_free (data);
g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
} }
static void static void
filetree_plugin_class_init (XedFileBrowserPluginClass * klass) xed_file_browser_plugin_class_init (XedFileBrowserPluginClass * klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
XedPluginClass * plugin_class = XED_PLUGIN_CLASS (klass);
object_class->finalize = filetree_plugin_finalize; object_class->dispose = xed_file_browser_plugin_dispose;
object_class->set_property = xed_file_browser_plugin_set_property;
object_class->get_property = xed_file_browser_plugin_get_property;
plugin_class->activate = impl_activate; g_object_class_override_property (object_class, PROP_OBJECT, "object");
plugin_class->deactivate = impl_deactivate;
plugin_class->update_ui = impl_updateui;
g_type_class_add_private (object_class, g_type_class_add_private (object_class,
sizeof (XedFileBrowserPluginPrivate)); sizeof (XedFileBrowserPluginPrivate));
} }
static void
xed_file_browser_plugin_class_finalize (XedFileBrowserPluginClass *klass)
{
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE_EXTENDED */
}
static void
peas_activatable_iface_init (PeasActivatableInterface *iface)
{
iface->activate = xed_file_browser_plugin_activate;
iface->deactivate = xed_file_browser_plugin_deactivate;
iface->update_state = xed_file_browser_plugin_update_state;
}
G_MODULE_EXPORT void
peas_register_types (PeasObjectModule *module)
{
xed_file_browser_plugin_register_type (G_TYPE_MODULE (module));
peas_object_module_register_extension_type (module,
PEAS_TYPE_ACTIVATABLE,
XED_TYPE_FILE_BROWSER_PLUGIN);
}
/* Callbacks */ /* Callbacks */
static void static void
on_uri_activated_cb (XedFileBrowserWidget * tree_widget, on_uri_activated_cb (XedFileBrowserWidget * tree_widget,
@ -651,13 +709,10 @@ on_uri_activated_cb (XedFileBrowserWidget * tree_widget,
static void static void
on_error_cb (XedFileBrowserWidget * tree_widget, on_error_cb (XedFileBrowserWidget * tree_widget,
guint code, gchar const *message, XedWindow * window) guint code, gchar const *message, XedFileBrowserPluginPrivate * data)
{ {
gchar * title; gchar * title;
GtkWidget * dlg; GtkWidget * dlg;
XedFileBrowserPluginData * data;
data = get_plugin_data (window);
/* Do not show the error when the root has been set automatically */ /* Do not show the error when the root has been set automatically */
if (data->auto_root && (code == XED_FILE_BROWSER_ERROR_SET_ROOT || if (data->auto_root && (code == XED_FILE_BROWSER_ERROR_SET_ROOT ||
@ -704,7 +759,7 @@ on_error_cb (XedFileBrowserWidget * tree_widget,
break; break;
} }
dlg = gtk_message_dialog_new (GTK_WINDOW (window), dlg = gtk_message_dialog_new (GTK_WINDOW (data->window),
GTK_DIALOG_MODAL | GTK_DIALOG_MODAL |
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
@ -719,9 +774,8 @@ on_error_cb (XedFileBrowserWidget * tree_widget,
static void static void
on_model_set_cb (XedFileBrowserView * widget, on_model_set_cb (XedFileBrowserView * widget,
GParamSpec *arg1, GParamSpec *arg1,
XedWindow * window) XedFileBrowserPluginPrivate * data)
{ {
XedFileBrowserPluginData * data = get_plugin_data (window);
GtkTreeModel * model; GtkTreeModel * model;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (xed_file_browser_widget_get_browser_view (data->tree_widget))); model = gtk_tree_view_get_model (GTK_TREE_VIEW (xed_file_browser_widget_get_browser_view (data->tree_widget)));
@ -737,9 +791,8 @@ on_model_set_cb (XedFileBrowserView * widget,
static void static void
on_filter_mode_changed_cb (XedFileBrowserStore * model, on_filter_mode_changed_cb (XedFileBrowserStore * model,
GParamSpec * param, GParamSpec * param,
XedWindow * window) XedFileBrowserPluginPrivate * data)
{ {
XedFileBrowserPluginData * data = get_plugin_data (window);
XedFileBrowserStoreFilterMode mode; XedFileBrowserStoreFilterMode mode;
mode = xed_file_browser_store_get_filter_mode (model); mode = xed_file_browser_store_get_filter_mode (model);
@ -823,9 +876,8 @@ on_rename_cb (XedFileBrowserStore * store,
static void static void
on_filter_pattern_changed_cb (XedFileBrowserWidget * widget, on_filter_pattern_changed_cb (XedFileBrowserWidget * widget,
GParamSpec * param, GParamSpec * param,
XedWindow * window) XedFileBrowserPluginPrivate * data)
{ {
XedFileBrowserPluginData * data = get_plugin_data (window);
gchar * pattern; gchar * pattern;
g_object_get (G_OBJECT (widget), "filter-pattern", &pattern, NULL); g_object_get (G_OBJECT (widget), "filter-pattern", &pattern, NULL);
@ -841,9 +893,8 @@ on_filter_pattern_changed_cb (XedFileBrowserWidget * widget,
static void static void
on_virtual_root_changed_cb (XedFileBrowserStore * store, on_virtual_root_changed_cb (XedFileBrowserStore * store,
GParamSpec * param, GParamSpec * param,
XedWindow * window) XedFileBrowserPluginPrivate * data)
{ {
XedFileBrowserPluginData * data = get_plugin_data (window);
gchar * root; gchar * root;
gchar * virtual_root; gchar * virtual_root;
@ -863,7 +914,7 @@ on_virtual_root_changed_cb (XedFileBrowserStore * store,
g_settings_set_string (data->onload_settings, "virtual-root", virtual_root); g_settings_set_string (data->onload_settings, "virtual-root", virtual_root);
} }
g_signal_handlers_disconnect_by_func (window, g_signal_handlers_disconnect_by_func (XED_WINDOW (data->window),
G_CALLBACK (on_tab_added_cb), G_CALLBACK (on_tab_added_cb),
data); data);
@ -874,7 +925,7 @@ on_virtual_root_changed_cb (XedFileBrowserStore * store,
static void static void
on_tab_added_cb (XedWindow * window, on_tab_added_cb (XedWindow * window,
XedTab * tab, XedTab * tab,
XedFileBrowserPluginData * data) XedFileBrowserPluginPrivate *data)
{ {
gboolean open; gboolean open;
gboolean load_default = TRUE; gboolean load_default = TRUE;
@ -956,15 +1007,12 @@ static gboolean
on_confirm_delete_cb (XedFileBrowserWidget *widget, on_confirm_delete_cb (XedFileBrowserWidget *widget,
XedFileBrowserStore *store, XedFileBrowserStore *store,
GList *paths, GList *paths,
XedWindow *window) XedFileBrowserPluginPrivate *data)
{ {
gchar *normal; gchar *normal;
gchar *message; gchar *message;
gchar *secondary; gchar *secondary;
gboolean result; gboolean result;
XedFileBrowserPluginData *data;
data = get_plugin_data (window);
if (paths->next == NULL) { if (paths->next == NULL) {
normal = get_filename_from_path (GTK_TREE_MODEL (store), (GtkTreePath *)(paths->data)); normal = get_filename_from_path (GTK_TREE_MODEL (store), (GtkTreePath *)(paths->data));
@ -976,7 +1024,7 @@ on_confirm_delete_cb (XedFileBrowserWidget *widget,
secondary = _("If you delete an item, it is permanently lost."); secondary = _("If you delete an item, it is permanently lost.");
result = xed_file_browser_utils_confirmation_dialog (window, result = xed_file_browser_utils_confirmation_dialog (XED_WINDOW (data->window),
GTK_MESSAGE_QUESTION, GTK_MESSAGE_QUESTION,
message, message,
secondary, secondary,

View File

@ -1,5 +1,5 @@
/* /*
* xed-file-browser-plugin.h - Xed plugin providing easy file access * xed-file-browser-plugin.h - Xed plugin providing easy file access
* from the sidepanel * from the sidepanel
* *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
@ -24,46 +24,48 @@
#include <glib.h> #include <glib.h>
#include <glib-object.h> #include <glib-object.h>
#include <xed/xed-plugin.h> #include <libpeas/peas-extension-base.h>
#include <libpeas/peas-object-module.h>
G_BEGIN_DECLS G_BEGIN_DECLS
/* /*
* Type checking and casting macros * Type checking and casting macros
*/ */
#define XED_TYPE_FILE_BROWSER_PLUGIN (filetree_plugin_get_type ()) #define XED_TYPE_FILE_BROWSER_PLUGIN (xed_file_browser_plugin_get_type ())
#define XED_FILE_BROWSER_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPlugin)) #define XED_FILE_BROWSER_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPlugin))
#define XED_FILE_BROWSER_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPluginClass)) #define XED_FILE_BROWSER_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPluginClass))
#define XED_IS_FILE_BROWSER_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XED_TYPE_FILE_BROWSER_PLUGIN)) #define XED_IS_FILE_BROWSER_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XED_TYPE_FILE_BROWSER_PLUGIN))
#define XED_IS_FILE_BROWSER_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_FILE_BROWSER_PLUGIN)) #define XED_IS_FILE_BROWSER_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_FILE_BROWSER_PLUGIN))
#define XED_FILE_BROWSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPluginClass)) #define XED_FILE_BROWSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPluginClass))
/* Private structure type */ /* Private structure type */
typedef struct _XedFileBrowserPluginPrivate XedFileBrowserPluginPrivate; typedef struct _XedFileBrowserPluginPrivate XedFileBrowserPluginPrivate;
typedef struct _XedFileBrowserPlugin XedFileBrowserPlugin; typedef struct _XedFileBrowserPlugin XedFileBrowserPlugin;
typedef struct _XedFileBrowserPluginClass XedFileBrowserPluginClass; typedef struct _XedFileBrowserPluginClass XedFileBrowserPluginClass;
struct _XedFileBrowserPlugin struct _XedFileBrowserPlugin
{ {
XedPlugin parent_instance; PeasExtensionBase parent_instance;
/*< private > */ /*< private > */
XedFileBrowserPluginPrivate *priv; XedFileBrowserPluginPrivate *priv;
}; };
struct _XedFileBrowserPluginClass struct _XedFileBrowserPluginClass
{ {
XedPluginClass parent_class; PeasExtensionBaseClass parent_class;
}; };
/* /*
* Public methods * Public methods
*/ */
GType filetree_plugin_get_type (void) G_GNUC_CONST; GType xed_file_browser_plugin_get_type (void) G_GNUC_CONST;
/* All the plugins must implement this function */ /* All the plugins must implement this function */
G_MODULE_EXPORT GType register_xed_plugin (GTypeModule * module); G_MODULE_EXPORT void peas_register_types (PeasObjectModule * module);
G_END_DECLS G_END_DECLS
#endif /* __XED_FILE_BROWSER_PLUGIN_H__ */ #endif /* __XED_FILE_BROWSER_PLUGIN_H__ */

View File

@ -1,5 +1,5 @@
/* /*
* xed-file-browser-store.c - Xed plugin providing easy file access * xed-file-browser-store.c - Xed plugin providing easy file access
* from the sidepanel * from the sidepanel
* *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
@ -26,7 +26,6 @@
#include <string.h> #include <string.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <xed/xed-plugin.h>
#include <xed/xed-utils.h> #include <xed/xed-utils.h>
#include "xed-file-browser-store.h" #include "xed-file-browser-store.h"
@ -88,7 +87,7 @@ typedef struct {
GCancellable * cancellable; GCancellable * cancellable;
} MountInfo; } MountInfo;
struct _FileBrowserNode struct _FileBrowserNode
{ {
GFile *file; GFile *file;
guint flags; guint flags;
@ -102,7 +101,7 @@ struct _FileBrowserNode
gboolean inserted; gboolean inserted;
}; };
struct _FileBrowserNodeDir struct _FileBrowserNodeDir
{ {
FileBrowserNode node; FileBrowserNode node;
GSList *children; GSList *children;
@ -113,7 +112,7 @@ struct _FileBrowserNodeDir
XedFileBrowserStore *model; XedFileBrowserStore *model;
}; };
struct _XedFileBrowserStorePrivate struct _XedFileBrowserStorePrivate
{ {
FileBrowserNode *root; FileBrowserNode *root;
FileBrowserNode *virtual_root; FileBrowserNode *virtual_root;
@ -133,7 +132,7 @@ static FileBrowserNode *model_find_node (XedFileBrowserStore *model,
FileBrowserNode *node, FileBrowserNode *node,
GFile *uri); GFile *uri);
static void model_remove_node (XedFileBrowserStore * model, static void model_remove_node (XedFileBrowserStore * model,
FileBrowserNode * node, FileBrowserNode * node,
GtkTreePath * path, GtkTreePath * path,
gboolean free_nodes); gboolean free_nodes);
@ -165,7 +164,7 @@ static gint xed_file_browser_store_iter_n_children (GtkTreeModel * tree_m
GtkTreeIter * iter); GtkTreeIter * iter);
static gboolean xed_file_browser_store_iter_nth_child (GtkTreeModel * tree_model, static gboolean xed_file_browser_store_iter_nth_child (GtkTreeModel * tree_model,
GtkTreeIter * iter, GtkTreeIter * iter,
GtkTreeIter * parent, GtkTreeIter * parent,
gint n); gint n);
static gboolean xed_file_browser_store_iter_parent (GtkTreeModel * tree_model, static gboolean xed_file_browser_store_iter_parent (GtkTreeModel * tree_model,
GtkTreeIter * iter, GtkTreeIter * iter,
@ -197,13 +196,12 @@ static void model_check_dummy (XedFileBrowserStore
static void next_files_async (GFileEnumerator * enumerator, static void next_files_async (GFileEnumerator * enumerator,
AsyncNode * async); AsyncNode * async);
XED_PLUGIN_DEFINE_TYPE_WITH_CODE (XedFileBrowserStore, xed_file_browser_store, G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedFileBrowserStore, xed_file_browser_store,
G_TYPE_OBJECT, G_TYPE_OBJECT,
XED_PLUGIN_IMPLEMENT_INTERFACE (xed_file_browser_store_tree_model, 0,
GTK_TYPE_TREE_MODEL, G_IMPLEMENT_INTERFACE_DYNAMIC (GTK_TYPE_TREE_MODEL,
xed_file_browser_store_iface_init) xed_file_browser_store_iface_init)
XED_PLUGIN_IMPLEMENT_INTERFACE (xed_file_browser_store_drag_source, G_IMPLEMENT_INTERFACE_DYNAMIC (GTK_TYPE_TREE_DRAG_SOURCE,
GTK_TYPE_TREE_DRAG_SOURCE,
xed_file_browser_store_drag_source_init)) xed_file_browser_store_drag_source_init))
/* Properties */ /* Properties */
@ -216,7 +214,7 @@ enum {
}; };
/* Signals */ /* Signals */
enum enum
{ {
BEGIN_LOADING, BEGIN_LOADING,
END_LOADING, END_LOADING,
@ -256,10 +254,10 @@ xed_file_browser_store_finalize (GObject * object)
{ {
AsyncData *data = (AsyncData *) (item->data); AsyncData *data = (AsyncData *) (item->data);
g_cancellable_cancel (data->cancellable); g_cancellable_cancel (data->cancellable);
data->removed = TRUE; data->removed = TRUE;
} }
cancel_mount_operation (obj); cancel_mount_operation (obj);
g_slist_free (obj->priv->async_handles); g_slist_free (obj->priv->async_handles);
@ -295,7 +293,7 @@ xed_file_browser_store_get_property (GObject *object,
break; break;
case PROP_VIRTUAL_ROOT: case PROP_VIRTUAL_ROOT:
set_gvalue_from_node (value, obj->priv->virtual_root); set_gvalue_from_node (value, obj->priv->virtual_root);
break; break;
case PROP_FILTER_MODE: case PROP_FILTER_MODE:
g_value_set_flags (value, obj->priv->filter_mode); g_value_set_flags (value, obj->priv->filter_mode);
break; break;
@ -393,7 +391,7 @@ xed_file_browser_store_class_init (XedFileBrowserStoreClass * klass)
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (XedFileBrowserStoreClass, G_STRUCT_OFFSET (XedFileBrowserStoreClass,
rename), NULL, NULL, rename), NULL, NULL,
xed_file_browser_marshal_VOID__STRING_STRING, xed_file_browser_marshal_VOID__STRING_STRING,
G_TYPE_NONE, 2, G_TYPE_NONE, 2,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING); G_TYPE_STRING);
@ -427,6 +425,12 @@ xed_file_browser_store_class_init (XedFileBrowserStoreClass * klass)
sizeof (XedFileBrowserStorePrivate)); sizeof (XedFileBrowserStorePrivate));
} }
static void
xed_file_browser_store_class_finalize (XedFileBrowserStoreClass *klass)
{
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE_EXTENDED */
}
static void static void
xed_file_browser_store_iface_init (GtkTreeModelIface * iface) xed_file_browser_store_iface_init (GtkTreeModelIface * iface)
{ {
@ -659,13 +663,13 @@ xed_file_browser_store_get_path (GtkTreeModel * tree_model,
g_return_val_if_fail (iter != NULL, NULL); g_return_val_if_fail (iter != NULL, NULL);
g_return_val_if_fail (iter->user_data != NULL, NULL); g_return_val_if_fail (iter->user_data != NULL, NULL);
return xed_file_browser_store_get_path_real (XED_FILE_BROWSER_STORE (tree_model), return xed_file_browser_store_get_path_real (XED_FILE_BROWSER_STORE (tree_model),
(FileBrowserNode *) (iter->user_data)); (FileBrowserNode *) (iter->user_data));
} }
static void static void
xed_file_browser_store_get_value (GtkTreeModel * tree_model, xed_file_browser_store_get_value (GtkTreeModel * tree_model,
GtkTreeIter * iter, GtkTreeIter * iter,
gint column, gint column,
GValue * value) GValue * value)
{ {
@ -774,7 +778,7 @@ filter_tree_model_iter_has_child_real (XedFileBrowserStore * model,
FileBrowserNode * node) FileBrowserNode * node)
{ {
GSList *item; GSList *item;
if (!NODE_IS_DIR (node)) if (!NODE_IS_DIR (node))
return FALSE; return FALSE;
@ -910,7 +914,7 @@ xed_file_browser_store_row_inserted (GtkTreeModel * tree_model,
GtkTreeIter * iter) GtkTreeIter * iter)
{ {
FileBrowserNode * node = (FileBrowserNode *)(iter->user_data); FileBrowserNode * node = (FileBrowserNode *)(iter->user_data);
node->inserted = TRUE; node->inserted = TRUE;
} }
@ -1143,7 +1147,7 @@ row_changed (XedFileBrowserStore * model,
signal may alter the path */ signal may alter the path */
gtk_tree_model_row_changed (GTK_TREE_MODEL(model), *path, iter); gtk_tree_model_row_changed (GTK_TREE_MODEL(model), *path, iter);
gtk_tree_path_free (*path); gtk_tree_path_free (*path);
*path = gtk_tree_row_reference_get_path (ref); *path = gtk_tree_row_reference_get_path (ref);
gtk_tree_row_reference_free (ref); gtk_tree_row_reference_free (ref);
} }
@ -1155,7 +1159,7 @@ row_inserted (XedFileBrowserStore * model,
{ {
/* This function creates a row reference for the path because it's /* This function creates a row reference for the path because it's
uncertain what might change the actual model/view when we insert uncertain what might change the actual model/view when we insert
a node, maybe another directory load is triggered for example. a node, maybe another directory load is triggered for example.
Because functions that use this function rely on the notion that Because functions that use this function rely on the notion that
the path remains pointed towards the inserted node, we use the the path remains pointed towards the inserted node, we use the
reference to keep track. */ reference to keep track. */
@ -1164,7 +1168,7 @@ row_inserted (XedFileBrowserStore * model,
gtk_tree_model_row_inserted (GTK_TREE_MODEL(model), copy, iter); gtk_tree_model_row_inserted (GTK_TREE_MODEL(model), copy, iter);
gtk_tree_path_free (copy); gtk_tree_path_free (copy);
if (ref) if (ref)
{ {
gtk_tree_path_free (*path); gtk_tree_path_free (*path);
@ -1184,7 +1188,7 @@ row_deleted (XedFileBrowserStore * model,
const GtkTreePath * path) const GtkTreePath * path)
{ {
GtkTreePath *copy = gtk_tree_path_copy (path); GtkTreePath *copy = gtk_tree_path_copy (path);
/* Delete a copy of the actual path here because the row-deleted /* Delete a copy of the actual path here because the row-deleted
signal may alter the path */ signal may alter the path */
gtk_tree_model_row_deleted (GTK_TREE_MODEL(model), copy); gtk_tree_model_row_deleted (GTK_TREE_MODEL(model), copy);
@ -1255,7 +1259,7 @@ model_refilter_node (XedFileBrowserStore * model,
gtk_tree_path_next (*path); gtk_tree_path_next (*path);
} }
} }
model_check_dummy (model, node); model_check_dummy (model, node);
if (tmppath) if (tmppath)
@ -1373,7 +1377,7 @@ file_browser_node_free (XedFileBrowserStore * model,
if (dir->hidden_file_hash) if (dir->hidden_file_hash)
g_hash_table_destroy (dir->hidden_file_hash); g_hash_table_destroy (dir->hidden_file_hash);
} }
if (node->file) if (node->file)
{ {
uri = g_file_get_uri (node->file); uri = g_file_get_uri (node->file);
@ -1390,7 +1394,7 @@ file_browser_node_free (XedFileBrowserStore * model,
g_object_unref (node->emblem); g_object_unref (node->emblem);
g_free (node->name); g_free (node->name);
if (NODE_IS_DIR (node)) if (NODE_IS_DIR (node))
g_slice_free (FileBrowserNodeDir, (FileBrowserNodeDir *)node); g_slice_free (FileBrowserNodeDir, (FileBrowserNodeDir *)node);
else else
@ -1432,10 +1436,10 @@ model_remove_node_children (XedFileBrowserStore * model,
// be freed // be freed
if (free_nodes) if (free_nodes)
file_browser_node_free_children (model, node); file_browser_node_free_children (model, node);
return; return;
} }
if (path == NULL) if (path == NULL)
path_child = path_child =
xed_file_browser_store_get_path_real (model, node); xed_file_browser_store_get_path_real (model, node);
@ -1459,10 +1463,10 @@ model_remove_node_children (XedFileBrowserStore * model,
* model_remove_node: * model_remove_node:
* @model: the #XedFileBrowserStore * @model: the #XedFileBrowserStore
* @node: the FileBrowserNode to remove * @node: the FileBrowserNode to remove
* @path: the path to use to remove this node, or NULL to use the path * @path: the path to use to remove this node, or NULL to use the path
* calculated from the node itself * calculated from the node itself
* @free_nodes: whether to also remove the nodes from memory * @free_nodes: whether to also remove the nodes from memory
* *
* Removes this node and all its children from the model. This function is used * Removes this node and all its children from the model. This function is used
* to remove the node from the _model_. Don't use it to just free * to remove the node from the _model_. Don't use it to just free
* a node. * a node.
@ -1505,7 +1509,7 @@ model_remove_node (XedFileBrowserStore * model,
(node->parent)->children, (node->parent)->children,
node); node);
} }
/* If this is the virtual root, than set the parent as the virtual root */ /* If this is the virtual root, than set the parent as the virtual root */
if (node == model->priv->virtual_root) if (node == model->priv->virtual_root)
set_virtual_root_from_node (model, parent); set_virtual_root_from_node (model, parent);
@ -1548,7 +1552,7 @@ model_clear (XedFileBrowserStore * model, gboolean free_nodes)
if (NODE_IS_DUMMY (dummy) if (NODE_IS_DUMMY (dummy)
&& model_node_visibility (model, dummy)) { && model_node_visibility (model, dummy)) {
path = gtk_tree_path_new_first (); path = gtk_tree_path_new_first ();
dummy->inserted = FALSE; dummy->inserted = FALSE;
row_deleted (model, path); row_deleted (model, path);
gtk_tree_path_free (path); gtk_tree_path_free (path);
@ -1562,7 +1566,7 @@ file_browser_node_unload (XedFileBrowserStore * model,
FileBrowserNode * node, gboolean remove_children) FileBrowserNode * node, gboolean remove_children)
{ {
FileBrowserNodeDir *dir; FileBrowserNodeDir *dir;
if (node == NULL) if (node == NULL)
return; return;
@ -1585,7 +1589,7 @@ file_browser_node_unload (XedFileBrowserStore * model,
if (dir->monitor) { if (dir->monitor) {
g_file_monitor_cancel (dir->monitor); g_file_monitor_cancel (dir->monitor);
g_object_unref (dir->monitor); g_object_unref (dir->monitor);
dir->monitor = NULL; dir->monitor = NULL;
} }
@ -1734,7 +1738,7 @@ model_check_dummy (XedFileBrowserStore * model, FileBrowserNode * node)
path = path =
xed_file_browser_store_get_path_real xed_file_browser_store_get_path_real
(model, dummy); (model, dummy);
row_inserted (model, &path, &iter); row_inserted (model, &path, &iter);
gtk_tree_path_free (path); gtk_tree_path_free (path);
} }
@ -1750,7 +1754,7 @@ model_check_dummy (XedFileBrowserStore * model, FileBrowserNode * node)
(model, dummy); (model, dummy);
dummy->flags |= dummy->flags |=
XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN; XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN;
dummy->inserted = FALSE; dummy->inserted = FALSE;
row_deleted (model, path); row_deleted (model, path);
gtk_tree_path_free (path); gtk_tree_path_free (path);
@ -1892,15 +1896,15 @@ static gchar const *
backup_content_type (GFileInfo * info) backup_content_type (GFileInfo * info)
{ {
gchar const * content; gchar const * content;
if (!g_file_info_get_is_backup (info)) if (!g_file_info_get_is_backup (info))
return NULL; return NULL;
content = g_file_info_get_content_type (info); content = g_file_info_get_content_type (info);
if (!content || g_content_type_equals (content, "application/x-trash")) if (!content || g_content_type_equals (content, "application/x-trash"))
return "text/plain"; return "text/plain";
return content; return content;
} }
@ -1919,12 +1923,12 @@ file_browser_node_set_from_info (XedFileBrowserStore * model,
GError * error = NULL; GError * error = NULL;
if (info == NULL) { if (info == NULL) {
info = g_file_query_info (node->file, info = g_file_query_info (node->file,
STANDARD_ATTRIBUTE_TYPES, STANDARD_ATTRIBUTE_TYPES,
G_FILE_QUERY_INFO_NONE, G_FILE_QUERY_INFO_NONE,
NULL, NULL,
&error); &error);
if (!info) { if (!info) {
if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND)) { if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND)) {
uri = g_file_get_uri (node->file); uri = g_file_get_uri (node->file);
@ -1935,7 +1939,7 @@ file_browser_node_set_from_info (XedFileBrowserStore * model,
return; return;
} }
free_info = TRUE; free_info = TRUE;
} }
@ -1953,13 +1957,13 @@ file_browser_node_set_from_info (XedFileBrowserStore * model,
else { else {
if (!(content = backup_content_type (info))) if (!(content = backup_content_type (info)))
content = g_file_info_get_content_type (info); content = g_file_info_get_content_type (info);
if (!content || if (!content ||
g_content_type_is_unknown (content) || g_content_type_is_unknown (content) ||
g_content_type_is_a (content, "text/plain")) g_content_type_is_a (content, "text/plain"))
node->flags |= XED_FILE_BROWSER_STORE_FLAG_IS_TEXT; node->flags |= XED_FILE_BROWSER_STORE_FLAG_IS_TEXT;
} }
model_recomposite_icon_real (model, node, info); model_recomposite_icon_real (model, node, info);
if (free_info) if (free_info)
@ -1969,7 +1973,7 @@ file_browser_node_set_from_info (XedFileBrowserStore * model,
path = xed_file_browser_store_get_path_real (model, node); path = xed_file_browser_store_get_path_real (model, node);
model_refilter_node (model, node, &path); model_refilter_node (model, node, &path);
gtk_tree_path_free (path); gtk_tree_path_free (path);
model_check_dummy (model, node->parent); model_check_dummy (model, node->parent);
} else { } else {
model_node_update_visibility (model, node); model_node_update_visibility (model, node);
@ -2013,11 +2017,11 @@ model_add_node_from_file (XedFileBrowserStore * model,
&error); &error);
free_info = TRUE; free_info = TRUE;
} }
if (!info) { if (!info) {
g_warning ("Error querying file info: %s", error->message); g_warning ("Error querying file info: %s", error->message);
g_error_free (error); g_error_free (error);
/* FIXME: What to do now then... */ /* FIXME: What to do now then... */
node = file_browser_node_new (file, parent); node = file_browser_node_new (file, parent);
} else if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) { } else if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
@ -2028,7 +2032,7 @@ model_add_node_from_file (XedFileBrowserStore * model,
file_browser_node_set_from_info (model, node, info, FALSE); file_browser_node_set_from_info (model, node, info, FALSE);
model_add_node (model, node, parent); model_add_node (model, node, parent);
if (info && free_info) if (info && free_info)
g_object_unref (info); g_object_unref (info);
} }
@ -2063,7 +2067,7 @@ model_add_nodes_from_files (XedFileBrowserStore * model,
type != G_FILE_TYPE_SYMBOLIC_LINK) { type != G_FILE_TYPE_SYMBOLIC_LINK) {
g_object_unref (info); g_object_unref (info);
continue; continue;
} }
name = g_file_info_get_name (info); name = g_file_info_get_name (info);
@ -2105,7 +2109,7 @@ model_add_node_from_dir (XedFileBrowserStore * model,
FileBrowserNode *node; FileBrowserNode *node;
/* Check if it already exists */ /* Check if it already exists */
if ((node = node_list_contains_file (FILE_BROWSER_NODE_DIR (parent)->children, file)) == NULL) { if ((node = node_list_contains_file (FILE_BROWSER_NODE_DIR (parent)->children, file)) == NULL) {
node = file_browser_node_dir_new (model, file, parent); node = file_browser_node_dir_new (model, file, parent);
file_browser_node_set_from_info (model, node, NULL, FALSE); file_browser_node_set_from_info (model, node, NULL, FALSE);
@ -2142,15 +2146,15 @@ parse_dot_hidden_file (FileBrowserNode *directory)
if (directory->file == NULL || !g_file_is_native (directory->file)) { if (directory->file == NULL || !g_file_is_native (directory->file)) {
return; return;
} }
child = g_file_get_child (directory->file, ".hidden"); child = g_file_get_child (directory->file, ".hidden");
info = g_file_query_info (child, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); info = g_file_query_info (child, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
type = info ? g_file_info_get_file_type (info) : G_FILE_TYPE_UNKNOWN; type = info ? g_file_info_get_file_type (info) : G_FILE_TYPE_UNKNOWN;
if (info) if (info)
g_object_unref (info); g_object_unref (info);
if (type != G_FILE_TYPE_REGULAR) { if (type != G_FILE_TYPE_REGULAR) {
g_object_unref (child); g_object_unref (child);
@ -2168,7 +2172,7 @@ parse_dot_hidden_file (FileBrowserNode *directory)
dir->hidden_file_hash = dir->hidden_file_hash =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
} }
/* Now parse the data */ /* Now parse the data */
i = 0; i = 0;
while (i < file_size) { while (i < file_size) {
@ -2181,14 +2185,14 @@ parse_dot_hidden_file (FileBrowserNode *directory)
if (i > start) { if (i > start) {
char *hidden_filename; char *hidden_filename;
hidden_filename = g_strndup (file_contents + start, i - start); hidden_filename = g_strndup (file_contents + start, i - start);
g_hash_table_insert (dir->hidden_file_hash, g_hash_table_insert (dir->hidden_file_hash,
hidden_filename, hidden_filename); hidden_filename, hidden_filename);
} }
i++; i++;
} }
g_free (file_contents); g_free (file_contents);
@ -2216,7 +2220,7 @@ on_directory_monitor_event (GFileMonitor * monitor,
if (g_file_query_exists (file, NULL)) { if (g_file_query_exists (file, NULL)) {
model_add_node_from_file (dir->model, parent, file, NULL); model_add_node_from_file (dir->model, parent, file, NULL);
} }
break; break;
default: default:
break; break;
@ -2232,33 +2236,33 @@ async_node_free (AsyncNode *async)
} }
static void static void
model_iterate_next_files_cb (GFileEnumerator * enumerator, model_iterate_next_files_cb (GFileEnumerator * enumerator,
GAsyncResult * result, GAsyncResult * result,
AsyncNode * async) AsyncNode * async)
{ {
GList * files; GList * files;
GError * error = NULL; GError * error = NULL;
FileBrowserNodeDir * dir = async->dir; FileBrowserNodeDir * dir = async->dir;
FileBrowserNode * parent = (FileBrowserNode *)dir; FileBrowserNode * parent = (FileBrowserNode *)dir;
files = g_file_enumerator_next_files_finish (enumerator, result, &error); files = g_file_enumerator_next_files_finish (enumerator, result, &error);
if (files == NULL) { if (files == NULL) {
g_file_enumerator_close (enumerator, NULL, NULL); g_file_enumerator_close (enumerator, NULL, NULL);
async_node_free (async); async_node_free (async);
if (!error) if (!error)
{ {
/* We're done loading */ /* We're done loading */
g_object_unref (dir->cancellable); g_object_unref (dir->cancellable);
dir->cancellable = NULL; dir->cancellable = NULL;
/* /*
* FIXME: This is temporarly, it is a bug in gio: * FIXME: This is temporarly, it is a bug in gio:
* http://bugzilla.gnome.org/show_bug.cgi?id=565924 * http://bugzilla.gnome.org/show_bug.cgi?id=565924
*/ */
if (g_file_is_native (parent->file) && dir->monitor == NULL) { if (g_file_is_native (parent->file) && dir->monitor == NULL) {
dir->monitor = g_file_monitor_directory (parent->file, dir->monitor = g_file_monitor_directory (parent->file,
G_FILE_MONITOR_NONE, G_FILE_MONITOR_NONE,
NULL, NULL,
NULL); NULL);
@ -2277,7 +2281,7 @@ model_iterate_next_files_cb (GFileEnumerator * enumerator,
/* Simply return if we were cancelled */ /* Simply return if we were cancelled */
if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED) if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)
return; return;
/* Otherwise handle the error appropriately */ /* Otherwise handle the error appropriately */
g_signal_emit (dir->model, g_signal_emit (dir->model,
model_signals[ERROR], model_signals[ERROR],
@ -2294,7 +2298,7 @@ model_iterate_next_files_cb (GFileEnumerator * enumerator,
async_node_free (async); async_node_free (async);
} else { } else {
model_add_nodes_from_files (dir->model, parent, async->original_children, files); model_add_nodes_from_files (dir->model, parent, async->original_children, files);
g_list_free (files); g_list_free (files);
next_files_async (enumerator, async); next_files_async (enumerator, async);
} }
@ -2313,7 +2317,7 @@ next_files_async (GFileEnumerator * enumerator,
} }
static void static void
model_iterate_children_cb (GFile * file, model_iterate_children_cb (GFile * file,
GAsyncResult * result, GAsyncResult * result,
AsyncNode * async) AsyncNode * async)
{ {
@ -2325,13 +2329,13 @@ model_iterate_children_cb (GFile * file,
async_node_free (async); async_node_free (async);
return; return;
} }
enumerator = g_file_enumerate_children_finish (file, result, &error); enumerator = g_file_enumerate_children_finish (file, result, &error);
if (enumerator == NULL) { if (enumerator == NULL) {
/* Simply return if we were cancelled or if the dir is not there */ /* Simply return if we were cancelled or if the dir is not there */
FileBrowserNodeDir *dir = async->dir; FileBrowserNodeDir *dir = async->dir;
/* Otherwise handle the error appropriately */ /* Otherwise handle the error appropriately */
g_signal_emit (dir->model, g_signal_emit (dir->model,
model_signals[ERROR], model_signals[ERROR],
@ -2368,9 +2372,9 @@ model_load_directory (XedFileBrowserStore * model,
/* Read the '.hidden' file first (if any) */ /* Read the '.hidden' file first (if any) */
parse_dot_hidden_file (node); parse_dot_hidden_file (node);
dir->cancellable = g_cancellable_new (); dir->cancellable = g_cancellable_new ();
async = g_new (AsyncNode, 1); async = g_new (AsyncNode, 1);
async->dir = dir; async->dir = dir;
async->cancellable = g_object_ref (dir->cancellable); async->cancellable = g_object_ref (dir->cancellable);
@ -2390,7 +2394,7 @@ static GList *
get_parent_files (XedFileBrowserStore * model, GFile * file) get_parent_files (XedFileBrowserStore * model, GFile * file)
{ {
GList * result = NULL; GList * result = NULL;
result = g_list_prepend (result, g_object_ref (file)); result = g_list_prepend (result, g_object_ref (file));
while ((file = g_file_get_parent (file))) { while ((file = g_file_get_parent (file))) {
@ -2436,7 +2440,7 @@ model_fill (XedFileBrowserStore * model, FileBrowserNode * node,
if (node != model->priv->virtual_root) { if (node != model->priv->virtual_root) {
/* Insert node */ /* Insert node */
iter.user_data = node; iter.user_data = node;
row_inserted(model, path, &iter); row_inserted(model, path, &iter);
} }
@ -2459,7 +2463,7 @@ model_fill (XedFileBrowserStore * model, FileBrowserNode * node,
/* Move back up to node path */ /* Move back up to node path */
gtk_tree_path_up (*path); gtk_tree_path_up (*path);
} }
model_check_dummy (model, node); model_check_dummy (model, node);
if (free_path) if (free_path)
@ -2520,8 +2524,8 @@ set_virtual_root_from_node (XedFileBrowserStore * model,
for (item = FILE_BROWSER_NODE_DIR (node)->children; item; for (item = FILE_BROWSER_NODE_DIR (node)->children; item;
item = item->next) { item = item->next) {
check = (FileBrowserNode *) (item->data); check = (FileBrowserNode *) (item->data);
if (NODE_IS_DIR (check)) { if (NODE_IS_DIR (check)) {
for (copy = for (copy =
FILE_BROWSER_NODE_DIR (check)->children; copy; FILE_BROWSER_NODE_DIR (check)->children; copy;
copy = copy->next) { copy = copy->next) {
@ -2572,7 +2576,7 @@ set_virtual_root_from_file (XedFileBrowserStore * model,
for (item = files; item; item = item->next) { for (item = files; item; item = item->next) {
check = G_FILE (item->data); check = G_FILE (item->data);
parent = model_add_node_from_dir (model, parent, check); parent = model_add_node_from_dir (model, parent, check);
g_object_unref (check); g_object_unref (check);
} }
@ -2590,21 +2594,21 @@ model_find_node_children (XedFileBrowserStore * model,
FileBrowserNode *child; FileBrowserNode *child;
FileBrowserNode *result; FileBrowserNode *result;
GSList *children; GSList *children;
if (!NODE_IS_DIR (parent)) if (!NODE_IS_DIR (parent))
return NULL; return NULL;
dir = FILE_BROWSER_NODE_DIR (parent); dir = FILE_BROWSER_NODE_DIR (parent);
for (children = dir->children; children; children = children->next) { for (children = dir->children; children; children = children->next) {
child = (FileBrowserNode *)(children->data); child = (FileBrowserNode *)(children->data);
result = model_find_node (model, child, file); result = model_find_node (model, child, file);
if (result) if (result)
return result; return result;
} }
return NULL; return NULL;
} }
@ -2621,7 +2625,7 @@ model_find_node (XedFileBrowserStore * model,
if (NODE_IS_DIR (node) && g_file_has_prefix (file, node->file)) if (NODE_IS_DIR (node) && g_file_has_prefix (file, node->file))
return model_find_node_children (model, node, file); return model_find_node_children (model, node, file);
return NULL; return NULL;
} }
@ -2684,40 +2688,40 @@ handle_root_error (XedFileBrowserStore * model, GError *error)
{ {
FileBrowserNode * root; FileBrowserNode * root;
g_signal_emit (model, g_signal_emit (model,
model_signals[ERROR], model_signals[ERROR],
0, 0,
XED_FILE_BROWSER_ERROR_SET_ROOT, XED_FILE_BROWSER_ERROR_SET_ROOT,
error->message); error->message);
/* Set the virtual root to the root */ /* Set the virtual root to the root */
root = model->priv->root; root = model->priv->root;
model->priv->virtual_root = root; model->priv->virtual_root = root;
/* Set the root to be loaded */ /* Set the root to be loaded */
root->flags |= XED_FILE_BROWSER_STORE_FLAG_LOADED; root->flags |= XED_FILE_BROWSER_STORE_FLAG_LOADED;
/* Check the dummy */ /* Check the dummy */
model_check_dummy (model, root); model_check_dummy (model, root);
g_object_notify (G_OBJECT (model), "root"); g_object_notify (G_OBJECT (model), "root");
g_object_notify (G_OBJECT (model), "virtual-root"); g_object_notify (G_OBJECT (model), "virtual-root");
} }
static void static void
mount_cb (GFile * file, mount_cb (GFile * file,
GAsyncResult * res, GAsyncResult * res,
MountInfo * mount_info) MountInfo * mount_info)
{ {
gboolean mounted; gboolean mounted;
GError * error = NULL; GError * error = NULL;
XedFileBrowserStore * model = mount_info->model; XedFileBrowserStore * model = mount_info->model;
mounted = g_file_mount_enclosing_volume_finish (file, res, &error); mounted = g_file_mount_enclosing_volume_finish (file, res, &error);
if (mount_info->model) if (mount_info->model)
{ {
model->priv->mount_info = NULL; model->priv->mount_info = NULL;
model_end_loading (model, model->priv->root); model_end_loading (model, model->priv->root);
} }
@ -2734,7 +2738,7 @@ mount_cb (GFile * file,
{ {
handle_root_error (model, error); handle_root_error (model, error);
} }
if (error) if (error)
g_error_free (error); g_error_free (error);
@ -2751,9 +2755,9 @@ model_mount_root (XedFileBrowserStore * model, gchar const * virtual_root)
GFileInfo * info; GFileInfo * info;
GError * error = NULL; GError * error = NULL;
MountInfo * mount_info; MountInfo * mount_info;
info = g_file_query_info (model->priv->root->file, info = g_file_query_info (model->priv->root->file,
G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE, G_FILE_QUERY_INFO_NONE,
NULL, NULL,
&error); &error);
@ -2762,23 +2766,23 @@ model_mount_root (XedFileBrowserStore * model, gchar const * virtual_root)
if (error->code == G_IO_ERROR_NOT_MOUNTED) { if (error->code == G_IO_ERROR_NOT_MOUNTED) {
/* Try to mount it */ /* Try to mount it */
FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable = g_cancellable_new (); FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable = g_cancellable_new ();
mount_info = g_new(MountInfo, 1); mount_info = g_new(MountInfo, 1);
mount_info->model = model; mount_info->model = model;
mount_info->virtual_root = g_strdup (virtual_root); mount_info->virtual_root = g_strdup (virtual_root);
/* FIXME: we should be setting the correct window */ /* FIXME: we should be setting the correct window */
mount_info->operation = gtk_mount_operation_new (NULL); mount_info->operation = gtk_mount_operation_new (NULL);
mount_info->cancellable = g_object_ref (FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable); mount_info->cancellable = g_object_ref (FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable);
model_begin_loading (model, model->priv->root); model_begin_loading (model, model->priv->root);
g_file_mount_enclosing_volume (model->priv->root->file, g_file_mount_enclosing_volume (model->priv->root->file,
G_MOUNT_MOUNT_NONE, G_MOUNT_MOUNT_NONE,
mount_info->operation, mount_info->operation,
mount_info->cancellable, mount_info->cancellable,
(GAsyncReadyCallback)mount_cb, (GAsyncReadyCallback)mount_cb,
mount_info); mount_info);
model->priv->mount_info = mount_info; model->priv->mount_info = mount_info;
return XED_FILE_BROWSER_STORE_RESULT_MOUNTING; return XED_FILE_BROWSER_STORE_RESULT_MOUNTING;
} }
@ -2786,14 +2790,14 @@ model_mount_root (XedFileBrowserStore * model, gchar const * virtual_root)
{ {
handle_root_error (model, error); handle_root_error (model, error);
} }
g_error_free (error); g_error_free (error);
} else { } else {
g_object_unref (info); g_object_unref (info);
return model_root_mounted (model, virtual_root); return model_root_mounted (model, virtual_root);
} }
return XED_FILE_BROWSER_STORE_RESULT_OK; return XED_FILE_BROWSER_STORE_RESULT_OK;
} }
@ -2844,7 +2848,7 @@ xed_file_browser_store_set_value (XedFileBrowserStore * tree_model,
model_recomposite_icon (tree_model, iter); model_recomposite_icon (tree_model, iter);
if (model_node_visibility (tree_model, node)) { if (model_node_visibility (tree_model, node)) {
path = xed_file_browser_store_get_path (GTK_TREE_MODEL (tree_model), path = xed_file_browser_store_get_path (GTK_TREE_MODEL (tree_model),
iter); iter);
row_changed (tree_model, &path, iter); row_changed (tree_model, &path, iter);
gtk_tree_path_free (path); gtk_tree_path_free (path);
@ -3002,7 +3006,7 @@ void
xed_file_browser_store_cancel_mount_operation (XedFileBrowserStore *store) xed_file_browser_store_cancel_mount_operation (XedFileBrowserStore *store)
{ {
g_return_if_fail (XED_IS_FILE_BROWSER_STORE (store)); g_return_if_fail (XED_IS_FILE_BROWSER_STORE (store));
cancel_mount_operation (store); cancel_mount_operation (store);
} }
@ -3049,7 +3053,7 @@ xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore *
g_object_unref (vfile); g_object_unref (vfile);
} }
/* make sure to cancel any previous mount operations */ /* make sure to cancel any previous mount operations */
cancel_mount_operation (model); cancel_mount_operation (model);
@ -3063,7 +3067,7 @@ xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore *
if (file != NULL) { if (file != NULL) {
/* Create the root node */ /* Create the root node */
node = file_browser_node_dir_new (model, file, NULL); node = file_browser_node_dir_new (model, file, NULL);
g_object_unref (file); g_object_unref (file);
model->priv->root = node; model->priv->root = node;
@ -3091,18 +3095,18 @@ gchar *
xed_file_browser_store_get_root (XedFileBrowserStore * model) xed_file_browser_store_get_root (XedFileBrowserStore * model)
{ {
g_return_val_if_fail (XED_IS_FILE_BROWSER_STORE (model), NULL); g_return_val_if_fail (XED_IS_FILE_BROWSER_STORE (model), NULL);
if (model->priv->root == NULL || model->priv->root->file == NULL) if (model->priv->root == NULL || model->priv->root->file == NULL)
return NULL; return NULL;
else else
return g_file_get_uri (model->priv->root->file); return g_file_get_uri (model->priv->root->file);
} }
gchar * gchar *
xed_file_browser_store_get_virtual_root (XedFileBrowserStore * model) xed_file_browser_store_get_virtual_root (XedFileBrowserStore * model)
{ {
g_return_val_if_fail (XED_IS_FILE_BROWSER_STORE (model), NULL); g_return_val_if_fail (XED_IS_FILE_BROWSER_STORE (model), NULL);
if (model->priv->virtual_root == NULL || model->priv->virtual_root->file == NULL) if (model->priv->virtual_root == NULL || model->priv->virtual_root->file == NULL)
return NULL; return NULL;
else else
@ -3228,7 +3232,7 @@ reparent_node (FileBrowserNode * node, gboolean reparent)
if (!node->file) { if (!node->file) {
return; return;
} }
if (reparent) { if (reparent) {
parent = node->parent->file; parent = node->parent->file;
base = g_file_get_basename (node->file); base = g_file_get_basename (node->file);
@ -3237,10 +3241,10 @@ reparent_node (FileBrowserNode * node, gboolean reparent)
node->file = g_file_get_child (parent, base); node->file = g_file_get_child (parent, base);
g_free (base); g_free (base);
} }
if (NODE_IS_DIR (node)) { if (NODE_IS_DIR (node)) {
dir = FILE_BROWSER_NODE_DIR (node); dir = FILE_BROWSER_NODE_DIR (node);
for (child = dir->children; child; child = child->next) { for (child = dir->children; child; child = child->next) {
reparent_node ((FileBrowserNode *)child->data, TRUE); reparent_node ((FileBrowserNode *)child->data, TRUE);
} }
@ -3286,7 +3290,7 @@ xed_file_browser_store_rename (XedFileBrowserStore * model,
/* This makes sure the actual info for the node is requeried */ /* This makes sure the actual info for the node is requeried */
file_browser_node_set_name (node); file_browser_node_set_name (node);
file_browser_node_set_from_info (model, node, NULL, TRUE); file_browser_node_set_from_info (model, node, NULL, TRUE);
reparent_node (node, FALSE); reparent_node (node, FALSE);
if (model_node_visibility (model, node)) { if (model_node_visibility (model, node)) {
@ -3298,7 +3302,7 @@ xed_file_browser_store_rename (XedFileBrowserStore * model,
model_resort_node (model, node); model_resort_node (model, node);
} else { } else {
g_object_unref (previous); g_object_unref (previous);
if (error != NULL) if (error != NULL)
*error = g_error_new_literal (xed_file_browser_store_error_quark (), *error = g_error_new_literal (xed_file_browser_store_error_quark (),
XED_FILE_BROWSER_ERROR_RENAME, XED_FILE_BROWSER_ERROR_RENAME,
@ -3327,7 +3331,7 @@ xed_file_browser_store_rename (XedFileBrowserStore * model,
XED_FILE_BROWSER_ERROR_RENAME, XED_FILE_BROWSER_ERROR_RENAME,
err->message); err->message);
} }
g_error_free (err); g_error_free (err);
} }
@ -3339,13 +3343,13 @@ static void
async_data_free (AsyncData * data) async_data_free (AsyncData * data)
{ {
g_object_unref (data->cancellable); g_object_unref (data->cancellable);
g_list_foreach (data->files, (GFunc)g_object_unref, NULL); g_list_foreach (data->files, (GFunc)g_object_unref, NULL);
g_list_free (data->files); g_list_free (data->files);
if (!data->removed) if (!data->removed)
data->model->priv->async_handles = g_slist_remove (data->model->priv->async_handles, data); data->model->priv->async_handles = g_slist_remove (data->model->priv->async_handles, data);
g_free (data); g_free (data);
} }
@ -3372,7 +3376,7 @@ file_deleted (IdleDelete * data)
if (node != NULL) if (node != NULL)
model_remove_node (data->model, node, NULL, TRUE); model_remove_node (data->model, node, NULL, TRUE);
return FALSE; return FALSE;
} }
@ -3386,14 +3390,14 @@ delete_files (GIOSchedulerJob * job,
gboolean ret; gboolean ret;
gint code; gint code;
IdleDelete delete; IdleDelete delete;
/* Check if our job is done */ /* Check if our job is done */
if (!data->iter) if (!data->iter)
return FALSE; return FALSE;
/* Move a file to the trash */ /* Move a file to the trash */
file = G_FILE (data->iter->data); file = G_FILE (data->iter->data);
if (data->trash) if (data->trash)
ret = g_file_trash (file, cancellable, &error); ret = g_file_trash (file, cancellable, &error);
else else
@ -3419,7 +3423,7 @@ delete_files (GIOSchedulerJob * job,
return TRUE; return TRUE;
} }
/* End the job */ /* End the job */
return FALSE; return FALSE;
} else if (code == G_IO_ERROR_CANCELLED) { } else if (code == G_IO_ERROR_CANCELLED) {
@ -3427,7 +3431,7 @@ delete_files (GIOSchedulerJob * job,
return FALSE; return FALSE;
} }
} }
/* Process the next item */ /* Process the next item */
data->iter = data->iter->next; data->iter = data->iter->next;
return TRUE; return TRUE;
@ -3446,7 +3450,7 @@ xed_file_browser_store_delete_all (XedFileBrowserStore *model,
GtkTreePath * path; GtkTreePath * path;
g_return_val_if_fail (XED_IS_FILE_BROWSER_STORE (model), XED_FILE_BROWSER_STORE_RESULT_NO_CHANGE); g_return_val_if_fail (XED_IS_FILE_BROWSER_STORE (model), XED_FILE_BROWSER_STORE_RESULT_NO_CHANGE);
if (rows == NULL) if (rows == NULL)
return XED_FILE_BROWSER_STORE_RESULT_NO_CHANGE; return XED_FILE_BROWSER_STORE_RESULT_NO_CHANGE;
@ -3460,17 +3464,17 @@ xed_file_browser_store_delete_all (XedFileBrowserStore *model,
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path)) if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path))
continue; continue;
/* Skip if the current path is actually a descendant of the /* Skip if the current path is actually a descendant of the
previous path */ previous path */
if (prev != NULL && gtk_tree_path_is_descendant (path, prev)) if (prev != NULL && gtk_tree_path_is_descendant (path, prev))
continue; continue;
prev = path; prev = path;
node = (FileBrowserNode *)(iter.user_data); node = (FileBrowserNode *)(iter.user_data);
files = g_list_prepend (files, g_object_ref (node->file)); files = g_list_prepend (files, g_object_ref (node->file));
} }
data = g_new (AsyncData, 1); data = g_new (AsyncData, 1);
data->model = model; data->model = model;
@ -3479,17 +3483,17 @@ xed_file_browser_store_delete_all (XedFileBrowserStore *model,
data->trash = trash; data->trash = trash;
data->iter = files; data->iter = files;
data->removed = FALSE; data->removed = FALSE;
model->priv->async_handles = model->priv->async_handles =
g_slist_prepend (model->priv->async_handles, data); g_slist_prepend (model->priv->async_handles, data);
g_io_scheduler_push_job ((GIOSchedulerJobFunc)delete_files, g_io_scheduler_push_job ((GIOSchedulerJobFunc)delete_files,
data, data,
(GDestroyNotify)async_data_free, (GDestroyNotify)async_data_free,
G_PRIORITY_DEFAULT, G_PRIORITY_DEFAULT,
data->cancellable); data->cancellable);
g_list_free (rows); g_list_free (rows);
return XED_FILE_BROWSER_STORE_RESULT_OK; return XED_FILE_BROWSER_STORE_RESULT_OK;
} }
@ -3512,10 +3516,10 @@ xed_file_browser_store_delete (XedFileBrowserStore * model,
rows = g_list_append(NULL, xed_file_browser_store_get_path_real (model, node)); rows = g_list_append(NULL, xed_file_browser_store_get_path_real (model, node));
result = xed_file_browser_store_delete_all (model, rows, trash); result = xed_file_browser_store_delete_all (model, rows, trash);
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
g_list_free (rows); g_list_free (rows);
return result; return result;
} }
@ -3544,7 +3548,7 @@ xed_file_browser_store_new_file (XedFileBrowserStore * model,
file = unique_new_name (((FileBrowserNode *) parent_node)->file, _("file")); file = unique_new_name (((FileBrowserNode *) parent_node)->file, _("file"));
stream = g_file_create (file, G_FILE_CREATE_NONE, NULL, &error); stream = g_file_create (file, G_FILE_CREATE_NONE, NULL, &error);
if (!stream) if (!stream)
{ {
g_signal_emit (model, model_signals[ERROR], 0, g_signal_emit (model, model_signals[ERROR], 0,
@ -3553,9 +3557,9 @@ xed_file_browser_store_new_file (XedFileBrowserStore * model,
g_error_free (error); g_error_free (error);
} else { } else {
g_object_unref (stream); g_object_unref (stream);
node = model_add_node_from_file (model, node = model_add_node_from_file (model,
(FileBrowserNode *)parent_node, (FileBrowserNode *)parent_node,
file, file,
NULL); NULL);
if (model_node_visibility (model, node)) { if (model_node_visibility (model, node)) {
@ -3602,9 +3606,9 @@ xed_file_browser_store_new_directory (XedFileBrowserStore * model,
error->message); error->message);
g_error_free (error); g_error_free (error);
} else { } else {
node = model_add_node_from_file (model, node = model_add_node_from_file (model,
(FileBrowserNode *)parent_node, (FileBrowserNode *)parent_node,
file, file,
NULL); NULL);
if (model_node_visibility (model, node)) { if (model_node_visibility (model, node)) {
@ -3622,4 +3626,10 @@ xed_file_browser_store_new_directory (XedFileBrowserStore * model,
return result; return result;
} }
void
_xed_file_browser_store_register_type (GTypeModule *type_module)
{
xed_file_browser_store_register_type (type_module);
}
// ex:ts=8:noet: // ex:ts=8:noet:

View File

@ -1,5 +1,5 @@
/* /*
* xed-file-browser-store.h - Xed plugin providing easy file access * xed-file-browser-store.h - Xed plugin providing easy file access
* from the sidepanel * from the sidepanel
* *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
@ -25,113 +25,113 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define XED_TYPE_FILE_BROWSER_STORE (xed_file_browser_store_get_type ()) #define XED_TYPE_FILE_BROWSER_STORE (xed_file_browser_store_get_type ())
#define XED_FILE_BROWSER_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_STORE, XedFileBrowserStore)) #define XED_FILE_BROWSER_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_STORE, XedFileBrowserStore))
#define XED_FILE_BROWSER_STORE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_STORE, XedFileBrowserStore const)) #define XED_FILE_BROWSER_STORE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_STORE, XedFileBrowserStore const))
#define XED_FILE_BROWSER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_FILE_BROWSER_STORE, XedFileBrowserStoreClass)) #define XED_FILE_BROWSER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_FILE_BROWSER_STORE, XedFileBrowserStoreClass))
#define XED_IS_FILE_BROWSER_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_FILE_BROWSER_STORE)) #define XED_IS_FILE_BROWSER_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_FILE_BROWSER_STORE))
#define XED_IS_FILE_BROWSER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_FILE_BROWSER_STORE)) #define XED_IS_FILE_BROWSER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_FILE_BROWSER_STORE))
#define XED_FILE_BROWSER_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BROWSER_STORE, XedFileBrowserStoreClass)) #define XED_FILE_BROWSER_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BROWSER_STORE, XedFileBrowserStoreClass))
typedef enum typedef enum
{ {
XED_FILE_BROWSER_STORE_COLUMN_ICON = 0, XED_FILE_BROWSER_STORE_COLUMN_ICON = 0,
XED_FILE_BROWSER_STORE_COLUMN_NAME, XED_FILE_BROWSER_STORE_COLUMN_NAME,
XED_FILE_BROWSER_STORE_COLUMN_URI, XED_FILE_BROWSER_STORE_COLUMN_URI,
XED_FILE_BROWSER_STORE_COLUMN_FLAGS, XED_FILE_BROWSER_STORE_COLUMN_FLAGS,
XED_FILE_BROWSER_STORE_COLUMN_EMBLEM, XED_FILE_BROWSER_STORE_COLUMN_EMBLEM,
XED_FILE_BROWSER_STORE_COLUMN_NUM XED_FILE_BROWSER_STORE_COLUMN_NUM
} XedFileBrowserStoreColumn; } XedFileBrowserStoreColumn;
typedef enum typedef enum
{ {
XED_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY = 1 << 0, XED_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY = 1 << 0,
XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN = 1 << 1, XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN = 1 << 1,
XED_FILE_BROWSER_STORE_FLAG_IS_TEXT = 1 << 2, XED_FILE_BROWSER_STORE_FLAG_IS_TEXT = 1 << 2,
XED_FILE_BROWSER_STORE_FLAG_LOADED = 1 << 3, XED_FILE_BROWSER_STORE_FLAG_LOADED = 1 << 3,
XED_FILE_BROWSER_STORE_FLAG_IS_FILTERED = 1 << 4, XED_FILE_BROWSER_STORE_FLAG_IS_FILTERED = 1 << 4,
XED_FILE_BROWSER_STORE_FLAG_IS_DUMMY = 1 << 5 XED_FILE_BROWSER_STORE_FLAG_IS_DUMMY = 1 << 5
} XedFileBrowserStoreFlag; } XedFileBrowserStoreFlag;
typedef enum typedef enum
{ {
XED_FILE_BROWSER_STORE_RESULT_OK, XED_FILE_BROWSER_STORE_RESULT_OK,
XED_FILE_BROWSER_STORE_RESULT_NO_CHANGE, XED_FILE_BROWSER_STORE_RESULT_NO_CHANGE,
XED_FILE_BROWSER_STORE_RESULT_ERROR, XED_FILE_BROWSER_STORE_RESULT_ERROR,
XED_FILE_BROWSER_STORE_RESULT_NO_TRASH, XED_FILE_BROWSER_STORE_RESULT_NO_TRASH,
XED_FILE_BROWSER_STORE_RESULT_MOUNTING, XED_FILE_BROWSER_STORE_RESULT_MOUNTING,
XED_FILE_BROWSER_STORE_RESULT_NUM XED_FILE_BROWSER_STORE_RESULT_NUM
} XedFileBrowserStoreResult; } XedFileBrowserStoreResult;
typedef enum typedef enum
{ {
XED_FILE_BROWSER_STORE_FILTER_MODE_NONE = 0, XED_FILE_BROWSER_STORE_FILTER_MODE_NONE = 0,
XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN = 1 << 0, XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN = 1 << 0,
XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY = 1 << 1 XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY = 1 << 1
} XedFileBrowserStoreFilterMode; } XedFileBrowserStoreFilterMode;
#define FILE_IS_DIR(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY) #define FILE_IS_DIR(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY)
#define FILE_IS_HIDDEN(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN) #define FILE_IS_HIDDEN(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_HIDDEN)
#define FILE_IS_TEXT(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_TEXT) #define FILE_IS_TEXT(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_TEXT)
#define FILE_LOADED(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_LOADED) #define FILE_LOADED(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_LOADED)
#define FILE_IS_FILTERED(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_FILTERED) #define FILE_IS_FILTERED(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_FILTERED)
#define FILE_IS_DUMMY(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_DUMMY) #define FILE_IS_DUMMY(flags) (flags & XED_FILE_BROWSER_STORE_FLAG_IS_DUMMY)
typedef struct _XedFileBrowserStore XedFileBrowserStore; typedef struct _XedFileBrowserStore XedFileBrowserStore;
typedef struct _XedFileBrowserStoreClass XedFileBrowserStoreClass; typedef struct _XedFileBrowserStoreClass XedFileBrowserStoreClass;
typedef struct _XedFileBrowserStorePrivate XedFileBrowserStorePrivate; typedef struct _XedFileBrowserStorePrivate XedFileBrowserStorePrivate;
typedef gboolean (*XedFileBrowserStoreFilterFunc) (XedFileBrowserStore typedef gboolean (*XedFileBrowserStoreFilterFunc) (XedFileBrowserStore
* model, * model,
GtkTreeIter * iter, GtkTreeIter * iter,
gpointer user_data); gpointer user_data);
struct _XedFileBrowserStore struct _XedFileBrowserStore
{ {
GObject parent; GObject parent;
XedFileBrowserStorePrivate *priv; XedFileBrowserStorePrivate *priv;
}; };
struct _XedFileBrowserStoreClass { struct _XedFileBrowserStoreClass {
GObjectClass parent_class; GObjectClass parent_class;
/* Signals */ /* Signals */
void (*begin_loading) (XedFileBrowserStore * model, void (*begin_loading) (XedFileBrowserStore * model,
GtkTreeIter * iter); GtkTreeIter * iter);
void (*end_loading) (XedFileBrowserStore * model, void (*end_loading) (XedFileBrowserStore * model,
GtkTreeIter * iter); GtkTreeIter * iter);
void (*error) (XedFileBrowserStore * model, void (*error) (XedFileBrowserStore * model,
guint code, guint code,
gchar * message); gchar * message);
gboolean (*no_trash) (XedFileBrowserStore * model, gboolean (*no_trash) (XedFileBrowserStore * model,
GList * files); GList * files);
void (*rename) (XedFileBrowserStore * model, void (*rename) (XedFileBrowserStore * model,
const gchar * olduri, const gchar * olduri,
const gchar * newuri); const gchar * newuri);
void (*begin_refresh) (XedFileBrowserStore * model); void (*begin_refresh) (XedFileBrowserStore * model);
void (*end_refresh) (XedFileBrowserStore * model); void (*end_refresh) (XedFileBrowserStore * model);
void (*unload) (XedFileBrowserStore * model, void (*unload) (XedFileBrowserStore * model,
const gchar * uri); const gchar * uri);
}; };
GType xed_file_browser_store_get_type (void) G_GNUC_CONST; GType xed_file_browser_store_get_type (void) G_GNUC_CONST;
GType xed_file_browser_store_register_type (GTypeModule * module); void _xed_file_browser_store_register_type (GTypeModule * module);
XedFileBrowserStore *xed_file_browser_store_new (gchar const *root); XedFileBrowserStore *xed_file_browser_store_new (gchar const *root);
XedFileBrowserStoreResult XedFileBrowserStoreResult
xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore * model, xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore * model,
gchar const *root, gchar const *root,
gchar const *virtual_root); gchar const *virtual_root);
XedFileBrowserStoreResult XedFileBrowserStoreResult
xed_file_browser_store_set_root (XedFileBrowserStore * model, xed_file_browser_store_set_root (XedFileBrowserStore * model,
gchar const *root); gchar const *root);
XedFileBrowserStoreResult XedFileBrowserStoreResult
xed_file_browser_store_set_virtual_root (XedFileBrowserStore * model, xed_file_browser_store_set_virtual_root (XedFileBrowserStore * model,
GtkTreeIter * iter); GtkTreeIter * iter);
XedFileBrowserStoreResult XedFileBrowserStoreResult
xed_file_browser_store_set_virtual_root_from_string (XedFileBrowserStore * model, xed_file_browser_store_set_virtual_root_from_string (XedFileBrowserStore * model,
gchar const *root); gchar const *root);
XedFileBrowserStoreResult XedFileBrowserStoreResult
xed_file_browser_store_set_virtual_root_up (XedFileBrowserStore * model); xed_file_browser_store_set_virtual_root_up (XedFileBrowserStore * model);
@ -139,25 +139,25 @@ XedFileBrowserStoreResult
xed_file_browser_store_set_virtual_root_top (XedFileBrowserStore * model); xed_file_browser_store_set_virtual_root_top (XedFileBrowserStore * model);
gboolean gboolean
xed_file_browser_store_get_iter_virtual_root (XedFileBrowserStore * model, xed_file_browser_store_get_iter_virtual_root (XedFileBrowserStore * model,
GtkTreeIter * iter); GtkTreeIter * iter);
gboolean xed_file_browser_store_get_iter_root (XedFileBrowserStore * model, gboolean xed_file_browser_store_get_iter_root (XedFileBrowserStore * model,
GtkTreeIter * iter); GtkTreeIter * iter);
gchar * xed_file_browser_store_get_root (XedFileBrowserStore * model); gchar * xed_file_browser_store_get_root (XedFileBrowserStore * model);
gchar * xed_file_browser_store_get_virtual_root (XedFileBrowserStore * model); gchar * xed_file_browser_store_get_virtual_root (XedFileBrowserStore * model);
gboolean xed_file_browser_store_iter_equal (XedFileBrowserStore * model, gboolean xed_file_browser_store_iter_equal (XedFileBrowserStore * model,
GtkTreeIter * iter1, GtkTreeIter * iter1,
GtkTreeIter * iter2); GtkTreeIter * iter2);
void xed_file_browser_store_set_value (XedFileBrowserStore * tree_model, void xed_file_browser_store_set_value (XedFileBrowserStore * tree_model,
GtkTreeIter * iter, GtkTreeIter * iter,
gint column, gint column,
GValue * value); GValue * value);
void _xed_file_browser_store_iter_expanded (XedFileBrowserStore * model, void _xed_file_browser_store_iter_expanded (XedFileBrowserStore * model,
GtkTreeIter * iter); GtkTreeIter * iter);
void _xed_file_browser_store_iter_collapsed (XedFileBrowserStore * model, void _xed_file_browser_store_iter_collapsed (XedFileBrowserStore * model,
GtkTreeIter * iter); GtkTreeIter * iter);
XedFileBrowserStoreFilterMode XedFileBrowserStoreFilterMode
@ -165,7 +165,7 @@ xed_file_browser_store_get_filter_mode (XedFileBrowserStore * model
void xed_file_browser_store_set_filter_mode (XedFileBrowserStore * model, void xed_file_browser_store_set_filter_mode (XedFileBrowserStore * model,
XedFileBrowserStoreFilterMode mode); XedFileBrowserStoreFilterMode mode);
void xed_file_browser_store_set_filter_func (XedFileBrowserStore * model, void xed_file_browser_store_set_filter_func (XedFileBrowserStore * model,
XedFileBrowserStoreFilterFunc func, XedFileBrowserStoreFilterFunc func,
gpointer user_data); gpointer user_data);
void xed_file_browser_store_refilter (XedFileBrowserStore * model); void xed_file_browser_store_refilter (XedFileBrowserStore * model);
XedFileBrowserStoreFilterMode XedFileBrowserStoreFilterMode
@ -178,11 +178,11 @@ gboolean xed_file_browser_store_rename (XedFileBrowserStore * model
GError ** error); GError ** error);
XedFileBrowserStoreResult XedFileBrowserStoreResult
xed_file_browser_store_delete (XedFileBrowserStore * model, xed_file_browser_store_delete (XedFileBrowserStore * model,
GtkTreeIter * iter, GtkTreeIter * iter,
gboolean trash); gboolean trash);
XedFileBrowserStoreResult XedFileBrowserStoreResult
xed_file_browser_store_delete_all (XedFileBrowserStore * model, xed_file_browser_store_delete_all (XedFileBrowserStore * model,
GList *rows, GList *rows,
gboolean trash); gboolean trash);
gboolean xed_file_browser_store_new_file (XedFileBrowserStore * model, gboolean xed_file_browser_store_new_file (XedFileBrowserStore * model,
@ -195,6 +195,6 @@ gboolean xed_file_browser_store_new_directory (XedFileBrowserStore * model
void xed_file_browser_store_cancel_mount_operation (XedFileBrowserStore *store); void xed_file_browser_store_cancel_mount_operation (XedFileBrowserStore *store);
G_END_DECLS G_END_DECLS
#endif /* __XED_FILE_BROWSER_STORE_H__ */ #endif /* __XED_FILE_BROWSER_STORE_H__ */
// ex:ts=8:noet: // ex:ts=8:noet:

View File

@ -1,5 +1,5 @@
/* /*
* xed-file-browser-view.c - Xed plugin providing easy file access * xed-file-browser-view.c - Xed plugin providing easy file access
* from the sidepanel * from the sidepanel
* *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
@ -21,7 +21,6 @@
#include <string.h> #include <string.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <xed/xed-plugin.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
@ -35,7 +34,7 @@
G_TYPE_INSTANCE_GET_PRIVATE((object), \ G_TYPE_INSTANCE_GET_PRIVATE((object), \
XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserViewPrivate)) XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserViewPrivate))
struct _XedFileBrowserViewPrivate struct _XedFileBrowserViewPrivate
{ {
GtkTreeViewColumn *column; GtkTreeViewColumn *column;
GtkCellRenderer *pixbuf_renderer; GtkCellRenderer *pixbuf_renderer;
@ -55,7 +54,7 @@ struct _XedFileBrowserViewPrivate
gboolean selected_on_button_down; gboolean selected_on_button_down;
gint drag_button; gint drag_button;
gboolean drag_started; gboolean drag_started;
gboolean restore_expand_state; gboolean restore_expand_state;
gboolean is_refresh; gboolean is_refresh;
GHashTable * expand_state; GHashTable * expand_state;
@ -65,7 +64,7 @@ struct _XedFileBrowserViewPrivate
enum enum
{ {
PROP_0, PROP_0,
PROP_CLICK_POLICY, PROP_CLICK_POLICY,
PROP_RESTORE_EXPAND_STATE PROP_RESTORE_EXPAND_STATE
}; };
@ -86,33 +85,33 @@ static const GtkTargetEntry drag_source_targets[] = {
{ "text/uri-list", 0, 0 } { "text/uri-list", 0, 0 }
}; };
XED_PLUGIN_DEFINE_TYPE (XedFileBrowserView, xed_file_browser_view, G_DEFINE_DYNAMIC_TYPE (XedFileBrowserView, xed_file_browser_view,
GTK_TYPE_TREE_VIEW) GTK_TYPE_TREE_VIEW)
static void on_cell_edited (GtkCellRendererText * cell, static void on_cell_edited (GtkCellRendererText * cell,
gchar * path, gchar * path,
gchar * new_text, gchar * new_text,
XedFileBrowserView * tree_view); XedFileBrowserView * tree_view);
static void on_begin_refresh (XedFileBrowserStore * model, static void on_begin_refresh (XedFileBrowserStore * model,
XedFileBrowserView * view); XedFileBrowserView * view);
static void on_end_refresh (XedFileBrowserStore * model, static void on_end_refresh (XedFileBrowserStore * model,
XedFileBrowserView * view); XedFileBrowserView * view);
static void on_unload (XedFileBrowserStore * model, static void on_unload (XedFileBrowserStore * model,
gchar const * uri, gchar const * uri,
XedFileBrowserView * view); XedFileBrowserView * view);
static void on_row_inserted (XedFileBrowserStore * model, static void on_row_inserted (XedFileBrowserStore * model,
GtkTreePath * path, GtkTreePath * path,
GtkTreeIter * iter, GtkTreeIter * iter,
XedFileBrowserView * view); XedFileBrowserView * view);
static void static void
xed_file_browser_view_finalize (GObject * object) xed_file_browser_view_finalize (GObject * object)
{ {
XedFileBrowserView *obj = XED_FILE_BROWSER_VIEW(object); XedFileBrowserView *obj = XED_FILE_BROWSER_VIEW(object);
if (obj->priv->hand_cursor) if (obj->priv->hand_cursor)
g_object_unref (obj->priv->hand_cursor); g_object_unref (obj->priv->hand_cursor);
@ -136,12 +135,12 @@ add_expand_state (XedFileBrowserView * view,
gchar const * uri) gchar const * uri)
{ {
GFile * file; GFile * file;
if (!uri) if (!uri)
return; return;
file = g_file_new_for_uri (uri); file = g_file_new_for_uri (uri);
if (view->priv->expand_state) if (view->priv->expand_state)
g_hash_table_insert (view->priv->expand_state, file, file); g_hash_table_insert (view->priv->expand_state, file, file);
else else
@ -153,12 +152,12 @@ remove_expand_state (XedFileBrowserView * view,
gchar const * uri) gchar const * uri)
{ {
GFile * file; GFile * file;
if (!uri) if (!uri)
return; return;
file = g_file_new_for_uri (uri); file = g_file_new_for_uri (uri);
if (view->priv->expand_state) if (view->priv->expand_state)
g_hash_table_remove (view->priv->expand_state, file); g_hash_table_remove (view->priv->expand_state, file);
@ -182,7 +181,7 @@ row_expanded (GtkTreeView * tree_view,
if (view->priv->restore_expand_state) if (view->priv->restore_expand_state)
{ {
gtk_tree_model_get (view->priv->model, gtk_tree_model_get (view->priv->model,
iter, iter,
XED_FILE_BROWSER_STORE_COLUMN_URI, XED_FILE_BROWSER_STORE_COLUMN_URI,
&uri, &uri,
-1); -1);
@ -208,11 +207,11 @@ row_collapsed (GtkTreeView * tree_view,
if (!XED_IS_FILE_BROWSER_STORE (view->priv->model)) if (!XED_IS_FILE_BROWSER_STORE (view->priv->model))
return; return;
if (view->priv->restore_expand_state) if (view->priv->restore_expand_state)
{ {
gtk_tree_model_get (view->priv->model, gtk_tree_model_get (view->priv->model,
iter, iter,
XED_FILE_BROWSER_STORE_COLUMN_URI, XED_FILE_BROWSER_STORE_COLUMN_URI,
&uri, &uri,
-1); -1);
@ -291,7 +290,7 @@ motion_notify_event (GtkWidget * widget,
if (old_hover_path != NULL) if (old_hover_path != NULL)
gtk_tree_path_free (old_hover_path); gtk_tree_path_free (old_hover_path);
} }
// Chainup // Chainup
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->motion_notify_event (widget, event); return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->motion_notify_event (widget, event);
} }
@ -323,7 +322,7 @@ set_click_policy_property (XedFileBrowserView *obj,
if (gtk_widget_get_realized (GTK_WIDGET (obj))) { if (gtk_widget_get_realized (GTK_WIDGET (obj))) {
win = gtk_widget_get_window (GTK_WIDGET (obj)); win = gtk_widget_get_window (GTK_WIDGET (obj));
gdk_window_set_cursor (win, NULL); gdk_window_set_cursor (win, NULL);
display = gtk_widget_get_display (GTK_WIDGET (obj)); display = gtk_widget_get_display (GTK_WIDGET (obj));
if (display != NULL) if (display != NULL)
@ -338,7 +337,7 @@ set_click_policy_property (XedFileBrowserView *obj,
} }
static void static void
directory_activated (XedFileBrowserView *view, directory_activated (XedFileBrowserView *view,
GtkTreeIter *iter) GtkTreeIter *iter)
{ {
xed_file_browser_store_set_virtual_root (XED_FILE_BROWSER_STORE (view->priv->model), iter); xed_file_browser_store_set_virtual_root (XED_FILE_BROWSER_STORE (view->priv->model), iter);
@ -355,30 +354,30 @@ activate_selected_files (XedFileBrowserView *view) {
XedFileBrowserStoreFlag flags; XedFileBrowserStoreFlag flags;
rows = gtk_tree_selection_get_selected_rows (selection, &view->priv->model); rows = gtk_tree_selection_get_selected_rows (selection, &view->priv->model);
for (row = rows; row; row = row->next) { for (row = rows; row; row = row->next) {
path = (GtkTreePath *)(row->data); path = (GtkTreePath *)(row->data);
/* Get iter from path */ /* Get iter from path */
if (!gtk_tree_model_get_iter (view->priv->model, &iter, path)) if (!gtk_tree_model_get_iter (view->priv->model, &iter, path))
continue; continue;
gtk_tree_model_get (view->priv->model, &iter, XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1); gtk_tree_model_get (view->priv->model, &iter, XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1);
if (FILE_IS_DIR (flags)) { if (FILE_IS_DIR (flags)) {
if (directory == NULL) if (directory == NULL)
directory = path; directory = path;
} else if (!FILE_IS_DUMMY (flags)) { } else if (!FILE_IS_DUMMY (flags)) {
g_signal_emit (view, signals[FILE_ACTIVATED], 0, &iter); g_signal_emit (view, signals[FILE_ACTIVATED], 0, &iter);
} }
} }
if (directory != NULL) { if (directory != NULL) {
if (gtk_tree_model_get_iter (view->priv->model, &iter, directory)) if (gtk_tree_model_get_iter (view->priv->model, &iter, directory))
g_signal_emit (view, signals[DIRECTORY_ACTIVATED], 0, &iter); g_signal_emit (view, signals[DIRECTORY_ACTIVATED], 0, &iter);
} }
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
g_list_free (rows); g_list_free (rows);
} }
@ -428,10 +427,10 @@ drag_begin (GtkWidget *widget,
GdkDragContext *context) GdkDragContext *context)
{ {
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget); XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget);
view->priv->drag_button = 0; view->priv->drag_button = 0;
view->priv->drag_started = TRUE; view->priv->drag_started = TRUE;
/* Chain up */ /* Chain up */
GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->drag_begin (widget, context); GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->drag_begin (widget, context);
} }
@ -443,14 +442,14 @@ did_not_drag (XedFileBrowserView *view,
GtkTreeView *tree_view; GtkTreeView *tree_view;
GtkTreeSelection *selection; GtkTreeSelection *selection;
GtkTreePath *path; GtkTreePath *path;
tree_view = GTK_TREE_VIEW (view); tree_view = GTK_TREE_VIEW (view);
selection = gtk_tree_view_get_selection (tree_view); selection = gtk_tree_view_get_selection (tree_view);
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y, if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
&path, NULL, NULL, NULL)) { &path, NULL, NULL, NULL)) {
if ((view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) if ((view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
&& !button_event_modifies_selection(event) && !button_event_modifies_selection(event)
&& (event->button == 1 || event->button == 2)) { && (event->button == 1 || event->button == 2)) {
/* Activate all selected items, and leave them selected */ /* Activate all selected items, and leave them selected */
activate_selected_items (view); activate_selected_items (view);
@ -483,9 +482,9 @@ button_release_event (GtkWidget *widget,
!view->priv->ignore_release) !view->priv->ignore_release)
did_not_drag (view, event); did_not_drag (view, event);
} }
/* Chain up */ /* Chain up */
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->button_release_event (widget, event); return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->button_release_event (widget, event);
} }
static gboolean static gboolean
@ -511,7 +510,7 @@ button_press_event (GtkWidget *widget,
selection = gtk_tree_view_get_selection (tree_view); selection = gtk_tree_view_get_selection (tree_view);
/* Get double click time */ /* Get double click time */
g_object_get (G_OBJECT (gtk_widget_get_settings (widget)), g_object_get (G_OBJECT (gtk_widget_get_settings (widget)),
"gtk-double-click-time", &double_click_time, "gtk-double-click-time", &double_click_time,
NULL); NULL);
@ -520,11 +519,11 @@ button_press_event (GtkWidget *widget,
click_count++; click_count++;
else else
click_count = 0; click_count = 0;
last_click_time = event->time; last_click_time = event->time;
/* Ignore double click if we are in single click mode */ /* Ignore double click if we are in single click mode */
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE && if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
click_count >= 2) { click_count >= 2) {
return TRUE; return TRUE;
} }
@ -536,7 +535,7 @@ button_press_event (GtkWidget *widget,
&path, NULL, NULL, NULL)) { &path, NULL, NULL, NULL)) {
/* Keep track of path of last click so double clicks only happen /* Keep track of path of last click so double clicks only happen
* on the same item */ * on the same item */
if ((event->button == 1 || event->button == 2) && if ((event->button == 1 || event->button == 2) &&
event->type == GDK_BUTTON_PRESS) { event->type == GDK_BUTTON_PRESS) {
if (view->priv->double_click_path[1]) if (view->priv->double_click_path[1])
gtk_tree_path_free (view->priv->double_click_path[1]); gtk_tree_path_free (view->priv->double_click_path[1]);
@ -549,7 +548,7 @@ button_press_event (GtkWidget *widget,
if (view->priv->double_click_path[1] && if (view->priv->double_click_path[1] &&
gtk_tree_path_compare (view->priv->double_click_path[0], view->priv->double_click_path[1]) == 0) gtk_tree_path_compare (view->priv->double_click_path[0], view->priv->double_click_path[1]) == 0)
activate_selected_items (view); activate_selected_items (view);
/* Chain up */ /* Chain up */
widget_parent->button_press_event (widget, event); widget_parent->button_press_event (widget, event);
} else { } else {
@ -585,14 +584,14 @@ button_press_event (GtkWidget *widget,
view->priv->ignore_release = on_expander; view->priv->ignore_release = on_expander;
} }
} }
if (call_parent) { if (call_parent) {
/* Chain up */ /* Chain up */
widget_parent->button_press_event (widget, event); widget_parent->button_press_event (widget, event);
} else if (selected) { } else if (selected) {
gtk_widget_grab_focus (widget); gtk_widget_grab_focus (widget);
} }
if ((event->button == 1 || event->button == 2) && if ((event->button == 1 || event->button == 2) &&
event->type == GDK_BUTTON_PRESS) { event->type == GDK_BUTTON_PRESS) {
view->priv->drag_started = FALSE; view->priv->drag_started = FALSE;
@ -602,7 +601,7 @@ button_press_event (GtkWidget *widget,
gtk_tree_path_free (path); gtk_tree_path_free (path);
} else { } else {
if ((event->button == 1 || event->button == 2) && if ((event->button == 1 || event->button == 2) &&
event->type == GDK_BUTTON_PRESS) { event->type == GDK_BUTTON_PRESS) {
if (view->priv->double_click_path[1]) if (view->priv->double_click_path[1])
gtk_tree_path_free (view->priv->double_click_path[1]); gtk_tree_path_free (view->priv->double_click_path[1]);
@ -668,7 +667,7 @@ key_press_event (GtkWidget *widget,
/* Chain up */ /* Chain up */
if (!handled) if (!handled)
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->key_press_event (widget, event); return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->key_press_event (widget, event);
return TRUE; return TRUE;
} }
@ -678,31 +677,31 @@ fill_expand_state (XedFileBrowserView * view, GtkTreeIter * iter)
GtkTreePath * path; GtkTreePath * path;
GtkTreeIter child; GtkTreeIter child;
gchar * uri; gchar * uri;
if (!gtk_tree_model_iter_has_child (view->priv->model, iter)) if (!gtk_tree_model_iter_has_child (view->priv->model, iter))
return; return;
path = gtk_tree_model_get_path (view->priv->model, iter); path = gtk_tree_model_get_path (view->priv->model, iter);
if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path)) if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path))
{ {
gtk_tree_model_get (view->priv->model, gtk_tree_model_get (view->priv->model,
iter, iter,
XED_FILE_BROWSER_STORE_COLUMN_URI, XED_FILE_BROWSER_STORE_COLUMN_URI,
&uri, &uri,
-1); -1);
add_expand_state (view, uri); add_expand_state (view, uri);
g_free (uri); g_free (uri);
} }
if (gtk_tree_model_iter_children (view->priv->model, &child, iter)) if (gtk_tree_model_iter_children (view->priv->model, &child, iter))
{ {
do { do {
fill_expand_state (view, &child); fill_expand_state (view, &child);
} while (gtk_tree_model_iter_next (view->priv->model, &child)); } while (gtk_tree_model_iter_next (view->priv->model, &child));
} }
gtk_tree_path_free (path); gtk_tree_path_free (path);
} }
@ -710,20 +709,20 @@ static void
uninstall_restore_signals (XedFileBrowserView * tree_view, uninstall_restore_signals (XedFileBrowserView * tree_view,
GtkTreeModel * model) GtkTreeModel * model)
{ {
g_signal_handlers_disconnect_by_func (model, g_signal_handlers_disconnect_by_func (model,
on_begin_refresh, on_begin_refresh,
tree_view);
g_signal_handlers_disconnect_by_func (model,
on_end_refresh,
tree_view);
g_signal_handlers_disconnect_by_func (model,
on_unload,
tree_view); tree_view);
g_signal_handlers_disconnect_by_func (model, g_signal_handlers_disconnect_by_func (model,
on_row_inserted, on_end_refresh,
tree_view);
g_signal_handlers_disconnect_by_func (model,
on_unload,
tree_view);
g_signal_handlers_disconnect_by_func (model,
on_row_inserted,
tree_view); tree_view);
} }
@ -731,24 +730,24 @@ static void
install_restore_signals (XedFileBrowserView * tree_view, install_restore_signals (XedFileBrowserView * tree_view,
GtkTreeModel * model) GtkTreeModel * model)
{ {
g_signal_connect (model, g_signal_connect (model,
"begin-refresh", "begin-refresh",
G_CALLBACK (on_begin_refresh), G_CALLBACK (on_begin_refresh),
tree_view); tree_view);
g_signal_connect (model, g_signal_connect (model,
"end-refresh", "end-refresh",
G_CALLBACK (on_end_refresh), G_CALLBACK (on_end_refresh),
tree_view); tree_view);
g_signal_connect (model, g_signal_connect (model,
"unload", "unload",
G_CALLBACK (on_unload), G_CALLBACK (on_unload),
tree_view); tree_view);
g_signal_connect_after (model, g_signal_connect_after (model,
"row-inserted", "row-inserted",
G_CALLBACK (on_row_inserted), G_CALLBACK (on_row_inserted),
tree_view); tree_view);
} }
@ -771,7 +770,7 @@ set_restore_expand_state (XedFileBrowserView * view,
(GEqualFunc)g_file_equal, (GEqualFunc)g_file_equal,
g_object_unref, g_object_unref,
NULL); NULL);
if (view->priv->model && XED_IS_FILE_BROWSER_STORE (view->priv->model)) if (view->priv->model && XED_IS_FILE_BROWSER_STORE (view->priv->model))
{ {
fill_expand_state (view, NULL); fill_expand_state (view, NULL);
@ -837,11 +836,11 @@ xed_file_browser_view_class_init (XedFileBrowserViewClass * klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkTreeViewClass *tree_view_class = GTK_TREE_VIEW_CLASS (klass); GtkTreeViewClass *tree_view_class = GTK_TREE_VIEW_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = xed_file_browser_view_finalize; object_class->finalize = xed_file_browser_view_finalize;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
/* Event handlers */ /* Event handlers */
widget_class->motion_notify_event = motion_notify_event; widget_class->motion_notify_event = motion_notify_event;
widget_class->enter_notify_event = enter_notify_event; widget_class->enter_notify_event = enter_notify_event;
@ -854,7 +853,7 @@ xed_file_browser_view_class_init (XedFileBrowserViewClass * klass)
/* Tree view handlers */ /* Tree view handlers */
tree_view_class->row_expanded = row_expanded; tree_view_class->row_expanded = row_expanded;
tree_view_class->row_collapsed = row_collapsed; tree_view_class->row_collapsed = row_collapsed;
/* Default handlers */ /* Default handlers */
klass->directory_activated = directory_activated; klass->directory_activated = directory_activated;
@ -910,6 +909,12 @@ xed_file_browser_view_class_init (XedFileBrowserViewClass * klass)
sizeof (XedFileBrowserViewPrivate)); sizeof (XedFileBrowserViewPrivate));
} }
static void
xed_file_browser_view_class_finalize (XedFileBrowserViewClass *klass)
{
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE */
}
static void static void
cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell, cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
GtkTreeModel * tree_model, GtkTreeIter * iter, GtkTreeModel * tree_model, GtkTreeIter * iter,
@ -922,18 +927,18 @@ cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
path = gtk_tree_model_get_path (tree_model, iter); path = gtk_tree_model_get_path (tree_model, iter);
if (obj->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) { if (obj->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
if (obj->priv->hover_path != NULL && if (obj->priv->hover_path != NULL &&
gtk_tree_path_compare (path, obj->priv->hover_path) == 0) gtk_tree_path_compare (path, obj->priv->hover_path) == 0)
underline = PANGO_UNDERLINE_SINGLE; underline = PANGO_UNDERLINE_SINGLE;
} }
if (XED_IS_FILE_BROWSER_STORE (tree_model)) if (XED_IS_FILE_BROWSER_STORE (tree_model))
{ {
if (obj->priv->editable != NULL && if (obj->priv->editable != NULL &&
gtk_tree_row_reference_valid (obj->priv->editable)) gtk_tree_row_reference_valid (obj->priv->editable))
{ {
GtkTreePath *edpath = gtk_tree_row_reference_get_path (obj->priv->editable); GtkTreePath *edpath = gtk_tree_row_reference_get_path (obj->priv->editable);
editable = edpath && gtk_tree_path_compare (path, edpath) == 0; editable = edpath && gtk_tree_path_compare (path, edpath) == 0;
} }
} }
@ -1018,7 +1023,7 @@ xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
if (XED_IS_FILE_BOOKMARKS_STORE (model)) { if (XED_IS_FILE_BOOKMARKS_STORE (model)) {
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW
(tree_view), (tree_view),
bookmarks_separator_func, bookmarks_separator_func,
@ -1045,7 +1050,7 @@ xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
if (tree_view->priv->restore_expand_state) if (tree_view->priv->restore_expand_state)
install_restore_signals (tree_view, model); install_restore_signals (tree_view, model);
} }
if (tree_view->priv->hover_path != NULL) { if (tree_view->priv->hover_path != NULL) {
@ -1055,7 +1060,7 @@ xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
if (XED_IS_FILE_BROWSER_STORE (tree_view->priv->model)) { if (XED_IS_FILE_BROWSER_STORE (tree_view->priv->model)) {
if (tree_view->priv->restore_expand_state) if (tree_view->priv->restore_expand_state)
uninstall_restore_signals (tree_view, uninstall_restore_signals (tree_view,
tree_view->priv->model); tree_view->priv->model);
} }
@ -1088,18 +1093,18 @@ xed_file_browser_view_start_rename (XedFileBrowserView * tree_view,
/* Start editing */ /* Start editing */
gtk_widget_grab_focus (GTK_WIDGET (tree_view)); gtk_widget_grab_focus (GTK_WIDGET (tree_view));
if (gtk_tree_path_up (path)) if (gtk_tree_path_up (path))
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (tree_view), gtk_tree_view_expand_to_path (GTK_TREE_VIEW (tree_view),
path); path);
gtk_tree_path_free (path); gtk_tree_path_free (path);
tree_view->priv->editable = rowref; tree_view->priv->editable = rowref;
gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view), gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view),
gtk_tree_row_reference_get_path (tree_view->priv->editable), gtk_tree_row_reference_get_path (tree_view->priv->editable),
tree_view->priv->column, TRUE); tree_view->priv->column, TRUE);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view), gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view),
gtk_tree_row_reference_get_path (tree_view->priv->editable), gtk_tree_row_reference_get_path (tree_view->priv->editable),
tree_view->priv->column, tree_view->priv->column,
@ -1111,9 +1116,9 @@ xed_file_browser_view_set_click_policy (XedFileBrowserView *tree_view,
XedFileBrowserViewClickPolicy policy) XedFileBrowserViewClickPolicy policy)
{ {
g_return_if_fail (XED_IS_FILE_BROWSER_VIEW (tree_view)); g_return_if_fail (XED_IS_FILE_BROWSER_VIEW (tree_view));
set_click_policy_property (tree_view, policy); set_click_policy_property (tree_view, policy);
g_object_notify (G_OBJECT (tree_view), "click-policy"); g_object_notify (G_OBJECT (tree_view), "click-policy");
} }
@ -1136,13 +1141,13 @@ on_cell_edited (GtkCellRendererText * cell, gchar * path, gchar * new_text,
GtkTreeIter iter; GtkTreeIter iter;
gboolean ret; gboolean ret;
GError * error = NULL; GError * error = NULL;
gtk_tree_row_reference_free (tree_view->priv->editable); gtk_tree_row_reference_free (tree_view->priv->editable);
tree_view->priv->editable = NULL; tree_view->priv->editable = NULL;
if (new_text == NULL || *new_text == '\0') if (new_text == NULL || *new_text == '\0')
return; return;
treepath = gtk_tree_path_new_from_string (path); treepath = gtk_tree_path_new_from_string (path);
ret = gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_view->priv->model), &iter, treepath); ret = gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_view->priv->model), &iter, treepath);
gtk_tree_path_free (treepath); gtk_tree_path_free (treepath);
@ -1166,8 +1171,8 @@ on_cell_edited (GtkCellRendererText * cell, gchar * path, gchar * new_text,
} }
} }
static void static void
on_begin_refresh (XedFileBrowserStore * model, on_begin_refresh (XedFileBrowserStore * model,
XedFileBrowserView * view) XedFileBrowserView * view)
{ {
/* Store the refresh state, so we can handle unloading of nodes while /* Store the refresh state, so we can handle unloading of nodes while
@ -1175,8 +1180,8 @@ on_begin_refresh (XedFileBrowserStore * model,
view->priv->is_refresh = TRUE; view->priv->is_refresh = TRUE;
} }
static void static void
on_end_refresh (XedFileBrowserStore * model, on_end_refresh (XedFileBrowserStore * model,
XedFileBrowserView * view) XedFileBrowserView * view)
{ {
/* Store the refresh state, so we can handle unloading of nodes while /* Store the refresh state, so we can handle unloading of nodes while
@ -1185,14 +1190,14 @@ on_end_refresh (XedFileBrowserStore * model,
} }
static void static void
on_unload (XedFileBrowserStore * model, on_unload (XedFileBrowserStore * model,
gchar const * uri, gchar const * uri,
XedFileBrowserView * view) XedFileBrowserView * view)
{ {
/* Don't remove the expand state if we are refreshing */ /* Don't remove the expand state if we are refreshing */
if (!view->priv->restore_expand_state || view->priv->is_refresh) if (!view->priv->restore_expand_state || view->priv->is_refresh)
return; return;
remove_expand_state (view, uri); remove_expand_state (view, uri);
} }
@ -1205,10 +1210,10 @@ restore_expand_state (XedFileBrowserView * view,
GFile * file; GFile * file;
GtkTreePath * path; GtkTreePath * path;
gtk_tree_model_get (GTK_TREE_MODEL (model), gtk_tree_model_get (GTK_TREE_MODEL (model),
iter, iter,
XED_FILE_BROWSER_STORE_COLUMN_URI, XED_FILE_BROWSER_STORE_COLUMN_URI,
&uri, &uri,
-1); -1);
if (!uri) if (!uri)
@ -1223,15 +1228,15 @@ restore_expand_state (XedFileBrowserView * view,
path, path,
FALSE); FALSE);
} }
gtk_tree_path_free (path); gtk_tree_path_free (path);
g_object_unref (file); g_object_unref (file);
g_free (uri); g_free (uri);
} }
static void static void
on_row_inserted (XedFileBrowserStore * model, on_row_inserted (XedFileBrowserStore * model,
GtkTreePath * path, GtkTreePath * path,
GtkTreeIter * iter, GtkTreeIter * iter,
XedFileBrowserView * view) XedFileBrowserView * view)
@ -1253,5 +1258,11 @@ on_row_inserted (XedFileBrowserStore * model,
gtk_tree_path_free (copy); gtk_tree_path_free (copy);
} }
void
_xed_file_browser_view_register_type (GTypeModule *type_module)
{
xed_file_browser_view_register_type (type_module);
}
// ex:ts=8:noet: // ex:ts=8:noet:

View File

@ -1,5 +1,5 @@
/* /*
* xed-file-browser-view.h - Xed plugin providing easy file access * xed-file-browser-view.h - Xed plugin providing easy file access
* from the sidepanel * from the sidepanel
* *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
@ -39,22 +39,22 @@ typedef struct _XedFileBrowserViewPrivate XedFileBrowserViewPrivate;
typedef enum { typedef enum {
XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE, XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE
} XedFileBrowserViewClickPolicy; } XedFileBrowserViewClickPolicy;
struct _XedFileBrowserView struct _XedFileBrowserView
{ {
GtkTreeView parent; GtkTreeView parent;
XedFileBrowserViewPrivate *priv; XedFileBrowserViewPrivate *priv;
}; };
struct _XedFileBrowserViewClass struct _XedFileBrowserViewClass
{ {
GtkTreeViewClass parent_class; GtkTreeViewClass parent_class;
/* Signals */ /* Signals */
void (*error) (XedFileBrowserView * filetree, void (*error) (XedFileBrowserView * filetree,
guint code, guint code,
gchar const *message); gchar const *message);
void (*file_activated) (XedFileBrowserView * filetree, void (*file_activated) (XedFileBrowserView * filetree,
@ -66,12 +66,12 @@ struct _XedFileBrowserViewClass
}; };
GType xed_file_browser_view_get_type (void) G_GNUC_CONST; GType xed_file_browser_view_get_type (void) G_GNUC_CONST;
GType xed_file_browser_view_register_type (GTypeModule * module); void _xed_file_browser_view_register_type (GTypeModule * module);
GtkWidget *xed_file_browser_view_new (void); GtkWidget *xed_file_browser_view_new (void);
void xed_file_browser_view_set_model (XedFileBrowserView * tree_view, void xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
GtkTreeModel * model); GtkTreeModel * model);
void xed_file_browser_view_start_rename (XedFileBrowserView * tree_view, void xed_file_browser_view_start_rename (XedFileBrowserView * tree_view,
GtkTreeIter * iter); GtkTreeIter * iter);
void xed_file_browser_view_set_click_policy (XedFileBrowserView * tree_view, void xed_file_browser_view_set_click_policy (XedFileBrowserView * tree_view,
XedFileBrowserViewClickPolicy policy); XedFileBrowserViewClickPolicy policy);

View File

@ -32,7 +32,6 @@
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <xed/xed-utils.h> #include <xed/xed-utils.h>
#include <xed/xed-plugin.h>
#include "xed-file-browser-utils.h" #include "xed-file-browser-utils.h"
#include "xed-file-browser-error.h" #include "xed-file-browser-error.h"
@ -236,7 +235,7 @@ static void on_action_filter_binary (GtkAction * action,
static void on_action_bookmark_open (GtkAction * action, static void on_action_bookmark_open (GtkAction * action,
XedFileBrowserWidget * obj); XedFileBrowserWidget * obj);
XED_PLUGIN_DEFINE_TYPE (XedFileBrowserWidget, xed_file_browser_widget, G_DEFINE_DYNAMIC_TYPE (XedFileBrowserWidget, xed_file_browser_widget,
GTK_TYPE_BOX) GTK_TYPE_BOX)
static void static void
@ -479,6 +478,12 @@ xed_file_browser_widget_class_init (XedFileBrowserWidgetClass * klass)
sizeof (XedFileBrowserWidgetPrivate)); sizeof (XedFileBrowserWidgetPrivate));
} }
static void
xed_file_browser_widget_class_finalize (XedFileBrowserWidgetClass *klass)
{
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE */
}
static void static void
add_signal (XedFileBrowserWidget * obj, gpointer object, gulong id) add_signal (XedFileBrowserWidget * obj, gpointer object, gulong id)
{ {
@ -3146,4 +3151,10 @@ on_action_bookmark_open (GtkAction * action, XedFileBrowserWidget * obj)
bookmark_open (obj, model, &iter); bookmark_open (obj, model, &iter);
} }
void
_xed_file_browser_widget_register_type (GTypeModule *type_module)
{
xed_file_browser_widget_register_type (type_module);
}
// ex:ts=8:noet: // ex:ts=8:noet:

View File

@ -1,5 +1,5 @@
/* /*
* xed-file-browser-widget.h - Xed plugin providing easy file access * xed-file-browser-widget.h - Xed plugin providing easy file access
* from the sidepanel * from the sidepanel
* *
* Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl> * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
@ -28,13 +28,13 @@
#include "xed-file-browser-view.h" #include "xed-file-browser-view.h"
G_BEGIN_DECLS G_BEGIN_DECLS
#define XED_TYPE_FILE_BROWSER_WIDGET (xed_file_browser_widget_get_type ()) #define XED_TYPE_FILE_BROWSER_WIDGET (xed_file_browser_widget_get_type ())
#define XED_FILE_BROWSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_WIDGET, XedFileBrowserWidget)) #define XED_FILE_BROWSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_WIDGET, XedFileBrowserWidget))
#define XED_FILE_BROWSER_WIDGET_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_WIDGET, XedFileBrowserWidget const)) #define XED_FILE_BROWSER_WIDGET_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_WIDGET, XedFileBrowserWidget const))
#define XED_FILE_BROWSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_FILE_BROWSER_WIDGET, XedFileBrowserWidgetClass)) #define XED_FILE_BROWSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_FILE_BROWSER_WIDGET, XedFileBrowserWidgetClass))
#define XED_IS_FILE_BROWSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_FILE_BROWSER_WIDGET)) #define XED_IS_FILE_BROWSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_FILE_BROWSER_WIDGET))
#define XED_IS_FILE_BROWSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_FILE_BROWSER_WIDGET)) #define XED_IS_FILE_BROWSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_FILE_BROWSER_WIDGET))
#define XED_FILE_BROWSER_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BROWSER_WIDGET, XedFileBrowserWidgetClass)) #define XED_FILE_BROWSER_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BROWSER_WIDGET, XedFileBrowserWidgetClass))
typedef struct _XedFileBrowserWidget XedFileBrowserWidget; typedef struct _XedFileBrowserWidget XedFileBrowserWidget;
typedef struct _XedFileBrowserWidgetClass XedFileBrowserWidgetClass; typedef struct _XedFileBrowserWidgetClass XedFileBrowserWidgetClass;
@ -42,36 +42,36 @@ typedef struct _XedFileBrowserWidgetPrivate XedFileBrowserWidgetPrivate;
typedef typedef
gboolean (*XedFileBrowserWidgetFilterFunc) (XedFileBrowserWidget * obj, gboolean (*XedFileBrowserWidgetFilterFunc) (XedFileBrowserWidget * obj,
XedFileBrowserStore * XedFileBrowserStore *
model, GtkTreeIter * iter, model, GtkTreeIter * iter,
gpointer user_data); gpointer user_data);
struct _XedFileBrowserWidget struct _XedFileBrowserWidget
{ {
GtkBox parent; GtkBox parent;
XedFileBrowserWidgetPrivate *priv; XedFileBrowserWidgetPrivate *priv;
}; };
struct _XedFileBrowserWidgetClass struct _XedFileBrowserWidgetClass
{ {
GtkBoxClass parent_class; GtkBoxClass parent_class;
/* Signals */ /* Signals */
void (*uri_activated) (XedFileBrowserWidget * widget, void (*uri_activated) (XedFileBrowserWidget * widget,
gchar const *uri); gchar const *uri);
void (*error) (XedFileBrowserWidget * widget, void (*error) (XedFileBrowserWidget * widget,
guint code, guint code,
gchar const *message); gchar const *message);
gboolean (*confirm_delete) (XedFileBrowserWidget * widget, gboolean (*confirm_delete) (XedFileBrowserWidget * widget,
XedFileBrowserStore * model, XedFileBrowserStore * model,
GList *list); GList *list);
gboolean (*confirm_no_trash) (XedFileBrowserWidget * widget, gboolean (*confirm_no_trash) (XedFileBrowserWidget * widget,
GList *list); GList *list);
}; };
GType xed_file_browser_widget_get_type (void) G_GNUC_CONST; GType xed_file_browser_widget_get_type (void) G_GNUC_CONST;
GType xed_file_browser_widget_register_type (GTypeModule * module); void _xed_file_browser_widget_register_type (GTypeModule * module);
GtkWidget *xed_file_browser_widget_new (const gchar *data_dir); GtkWidget *xed_file_browser_widget_new (const gchar *data_dir);
@ -83,27 +83,27 @@ void xed_file_browser_widget_set_root (XedFileBrowserWidget * obj,
gboolean virtual_root); gboolean virtual_root);
void void
xed_file_browser_widget_set_root_and_virtual_root (XedFileBrowserWidget * obj, xed_file_browser_widget_set_root_and_virtual_root (XedFileBrowserWidget * obj,
gchar const *root, gchar const *root,
gchar const *virtual_root); gchar const *virtual_root);
gboolean gboolean
xed_file_browser_widget_get_selected_directory (XedFileBrowserWidget * obj, xed_file_browser_widget_get_selected_directory (XedFileBrowserWidget * obj,
GtkTreeIter * iter); GtkTreeIter * iter);
XedFileBrowserStore * XedFileBrowserStore *
xed_file_browser_widget_get_browser_store (XedFileBrowserWidget * obj); xed_file_browser_widget_get_browser_store (XedFileBrowserWidget * obj);
XedFileBookmarksStore * XedFileBookmarksStore *
xed_file_browser_widget_get_bookmarks_store (XedFileBrowserWidget * obj); xed_file_browser_widget_get_bookmarks_store (XedFileBrowserWidget * obj);
XedFileBrowserView * XedFileBrowserView *
xed_file_browser_widget_get_browser_view (XedFileBrowserWidget * obj); xed_file_browser_widget_get_browser_view (XedFileBrowserWidget * obj);
GtkWidget * GtkWidget *
xed_file_browser_widget_get_filter_entry (XedFileBrowserWidget * obj); xed_file_browser_widget_get_filter_entry (XedFileBrowserWidget * obj);
GtkUIManager * GtkUIManager *
xed_file_browser_widget_get_ui_manager (XedFileBrowserWidget * obj); xed_file_browser_widget_get_ui_manager (XedFileBrowserWidget * obj);
gulong xed_file_browser_widget_add_filter (XedFileBrowserWidget * obj, gulong xed_file_browser_widget_add_filter (XedFileBrowserWidget * obj,
XedFileBrowserWidgetFilterFunc func, XedFileBrowserWidgetFilterFunc func,
gpointer user_data, gpointer user_data,
GDestroyNotify notify); GDestroyNotify notify);
void xed_file_browser_widget_remove_filter (XedFileBrowserWidget * obj, void xed_file_browser_widget_remove_filter (XedFileBrowserWidget * obj,
@ -111,9 +111,9 @@ void xed_file_browser_widget_remove_filter (XedFileBrowserWidget * obj,
void xed_file_browser_widget_set_filter_pattern (XedFileBrowserWidget * obj, void xed_file_browser_widget_set_filter_pattern (XedFileBrowserWidget * obj,
gchar const *pattern); gchar const *pattern);
void xed_file_browser_widget_refresh (XedFileBrowserWidget * obj); void xed_file_browser_widget_refresh (XedFileBrowserWidget * obj);
void xed_file_browser_widget_history_back (XedFileBrowserWidget * obj); void xed_file_browser_widget_history_back (XedFileBrowserWidget * obj);
void xed_file_browser_widget_history_forward (XedFileBrowserWidget * obj); void xed_file_browser_widget_history_forward (XedFileBrowserWidget * obj);
G_END_DECLS G_END_DECLS
#endif /* __XED_FILE_BROWSER_WIDGET_H__ */ #endif /* __XED_FILE_BROWSER_WIDGET_H__ */