[gnome-builder] libide: add IdeProjectInfo:priority



commit ed9850b2e76141c2aa6a19352c8aa66d9bf867f4
Author: Christian Hergert <christian hergert me>
Date:   Thu Apr 16 14:51:19 2015 -0700

    libide: add IdeProjectInfo:priority
    
    This will allow us to prioritize projects which have been loaded vs
    projects that have not yet been loaded.
    
    This should ensure that projects discovered from jhbuild are lower than
    previously loaded projects.

 libide/autotools/ide-autotools-project-miner.c |    1 +
 libide/autotools/ide-autotools-project-miner.h |    3 +-
 libide/ide-project-info.c                      |   42 ++++++++++++++++++++++++
 libide/ide-project-info.h                      |    3 ++
 4 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/libide/autotools/ide-autotools-project-miner.c b/libide/autotools/ide-autotools-project-miner.c
index ee7fe8c..b4ce48e 100644
--- a/libide/autotools/ide-autotools-project-miner.c
+++ b/libide/autotools/ide-autotools-project-miner.c
@@ -92,6 +92,7 @@ ide_autotools_project_miner_discovered (IdeAutotoolsProjectMiner *self,
                                "file", file,
                                "last-modified-at", last_modified_at,
                                "name", name,
+                               "priority", IDE_AUTOTOOLS_PROJECT_MINER_PRIORITY,
                                NULL);
 
   ide_project_miner_emit_discovered (IDE_PROJECT_MINER (self), project_info);
diff --git a/libide/autotools/ide-autotools-project-miner.h b/libide/autotools/ide-autotools-project-miner.h
index fc98884..1c9b905 100644
--- a/libide/autotools/ide-autotools-project-miner.h
+++ b/libide/autotools/ide-autotools-project-miner.h
@@ -23,7 +23,8 @@
 
 G_BEGIN_DECLS
 
-#define IDE_TYPE_AUTOTOOLS_PROJECT_MINER (ide_autotools_project_miner_get_type())
+#define IDE_TYPE_AUTOTOOLS_PROJECT_MINER     (ide_autotools_project_miner_get_type())
+#define IDE_AUTOTOOLS_PROJECT_MINER_PRIORITY 100
 
 G_DECLARE_FINAL_TYPE (IdeAutotoolsProjectMiner, ide_autotools_project_miner,
                       IDE, AUTOTOOLS_PROJECT_MINER, IdeProjectMiner)
diff --git a/libide/ide-project-info.c b/libide/ide-project-info.c
index 9ef5426..2edfe59 100644
--- a/libide/ide-project-info.c
+++ b/libide/ide-project-info.c
@@ -39,6 +39,8 @@ struct _IdeProjectInfo
   GFile     *directory;
   GFile     *file;
   gchar     *name;
+
+  gint       priority;
 };
 
 G_DEFINE_TYPE (IdeProjectInfo, ide_project_info, G_TYPE_OBJECT)
@@ -49,11 +51,33 @@ enum {
   PROP_FILE,
   PROP_LAST_MODIFIED_AT,
   PROP_NAME,
+  PROP_PRIORITY,
   LAST_PROP
 };
 
 static GParamSpec *gParamSpecs [LAST_PROP];
 
+gint
+ide_project_info_get_priority (IdeProjectInfo *self)
+{
+  g_return_val_if_fail (IDE_IS_PROJECT_INFO (self), 0);
+
+  return self->priority;
+}
+
+void
+ide_project_info_set_priority (IdeProjectInfo *self,
+                               gint            priority)
+{
+  g_return_if_fail (IDE_IS_PROJECT_INFO (self));
+
+  if (self->priority != priority)
+    {
+      self->priority = priority;
+      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_PRIORITY]);
+    }
+}
+
 /**
  * ide_project_info_get_directory:
  * @self: (in): A #IdeProjectInfo.
@@ -199,6 +223,10 @@ ide_project_info_get_property (GObject    *object,
       g_value_set_string (value, ide_project_info_get_name (self));
       break;
 
+    case PROP_PRIORITY:
+      g_value_set_int (value, ide_project_info_get_priority (self));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -230,6 +258,10 @@ ide_project_info_set_property (GObject      *object,
       ide_project_info_set_name (self, g_value_get_string (value));
       break;
 
+    case PROP_PRIORITY:
+      ide_project_info_set_priority (self, g_value_get_int (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -276,6 +308,16 @@ ide_project_info_class_init (IdeProjectInfoClass *klass)
                         (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (object_class, PROP_LAST_MODIFIED_AT,
                                    gParamSpecs [PROP_LAST_MODIFIED_AT]);
+
+  gParamSpecs [PROP_PRIORITY] =
+    g_param_spec_int ("priority",
+                      _("Priority"),
+                      _("The priority of the project info type."),
+                      G_MININT,
+                      G_MAXINT,
+                      0,
+                      (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_PRIORITY, gParamSpecs [PROP_PRIORITY]);
 }
 
 static void
diff --git a/libide/ide-project-info.h b/libide/ide-project-info.h
index f59c948..a547d71 100644
--- a/libide/ide-project-info.h
+++ b/libide/ide-project-info.h
@@ -29,6 +29,7 @@ G_DECLARE_FINAL_TYPE (IdeProjectInfo, ide_project_info, IDE, PROJECT_INFO, GObje
 
 GFile       *ide_project_info_get_file             (IdeProjectInfo *self);
 GFile       *ide_project_info_get_directory        (IdeProjectInfo *self);
+gint         ide_project_info_get_priority         (IdeProjectInfo *self);
 const gchar *ide_project_info_get_name             (IdeProjectInfo *self);
 void         ide_project_info_set_file             (IdeProjectInfo *self,
                                                     GFile          *file);
@@ -36,6 +37,8 @@ void         ide_project_info_set_directory        (IdeProjectInfo *self,
                                                     GFile          *directory);
 void         ide_project_info_set_name             (IdeProjectInfo *self,
                                                     const gchar    *name);
+void         ide_project_info_set_priority         (IdeProjectInfo *self,
+                                                    gint            priority);
 GDateTime   *ide_project_info_get_last_modified_at (IdeProjectInfo *self);
 
 G_END_DECLS


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