[gnome-builder/wip/libide: 112/237] libide: add ide_project_file_get_name() convenience property



commit 54e0774d08b0705e5507b8e5905dce4a2b36db2a
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 11 19:32:43 2015 -0800

    libide: add ide_project_file_get_name() convenience property

 libide/ide-project-file.c |   24 ++++++++++++++++++++++++
 libide/ide-project-file.h |    5 +++--
 2 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-project-file.c b/libide/ide-project-file.c
index 034ae6b..d964f04 100644
--- a/libide/ide-project-file.c
+++ b/libide/ide-project-file.c
@@ -33,11 +33,22 @@ enum {
   PROP_0,
   PROP_FILE,
   PROP_FILE_INFO,
+  PROP_NAME,
   LAST_PROP
 };
 
 static GParamSpec *gParamSpecs [LAST_PROP];
 
+const gchar *
+ide_project_file_get_name (IdeProjectFile *self)
+{
+  IdeProjectFilePrivate *priv = ide_project_file_get_instance_private (self);
+
+  g_return_val_if_fail (IDE_IS_PROJECT_FILE (self), NULL);
+
+  return g_file_info_get_name (priv->file_info);
+}
+
 GFile *
 ide_project_file_get_file (IdeProjectFile *file)
 {
@@ -113,6 +124,10 @@ ide_project_file_get_property (GObject    *object,
       g_value_set_object (value, ide_project_file_get_file_info (self));
       break;
 
+    case PROP_NAME:
+      g_value_set_string (value, ide_project_file_get_name (self));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -169,6 +184,15 @@ ide_project_file_class_init (IdeProjectFileClass *klass)
                           G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (object_class, PROP_FILE_INFO,
                                    gParamSpecs [PROP_FILE_INFO]);
+
+  gParamSpecs [PROP_NAME] =
+    g_param_spec_string ("name",
+                         _("Name"),
+                         _("The shortname of the file."),
+                         NULL,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_NAME,
+                                   gParamSpecs [PROP_NAME]);
 }
 
 static void
diff --git a/libide/ide-project-file.h b/libide/ide-project-file.h
index 1e0d66c..53482f3 100644
--- a/libide/ide-project-file.h
+++ b/libide/ide-project-file.h
@@ -35,8 +35,9 @@ struct _IdeProjectFileClass
   GObjectClass parent;
 };
 
-GFile     *ide_project_file_get_file      (IdeProjectFile *file);
-GFileInfo *ide_project_file_get_file_info (IdeProjectFile *file);
+GFile       *ide_project_file_get_file      (IdeProjectFile *file);
+GFileInfo   *ide_project_file_get_file_info (IdeProjectFile *file);
+const gchar *ide_project_file_get_name      (IdeProjectFile *file);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]