[gnome-builder] buildui: track changes to pty window title



commit cf180c07d86a9d566dc99b4c96dc6b62375b9b90
Author: Christian Hergert <chergert redhat com>
Date:   Thu Nov 23 03:06:44 2017 -0800

    buildui: track changes to pty window title
    
    We can track the changes in the terminal widget's interpretation
    of the pty to update messages in the pipeline. We still need
    more logic to determine when to use these messages.

 src/libide/buildsystem/ide-build-pipeline.c |   22 ++++++++++++++++++++++
 src/libide/buildsystem/ide-build-private.h  |    4 +++-
 src/libide/buildui/ide-build-log-panel.c    |   22 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/src/libide/buildsystem/ide-build-pipeline.c b/src/libide/buildsystem/ide-build-pipeline.c
index 5ff60fb..99e32db 100644
--- a/src/libide/buildsystem/ide-build-pipeline.c
+++ b/src/libide/buildsystem/ide-build-pipeline.c
@@ -170,6 +170,13 @@ struct _IdeBuildPipeline
   int pty_slave;
 
   /*
+   * If the terminal interpreting our Pty has received a terminal
+   * title update, it might set this message which we can use for
+   * better build messages.
+   */
+  gchar *message;
+
+  /*
    * No reference to the current stage. It is only available during
    * the asynchronous execution of the stage.
    */
@@ -983,6 +990,7 @@ ide_build_pipeline_dispose (GObject *object)
 
   ide_build_pipeline_unload (self);
 
+  g_clear_pointer (&self->message, g_free);
   g_clear_object (&self->pty);
 
   if (self->pty_slave != -1)
@@ -2989,3 +2997,17 @@ ide_build_pipeline_get_can_export (IdeBuildPipeline *self)
 
   return FALSE;
 }
+
+void
+_ide_build_pipeline_set_message (IdeBuildPipeline *self,
+                                 const gchar      *message)
+{
+  g_return_if_fail (IDE_IS_BUILD_PIPELINE (self));
+
+  if (!ide_str_equal0 (message, self->message))
+    {
+      g_free (self->message);
+      self->message = g_strdup (message);
+      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_MESSAGE]);
+    }
+}
diff --git a/src/libide/buildsystem/ide-build-private.h b/src/libide/buildsystem/ide-build-private.h
index dc67fa7..d0ba0cb 100644
--- a/src/libide/buildsystem/ide-build-private.h
+++ b/src/libide/buildsystem/ide-build-private.h
@@ -24,6 +24,8 @@
 
 G_BEGIN_DECLS
 
-VtePty *_ide_build_pipeline_get_pty (IdeBuildPipeline *self);
+VtePty *_ide_build_pipeline_get_pty     (IdeBuildPipeline *self);
+void    _ide_build_pipeline_set_message (IdeBuildPipeline *self,
+                                         const gchar      *message);
 
 G_END_DECLS
diff --git a/src/libide/buildui/ide-build-log-panel.c b/src/libide/buildui/ide-build-log-panel.c
index 1f911d0..6052e19 100644
--- a/src/libide/buildui/ide-build-log-panel.c
+++ b/src/libide/buildui/ide-build-log-panel.c
@@ -132,6 +132,22 @@ ide_build_log_panel_changed_font_name (IdeBuildLogPanel *self,
 }
 
 static void
+ide_build_log_panel_window_title_changed (IdeBuildLogPanel *self,
+                                          IdeTerminal      *terminal)
+{
+  g_assert (IDE_IS_BUILD_LOG_PANEL (self));
+  g_assert (VTE_IS_TERMINAL (terminal));
+
+  if (self->pipeline != NULL)
+    {
+      const gchar *title;
+
+      title = vte_terminal_get_window_title (VTE_TERMINAL (terminal));
+      _ide_build_pipeline_set_message (self->pipeline, title);
+    }
+}
+
+static void
 ide_build_log_panel_finalize (GObject *object)
 {
   IdeBuildLogPanel *self = (IdeBuildLogPanel *)object;
@@ -300,6 +316,12 @@ ide_build_log_panel_init (IdeBuildLogPanel *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  g_signal_connect_object (self->terminal,
+                           "window-title-changed",
+                           G_CALLBACK (ide_build_log_panel_window_title_changed),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   gtk_range_set_adjustment (GTK_RANGE (self->scrollbar),
                             gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (self->terminal)));
 


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