[gnome-builder/wip/chergert/pipeline-merge: 55/78] 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/chergert/pipeline-merge: 55/78] configuration: Mark config as dirty when IdeEnvironment changes
- Date: Fri, 10 Feb 2017 03:31:45 +0000 (UTC)
commit e747b35bb41511dfad976e6c98627c12692b35fc
Author: Matthew Leeds <mleeds redhat com>
Date: Tue Jan 24 17:29:17 2017 -0600
configuration: Mark config as dirty when IdeEnvironment changes
This commit makes the IdeConfiguration mark itself as dirty when an environment
variable (or its value) is changed by the user, rather than just when an
env var is added or removed. That way such changes can be written back
to the disk (almost) immediately.
https://bugzilla.gnome.org/show_bug.cgi?id=777959
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 121926c..84a13be 100644
--- a/libide/buildsystem/ide-configuration.c
+++ b/libide/buildsystem/ide-configuration.c
@@ -209,9 +209,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;
@@ -540,7 +537,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);
@@ -1031,6 +1028,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]