[gnome-builder] omnibar: add running time to omnibar popover



commit 29391c36bf802441aba60b7d5913a417804118dd
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 23 17:47:51 2016 -0700

    omnibar: add running time to omnibar popover

 libide/workbench/ide-omni-bar.c  |   37 +++++++++++++++++++++++++++++++++++++
 libide/workbench/ide-omni-bar.ui |    7 +++++--
 2 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/libide/workbench/ide-omni-bar.c b/libide/workbench/ide-omni-bar.c
index da97050..fd05df4 100644
--- a/libide/workbench/ide-omni-bar.c
+++ b/libide/workbench/ide-omni-bar.c
@@ -56,8 +56,10 @@ struct _IdeOmniBar
   GtkPopover     *popover;
   GtkLabel       *popover_branch_label;
   GtkButton      *popover_build_cancel_button;
+  GtkLabel       *popover_build_running_time_label;
   GtkLabel       *popover_build_status;
   GtkListBox     *popover_configuration_list_box;
+  GtkLabel       *popover_last_build_time_label;
   GtkLabel       *popover_project_label;
 };
 
@@ -236,6 +238,30 @@ ide_omni_bar_build_result_notify_mode (IdeOmniBar     *self,
 }
 
 static void
+ide_omni_bar_build_result_notify_running_time (IdeOmniBar     *self,
+                                               GParamSpec     *pspec,
+                                               IdeBuildResult *result)
+{
+  g_autofree gchar *text = NULL;
+  GTimeSpan span;
+  guint hours;
+  guint minutes;
+  guint seconds;
+
+  g_assert (IDE_IS_OMNI_BAR (self));
+  g_assert (IDE_IS_BUILD_RESULT (result));
+
+  span = ide_build_result_get_running_time (result);
+
+  hours = span / G_TIME_SPAN_HOUR;
+  minutes = (span % G_TIME_SPAN_HOUR) / G_TIME_SPAN_MINUTE;
+  seconds = (span % G_TIME_SPAN_MINUTE) / G_TIME_SPAN_SECOND;
+
+  text = g_strdup_printf ("%02u:%02u:%02u", hours, minutes, seconds);
+  gtk_label_set_label (self->popover_build_running_time_label, text);
+}
+
+static void
 ide_omni_bar_build_result_notify_running (IdeOmniBar     *self,
                                           GParamSpec     *pspec,
                                           IdeBuildResult *result)
@@ -258,6 +284,8 @@ ide_omni_bar_build_result_notify_running (IdeOmniBar     *self,
 
       gtk_widget_show (GTK_WIDGET (self->popover_build_cancel_button));
       gtk_widget_hide (GTK_WIDGET (self->popover_build_status));
+      gtk_widget_hide (GTK_WIDGET (self->popover_last_build_time_label));
+      gtk_widget_show (GTK_WIDGET (self->popover_build_running_time_label));
     }
   else
     {
@@ -270,6 +298,8 @@ ide_omni_bar_build_result_notify_running (IdeOmniBar     *self,
 
       gtk_widget_hide (GTK_WIDGET (self->popover_build_cancel_button));
       gtk_widget_show (GTK_WIDGET (self->popover_build_status));
+      gtk_widget_show (GTK_WIDGET (self->popover_last_build_time_label));
+      gtk_widget_hide (GTK_WIDGET (self->popover_build_running_time_label));
     }
 }
 
@@ -425,8 +455,10 @@ ide_omni_bar_class_init (IdeOmniBarClass *klass)
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_branch_label);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_build_cancel_button);
+  gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_build_running_time_label);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_build_status);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_configuration_list_box);
+  gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_last_build_time_label);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, popover_project_label);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, project_label);
 }
@@ -459,6 +491,11 @@ ide_omni_bar_init (IdeOmniBar *self)
                                    self,
                                    G_CONNECT_SWAPPED);
   egg_signal_group_connect_object (self->build_result_signals,
+                                   "notify::running-time",
+                                   G_CALLBACK (ide_omni_bar_build_result_notify_running_time),
+                                   self,
+                                   G_CONNECT_SWAPPED);
+  egg_signal_group_connect_object (self->build_result_signals,
                                    "diagnostic",
                                    G_CALLBACK (ide_omni_bar_build_result_diagnostic),
                                    self,
diff --git a/libide/workbench/ide-omni-bar.ui b/libide/workbench/ide-omni-bar.ui
index 0fdfc1a..2708a21 100644
--- a/libide/workbench/ide-omni-bar.ui
+++ b/libide/workbench/ide-omni-bar.ui
@@ -225,6 +225,7 @@
             <child>
               <object class="GtkBox">
                 <property name="orientation">vertical</property>
+                <property name="valign">center</property>
                 <property name="visible">true</property>
                 <child>
                   <object class="GtkLabel" id="popover_build_label">
@@ -250,7 +251,8 @@
             </child>
             <child>
               <object class="GtkLabel" id="popover_build_running_time_label">
-                <property name="label">0:32</property>
+                <property name="margin-end">8</property>
+                <property name="margin-start">8</property>
               </object>
               <packing>
                 <property name="position">1</property>
@@ -259,7 +261,8 @@
             </child>
             <child>
               <object class="GtkLabel" id="popover_build_status">
-                <property name="label">Failed</property>
+                <property name="margin-end">8</property>
+                <property name="margin-start">8</property>
               </object>
               <packing>
                 <property name="position">2</property>


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