[gnome-builder/wip/mwleeds/ide-config-provider: 2/2] configuration: Mark config as dirty when IdeEnvironment changes
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/mwleeds/ide-config-provider: 2/2] configuration: Mark config as dirty when IdeEnvironment changes
- Date: Thu, 26 Jan 2017 06:22:00 +0000 (UTC)
commit d58c674c758e0ffdc982df4c108b94be596df587
Author: Matthew Leeds <mleeds redhat com>
Date: Tue Jan 24 17:29:17 2017 -0600
configuration: Mark config as dirty when IdeEnvironment changes
libide/buildsystem/ide-configuration.c | 10 ++++---
libide/buildsystem/ide-environment.c | 46 ++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 4 deletions(-)
---
diff --git a/libide/buildsystem/ide-configuration.c b/libide/buildsystem/ide-configuration.c
index 4179516..bb1a7f7 100644
--- a/libide/buildsystem/ide-configuration.c
+++ b/libide/buildsystem/ide-configuration.c
@@ -188,9 +188,6 @@ ide_configuration_runtime_manager_items_changed (IdeConfiguration *self,
static void
ide_configuration_environment_changed (IdeConfiguration *self,
- guint position,
- guint added,
- guint removed,
IdeEnvironment *environment)
{
IDE_ENTRY;
@@ -510,7 +507,7 @@ ide_configuration_init (IdeConfiguration *self)
priv->internal = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, _value_free);
g_signal_connect_object (priv->environment,
- "items-changed",
+ "changed",
G_CALLBACK (ide_configuration_environment_changed),
self,
G_CONNECT_SWAPPED);
@@ -1001,6 +998,11 @@ ide_configuration_set_environment (IdeConfiguration *self,
g_clear_object (&priv->environment);
priv->environment = g_object_ref (environment);
+ g_signal_connect_object (priv->environment,
+ "changed",
+ G_CALLBACK (ide_configuration_environment_changed),
+ self,
+ G_CONNECT_SWAPPED);
}
const gchar *
diff --git a/libide/buildsystem/ide-environment.c b/libide/buildsystem/ide-environment.c
index 3bdbdae..31eb9d0 100644
--- a/libide/buildsystem/ide-environment.c
+++ b/libide/buildsystem/ide-environment.c
@@ -30,6 +30,13 @@ static void list_model_iface_init (GListModelInterface *iface);
G_DEFINE_TYPE_EXTENDED (IdeEnvironment, ide_environment, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init))
+enum {
+ CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL];
+
static void
ide_environment_finalize (GObject *object)
{
@@ -46,12 +53,31 @@ ide_environment_class_init (IdeEnvironmentClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = ide_environment_finalize;
+
+ signals [CHANGED] =
+ g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
+}
+
+static void
+ide_environment_items_changed (IdeEnvironment *self)
+{
+ g_assert (IDE_IS_ENVIRONMENT (self));
+
+ g_signal_emit (self, signals [CHANGED], 0);
}
static void
ide_environment_init (IdeEnvironment *self)
{
self->variables = g_ptr_array_new_with_free_func (g_object_unref);
+
+ g_signal_connect (self,
+ "items-changed",
+ G_CALLBACK (ide_environment_items_changed),
+ NULL);
}
static GType
@@ -90,6 +116,16 @@ list_model_iface_init (GListModelInterface *iface)
iface->get_item_type = ide_environment_get_item_type;
}
+static void
+ide_environment_variable_notify (IdeEnvironment *self,
+ GParamSpec *pspec,
+ IdeEnvironmentVariable *variable)
+{
+ g_assert (IDE_IS_ENVIRONMENT (self));
+
+ g_signal_emit (self, signals [CHANGED], 0);
+}
+
void
ide_environment_setenv (IdeEnvironment *self,
const gchar *key,
@@ -128,6 +164,11 @@ ide_environment_setenv (IdeEnvironment *self,
"key", key,
"value", value,
NULL);
+ g_signal_connect_object (var,
+ "notify",
+ G_CALLBACK (ide_environment_variable_notify),
+ self,
+ G_CONNECT_SWAPPED);
g_ptr_array_add (self->variables, var);
g_list_model_items_changed (G_LIST_MODEL (self), position, 0, 1);
}
@@ -230,6 +271,11 @@ ide_environment_append (IdeEnvironment *self,
position = self->variables->len;
+ g_signal_connect_object (variable,
+ "notify",
+ G_CALLBACK (ide_environment_variable_notify),
+ self,
+ G_CONNECT_SWAPPED);
g_ptr_array_add (self->variables, g_object_ref (variable));
g_list_model_items_changed (G_LIST_MODEL (self), position, 0, 1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]