[gnome-builder] plugins/projectui: add overview information for project
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/projectui: add overview information for project
- Date: Wed, 24 Aug 2022 01:28:22 +0000 (UTC)
commit 5c46e9b16b29b2ac28fd230ab99d2da5e3590e4a
Author: Christian Hergert <chergert redhat com>
Date: Tue Aug 23 18:28:16 2022 -0700
plugins/projectui: add overview information for project
src/plugins/projectui/gbp-projectui-tweaks-addin.c | 108 ++++++++++++++++++++-
src/plugins/projectui/tweaks.ui | 50 ++++++++++
2 files changed, 155 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/projectui/gbp-projectui-tweaks-addin.c
b/src/plugins/projectui/gbp-projectui-tweaks-addin.c
index 4cf94d02e..f261e0fae 100644
--- a/src/plugins/projectui/gbp-projectui-tweaks-addin.c
+++ b/src/plugins/projectui/gbp-projectui-tweaks-addin.c
@@ -27,16 +27,98 @@
#include <gtk/gtk.h>
#include <libide-foundry.h>
+#include <libide-vcs.h>
#include "gbp-projectui-tweaks-addin.h"
struct _GbpProjectuiTweaksAddin
{
IdeTweaksAddin parent_instance;
+ IdeContext *context;
};
G_DEFINE_FINAL_TYPE (GbpProjectuiTweaksAddin, gbp_projectui_tweaks_addin, IDE_TYPE_TWEAKS_ADDIN)
+enum {
+ PROP_0,
+ PROP_BUILD_SYSTEM,
+ PROP_SOURCE_DIRECTORY,
+ PROP_VCS,
+ N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
+
+static char *
+gbp_projectui_tweaks_addin_get_build_system (GbpProjectuiTweaksAddin *self)
+{
+ IdeBuildSystem *build_system;
+
+ if (self->context &&
+ (build_system = ide_build_system_from_context (self->context)))
+ return ide_build_system_get_display_name (build_system);
+
+ return NULL;
+}
+
+static char *
+gbp_projectui_tweaks_addin_get_source_directory (GbpProjectuiTweaksAddin *self)
+{
+ g_autoptr(GFile) workdir = NULL;
+
+ if (self->context && (workdir = ide_context_ref_workdir (self->context)))
+ {
+ if (g_file_is_native (workdir))
+ {
+ g_autofree char *srcdir = g_file_get_path (workdir);
+ return ide_path_collapse (srcdir);
+ }
+
+ return g_file_get_uri (workdir);
+ }
+
+ return NULL;
+}
+
+static char *
+gbp_projectui_tweaks_addin_get_vcs (GbpProjectuiTweaksAddin *self)
+{
+ IdeVcs *vcs;
+
+ if (self->context &&
+ (vcs = ide_vcs_from_context (self->context)))
+ return ide_vcs_get_display_name (vcs);
+
+ return NULL;
+}
+
+static void
+gbp_projectui_tweaks_addin_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbpProjectuiTweaksAddin *self = GBP_PROJECTUI_TWEAKS_ADDIN (object);
+
+ switch (prop_id)
+ {
+ case PROP_BUILD_SYSTEM:
+ g_value_take_string (value, gbp_projectui_tweaks_addin_get_build_system (self));
+ break;
+
+ case PROP_SOURCE_DIRECTORY:
+ g_value_take_string (value, gbp_projectui_tweaks_addin_get_source_directory (self));
+ break;
+
+ case PROP_VCS:
+ g_value_take_string (value, gbp_projectui_tweaks_addin_get_vcs (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
static void
gbp_projectui_tweaks_addin_load (IdeTweaksAddin *addin,
IdeTweaks *tweaks)
@@ -44,7 +126,6 @@ gbp_projectui_tweaks_addin_load (IdeTweaksAddin *addin,
GbpProjectuiTweaksAddin *self = (GbpProjectuiTweaksAddin *)addin;
g_autoptr(GtkFlattenListModel) configs = NULL;
g_autoptr(GListStore) store = NULL;
- IdeContext *context;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_PROJECTUI_TWEAKS_ADDIN (self));
@@ -57,21 +138,42 @@ gbp_projectui_tweaks_addin_load (IdeTweaksAddin *addin,
configs = gtk_flatten_list_model_new (G_LIST_MODEL (g_object_ref (store)));
ide_tweaks_expose_object (tweaks, "Configurations", G_OBJECT (configs));
- if ((context = ide_tweaks_get_context (tweaks)))
+ self->context = ide_tweaks_get_context (tweaks);
+
+ if (self->context != NULL)
{
- IdeConfigManager *config_manager = ide_config_manager_from_context (context);
+ IdeConfigManager *config_manager = ide_config_manager_from_context (self->context);
g_list_store_append (store, config_manager);
}
IDE_TWEAKS_ADDIN_CLASS (gbp_projectui_tweaks_addin_parent_class)->load (addin, tweaks);
}
+static void
+gbp_projectui_tweaks_addin_unload (IdeTweaksAddin *addin,
+ IdeTweaks *tweaks)
+{
+ GbpProjectuiTweaksAddin *self = GBP_PROJECTUI_TWEAKS_ADDIN (addin);
+
+ self->context = NULL;
+}
+
static void
gbp_projectui_tweaks_addin_class_init (GbpProjectuiTweaksAddinClass *klass)
{
IdeTweaksAddinClass *tweaks_addin_class = IDE_TWEAKS_ADDIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = gbp_projectui_tweaks_addin_get_property;
tweaks_addin_class->load = gbp_projectui_tweaks_addin_load;
+ tweaks_addin_class->unload = gbp_projectui_tweaks_addin_unload;
+
+ IDE_DEFINE_STRING_PROPERTY ("build-system", NULL, G_PARAM_READABLE, BUILD_SYSTEM);
+ IDE_DEFINE_STRING_PROPERTY ("source-directory", NULL, G_PARAM_READABLE, SOURCE_DIRECTORY);
+ IDE_DEFINE_STRING_PROPERTY ("vcs", NULL, G_PARAM_READABLE, VCS);
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
diff --git a/src/plugins/projectui/tweaks.ui b/src/plugins/projectui/tweaks.ui
index 93384ab50..0f9e344a6 100644
--- a/src/plugins/projectui/tweaks.ui
+++ b/src/plugins/projectui/tweaks.ui
@@ -95,6 +95,56 @@
<object class="IdeTweaksPage" id="overview_page">
<property name="title" translatable="yes">Overview</property>
<property name="icon-name" translatable="yes">info-symbolic</property>
+ <child>
+ <object class="IdeTweaksGroup" id="overview_id_group">
+ <binding name="title">
+ <lookup name="title" type="IdeContext">
+ <lookup name="context">IdeTweaks</lookup>
+ </lookup>
+ </binding>
+ <child>
+ <object class="IdeTweaksInfo">
+ <property name="title" translatable="yes">Project Identifier</property>
+ <binding name="value">
+ <lookup name="project-id">IdeTweaks</lookup>
+ </binding>
+ </object>
+ </child>
+ <child>
+ <object class="IdeTweaksCaption">
+ <property name="text" translatable="yes">The project identifier is used to reference
your projects settings, build directories, and cached information.</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="IdeTweaksGroup" id="overview_info_group">
+ <child>
+ <object class="IdeTweaksInfo">
+ <property name="title" translatable="yes">Build System</property>
+ <binding name="value">
+ <lookup name="build-system">GbpProjectuiTweaksAddin</lookup>
+ </binding>
+ </object>
+ </child>
+ <child>
+ <object class="IdeTweaksInfo">
+ <property name="title" translatable="yes">Source Directory</property>
+ <binding name="value">
+ <lookup name="source-directory">GbpProjectuiTweaksAddin</lookup>
+ </binding>
+ </object>
+ </child>
+ <child>
+ <object class="IdeTweaksInfo">
+ <property name="title" translatable="yes">Version Control</property>
+ <binding name="value">
+ <lookup name="vcs">GbpProjectuiTweaksAddin</lookup>
+ </binding>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]