parent
fdc2da63a9
commit
4cad8ffa7f
|
@ -23,7 +23,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <gio/gio.h>
|
||||
#include <xed/xed-utils.h>
|
||||
#include <xed/xed-plugin.h>
|
||||
|
||||
#include "xed-file-bookmarks-store.h"
|
||||
#include "xed-file-browser-utils.h"
|
||||
|
@ -56,23 +55,23 @@ static gboolean find_with_flags (GtkTreeModel * model,
|
|||
guint flags,
|
||||
guint notflags);
|
||||
|
||||
XED_PLUGIN_DEFINE_TYPE(XedFileBookmarksStore, xed_file_bookmarks_store, GTK_TYPE_TREE_STORE)
|
||||
G_DEFINE_DYNAMIC_TYPE (XedFileBookmarksStore, xed_file_bookmarks_store, GTK_TYPE_TREE_STORE)
|
||||
|
||||
static void
|
||||
xed_file_bookmarks_store_dispose (GObject * object)
|
||||
{
|
||||
XedFileBookmarksStore *obj = XED_FILE_BOOKMARKS_STORE (object);
|
||||
|
||||
if (obj->priv->volume_monitor != NULL) {
|
||||
g_signal_handlers_disconnect_by_func (obj->priv->volume_monitor,
|
||||
on_fs_changed,
|
||||
obj);
|
||||
if (obj->priv->volume_monitor != NULL)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (obj->priv->volume_monitor, on_fs_changed, obj);
|
||||
|
||||
g_object_unref (obj->priv->volume_monitor);
|
||||
obj->priv->volume_monitor = NULL;
|
||||
}
|
||||
|
||||
if (obj->priv->bookmarks_monitor != NULL) {
|
||||
if (obj->priv->bookmarks_monitor != NULL)
|
||||
{
|
||||
g_object_unref (obj->priv->bookmarks_monitor);
|
||||
obj->priv->bookmarks_monitor = NULL;
|
||||
}
|
||||
|
@ -97,6 +96,12 @@ xed_file_bookmarks_store_class_init (XedFileBookmarksStoreClass *klass)
|
|||
g_type_class_add_private (object_class, sizeof (XedFileBookmarksStorePrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_file_bookmarks_store_class_finalize (XedFileBookmarksStoreClass *klass)
|
||||
{
|
||||
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE */
|
||||
}
|
||||
|
||||
static void
|
||||
xed_file_bookmarks_store_init (XedFileBookmarksStore * obj)
|
||||
{
|
||||
|
@ -124,8 +129,10 @@ add_node (XedFileBookmarksStore *model,
|
|||
-1);
|
||||
|
||||
if (iter != NULL)
|
||||
{
|
||||
*iter = newiter;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
add_file (XedFileBookmarksStore *model,
|
||||
|
@ -140,36 +147,52 @@ add_file (XedFileBookmarksStore *model,
|
|||
|
||||
native = g_file_is_native (file);
|
||||
|
||||
if (native && !g_file_query_exists (file, NULL)) {
|
||||
if (native && !g_file_query_exists (file, NULL))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flags & XED_FILE_BOOKMARKS_STORE_IS_HOME)
|
||||
{
|
||||
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("user-home", GTK_ICON_SIZE_MENU);
|
||||
}
|
||||
else if (flags & XED_FILE_BOOKMARKS_STORE_IS_DESKTOP)
|
||||
{
|
||||
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("user-desktop", GTK_ICON_SIZE_MENU);
|
||||
}
|
||||
else if (flags & XED_FILE_BOOKMARKS_STORE_IS_ROOT)
|
||||
{
|
||||
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("drive-harddisk", GTK_ICON_SIZE_MENU);
|
||||
}
|
||||
|
||||
if (pixbuf == NULL) {
|
||||
if (pixbuf == NULL)
|
||||
{
|
||||
/* getting the icon is a sync get_info call, so we just do it for local files */
|
||||
if (native) {
|
||||
if (native)
|
||||
{
|
||||
pixbuf = xed_file_browser_utils_pixbuf_from_file (file, GTK_ICON_SIZE_MENU);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("folder", GTK_ICON_SIZE_MENU);
|
||||
}
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
if (name == NULL)
|
||||
{
|
||||
newname = xed_file_browser_utils_file_basename (file);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
newname = g_strdup (name);
|
||||
}
|
||||
|
||||
add_node (model, pixbuf, newname, G_OBJECT (file), flags, iter);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
g_free (newname);
|
||||
|
||||
|
@ -183,17 +206,16 @@ check_mount_separator (XedFileBookmarksStore * model, guint flags,
|
|||
GtkTreeIter iter;
|
||||
gboolean found;
|
||||
|
||||
found =
|
||||
find_with_flags (GTK_TREE_MODEL (model), &iter, NULL,
|
||||
flags |
|
||||
XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR, 0);
|
||||
found = find_with_flags (GTK_TREE_MODEL (model), &iter, NULL,
|
||||
flags | XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR, 0);
|
||||
|
||||
if (added && !found) {
|
||||
if (added && !found)
|
||||
{
|
||||
/* Add the separator */
|
||||
add_node (model, NULL, NULL, NULL,
|
||||
flags | XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR,
|
||||
NULL);
|
||||
} else if (!added && found) {
|
||||
add_node (model, NULL, NULL, NULL, flags | XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR, NULL);
|
||||
}
|
||||
else if (!added && found)
|
||||
{
|
||||
remove_node (GTK_TREE_MODEL (model), &iter);
|
||||
}
|
||||
}
|
||||
|
@ -208,8 +230,7 @@ init_special_directories (XedFileBookmarksStore * model)
|
|||
if (path != NULL)
|
||||
{
|
||||
file = g_file_new_for_path (path);
|
||||
add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_HOME |
|
||||
XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL);
|
||||
add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_HOME | XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
|
@ -294,7 +315,9 @@ add_fs (XedFileBookmarksStore *model,
|
|||
add_node (model, pixbuf, name, fs, flags | fsflags, iter);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
check_mount_separator (model, XED_FILE_BOOKMARKS_STORE_IS_FS, TRUE);
|
||||
|
@ -434,7 +457,8 @@ init_mounts (XedFileBookmarksStore *model)
|
|||
static void
|
||||
init_fs (XedFileBookmarksStore * model)
|
||||
{
|
||||
if (model->priv->volume_monitor == NULL) {
|
||||
if (model->priv->volume_monitor == NULL)
|
||||
{
|
||||
const gchar **ptr;
|
||||
const gchar *signals[] = {
|
||||
"drive-connected", "drive-changed", "drive-disconnected",
|
||||
|
@ -448,9 +472,7 @@ init_fs (XedFileBookmarksStore * model)
|
|||
/* Connect signals */
|
||||
for (ptr = signals; *ptr; ptr++)
|
||||
{
|
||||
g_signal_connect (model->priv->volume_monitor,
|
||||
*ptr,
|
||||
G_CALLBACK (on_fs_changed), model);
|
||||
g_signal_connect (model->priv->volume_monitor, *ptr, G_CALLBACK (on_fs_changed), model);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,9 +498,12 @@ add_bookmark (XedFileBookmarksStore * model,
|
|||
|
||||
file = g_file_new_for_uri (uri);
|
||||
|
||||
if (g_file_is_native (file)) {
|
||||
if (g_file_is_native (file))
|
||||
{
|
||||
flags |= XED_FILE_BOOKMARKS_STORE_IS_LOCAL_BOOKMARK;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
flags |= XED_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK;
|
||||
}
|
||||
|
||||
|
@ -500,31 +525,36 @@ init_bookmarks (XedFileBookmarksStore * model)
|
|||
gboolean added = FALSE;
|
||||
|
||||
/* Read the bookmarks file */
|
||||
bookmarks = g_build_filename (g_get_home_dir (),
|
||||
".gtk-bookmarks",
|
||||
NULL);
|
||||
bookmarks = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL);
|
||||
|
||||
if (g_file_get_contents (bookmarks, &contents, NULL, &error)) {
|
||||
if (g_file_get_contents (bookmarks, &contents, NULL, &error))
|
||||
{
|
||||
lines = g_strsplit (contents, "\n", 0);
|
||||
|
||||
for (line = lines; *line; ++line) {
|
||||
if (**line) {
|
||||
for (line = lines; *line; ++line)
|
||||
{
|
||||
if (**line)
|
||||
{
|
||||
gchar *pos;
|
||||
gchar *name;
|
||||
|
||||
/* CHECK: is this really utf8? */
|
||||
pos = g_utf8_strchr (*line, -1, ' ');
|
||||
|
||||
if (pos != NULL) {
|
||||
if (pos != NULL)
|
||||
{
|
||||
*pos = '\0';
|
||||
name = pos + 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
name = NULL;
|
||||
}
|
||||
|
||||
/* the bookmarks file should contain valid
|
||||
* URIs, but paranoia is good */
|
||||
if (xed_utils_is_valid_uri (*line)) {
|
||||
if (xed_utils_is_valid_uri (*line))
|
||||
{
|
||||
added |= add_bookmark (model, name, *line);
|
||||
}
|
||||
}
|
||||
|
@ -534,24 +564,26 @@ init_bookmarks (XedFileBookmarksStore * model)
|
|||
g_free (contents);
|
||||
|
||||
/* Add a watch */
|
||||
if (model->priv->bookmarks_monitor == NULL) {
|
||||
if (model->priv->bookmarks_monitor == NULL)
|
||||
{
|
||||
GFile * file;
|
||||
|
||||
file = g_file_new_for_path (bookmarks);
|
||||
model->priv->bookmarks_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL);
|
||||
g_object_unref (file);
|
||||
|
||||
g_signal_connect (model->priv->bookmarks_monitor,
|
||||
"changed",
|
||||
(GCallback)on_bookmarks_file_changed,
|
||||
model);
|
||||
g_signal_connect (model->priv->bookmarks_monitor, "changed",
|
||||
(GCallback)on_bookmarks_file_changed, model);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The bookmarks file doesn't exist (which is perfectly fine) */
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
if (added) {
|
||||
if (added)
|
||||
{
|
||||
/* Bookmarks separator */
|
||||
add_node (model, NULL, NULL, NULL,
|
||||
XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK |
|
||||
|
@ -590,7 +622,8 @@ utf8_casecmp (gchar const *s1, const gchar * s2)
|
|||
}
|
||||
|
||||
static gint
|
||||
bookmarks_compare_names (GtkTreeModel * model, GtkTreeIter * a,
|
||||
bookmarks_compare_names (GtkTreeModel * model,
|
||||
GtkTreeIter * a,
|
||||
GtkTreeIter * b)
|
||||
{
|
||||
gchar *n1;
|
||||
|
@ -609,17 +642,26 @@ bookmarks_compare_names (GtkTreeModel * model, GtkTreeIter * a,
|
|||
-1);
|
||||
|
||||
/* do not sort actual bookmarks to keep same order as in caja */
|
||||
if ((f1 & XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK) &&
|
||||
(f2 & XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK))
|
||||
if ((f1 & XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK) && (f2 & XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK))
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else if (n1 == NULL && n2 == NULL)
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else if (n1 == NULL)
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
else if (n2 == NULL)
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = utf8_casecmp (n1, n2);
|
||||
}
|
||||
|
||||
g_free (n1);
|
||||
g_free (n2);
|
||||
|
@ -628,7 +670,8 @@ bookmarks_compare_names (GtkTreeModel * model, GtkTreeIter * a,
|
|||
}
|
||||
|
||||
static gint
|
||||
bookmarks_compare_flags (GtkTreeModel * model, GtkTreeIter * a,
|
||||
bookmarks_compare_flags (GtkTreeModel * model,
|
||||
GtkTreeIter * a,
|
||||
GtkTreeIter * b)
|
||||
{
|
||||
guint f1;
|
||||
|
@ -638,48 +681,62 @@ bookmarks_compare_flags (GtkTreeModel * model, GtkTreeIter * a,
|
|||
|
||||
sep = XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR;
|
||||
|
||||
gtk_tree_model_get (model, a,
|
||||
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f1,
|
||||
-1);
|
||||
gtk_tree_model_get (model, b,
|
||||
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f2,
|
||||
-1);
|
||||
gtk_tree_model_get (model, a, XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f1, -1);
|
||||
gtk_tree_model_get (model, b, XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f2, -1);
|
||||
|
||||
for (flags = flags_order; *flags != -1; ++flags) {
|
||||
if ((f1 & *flags) != (f2 & *flags)) {
|
||||
if (f1 & *flags) {
|
||||
for (flags = flags_order; *flags != -1; ++flags)
|
||||
{
|
||||
if ((f1 & *flags) != (f2 & *flags))
|
||||
{
|
||||
if (f1 & *flags)
|
||||
{
|
||||
return -1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
} else if ((f1 & *flags) && (f1 & sep) != (f2 & sep)) {
|
||||
}
|
||||
else if ((f1 & *flags) && (f1 & sep) != (f2 & sep))
|
||||
{
|
||||
if (f1 & sep)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gint
|
||||
bookmarks_compare_func (GtkTreeModel * model, GtkTreeIter * a,
|
||||
GtkTreeIter * b, gpointer user_data)
|
||||
bookmarks_compare_func (GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint result;
|
||||
|
||||
result = bookmarks_compare_flags (model, a, b);
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
result = bookmarks_compare_names (model, a, b);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
|
||||
guint flags, guint notflags)
|
||||
find_with_flags (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer obj,
|
||||
guint flags,
|
||||
guint notflags)
|
||||
{
|
||||
GtkTreeIter child;
|
||||
guint childflags = 0;
|
||||
|
@ -687,7 +744,9 @@ find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
|
|||
gboolean fequal;
|
||||
|
||||
if (!gtk_tree_model_get_iter_first (model, &child))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
do {
|
||||
gtk_tree_model_get (model, &child,
|
||||
|
@ -699,11 +758,14 @@ find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
|
|||
fequal = (obj == childobj);
|
||||
|
||||
if (childobj)
|
||||
{
|
||||
g_object_unref (childobj);
|
||||
}
|
||||
|
||||
if ((obj == NULL || fequal) &&
|
||||
(childflags & flags) == flags
|
||||
&& !(childflags & notflags)) {
|
||||
&& !(childflags & notflags))
|
||||
{
|
||||
*iter = child;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -713,16 +775,17 @@ find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
|
|||
}
|
||||
|
||||
static void
|
||||
remove_node (GtkTreeModel * model, GtkTreeIter * iter)
|
||||
remove_node (GtkTreeModel *model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
guint flags;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &flags,
|
||||
-1);
|
||||
gtk_tree_model_get (model, iter, XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &flags, -1);
|
||||
|
||||
if (!(flags & XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR)) {
|
||||
if (flags & XED_FILE_BOOKMARKS_STORE_IS_FS) {
|
||||
if (!(flags & XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR))
|
||||
{
|
||||
if (flags & XED_FILE_BOOKMARKS_STORE_IS_FS)
|
||||
{
|
||||
check_mount_separator (XED_FILE_BOOKMARKS_STORE (model),
|
||||
flags & XED_FILE_BOOKMARKS_STORE_IS_FS,
|
||||
FALSE);
|
||||
|
@ -738,8 +801,8 @@ remove_bookmarks (XedFileBookmarksStore * model)
|
|||
GtkTreeIter iter;
|
||||
|
||||
while (find_with_flags (GTK_TREE_MODEL (model), &iter, NULL,
|
||||
XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK,
|
||||
0)) {
|
||||
XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK, 0))
|
||||
{
|
||||
remove_node (GTK_TREE_MODEL (model), &iter);
|
||||
}
|
||||
}
|
||||
|
@ -802,7 +865,9 @@ xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
|
|||
-1);
|
||||
|
||||
if (obj == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
isfs = (flags & XED_FILE_BOOKMARKS_STORE_IS_FS);
|
||||
|
||||
|
@ -876,4 +941,10 @@ on_bookmarks_file_changed (GFileMonitor * monitor,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
_xed_file_bookmarks_store_register_type (GTypeModule *type_module)
|
||||
{
|
||||
xed_file_bookmarks_store_register_type (type_module);
|
||||
}
|
||||
|
||||
// ex:ts=8:noet:
|
||||
|
|
|
@ -77,7 +77,7 @@ struct _XedFileBookmarksStoreClass
|
|||
};
|
||||
|
||||
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);
|
||||
gchar *xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
|
||||
|
|
|
@ -28,9 +28,11 @@
|
|||
#include <xed/xed-utils.h>
|
||||
#include <xed/xed-app.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-debug.h>
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
#include <libpeas/peas-activatable.h>
|
||||
|
||||
#include "xed-file-browser-enum-types.h"
|
||||
#include "xed-file-browser-plugin.h"
|
||||
|
@ -39,8 +41,6 @@
|
|||
#include "xed-file-browser-widget.h"
|
||||
#include "xed-file-browser-messages.h"
|
||||
|
||||
#define WINDOW_DATA_KEY "XedFileBrowserPluginWindowData"
|
||||
|
||||
#define FILE_BROWSER_SCHEMA "org.x.editor.plugins.filebrowser"
|
||||
#define FILE_BROWSER_ONLOAD_SCHEMA "org.x.editor.plugins.filebrowser.on-load"
|
||||
|
||||
|
@ -48,11 +48,8 @@
|
|||
|
||||
struct _XedFileBrowserPluginPrivate
|
||||
{
|
||||
gpointer *dummy;
|
||||
};
|
||||
GtkWidget *window;
|
||||
|
||||
typedef struct _XedFileBrowserPluginData
|
||||
{
|
||||
XedFileBrowserWidget * tree_widget;
|
||||
gulong merge_id;
|
||||
GtkActionGroup * action_group;
|
||||
|
@ -62,7 +59,13 @@ typedef struct _XedFileBrowserPluginData
|
|||
|
||||
GSettings *settings;
|
||||
GSettings *onload_settings;
|
||||
} XedFileBrowserPluginData;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_OBJECT
|
||||
};
|
||||
|
||||
static void on_uri_activated_cb (XedFileBrowserWidget * widget,
|
||||
gchar const *uri,
|
||||
|
@ -70,67 +73,113 @@ static void on_uri_activated_cb (XedFileBrowserWidget * widget,
|
|||
static void on_error_cb (XedFileBrowserWidget * widget,
|
||||
guint code,
|
||||
gchar const *message,
|
||||
XedWindow * window);
|
||||
XedFileBrowserPluginPrivate * data);
|
||||
static void on_model_set_cb (XedFileBrowserView * widget,
|
||||
GParamSpec *arg1,
|
||||
XedWindow * window);
|
||||
XedFileBrowserPluginPrivate * data);
|
||||
static void on_virtual_root_changed_cb (XedFileBrowserStore * model,
|
||||
GParamSpec * param,
|
||||
XedWindow * window);
|
||||
XedFileBrowserPluginPrivate * data);
|
||||
static void on_filter_mode_changed_cb (XedFileBrowserStore * model,
|
||||
GParamSpec * param,
|
||||
XedWindow * window);
|
||||
XedFileBrowserPluginPrivate * data);
|
||||
static void on_rename_cb (XedFileBrowserStore * model,
|
||||
const gchar * olduri,
|
||||
const gchar * newuri,
|
||||
XedWindow * window);
|
||||
static void on_filter_pattern_changed_cb (XedFileBrowserWidget * widget,
|
||||
GParamSpec * param,
|
||||
XedWindow * window);
|
||||
XedFileBrowserPluginPrivate * data);
|
||||
static void on_tab_added_cb (XedWindow * window,
|
||||
XedTab * tab,
|
||||
XedFileBrowserPluginData * data);
|
||||
XedFileBrowserPluginPrivate * data);
|
||||
static gboolean on_confirm_delete_cb (XedFileBrowserWidget * widget,
|
||||
XedFileBrowserStore * store,
|
||||
GList * rows,
|
||||
XedWindow * window);
|
||||
XedFileBrowserPluginPrivate * data);
|
||||
static gboolean on_confirm_no_trash_cb (XedFileBrowserWidget * widget,
|
||||
GList * files,
|
||||
XedWindow * window);
|
||||
|
||||
XED_PLUGIN_REGISTER_TYPE_WITH_CODE (XedFileBrowserPlugin, filetree_plugin, \
|
||||
static void peas_activatable_iface_init (PeasActivatableInterface *iface);
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedFileBrowserPlugin,
|
||||
xed_file_browser_plugin,
|
||||
PEAS_TYPE_EXTENSION_BASE,
|
||||
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); \
|
||||
_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
|
||||
filetree_plugin_init (XedFileBrowserPlugin * plugin)
|
||||
xed_file_browser_plugin_init (XedFileBrowserPlugin * plugin)
|
||||
{
|
||||
plugin->priv = XED_FILE_BROWSER_PLUGIN_GET_PRIVATE (plugin);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static XedFileBrowserPluginData *
|
||||
get_plugin_data (XedWindow * window)
|
||||
G_OBJECT_CLASS (xed_file_browser_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
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
|
||||
on_end_loading_cb (XedFileBrowserStore * store,
|
||||
GtkTreeIter * iter,
|
||||
XedFileBrowserPluginData * data)
|
||||
XedFileBrowserPluginPrivate * data)
|
||||
{
|
||||
/* Disconnect the signal */
|
||||
g_signal_handler_disconnect (store, data->end_loading_handle);
|
||||
|
@ -139,7 +188,7 @@ on_end_loading_cb (XedFileBrowserStore * store,
|
|||
}
|
||||
|
||||
static void
|
||||
prepare_auto_root (XedFileBrowserPluginData *data)
|
||||
prepare_auto_root (XedFileBrowserPluginPrivate *data)
|
||||
{
|
||||
XedFileBrowserStore *store;
|
||||
|
||||
|
@ -159,7 +208,7 @@ prepare_auto_root (XedFileBrowserPluginData *data)
|
|||
}
|
||||
|
||||
static void
|
||||
restore_default_location (XedFileBrowserPluginData *data)
|
||||
restore_default_location (XedFileBrowserPluginPrivate *data)
|
||||
{
|
||||
gchar * root;
|
||||
gchar * virtual_root;
|
||||
|
@ -205,7 +254,7 @@ restore_default_location (XedFileBrowserPluginData *data)
|
|||
}
|
||||
|
||||
static void
|
||||
restore_filter (XedFileBrowserPluginData * data)
|
||||
restore_filter (XedFileBrowserPluginPrivate *data)
|
||||
{
|
||||
gchar *filter_mode;
|
||||
XedFileBrowserStoreFilterMode mode;
|
||||
|
@ -247,7 +296,7 @@ restore_filter (XedFileBrowserPluginData * data)
|
|||
}
|
||||
|
||||
static void
|
||||
set_root_from_doc (XedFileBrowserPluginData * data,
|
||||
set_root_from_doc (XedFileBrowserPluginPrivate * data,
|
||||
XedDocument * doc)
|
||||
{
|
||||
GFile *file;
|
||||
|
@ -280,17 +329,13 @@ set_root_from_doc (XedFileBrowserPluginData * data,
|
|||
|
||||
static void
|
||||
on_action_set_active_root (GtkAction * action,
|
||||
XedWindow * window)
|
||||
XedFileBrowserPluginPrivate * data)
|
||||
{
|
||||
XedFileBrowserPluginData *data;
|
||||
|
||||
data = get_plugin_data (window);
|
||||
set_root_from_doc (data,
|
||||
xed_window_get_active_document (window));
|
||||
set_root_from_doc (data, xed_window_get_active_document (XED_WINDOW (data->window)));
|
||||
}
|
||||
|
||||
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)
|
||||
return g_strdup ("xterminal");
|
||||
|
@ -298,9 +343,8 @@ get_terminal (XedFileBrowserPluginData * data)
|
|||
|
||||
static void
|
||||
on_action_open_terminal (GtkAction * action,
|
||||
XedWindow * window)
|
||||
XedFileBrowserPluginPrivate * data)
|
||||
{
|
||||
XedFileBrowserPluginData * data;
|
||||
gchar * terminal;
|
||||
gchar * wd = NULL;
|
||||
gchar * local;
|
||||
|
@ -310,8 +354,6 @@ on_action_open_terminal (GtkAction * action,
|
|||
GtkTreeIter iter;
|
||||
XedFileBrowserStore * store;
|
||||
|
||||
data = get_plugin_data (window);
|
||||
|
||||
/* Get the current directory */
|
||||
if (!xed_file_browser_widget_get_selected_directory (data->tree_widget, &iter))
|
||||
return;
|
||||
|
@ -351,17 +393,14 @@ on_action_open_terminal (GtkAction * action,
|
|||
|
||||
static void
|
||||
on_selection_changed_cb (GtkTreeSelection *selection,
|
||||
XedWindow *window)
|
||||
XedFileBrowserPluginPrivate *data)
|
||||
{
|
||||
XedFileBrowserPluginData * data;
|
||||
GtkTreeView * tree_view;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
gboolean sensitive;
|
||||
gchar * uri;
|
||||
|
||||
data = get_plugin_data (window);
|
||||
|
||||
tree_view = GTK_TREE_VIEW (xed_file_browser_widget_get_browser_view (data->tree_widget));
|
||||
model = gtk_tree_view_get_model (tree_view);
|
||||
|
||||
|
@ -418,14 +457,12 @@ static GtkActionEntry extra_single_selection_actions[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
add_popup_ui (XedWindow * window)
|
||||
add_popup_ui (XedFileBrowserPluginPrivate *data)
|
||||
{
|
||||
XedFileBrowserPluginData * data;
|
||||
GtkUIManager * manager;
|
||||
GtkActionGroup * action_group;
|
||||
GError * error = NULL;
|
||||
|
||||
data = get_plugin_data (window);
|
||||
manager = xed_file_browser_widget_get_ui_manager (data->tree_widget);
|
||||
|
||||
action_group = gtk_action_group_new ("FileBrowserPluginExtra");
|
||||
|
@ -433,7 +470,7 @@ add_popup_ui (XedWindow * window)
|
|||
gtk_action_group_add_actions (action_group,
|
||||
extra_actions,
|
||||
G_N_ELEMENTS (extra_actions),
|
||||
window);
|
||||
data);
|
||||
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
||||
data->action_group = action_group;
|
||||
|
||||
|
@ -442,7 +479,7 @@ add_popup_ui (XedWindow * window)
|
|||
gtk_action_group_add_actions (action_group,
|
||||
extra_single_selection_actions,
|
||||
G_N_ELEMENTS (extra_single_selection_actions),
|
||||
window);
|
||||
data);
|
||||
gtk_ui_manager_insert_action_group (manager, action_group, 0);
|
||||
data->single_selection_action_group = action_group;
|
||||
|
||||
|
@ -458,12 +495,10 @@ add_popup_ui (XedWindow * window)
|
|||
}
|
||||
|
||||
static void
|
||||
remove_popup_ui (XedWindow * window)
|
||||
remove_popup_ui (XedFileBrowserPluginPrivate *data)
|
||||
{
|
||||
XedFileBrowserPluginData * data;
|
||||
GtkUIManager * manager;
|
||||
|
||||
data = get_plugin_data (window);
|
||||
manager = xed_file_browser_widget_get_ui_manager (data->tree_widget);
|
||||
gtk_ui_manager_remove_ui (manager, data->merge_id);
|
||||
|
||||
|
@ -475,14 +510,14 @@ remove_popup_ui (XedWindow * window)
|
|||
}
|
||||
|
||||
static void
|
||||
impl_updateui (XedPlugin * plugin, XedWindow * window)
|
||||
xed_file_browser_plugin_update_state (PeasActivatable *activatable)
|
||||
{
|
||||
XedFileBrowserPluginData * data;
|
||||
XedFileBrowserPluginPrivate *data;
|
||||
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,
|
||||
"SetActiveRoot"),
|
||||
|
@ -491,10 +526,11 @@ impl_updateui (XedPlugin * plugin, XedWindow * window)
|
|||
}
|
||||
|
||||
static void
|
||||
impl_activate (XedPlugin * plugin, XedWindow * window)
|
||||
xed_file_browser_plugin_activate (PeasActivatable *activatable)
|
||||
{
|
||||
XedFileBrowserPluginPrivate *data;
|
||||
XedWindow *window;
|
||||
XedPanel * panel;
|
||||
XedFileBrowserPluginData * data;
|
||||
GtkWidget * image;
|
||||
GdkPixbuf * pixbuf;
|
||||
XedFileBrowserStore * store;
|
||||
|
@ -502,9 +538,10 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
|
|||
GSettingsSchemaSource *schema_source;
|
||||
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));
|
||||
g_free (data_dir);
|
||||
|
||||
|
@ -516,17 +553,17 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
|
|||
G_CALLBACK (on_uri_activated_cb), window);
|
||||
|
||||
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,
|
||||
"notify::filter-pattern",
|
||||
G_CALLBACK (on_filter_pattern_changed_cb),
|
||||
window);
|
||||
data);
|
||||
|
||||
g_signal_connect (data->tree_widget,
|
||||
"confirm-delete",
|
||||
G_CALLBACK (on_confirm_delete_cb),
|
||||
window);
|
||||
data);
|
||||
|
||||
g_signal_connect (data->tree_widget,
|
||||
"confirm-no-trash",
|
||||
|
@ -538,7 +575,7 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
|
|||
(data->tree_widget))),
|
||||
"changed",
|
||||
G_CALLBACK (on_selection_changed_cb),
|
||||
window);
|
||||
data);
|
||||
|
||||
panel = xed_window_get_side_panel (window);
|
||||
pixbuf = xed_file_browser_utils_pixbuf_from_theme("system-file-manager",
|
||||
|
@ -557,9 +594,8 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
|
|||
_("File Browser"),
|
||||
image);
|
||||
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 (data);
|
||||
|
@ -568,18 +604,18 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
|
|||
g_signal_connect (xed_file_browser_widget_get_browser_view (data->tree_widget),
|
||||
"notify::model",
|
||||
G_CALLBACK (on_model_set_cb),
|
||||
window);
|
||||
data);
|
||||
|
||||
store = xed_file_browser_widget_get_browser_store (data->tree_widget);
|
||||
g_signal_connect (store,
|
||||
"notify::virtual-root",
|
||||
G_CALLBACK (on_virtual_root_changed_cb),
|
||||
window);
|
||||
data);
|
||||
|
||||
g_signal_connect (store,
|
||||
"notify::filter-mode",
|
||||
G_CALLBACK (on_filter_mode_changed_cb),
|
||||
window);
|
||||
data);
|
||||
|
||||
g_signal_connect (store,
|
||||
"rename",
|
||||
|
@ -594,16 +630,18 @@ impl_activate (XedPlugin * plugin, XedWindow * window)
|
|||
/* Register messages on the bus */
|
||||
xed_file_browser_messages_register (window, data->tree_widget);
|
||||
|
||||
impl_updateui (plugin, window);
|
||||
xed_file_browser_plugin_update_state (activatable);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_deactivate (XedPlugin * plugin, XedWindow * window)
|
||||
xed_file_browser_plugin_deactivate (PeasActivatable *activatable)
|
||||
{
|
||||
XedFileBrowserPluginData * data;
|
||||
XedFileBrowserPluginPrivate *data;
|
||||
XedWindow *window;
|
||||
XedPanel * panel;
|
||||
|
||||
data = get_plugin_data (window);
|
||||
data = XED_FILE_BROWSER_PLUGIN (activatable)->priv;
|
||||
window = XED_WINDOW (data->window);
|
||||
|
||||
/* Unregister messages from the bus */
|
||||
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->onload_settings);
|
||||
|
||||
remove_popup_ui (window);
|
||||
remove_popup_ui (data);
|
||||
|
||||
panel = xed_window_get_side_panel (window);
|
||||
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
|
||||
filetree_plugin_class_init (XedFileBrowserPluginClass * klass)
|
||||
xed_file_browser_plugin_class_init (XedFileBrowserPluginClass * 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;
|
||||
plugin_class->deactivate = impl_deactivate;
|
||||
plugin_class->update_ui = impl_updateui;
|
||||
g_object_class_override_property (object_class, PROP_OBJECT, "object");
|
||||
|
||||
g_type_class_add_private (object_class,
|
||||
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 */
|
||||
static void
|
||||
on_uri_activated_cb (XedFileBrowserWidget * tree_widget,
|
||||
|
@ -651,13 +709,10 @@ on_uri_activated_cb (XedFileBrowserWidget * tree_widget,
|
|||
|
||||
static void
|
||||
on_error_cb (XedFileBrowserWidget * tree_widget,
|
||||
guint code, gchar const *message, XedWindow * window)
|
||||
guint code, gchar const *message, XedFileBrowserPluginPrivate * data)
|
||||
{
|
||||
gchar * title;
|
||||
GtkWidget * dlg;
|
||||
XedFileBrowserPluginData * data;
|
||||
|
||||
data = get_plugin_data (window);
|
||||
|
||||
/* Do not show the error when the root has been set automatically */
|
||||
if (data->auto_root && (code == XED_FILE_BROWSER_ERROR_SET_ROOT ||
|
||||
|
@ -704,7 +759,7 @@ on_error_cb (XedFileBrowserWidget * tree_widget,
|
|||
break;
|
||||
}
|
||||
|
||||
dlg = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
dlg = gtk_message_dialog_new (GTK_WINDOW (data->window),
|
||||
GTK_DIALOG_MODAL |
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
|
||||
|
@ -719,9 +774,8 @@ on_error_cb (XedFileBrowserWidget * tree_widget,
|
|||
static void
|
||||
on_model_set_cb (XedFileBrowserView * widget,
|
||||
GParamSpec *arg1,
|
||||
XedWindow * window)
|
||||
XedFileBrowserPluginPrivate * data)
|
||||
{
|
||||
XedFileBrowserPluginData * data = get_plugin_data (window);
|
||||
GtkTreeModel * model;
|
||||
|
||||
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
|
||||
on_filter_mode_changed_cb (XedFileBrowserStore * model,
|
||||
GParamSpec * param,
|
||||
XedWindow * window)
|
||||
XedFileBrowserPluginPrivate * data)
|
||||
{
|
||||
XedFileBrowserPluginData * data = get_plugin_data (window);
|
||||
XedFileBrowserStoreFilterMode mode;
|
||||
|
||||
mode = xed_file_browser_store_get_filter_mode (model);
|
||||
|
@ -823,9 +876,8 @@ on_rename_cb (XedFileBrowserStore * store,
|
|||
static void
|
||||
on_filter_pattern_changed_cb (XedFileBrowserWidget * widget,
|
||||
GParamSpec * param,
|
||||
XedWindow * window)
|
||||
XedFileBrowserPluginPrivate * data)
|
||||
{
|
||||
XedFileBrowserPluginData * data = get_plugin_data (window);
|
||||
gchar * pattern;
|
||||
|
||||
g_object_get (G_OBJECT (widget), "filter-pattern", &pattern, NULL);
|
||||
|
@ -841,9 +893,8 @@ on_filter_pattern_changed_cb (XedFileBrowserWidget * widget,
|
|||
static void
|
||||
on_virtual_root_changed_cb (XedFileBrowserStore * store,
|
||||
GParamSpec * param,
|
||||
XedWindow * window)
|
||||
XedFileBrowserPluginPrivate * data)
|
||||
{
|
||||
XedFileBrowserPluginData * data = get_plugin_data (window);
|
||||
gchar * 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_signal_handlers_disconnect_by_func (window,
|
||||
g_signal_handlers_disconnect_by_func (XED_WINDOW (data->window),
|
||||
G_CALLBACK (on_tab_added_cb),
|
||||
data);
|
||||
|
||||
|
@ -874,7 +925,7 @@ on_virtual_root_changed_cb (XedFileBrowserStore * store,
|
|||
static void
|
||||
on_tab_added_cb (XedWindow * window,
|
||||
XedTab * tab,
|
||||
XedFileBrowserPluginData * data)
|
||||
XedFileBrowserPluginPrivate *data)
|
||||
{
|
||||
gboolean open;
|
||||
gboolean load_default = TRUE;
|
||||
|
@ -956,15 +1007,12 @@ static gboolean
|
|||
on_confirm_delete_cb (XedFileBrowserWidget *widget,
|
||||
XedFileBrowserStore *store,
|
||||
GList *paths,
|
||||
XedWindow *window)
|
||||
XedFileBrowserPluginPrivate *data)
|
||||
{
|
||||
gchar *normal;
|
||||
gchar *message;
|
||||
gchar *secondary;
|
||||
gboolean result;
|
||||
XedFileBrowserPluginData *data;
|
||||
|
||||
data = get_plugin_data (window);
|
||||
|
||||
if (paths->next == NULL) {
|
||||
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.");
|
||||
|
||||
result = xed_file_browser_utils_confirmation_dialog (window,
|
||||
result = xed_file_browser_utils_confirmation_dialog (XED_WINDOW (data->window),
|
||||
GTK_MESSAGE_QUESTION,
|
||||
message,
|
||||
secondary,
|
||||
|
|
|
@ -24,13 +24,15 @@
|
|||
|
||||
#include <glib.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
|
||||
|
||||
/*
|
||||
* 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_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))
|
||||
|
@ -44,7 +46,7 @@ typedef struct _XedFileBrowserPluginClass XedFileBrowserPluginClass;
|
|||
|
||||
struct _XedFileBrowserPlugin
|
||||
{
|
||||
XedPlugin parent_instance;
|
||||
PeasExtensionBase parent_instance;
|
||||
|
||||
/*< private > */
|
||||
XedFileBrowserPluginPrivate *priv;
|
||||
|
@ -54,16 +56,16 @@ struct _XedFileBrowserPlugin
|
|||
|
||||
struct _XedFileBrowserPluginClass
|
||||
{
|
||||
XedPluginClass parent_class;
|
||||
PeasExtensionBaseClass parent_class;
|
||||
};
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
G_MODULE_EXPORT GType register_xed_plugin (GTypeModule * module);
|
||||
G_MODULE_EXPORT void peas_register_types (PeasObjectModule * module);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __XED_FILE_BROWSER_PLUGIN_H__ */
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <string.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gio/gio.h>
|
||||
#include <xed/xed-plugin.h>
|
||||
#include <xed/xed-utils.h>
|
||||
|
||||
#include "xed-file-browser-store.h"
|
||||
|
@ -197,13 +196,12 @@ static void model_check_dummy (XedFileBrowserStore
|
|||
static void next_files_async (GFileEnumerator * enumerator,
|
||||
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,
|
||||
XED_PLUGIN_IMPLEMENT_INTERFACE (xed_file_browser_store_tree_model,
|
||||
GTK_TYPE_TREE_MODEL,
|
||||
0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (GTK_TYPE_TREE_MODEL,
|
||||
xed_file_browser_store_iface_init)
|
||||
XED_PLUGIN_IMPLEMENT_INTERFACE (xed_file_browser_store_drag_source,
|
||||
GTK_TYPE_TREE_DRAG_SOURCE,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (GTK_TYPE_TREE_DRAG_SOURCE,
|
||||
xed_file_browser_store_drag_source_init))
|
||||
|
||||
/* Properties */
|
||||
|
@ -427,6 +425,12 @@ xed_file_browser_store_class_init (XedFileBrowserStoreClass * klass)
|
|||
sizeof (XedFileBrowserStorePrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_file_browser_store_class_finalize (XedFileBrowserStoreClass *klass)
|
||||
{
|
||||
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE_EXTENDED */
|
||||
}
|
||||
|
||||
static void
|
||||
xed_file_browser_store_iface_init (GtkTreeModelIface * iface)
|
||||
{
|
||||
|
@ -3622,4 +3626,10 @@ xed_file_browser_store_new_directory (XedFileBrowserStore * model,
|
|||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
_xed_file_browser_store_register_type (GTypeModule *type_module)
|
||||
{
|
||||
xed_file_browser_store_register_type (type_module);
|
||||
}
|
||||
|
||||
// ex:ts=8:noet:
|
||||
|
|
|
@ -116,7 +116,7 @@ struct _XedFileBrowserStoreClass {
|
|||
};
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <gio/gio.h>
|
||||
#include <xed/xed-plugin.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
|
@ -86,7 +85,7 @@ static const GtkTargetEntry drag_source_targets[] = {
|
|||
{ "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)
|
||||
|
||||
static void on_cell_edited (GtkCellRendererText * cell,
|
||||
|
@ -910,6 +909,12 @@ xed_file_browser_view_class_init (XedFileBrowserViewClass * klass)
|
|||
sizeof (XedFileBrowserViewPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_file_browser_view_class_finalize (XedFileBrowserViewClass *klass)
|
||||
{
|
||||
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE */
|
||||
}
|
||||
|
||||
static void
|
||||
cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
|
||||
GtkTreeModel * tree_model, GtkTreeIter * iter,
|
||||
|
@ -1254,4 +1259,10 @@ on_row_inserted (XedFileBrowserStore * model,
|
|||
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:
|
||||
|
|
|
@ -66,7 +66,7 @@ struct _XedFileBrowserViewClass
|
|||
};
|
||||
|
||||
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);
|
||||
void xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include <xed/xed-utils.h>
|
||||
#include <xed/xed-plugin.h>
|
||||
|
||||
#include "xed-file-browser-utils.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,
|
||||
XedFileBrowserWidget * obj);
|
||||
|
||||
XED_PLUGIN_DEFINE_TYPE (XedFileBrowserWidget, xed_file_browser_widget,
|
||||
G_DEFINE_DYNAMIC_TYPE (XedFileBrowserWidget, xed_file_browser_widget,
|
||||
GTK_TYPE_BOX)
|
||||
|
||||
static void
|
||||
|
@ -479,6 +478,12 @@ xed_file_browser_widget_class_init (XedFileBrowserWidgetClass * klass)
|
|||
sizeof (XedFileBrowserWidgetPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_file_browser_widget_class_finalize (XedFileBrowserWidgetClass *klass)
|
||||
{
|
||||
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE */
|
||||
}
|
||||
|
||||
static void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
_xed_file_browser_widget_register_type (GTypeModule *type_module)
|
||||
{
|
||||
xed_file_browser_widget_register_type (type_module);
|
||||
}
|
||||
|
||||
// ex:ts=8:noet:
|
||||
|
|
|
@ -71,7 +71,7 @@ struct _XedFileBrowserWidgetClass
|
|||
};
|
||||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue