Commit d2958c99 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

folder tree: added root and root-uri properties

If no root is specified use the VFS root (gthumb-vfs:///).
parent c1725254
......@@ -34,6 +34,7 @@
#include "gth-request-dialog.h"
#define DEFAULT_URI "gthumb-vfs:///"
#define EMPTY_URI "..."
#define LOADING_URI "."
#define PARENT_URI ".."
......@@ -63,6 +64,14 @@ enum {
NUM_COLUMNS
};
enum {
PROP_0,
PROP_ROOT,
PROP_ROOT_URI
};
enum {
FOLDER_POPUP,
LIST_CHILDREN,
......@@ -116,6 +125,70 @@ G_DEFINE_TYPE_WITH_CODE (GthFolderTree,
G_ADD_PRIVATE (GthFolderTree))
static void
gth_folder_tree_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GthFolderTree *self;
const char *uri;
self = GTH_FOLDER_TREE (object);
switch (property_id) {
case PROP_ROOT:
_g_object_unref (self->priv->root);
self->priv->root = _g_object_ref (g_value_get_object (value));
if (self->priv->root == NULL)
self->priv->root = g_file_new_for_uri (DEFAULT_URI);
break;
case PROP_ROOT_URI:
_g_object_unref (self->priv->root);
self->priv->root = NULL;
uri = g_value_get_string (value);
if (uri != NULL)
self->priv->root = g_file_new_for_uri (uri);
if (self->priv->root == NULL)
self->priv->root = g_file_new_for_uri (DEFAULT_URI);
break;
default:
break;
}
}
static void
gth_folder_tree_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GthFolderTree *self;
char *uri;
self = GTH_FOLDER_TREE (object);
switch (property_id) {
case PROP_ROOT:
g_value_set_object (value, self->priv->root);
break;
case PROP_ROOT_URI:
uri = g_file_get_uri (self->priv->root);
g_value_set_string (value, uri);
g_free (uri);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void remove_all_locations_from_the_monitor (GthFolderTree *folder_tree);
......@@ -153,11 +226,32 @@ gth_folder_tree_class_init (GthFolderTreeClass *class)
GtkWidgetClass *widget_class;
object_class = (GObjectClass*) class;
object_class->set_property = gth_folder_tree_set_property;
object_class->get_property = gth_folder_tree_get_property;
object_class->finalize = gth_folder_tree_finalize;
widget_class = (GtkWidgetClass*) class;
widget_class->drag_begin = NULL;
/* properties */
g_object_class_install_property (object_class,
PROP_ROOT,
g_param_spec_object ("root",
"Root",
"The root of the folder tree",
G_TYPE_FILE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_ROOT_URI,
g_param_spec_string ("root-uri",
"Root uri",
"The root of the folder tree as an uri",
NULL,
G_PARAM_READWRITE));
/* signals */
gth_folder_tree_signals[FOLDER_POPUP] =
g_signal_new ("folder_popup",
G_TYPE_FROM_CLASS (class),
......@@ -1264,7 +1358,7 @@ gth_folder_tree_init (GthFolderTree *folder_tree)
GtkTreeSelection *selection;
folder_tree->priv = gth_folder_tree_get_instance_private (folder_tree);
folder_tree->priv->root = NULL;
folder_tree->priv->root = g_file_new_for_uri (DEFAULT_URI);
folder_tree->priv->entry_points = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);
folder_tree->priv->recalc_entry_points = FALSE;
folder_tree->priv->tree_store = gtk_tree_store_new (NUM_COLUMNS,
......@@ -1347,15 +1441,9 @@ gth_folder_tree_init (GthFolderTree *folder_tree)
GtkWidget *
gth_folder_tree_new (const char *uri)
gth_folder_tree_new (const char *root)
{
GthFolderTree *folder_tree;
folder_tree = g_object_new (GTH_TYPE_FOLDER_TREE, NULL);
if (uri != NULL)
folder_tree->priv->root = g_file_new_for_uri (uri);
return (GtkWidget *) folder_tree;
return g_object_new (GTH_TYPE_FOLDER_TREE, "root-uri", root, NULL);
}
......
......@@ -65,7 +65,7 @@ struct _GthFolderTreeClass {
};
GType gth_folder_tree_get_type (void);
GtkWidget * gth_folder_tree_new (const char *uri);
GtkWidget * gth_folder_tree_new (const char *root);
void gth_folder_tree_set_list (GthFolderTree *folder_tree,
GFile *root,
GList *files,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment