[gnome-builder/wip/greeter] project-info: add description property
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/greeter] project-info: add description property
- Date: Sun, 10 May 2015 18:46:47 +0000 (UTC)
commit 3796f06dab9cae84403c309401bfa25e51e99b19
Author: Christian Hergert <christian hergert me>
Date: Sun May 10 11:45:40 2015 -0700
project-info: add description property
libide/ide-project-info.c | 69 +++++++++++++++++++++++++++++++++++---------
libide/ide-project-info.h | 3 ++
2 files changed, 58 insertions(+), 14 deletions(-)
---
diff --git a/libide/ide-project-info.c b/libide/ide-project-info.c
index 647fbd0..4242487 100644
--- a/libide/ide-project-info.c
+++ b/libide/ide-project-info.c
@@ -26,6 +26,7 @@
#include <string.h>
#include "ide-doap.h"
+#include "ide-macros.h"
#include "ide-project-info.h"
/**
@@ -46,6 +47,7 @@ struct _IdeProjectInfo
GFile *directory;
GFile *file;
gchar *name;
+ gchar *description;
gint priority;
@@ -56,6 +58,7 @@ G_DEFINE_TYPE (IdeProjectInfo, ide_project_info, G_TYPE_OBJECT)
enum {
PROP_0,
+ PROP_DESCRIPTION,
PROP_DIRECTORY,
PROP_DOAP,
PROP_FILE,
@@ -157,6 +160,28 @@ ide_project_info_get_last_modified_at (IdeProjectInfo *self)
}
const gchar *
+ide_project_info_get_description (IdeProjectInfo *self)
+{
+ g_return_val_if_fail (IDE_IS_PROJECT_INFO (self), NULL);
+
+ return self->description;
+}
+
+void
+ide_project_info_set_description (IdeProjectInfo *self,
+ const gchar *description)
+{
+ g_return_if_fail (IDE_IS_PROJECT_INFO (self));
+
+ if (!ide_str_equal0 (self->description, description))
+ {
+ g_free (self->description);
+ self->description = g_strdup (description);
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_DESCRIPTION]);
+ }
+}
+
+const gchar *
ide_project_info_get_name (IdeProjectInfo *self)
{
g_return_val_if_fail (IDE_IS_PROJECT_INFO (self), NULL);
@@ -165,6 +190,20 @@ ide_project_info_get_name (IdeProjectInfo *self)
}
void
+ide_project_info_set_name (IdeProjectInfo *self,
+ const gchar *name)
+{
+ g_return_if_fail (IDE_IS_PROJECT_INFO (self));
+
+ if (!ide_str_equal0 (self->name, name))
+ {
+ g_free (self->name);
+ self->name = g_strdup (name);
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_NAME]);
+ }
+}
+
+void
ide_project_info_set_directory (IdeProjectInfo *self,
GFile *directory)
{
@@ -200,20 +239,6 @@ ide_project_info_set_last_modified_at (IdeProjectInfo *self,
}
}
-void
-ide_project_info_set_name (IdeProjectInfo *self,
- const gchar *name)
-{
- g_return_if_fail (IDE_IS_PROJECT_INFO (self));
-
- if (name != self->name)
- {
- g_free (self->name);
- self->name = g_strdup (name);
- g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_NAME]);
- }
-}
-
gboolean
ide_project_info_get_is_recent (IdeProjectInfo *self)
{
@@ -243,6 +268,7 @@ ide_project_info_finalize (GObject *object)
IdeProjectInfo *self = (IdeProjectInfo *)object;
g_clear_pointer (&self->last_modified_at, g_date_time_unref);
+ g_clear_pointer (&self->description, g_free);
g_clear_pointer (&self->name, g_free);
g_clear_object (&self->directory);
g_clear_object (&self->file);
@@ -260,6 +286,10 @@ ide_project_info_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_DESCRIPTION:
+ g_value_set_string (value, ide_project_info_get_description (self));
+ break;
+
case PROP_DIRECTORY:
g_value_set_object (value, ide_project_info_get_directory (self));
break;
@@ -303,6 +333,10 @@ ide_project_info_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_DESCRIPTION:
+ ide_project_info_set_description (self, g_value_get_string (value));
+ break;
+
case PROP_DIRECTORY:
ide_project_info_set_directory (self, g_value_get_object (value));
break;
@@ -345,6 +379,13 @@ ide_project_info_class_init (IdeProjectInfoClass *klass)
object_class->get_property = ide_project_info_get_property;
object_class->set_property = ide_project_info_set_property;
+ gParamSpecs [PROP_DESCRIPTION] =
+ g_param_spec_string ("description",
+ _("Description"),
+ _("The project description"),
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
gParamSpecs [PROP_NAME] =
g_param_spec_string ("name",
_("Name"),
diff --git a/libide/ide-project-info.h b/libide/ide-project-info.h
index 49a4c09..2838299 100644
--- a/libide/ide-project-info.h
+++ b/libide/ide-project-info.h
@@ -30,6 +30,7 @@ G_DECLARE_FINAL_TYPE (IdeProjectInfo, ide_project_info, IDE, PROJECT_INFO, GObje
gint ide_project_info_compare (IdeProjectInfo *info1,
IdeProjectInfo *info2);
GFile *ide_project_info_get_file (IdeProjectInfo *self);
+const gchar *ide_project_info_get_description (IdeProjectInfo *self);
GFile *ide_project_info_get_directory (IdeProjectInfo *self);
gboolean ide_project_info_get_is_recent (IdeProjectInfo *self);
gint ide_project_info_get_priority (IdeProjectInfo *self);
@@ -37,6 +38,8 @@ GDateTime *ide_project_info_get_last_modified_at (IdeProjectInfo *self);
const gchar *ide_project_info_get_name (IdeProjectInfo *self);
void ide_project_info_set_file (IdeProjectInfo *self,
GFile *file);
+void ide_project_info_set_description (IdeProjectInfo *self,
+ const gchar *description);
void ide_project_info_set_directory (IdeProjectInfo *self,
GFile *directory);
void ide_project_info_set_is_recent (IdeProjectInfo *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]