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

@ -25,13 +25,13 @@
#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;
@ -39,52 +39,52 @@ 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

@ -24,18 +24,20 @@
#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;
@ -44,26 +46,26 @@ 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

@ -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"
@ -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 */
@ -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)
{ {
@ -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

@ -25,111 +25,111 @@
#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);
@ -142,13 +142,13 @@ 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,
@ -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

@ -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>
@ -86,7 +85,7 @@ 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,
@ -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,
@ -1254,4 +1259,10 @@ 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

@ -66,7 +66,7 @@ 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,

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

@ -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,8 +83,8 @@ 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,
@ -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__ */