[anjuta] file-manager: Use a GFile instead of an URI for the base path property.
- From: Carl-Anton Ingmarsson <carlantoni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] file-manager: Use a GFile instead of an URI for the base path property.
- Date: Mon, 21 Jan 2013 20:28:40 +0000 (UTC)
commit 6ab47e1f95d3601a079046f4a550b6309c3ec3fa
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Wed Nov 14 23:58:48 2012 +0100
file-manager: Use a GFile instead of an URI for the base path property.
In AnjutaFileView and FileModel. Also rename the property to "base-path".
https://bugzilla.gnome.org/show_bug.cgi?id=692175
plugins/file-manager/file-model.c | 57 ++++++++++++++++++-------------------
plugins/file-manager/file-model.h | 2 +-
plugins/file-manager/file-view.c | 27 +++++++----------
plugins/file-manager/plugin.c | 24 ++++++++++------
4 files changed, 55 insertions(+), 55 deletions(-)
---
diff --git a/plugins/file-manager/file-model.c b/plugins/file-manager/file-model.c
index 7d5c817..1e383a1 100644
--- a/plugins/file-manager/file-model.c
+++ b/plugins/file-manager/file-model.c
@@ -47,7 +47,7 @@ const gchar* BINARY_SUFFIX[] =
enum
{
PROP_0,
- PROP_BASE_URI,
+ PROP_BASE_PATH,
PROP_FILTER_BINARY,
PROP_FILTER_HIDDEN,
PROP_FILTER_BACKUP,
@@ -59,7 +59,7 @@ typedef struct _FileModelAsyncData FileModelAsyncData;
struct _FileModelPrivate
{
- gchar* base_uri;
+ GFile *base_path;
gboolean filter_binary;
gboolean filter_hidden;
gboolean filter_backup;
@@ -607,7 +607,12 @@ file_model_init (FileModel *object)
static void
file_model_finalize (GObject *object)
-{
+{
+ FileModel *model = FILE_MODEL(object);
+ FileModelPrivate* priv = FILE_MODEL_GET_PRIVATE(model);
+
+ g_clear_object (&priv->base_path);
+
G_OBJECT_CLASS (file_model_parent_class)->finalize (object);
}
@@ -616,17 +621,15 @@ file_model_set_property (GObject *object, guint prop_id, const GValue *value, GP
{
g_return_if_fail (FILE_IS_MODEL (object));
FileModel* model = FILE_MODEL(object);
- FileModelPrivate* priv = FILE_MODEL_GET_PRIVATE(model);
+ FileModelPrivate* priv = FILE_MODEL_GET_PRIVATE(model);
switch (prop_id)
{
- case PROP_BASE_URI:
- g_free (priv->base_uri);
- priv->base_uri = g_value_dup_string (value);
- if (!priv->base_uri || !strlen (priv->base_uri))
- {
- priv->base_uri = g_strdup("file:///");
- }
+ case PROP_BASE_PATH:
+ g_clear_object (&priv->base_path);
+ priv->base_path = g_value_dup_object (value);
+ if (!priv->base_path)
+ priv->base_path = g_file_new_for_uri ("file:///");
break;
case PROP_FILTER_BINARY:
priv->filter_binary = g_value_get_boolean (value);
@@ -656,8 +659,8 @@ file_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
switch (prop_id)
{
- case PROP_BASE_URI:
- g_value_set_string (value, priv->base_uri);
+ case PROP_BASE_PATH:
+ g_value_set_object (value, priv->base_path);
break;
case PROP_FILTER_BINARY:
g_value_set_boolean (value, priv->filter_binary);
@@ -687,12 +690,12 @@ file_model_class_init (FileModelClass *klass)
g_type_class_add_private (object_class, sizeof(FileModelPrivate));
g_object_class_install_property (object_class,
- PROP_BASE_URI,
- g_param_spec_string ("base_uri",
- "Base uri",
- "Base uri",
- "NULL",
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+ PROP_BASE_PATH,
+ g_param_spec_object ("base-path",
+ _("Base Path"),
+ _("GFile representing the top-most path displayed"),
+ G_TYPE_FILE,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_FILTER_BINARY,
g_param_spec_boolean ("filter_binary",
@@ -728,10 +731,10 @@ file_model_class_init (FileModelClass *klass)
}
FileModel*
-file_model_new (GtkTreeView* tree_view, const gchar* base_uri)
+file_model_new (GtkTreeView* tree_view, GFile* base_path)
{
GObject* model =
- g_object_new (FILE_TYPE_MODEL, "base_uri", base_uri, NULL);
+ g_object_new (FILE_TYPE_MODEL, "base-path", base_path, NULL);
GType types[N_COLUMNS] = {GDK_TYPE_PIXBUF, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_UINT, G_TYPE_OBJECT,
G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_BOOLEAN};
@@ -755,22 +758,18 @@ file_model_refresh (FileModel* model)
{
GtkTreeStore* store = GTK_TREE_STORE (model);
FileModelPrivate* priv = FILE_MODEL_GET_PRIVATE(model);
- GFile* base;
GFileInfo* base_info;
gtk_tree_store_clear (store);
- base = g_file_new_for_uri (priv->base_uri);
- base_info = g_file_query_info (base, "standard::*",
- G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ base_info = g_file_query_info (priv->base_path, "standard::*",
+ G_FILE_QUERY_INFO_NONE, NULL, NULL);
if (!base_info)
- goto out;
+ return;
- file_model_add_file (model, NULL, base, base_info);
+ file_model_add_file (model, NULL, priv->base_path, base_info);
g_object_unref (base_info);
-out:
- g_object_unref (base);
}
GFile*
diff --git a/plugins/file-manager/file-model.h b/plugins/file-manager/file-model.h
index 46c74ef..5809c02 100644
--- a/plugins/file-manager/file-model.h
+++ b/plugins/file-manager/file-model.h
@@ -71,7 +71,7 @@ struct _FileModel
GType
file_model_get_type (void) G_GNUC_CONST;
FileModel*
-file_model_new (GtkTreeView* tree_view, const gchar* base_uri);
+file_model_new (GtkTreeView* tree_view, GFile *base_path);
void
file_model_refresh (FileModel* model);
diff --git a/plugins/file-manager/file-view.c b/plugins/file-manager/file-view.c
index 821d211..b57fc06 100644
--- a/plugins/file-manager/file-view.c
+++ b/plugins/file-manager/file-view.c
@@ -98,7 +98,7 @@ get_status_string(AnjutaVcsStatus status)
enum
{
- PROP_BASE_URI = 1,
+ PROP_BASE_PATH = 1,
PROP_END
};
@@ -689,13 +689,11 @@ file_view_get_property (GObject *object, guint prop_id, GValue *value,
GParamSpec *pspec)
{
AnjutaFileViewPrivate *priv = ANJUTA_FILE_VIEW_GET_PRIVATE (object);
- gchar* uri;
switch (prop_id)
{
- case PROP_BASE_URI:
- g_object_get (G_OBJECT(priv->model), "base_uri", &uri, NULL);
- g_value_set_string (value, uri);
+ case PROP_BASE_PATH:
+ g_object_get_property (G_OBJECT(priv->model), "base-path", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -711,9 +709,8 @@ file_view_set_property (GObject *object, guint prop_id, const GValue *value,
switch (prop_id)
{
- case PROP_BASE_URI:
- g_object_set (G_OBJECT (priv->model), "base_uri", g_value_get_string (value),
- NULL);
+ case PROP_BASE_PATH:
+ g_object_set_property (G_OBJECT (priv->model), "base-path", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -745,14 +742,12 @@ file_view_class_init (AnjutaFileViewClass *klass)
object_class->get_property = file_view_get_property;
g_object_class_install_property (object_class,
- PROP_BASE_URI,
- g_param_spec_string ("base_uri",
- _("Base URI"),
- _("URI of the top-most path displayed"),
- NULL,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT));
+ PROP_BASE_PATH,
+ g_param_spec_object ("base-path",
+ _("Base Path"),
+ _("GFile representing the top-most path displayed"),
+ G_TYPE_FILE,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
g_signal_new ("file-open",
ANJUTA_TYPE_FILE_VIEW,
G_SIGNAL_RUN_LAST,
diff --git a/plugins/file-manager/plugin.c b/plugins/file-manager/plugin.c
index 66ddb78..ab5e758 100644
--- a/plugins/file-manager/plugin.c
+++ b/plugins/file-manager/plugin.c
@@ -80,18 +80,17 @@ static GtkActionEntry popup_actions[] =
static void
file_manager_set_default_uri (AnjutaFileManager* file_manager)
{
- GFile *file;
gchar* path = g_settings_get_string (file_manager->settings, PREF_ROOT);
if (path)
{
- file = g_file_new_for_path (path);
- char *uri = g_file_get_uri (file);
- if (uri)
- g_object_set (G_OBJECT (file_manager->fv), "base_uri", uri, NULL);
+ GFile *base_path;
+
+ base_path = g_file_new_for_path (path);
+ g_object_set (G_OBJECT (file_manager->fv), "base-path", base_path, NULL);
+ g_object_unref (base_path);
+
file_manager->have_project = FALSE;
- g_free (uri);
- g_object_unref (file);
}
g_free(path);
}
@@ -180,7 +179,12 @@ project_root_added (AnjutaPlugin *plugin, const gchar *name,
root_uri = g_value_get_string (value);
if (root_uri)
{
- g_object_set (G_OBJECT(file_manager->fv), "base_uri", root_uri, NULL);
+ GFile *base_path;
+
+ base_path = g_file_new_for_uri (root_uri);
+ g_object_set (G_OBJECT(file_manager->fv), "base-path", base_path, NULL);
+ g_object_unref (base_path);
+
file_model_set_ivcs (file_model, get_vcs_plugin (file_manager,
root_uri));
@@ -426,7 +430,9 @@ ifile_manager_set_root (IAnjutaFileManager *ifile_manager, const gchar *root,
GError **err)
{
AnjutaFileManager* file_manager = (AnjutaFileManager*) ifile_manager;
- g_object_set (G_OBJECT(file_manager->fv), "base_uri", root, NULL);
+ GFile *base_path = g_file_new_for_uri (root);
+ g_object_set (G_OBJECT(file_manager->fv), "base-path", base_path, NULL);
+ g_object_unref (base_path);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]