[gnome-builder/wip/greeter] project-info: give info access to programming languages
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/greeter] project-info: give info access to programming languages
- Date: Sun, 10 May 2015 22:06:43 +0000 (UTC)
commit ae97a40dcedea7fa1d7c83d8e5ede56b70ea7197
Author: Christian Hergert <christian hergert me>
Date: Sun May 10 15:06:29 2015 -0700
project-info: give info access to programming languages
I'm not super thrilled about shoving more info in the GtkRecentManager
item. I'm okay with abusing group names as long as we keep the file
private to Builder.
libide/autotools/ide-autotools-project-miner.c | 3 +
libide/ide-project-info.c | 59 ++++++++++++++++++++----
libide/ide-project-info.h | 47 ++++++++++---------
libide/ide-recent-projects.c | 15 ++++++-
src/greeter/gb-greeter-project-row.c | 8 +---
5 files changed, 93 insertions(+), 39 deletions(-)
---
diff --git a/libide/autotools/ide-autotools-project-miner.c b/libide/autotools/ide-autotools-project-miner.c
index dd03d52..5465f49 100644
--- a/libide/autotools/ide-autotools-project-miner.c
+++ b/libide/autotools/ide-autotools-project-miner.c
@@ -105,6 +105,7 @@ ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
g_autoptr(IdeDoap) doap = NULL;
const gchar *filename;
const gchar *shortdesc = NULL;
+ gchar **languages = NULL;
guint64 mtime;
IDE_ENTRY;
@@ -150,6 +151,7 @@ ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
}
shortdesc = ide_doap_get_shortdesc (doap);
+ languages = ide_doap_get_languages (doap);
}
project_info = g_object_new (IDE_TYPE_PROJECT_INFO,
@@ -158,6 +160,7 @@ ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
"doap", doap,
"file", file,
"last-modified-at", last_modified_at,
+ "languages", languages,
"name", name,
"priority", IDE_AUTOTOOLS_PROJECT_MINER_PRIORITY,
NULL);
diff --git a/libide/ide-project-info.c b/libide/ide-project-info.c
index 34ed5a3..2e7006b 100644
--- a/libide/ide-project-info.c
+++ b/libide/ide-project-info.c
@@ -39,18 +39,19 @@
struct _IdeProjectInfo
{
- GObject parent_instance;
+ GObject parent_instance;
- IdeDoap *doap;
- GDateTime *last_modified_at;
- GFile *directory;
- GFile *file;
- gchar *name;
- gchar *description;
+ IdeDoap *doap;
+ GDateTime *last_modified_at;
+ GFile *directory;
+ GFile *file;
+ gchar *name;
+ gchar *description;
+ gchar **languages;
- gint priority;
+ gint priority;
- guint is_recent : 1;
+ guint is_recent : 1;
};
G_DEFINE_TYPE (IdeProjectInfo, ide_project_info, G_TYPE_OBJECT)
@@ -62,6 +63,7 @@ enum {
PROP_DOAP,
PROP_FILE,
PROP_IS_RECENT,
+ PROP_LANGUAGES,
PROP_LAST_MODIFIED_AT,
PROP_NAME,
PROP_PRIORITY,
@@ -95,6 +97,30 @@ ide_project_info_set_doap (IdeProjectInfo *self,
g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_DOAP]);
}
+/**
+ * ide_project_info_get_languages:
+ *
+ * Returns: (transfer none): An array of language names.
+ */
+gchar **
+ide_project_info_get_languages (IdeProjectInfo *self)
+{
+ g_return_val_if_fail (IDE_IS_PROJECT_INFO (self), NULL);
+
+ return self->languages;
+}
+
+void
+ide_project_info_set_languages (IdeProjectInfo *self,
+ gchar **languages)
+{
+ g_return_if_fail (IDE_IS_PROJECT_INFO (self));
+
+ g_strfreev (self->languages);
+ self->languages = g_strdupv (languages);
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_LANGUAGES]);
+}
+
gint
ide_project_info_get_priority (IdeProjectInfo *self)
{
@@ -311,6 +337,10 @@ ide_project_info_get_property (GObject *object,
g_value_set_boolean (value, ide_project_info_get_is_recent (self));
break;
+ case PROP_LANGUAGES:
+ g_value_set_boxed (value, ide_project_info_get_languages (self));
+ break;
+
case PROP_LAST_MODIFIED_AT:
g_value_set_boxed (value, ide_project_info_get_last_modified_at (self));
break;
@@ -358,6 +388,10 @@ ide_project_info_set_property (GObject *object,
ide_project_info_set_is_recent (self, g_value_get_boolean (value));
break;
+ case PROP_LANGUAGES:
+ ide_project_info_set_languages (self, g_value_get_boxed (value));
+ break;
+
case PROP_LAST_MODIFIED_AT:
ide_project_info_set_last_modified_at (self, g_value_get_boxed (value));
break;
@@ -426,6 +460,13 @@ ide_project_info_class_init (IdeProjectInfoClass *klass)
FALSE,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ gParamSpecs [PROP_LANGUAGES] =
+ g_param_spec_boxed ("languages",
+ _("Languages"),
+ _("Languages"),
+ G_TYPE_STRV,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
gParamSpecs [PROP_LAST_MODIFIED_AT] =
g_param_spec_boxed ("last-modified-at",
_("Last Modified At"),
diff --git a/libide/ide-project-info.h b/libide/ide-project-info.h
index 5062a31..631bd85 100644
--- a/libide/ide-project-info.h
+++ b/libide/ide-project-info.h
@@ -29,28 +29,31 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeProjectInfo, ide_project_info, IDE, PROJECT_INFO, GObject)
-gint ide_project_info_compare (IdeProjectInfo *info1,
- IdeProjectInfo *info2);
-GFile *ide_project_info_get_file (IdeProjectInfo *self);
-IdeDoap *ide_project_info_get_doap (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);
-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,
- gboolean is_recent);
-void ide_project_info_set_name (IdeProjectInfo *self,
- const gchar *name);
-void ide_project_info_set_priority (IdeProjectInfo *self,
- gint priority);
+gint ide_project_info_compare (IdeProjectInfo *info1,
+ IdeProjectInfo *info2);
+GFile *ide_project_info_get_file (IdeProjectInfo *self);
+IdeDoap *ide_project_info_get_doap (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);
+GDateTime *ide_project_info_get_last_modified_at (IdeProjectInfo *self);
+gchar **ide_project_info_get_languages (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,
+ gboolean is_recent);
+void ide_project_info_set_languages (IdeProjectInfo *self,
+ gchar **languages);
+void ide_project_info_set_name (IdeProjectInfo *self,
+ const gchar *name);
+void ide_project_info_set_priority (IdeProjectInfo *self,
+ gint priority);
G_END_DECLS
diff --git a/libide/ide-recent-projects.c b/libide/ide-recent-projects.c
index 448abb3..ecac3fc 100644
--- a/libide/ide-recent-projects.c
+++ b/libide/ide-recent-projects.c
@@ -22,6 +22,9 @@
#include "ide-project-miner.h"
#include "ide-recent-projects.h"
+#define PROJECT_GROUP "X-GNOME-Builder-Project"
+#define LANGUAGE_GROUP_PREFIX "X-GNOME-Builder-Language:"
+
struct _IdeRecentProjects
{
GObject parent_instance;
@@ -140,6 +143,7 @@ ide_recent_projects_load_recent (IdeRecentProjects *self,
g_autoptr(GDateTime) last_modified_at = NULL;
g_autoptr(GFile) project_file = NULL;
g_autoptr(GFile) directory = NULL;
+ g_autoptr(GPtrArray) languages = NULL;
g_autoptr(IdeProjectInfo) project_info = NULL;
GtkRecentInfo *recent_info = iter->data;
const gchar *description;
@@ -154,7 +158,7 @@ ide_recent_projects_load_recent (IdeRecentProjects *self,
for (i = 0; i < len; i++)
{
- if (g_str_equal (groups [i], "X-GNOME-Builder-Project"))
+ if (g_str_equal (groups [i], PROJECT_GROUP))
goto is_project;
}
@@ -169,11 +173,20 @@ ide_recent_projects_load_recent (IdeRecentProjects *self,
project_file = g_file_new_for_uri (uri);
directory = g_file_get_parent (project_file);
+ languages = g_ptr_array_new ();
+ for (i = 0; i < len; i++)
+ {
+ if (g_str_has_prefix (groups [i], LANGUAGE_GROUP_PREFIX))
+ g_ptr_array_add (languages, groups [i] + strlen (LANGUAGE_GROUP_PREFIX));
+ }
+ g_ptr_array_add (languages, NULL);
+
project_info = g_object_new (IDE_TYPE_PROJECT_INFO,
"description", description,
"directory", directory,
"file", project_file,
"is-recent", TRUE,
+ "languages", (gchar **)languages->pdata,
"last-modified-at", last_modified_at,
"name", name,
NULL);
diff --git a/src/greeter/gb-greeter-project-row.c b/src/greeter/gb-greeter-project-row.c
index 5bb2496..3c11df5 100644
--- a/src/greeter/gb-greeter-project-row.c
+++ b/src/greeter/gb-greeter-project-row.c
@@ -108,18 +108,12 @@ static void
gb_greeter_project_row_add_languages (GbGreeterProjectRow *self,
IdeProjectInfo *project_info)
{
- IdeDoap *doap;
gchar **languages;
g_return_if_fail (GB_IS_GREETER_PROJECT_ROW (self));
g_return_if_fail (IDE_IS_PROJECT_INFO (project_info));
- /*
- * TODO: What should we do about doap?
- */
-
- if ((doap = ide_project_info_get_doap (project_info)) &&
- (languages = ide_doap_get_languages (doap)))
+ if ((languages = ide_project_info_get_languages (project_info)))
{
gsize i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]