parent
fdc2da63a9
commit
4cad8ffa7f
|
@ -23,7 +23,6 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <xed/xed-utils.h>
|
#include <xed/xed-utils.h>
|
||||||
#include <xed/xed-plugin.h>
|
|
||||||
|
|
||||||
#include "xed-file-bookmarks-store.h"
|
#include "xed-file-bookmarks-store.h"
|
||||||
#include "xed-file-browser-utils.h"
|
#include "xed-file-browser-utils.h"
|
||||||
|
@ -56,23 +55,23 @@ static gboolean find_with_flags (GtkTreeModel * model,
|
||||||
guint flags,
|
guint flags,
|
||||||
guint notflags);
|
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
|
static void
|
||||||
xed_file_bookmarks_store_dispose (GObject * object)
|
xed_file_bookmarks_store_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
XedFileBookmarksStore *obj = XED_FILE_BOOKMARKS_STORE (object);
|
XedFileBookmarksStore *obj = XED_FILE_BOOKMARKS_STORE (object);
|
||||||
|
|
||||||
if (obj->priv->volume_monitor != NULL) {
|
if (obj->priv->volume_monitor != NULL)
|
||||||
g_signal_handlers_disconnect_by_func (obj->priv->volume_monitor,
|
{
|
||||||
on_fs_changed,
|
g_signal_handlers_disconnect_by_func (obj->priv->volume_monitor, on_fs_changed, obj);
|
||||||
obj);
|
|
||||||
|
|
||||||
g_object_unref (obj->priv->volume_monitor);
|
g_object_unref (obj->priv->volume_monitor);
|
||||||
obj->priv->volume_monitor = NULL;
|
obj->priv->volume_monitor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj->priv->bookmarks_monitor != NULL) {
|
if (obj->priv->bookmarks_monitor != NULL)
|
||||||
|
{
|
||||||
g_object_unref (obj->priv->bookmarks_monitor);
|
g_object_unref (obj->priv->bookmarks_monitor);
|
||||||
obj->priv->bookmarks_monitor = NULL;
|
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));
|
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
|
static void
|
||||||
xed_file_bookmarks_store_init (XedFileBookmarksStore * obj)
|
xed_file_bookmarks_store_init (XedFileBookmarksStore * obj)
|
||||||
{
|
{
|
||||||
|
@ -124,7 +129,9 @@ add_node (XedFileBookmarksStore *model,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
if (iter != NULL)
|
if (iter != NULL)
|
||||||
|
{
|
||||||
*iter = newiter;
|
*iter = newiter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -140,36 +147,52 @@ add_file (XedFileBookmarksStore *model,
|
||||||
|
|
||||||
native = g_file_is_native (file);
|
native = g_file_is_native (file);
|
||||||
|
|
||||||
if (native && !g_file_query_exists (file, NULL)) {
|
if (native && !g_file_query_exists (file, NULL))
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & XED_FILE_BOOKMARKS_STORE_IS_HOME)
|
if (flags & XED_FILE_BOOKMARKS_STORE_IS_HOME)
|
||||||
|
{
|
||||||
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("user-home", GTK_ICON_SIZE_MENU);
|
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("user-home", GTK_ICON_SIZE_MENU);
|
||||||
|
}
|
||||||
else if (flags & XED_FILE_BOOKMARKS_STORE_IS_DESKTOP)
|
else if (flags & XED_FILE_BOOKMARKS_STORE_IS_DESKTOP)
|
||||||
|
{
|
||||||
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("user-desktop", GTK_ICON_SIZE_MENU);
|
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("user-desktop", GTK_ICON_SIZE_MENU);
|
||||||
|
}
|
||||||
else if (flags & XED_FILE_BOOKMARKS_STORE_IS_ROOT)
|
else if (flags & XED_FILE_BOOKMARKS_STORE_IS_ROOT)
|
||||||
|
{
|
||||||
pixbuf = xed_file_browser_utils_pixbuf_from_theme ("drive-harddisk", GTK_ICON_SIZE_MENU);
|
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 */
|
/* 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);
|
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);
|
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);
|
newname = xed_file_browser_utils_file_basename (file);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
newname = g_strdup (name);
|
newname = g_strdup (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_node (model, pixbuf, newname, G_OBJECT (file), flags, iter);
|
add_node (model, pixbuf, newname, G_OBJECT (file), flags, iter);
|
||||||
|
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
|
{
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (newname);
|
g_free (newname);
|
||||||
|
|
||||||
|
@ -183,17 +206,16 @@ check_mount_separator (XedFileBookmarksStore * model, guint flags,
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gboolean found;
|
gboolean found;
|
||||||
|
|
||||||
found =
|
found = find_with_flags (GTK_TREE_MODEL (model), &iter, NULL,
|
||||||
find_with_flags (GTK_TREE_MODEL (model), &iter, NULL,
|
flags | XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR, 0);
|
||||||
flags |
|
|
||||||
XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR, 0);
|
|
||||||
|
|
||||||
if (added && !found) {
|
if (added && !found)
|
||||||
|
{
|
||||||
/* Add the separator */
|
/* Add the separator */
|
||||||
add_node (model, NULL, NULL, NULL,
|
add_node (model, NULL, NULL, NULL, flags | XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR, NULL);
|
||||||
flags | XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR,
|
}
|
||||||
NULL);
|
else if (!added && found)
|
||||||
} else if (!added && found) {
|
{
|
||||||
remove_node (GTK_TREE_MODEL (model), &iter);
|
remove_node (GTK_TREE_MODEL (model), &iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,8 +230,7 @@ init_special_directories (XedFileBookmarksStore * model)
|
||||||
if (path != NULL)
|
if (path != NULL)
|
||||||
{
|
{
|
||||||
file = g_file_new_for_path (path);
|
file = g_file_new_for_path (path);
|
||||||
add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_HOME |
|
add_file (model, file, NULL, XED_FILE_BOOKMARKS_STORE_IS_HOME | XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL);
|
||||||
XED_FILE_BOOKMARKS_STORE_IS_SPECIAL_DIR, NULL);
|
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +315,9 @@ add_fs (XedFileBookmarksStore *model,
|
||||||
add_node (model, pixbuf, name, fs, flags | fsflags, iter);
|
add_node (model, pixbuf, name, fs, flags | fsflags, iter);
|
||||||
|
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
|
{
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (name);
|
g_free (name);
|
||||||
check_mount_separator (model, XED_FILE_BOOKMARKS_STORE_IS_FS, TRUE);
|
check_mount_separator (model, XED_FILE_BOOKMARKS_STORE_IS_FS, TRUE);
|
||||||
|
@ -434,7 +457,8 @@ init_mounts (XedFileBookmarksStore *model)
|
||||||
static void
|
static void
|
||||||
init_fs (XedFileBookmarksStore * model)
|
init_fs (XedFileBookmarksStore * model)
|
||||||
{
|
{
|
||||||
if (model->priv->volume_monitor == NULL) {
|
if (model->priv->volume_monitor == NULL)
|
||||||
|
{
|
||||||
const gchar **ptr;
|
const gchar **ptr;
|
||||||
const gchar *signals[] = {
|
const gchar *signals[] = {
|
||||||
"drive-connected", "drive-changed", "drive-disconnected",
|
"drive-connected", "drive-changed", "drive-disconnected",
|
||||||
|
@ -448,9 +472,7 @@ init_fs (XedFileBookmarksStore * model)
|
||||||
/* Connect signals */
|
/* Connect signals */
|
||||||
for (ptr = signals; *ptr; ptr++)
|
for (ptr = signals; *ptr; ptr++)
|
||||||
{
|
{
|
||||||
g_signal_connect (model->priv->volume_monitor,
|
g_signal_connect (model->priv->volume_monitor, *ptr, G_CALLBACK (on_fs_changed), model);
|
||||||
*ptr,
|
|
||||||
G_CALLBACK (on_fs_changed), model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,9 +498,12 @@ add_bookmark (XedFileBookmarksStore * model,
|
||||||
|
|
||||||
file = g_file_new_for_uri (uri);
|
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;
|
flags |= XED_FILE_BOOKMARKS_STORE_IS_LOCAL_BOOKMARK;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
flags |= XED_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK;
|
flags |= XED_FILE_BOOKMARKS_STORE_IS_REMOTE_BOOKMARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,31 +525,36 @@ init_bookmarks (XedFileBookmarksStore * model)
|
||||||
gboolean added = FALSE;
|
gboolean added = FALSE;
|
||||||
|
|
||||||
/* Read the bookmarks file */
|
/* Read the bookmarks file */
|
||||||
bookmarks = g_build_filename (g_get_home_dir (),
|
bookmarks = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL);
|
||||||
".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);
|
lines = g_strsplit (contents, "\n", 0);
|
||||||
|
|
||||||
for (line = lines; *line; ++line) {
|
for (line = lines; *line; ++line)
|
||||||
if (**line) {
|
{
|
||||||
|
if (**line)
|
||||||
|
{
|
||||||
gchar *pos;
|
gchar *pos;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
|
||||||
/* CHECK: is this really utf8? */
|
/* CHECK: is this really utf8? */
|
||||||
pos = g_utf8_strchr (*line, -1, ' ');
|
pos = g_utf8_strchr (*line, -1, ' ');
|
||||||
|
|
||||||
if (pos != NULL) {
|
if (pos != NULL)
|
||||||
|
{
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
name = pos + 1;
|
name = pos + 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
name = NULL;
|
name = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the bookmarks file should contain valid
|
/* the bookmarks file should contain valid
|
||||||
* URIs, but paranoia is good */
|
* 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);
|
added |= add_bookmark (model, name, *line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,24 +564,26 @@ init_bookmarks (XedFileBookmarksStore * model)
|
||||||
g_free (contents);
|
g_free (contents);
|
||||||
|
|
||||||
/* Add a watch */
|
/* Add a watch */
|
||||||
if (model->priv->bookmarks_monitor == NULL) {
|
if (model->priv->bookmarks_monitor == NULL)
|
||||||
|
{
|
||||||
GFile * file;
|
GFile * file;
|
||||||
|
|
||||||
file = g_file_new_for_path (bookmarks);
|
file = g_file_new_for_path (bookmarks);
|
||||||
model->priv->bookmarks_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL);
|
model->priv->bookmarks_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
g_signal_connect (model->priv->bookmarks_monitor,
|
g_signal_connect (model->priv->bookmarks_monitor, "changed",
|
||||||
"changed",
|
(GCallback)on_bookmarks_file_changed, model);
|
||||||
(GCallback)on_bookmarks_file_changed,
|
|
||||||
model);
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* The bookmarks file doesn't exist (which is perfectly fine) */
|
/* The bookmarks file doesn't exist (which is perfectly fine) */
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (added) {
|
if (added)
|
||||||
|
{
|
||||||
/* Bookmarks separator */
|
/* Bookmarks separator */
|
||||||
add_node (model, NULL, NULL, NULL,
|
add_node (model, NULL, NULL, NULL,
|
||||||
XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK |
|
XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK |
|
||||||
|
@ -590,7 +622,8 @@ utf8_casecmp (gchar const *s1, const gchar * s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
bookmarks_compare_names (GtkTreeModel * model, GtkTreeIter * a,
|
bookmarks_compare_names (GtkTreeModel * model,
|
||||||
|
GtkTreeIter * a,
|
||||||
GtkTreeIter * b)
|
GtkTreeIter * b)
|
||||||
{
|
{
|
||||||
gchar *n1;
|
gchar *n1;
|
||||||
|
@ -609,17 +642,26 @@ bookmarks_compare_names (GtkTreeModel * model, GtkTreeIter * a,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
/* do not sort actual bookmarks to keep same order as in caja */
|
/* do not sort actual bookmarks to keep same order as in caja */
|
||||||
if ((f1 & XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK) &&
|
if ((f1 & XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK) && (f2 & XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK))
|
||||||
(f2 & XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK))
|
{
|
||||||
result = 0;
|
result = 0;
|
||||||
|
}
|
||||||
else if (n1 == NULL && n2 == NULL)
|
else if (n1 == NULL && n2 == NULL)
|
||||||
|
{
|
||||||
result = 0;
|
result = 0;
|
||||||
|
}
|
||||||
else if (n1 == NULL)
|
else if (n1 == NULL)
|
||||||
|
{
|
||||||
result = -1;
|
result = -1;
|
||||||
|
}
|
||||||
else if (n2 == NULL)
|
else if (n2 == NULL)
|
||||||
|
{
|
||||||
result = 1;
|
result = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
result = utf8_casecmp (n1, n2);
|
result = utf8_casecmp (n1, n2);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (n1);
|
g_free (n1);
|
||||||
g_free (n2);
|
g_free (n2);
|
||||||
|
@ -628,7 +670,8 @@ bookmarks_compare_names (GtkTreeModel * model, GtkTreeIter * a,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
bookmarks_compare_flags (GtkTreeModel * model, GtkTreeIter * a,
|
bookmarks_compare_flags (GtkTreeModel * model,
|
||||||
|
GtkTreeIter * a,
|
||||||
GtkTreeIter * b)
|
GtkTreeIter * b)
|
||||||
{
|
{
|
||||||
guint f1;
|
guint f1;
|
||||||
|
@ -638,48 +681,62 @@ bookmarks_compare_flags (GtkTreeModel * model, GtkTreeIter * a,
|
||||||
|
|
||||||
sep = XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR;
|
sep = XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR;
|
||||||
|
|
||||||
gtk_tree_model_get (model, a,
|
gtk_tree_model_get (model, a, XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f1, -1);
|
||||||
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f1,
|
gtk_tree_model_get (model, b, XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f2, -1);
|
||||||
-1);
|
|
||||||
gtk_tree_model_get (model, b,
|
|
||||||
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &f2,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
for (flags = flags_order; *flags != -1; ++flags) {
|
for (flags = flags_order; *flags != -1; ++flags)
|
||||||
if ((f1 & *flags) != (f2 & *flags)) {
|
{
|
||||||
if (f1 & *flags) {
|
if ((f1 & *flags) != (f2 & *flags))
|
||||||
|
{
|
||||||
|
if (f1 & *flags)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if ((f1 & *flags) && (f1 & sep) != (f2 & sep)) {
|
}
|
||||||
|
else if ((f1 & *flags) && (f1 & sep) != (f2 & sep))
|
||||||
|
{
|
||||||
if (f1 & sep)
|
if (f1 & sep)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
bookmarks_compare_func (GtkTreeModel * model, GtkTreeIter * a,
|
bookmarks_compare_func (GtkTreeModel *model,
|
||||||
GtkTreeIter * b, gpointer user_data)
|
GtkTreeIter *a,
|
||||||
|
GtkTreeIter *b,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
gint result;
|
gint result;
|
||||||
|
|
||||||
result = bookmarks_compare_flags (model, a, b);
|
result = bookmarks_compare_flags (model, a, b);
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
|
{
|
||||||
result = bookmarks_compare_names (model, a, b);
|
result = bookmarks_compare_names (model, a, b);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
|
find_with_flags (GtkTreeModel *model,
|
||||||
guint flags, guint notflags)
|
GtkTreeIter *iter,
|
||||||
|
gpointer obj,
|
||||||
|
guint flags,
|
||||||
|
guint notflags)
|
||||||
{
|
{
|
||||||
GtkTreeIter child;
|
GtkTreeIter child;
|
||||||
guint childflags = 0;
|
guint childflags = 0;
|
||||||
|
@ -687,7 +744,9 @@ find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
|
||||||
gboolean fequal;
|
gboolean fequal;
|
||||||
|
|
||||||
if (!gtk_tree_model_get_iter_first (model, &child))
|
if (!gtk_tree_model_get_iter_first (model, &child))
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
gtk_tree_model_get (model, &child,
|
gtk_tree_model_get (model, &child,
|
||||||
|
@ -699,11 +758,14 @@ find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
|
||||||
fequal = (obj == childobj);
|
fequal = (obj == childobj);
|
||||||
|
|
||||||
if (childobj)
|
if (childobj)
|
||||||
|
{
|
||||||
g_object_unref (childobj);
|
g_object_unref (childobj);
|
||||||
|
}
|
||||||
|
|
||||||
if ((obj == NULL || fequal) &&
|
if ((obj == NULL || fequal) &&
|
||||||
(childflags & flags) == flags
|
(childflags & flags) == flags
|
||||||
&& !(childflags & notflags)) {
|
&& !(childflags & notflags))
|
||||||
|
{
|
||||||
*iter = child;
|
*iter = child;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -713,16 +775,17 @@ find_with_flags (GtkTreeModel * model, GtkTreeIter * iter, gpointer obj,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_node (GtkTreeModel * model, GtkTreeIter * iter)
|
remove_node (GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter)
|
||||||
{
|
{
|
||||||
guint flags;
|
guint flags;
|
||||||
|
|
||||||
gtk_tree_model_get (model, iter,
|
gtk_tree_model_get (model, iter, XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &flags, -1);
|
||||||
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &flags,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
if (!(flags & XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR)) {
|
if (!(flags & XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR))
|
||||||
if (flags & XED_FILE_BOOKMARKS_STORE_IS_FS) {
|
{
|
||||||
|
if (flags & XED_FILE_BOOKMARKS_STORE_IS_FS)
|
||||||
|
{
|
||||||
check_mount_separator (XED_FILE_BOOKMARKS_STORE (model),
|
check_mount_separator (XED_FILE_BOOKMARKS_STORE (model),
|
||||||
flags & XED_FILE_BOOKMARKS_STORE_IS_FS,
|
flags & XED_FILE_BOOKMARKS_STORE_IS_FS,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
@ -733,19 +796,19 @@ remove_node (GtkTreeModel * model, GtkTreeIter * iter)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_bookmarks (XedFileBookmarksStore * model)
|
remove_bookmarks (XedFileBookmarksStore *model)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
||||||
while (find_with_flags (GTK_TREE_MODEL (model), &iter, NULL,
|
while (find_with_flags (GTK_TREE_MODEL (model), &iter, NULL,
|
||||||
XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK,
|
XED_FILE_BOOKMARKS_STORE_IS_BOOKMARK, 0))
|
||||||
0)) {
|
{
|
||||||
remove_node (GTK_TREE_MODEL (model), &iter);
|
remove_node (GTK_TREE_MODEL (model), &iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initialize_fill (XedFileBookmarksStore * model)
|
initialize_fill (XedFileBookmarksStore *model)
|
||||||
{
|
{
|
||||||
init_special_directories (model);
|
init_special_directories (model);
|
||||||
init_fs (model);
|
init_fs (model);
|
||||||
|
@ -782,8 +845,8 @@ xed_file_bookmarks_store_new (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
|
xed_file_bookmarks_store_get_uri (XedFileBookmarksStore *model,
|
||||||
GtkTreeIter * iter)
|
GtkTreeIter *iter)
|
||||||
{
|
{
|
||||||
GObject * obj;
|
GObject * obj;
|
||||||
GFile * file = NULL;
|
GFile * file = NULL;
|
||||||
|
@ -802,7 +865,9 @@ xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
if (obj == NULL)
|
if (obj == NULL)
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
isfs = (flags & XED_FILE_BOOKMARKS_STORE_IS_FS);
|
isfs = (flags & XED_FILE_BOOKMARKS_STORE_IS_FS);
|
||||||
|
|
||||||
|
@ -827,7 +892,7 @@ xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xed_file_bookmarks_store_refresh (XedFileBookmarksStore * model)
|
xed_file_bookmarks_store_refresh (XedFileBookmarksStore *model)
|
||||||
{
|
{
|
||||||
gtk_tree_store_clear (GTK_TREE_STORE (model));
|
gtk_tree_store_clear (GTK_TREE_STORE (model));
|
||||||
initialize_fill (model);
|
initialize_fill (model);
|
||||||
|
@ -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:
|
// 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_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,
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
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_enum_and_flag_register_type (type_module); \
|
||||||
xed_file_browser_store_register_type (type_module); \
|
_xed_file_browser_store_register_type (type_module); \
|
||||||
xed_file_bookmarks_store_register_type (type_module); \
|
_xed_file_bookmarks_store_register_type (type_module); \
|
||||||
xed_file_browser_view_register_type (type_module); \
|
_xed_file_browser_view_register_type (type_module); \
|
||||||
xed_file_browser_widget_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,
|
||||||
|
|
|
@ -24,13 +24,15 @@
|
||||||
|
|
||||||
#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))
|
||||||
|
@ -44,7 +46,7 @@ typedef struct _XedFileBrowserPluginClass XedFileBrowserPluginClass;
|
||||||
|
|
||||||
struct _XedFileBrowserPlugin
|
struct _XedFileBrowserPlugin
|
||||||
{
|
{
|
||||||
XedPlugin parent_instance;
|
PeasExtensionBase parent_instance;
|
||||||
|
|
||||||
/*< private > */
|
/*< private > */
|
||||||
XedFileBrowserPluginPrivate *priv;
|
XedFileBrowserPluginPrivate *priv;
|
||||||
|
@ -54,16 +56,16 @@ struct _XedFileBrowserPlugin
|
||||||
|
|
||||||
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__ */
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -116,7 +116,7 @@ struct _XedFileBrowserStoreClass {
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -71,7 +71,7 @@ struct _XedFileBrowserWidgetClass
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue