[sysprof/wip/chergert/sysprof-3] libsysprof-ui: focus record button by default



commit e58aa9b9209d3e236e9352300cb5f678f1df7fa7
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 20 18:57:30 2019 -0700

    libsysprof-ui: focus record button by default
    
    Because if we break the "hit enter to launch, escape to stop" workflow
    some people will be angry.

 src/libsysprof-ui/sysprof-display.c            | 11 ++++++++++
 src/libsysprof-ui/sysprof-notebook.c           |  9 ++++++---
 src/libsysprof-ui/sysprof-profiler-assistant.c |  9 +++++++++
 src/libsysprof-ui/sysprof-ui-private.h         | 28 +++++++++++++++-----------
 4 files changed, 42 insertions(+), 15 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-display.c b/src/libsysprof-ui/sysprof-display.c
index 9776b04..45cc6a3 100644
--- a/src/libsysprof-ui/sysprof-display.c
+++ b/src/libsysprof-ui/sysprof-display.c
@@ -33,6 +33,7 @@
 #include "sysprof-display.h"
 #include "sysprof-empty-state-view.h"
 #include "sysprof-recording-state-view.h"
+#include "sysprof-ui-private.h"
 
 typedef struct
 {
@@ -581,3 +582,13 @@ sysprof_display_stop_recording (SysprofDisplay *self)
   if (priv->profiler != NULL)
     sysprof_profiler_stop (priv->profiler);
 }
+
+void
+_sysprof_display_focus_record (SysprofDisplay *self)
+{
+  SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
+
+  g_return_if_fail (SYSPROF_IS_DISPLAY (self));
+
+  _sysprof_profiler_assistant_focus_record (priv->assistant);
+}
diff --git a/src/libsysprof-ui/sysprof-notebook.c b/src/libsysprof-ui/sysprof-notebook.c
index d0ddaa0..d1267b9 100644
--- a/src/libsysprof-ui/sysprof-notebook.c
+++ b/src/libsysprof-ui/sysprof-notebook.c
@@ -25,6 +25,7 @@
 #include "sysprof-display.h"
 #include "sysprof-notebook.h"
 #include "sysprof-tab.h"
+#include "sysprof-ui-private.h"
 
 G_DEFINE_TYPE (SysprofNotebook, sysprof_notebook, GTK_TYPE_NOTEBOOK)
 
@@ -71,6 +72,9 @@ sysprof_notebook_page_added (GtkNotebook *notebook,
   g_assert (SYSPROF_IS_NOTEBOOK (notebook));
   g_assert (GTK_IS_WIDGET (child));
 
+  gtk_notebook_set_show_tabs (notebook,
+                              gtk_notebook_get_n_pages (notebook) > 1);
+
   if (SYSPROF_IS_DISPLAY (child))
     {
       GtkWidget *tab = sysprof_tab_new (SYSPROF_DISPLAY (child));
@@ -86,10 +90,9 @@ sysprof_notebook_page_added (GtkNotebook *notebook,
 
       g_object_notify_by_pspec (G_OBJECT (notebook), properties [PROP_CAN_SAVE]);
       g_object_notify_by_pspec (G_OBJECT (notebook), properties [PROP_CURRENT]);
-    }
 
-  gtk_notebook_set_show_tabs (notebook,
-                              gtk_notebook_get_n_pages (notebook) > 1);
+      _sysprof_display_focus_record (SYSPROF_DISPLAY (child));
+    }
 }
 
 static void
diff --git a/src/libsysprof-ui/sysprof-profiler-assistant.c b/src/libsysprof-ui/sysprof-profiler-assistant.c
index ef22031..2506e11 100644
--- a/src/libsysprof-ui/sysprof-profiler-assistant.c
+++ b/src/libsysprof-ui/sysprof-profiler-assistant.c
@@ -30,6 +30,7 @@
 #include "sysprof-profiler-assistant.h"
 #include "sysprof-proxy-aid.h"
 #include "sysprof-process-model-row.h"
+#include "sysprof-ui-private.h"
 
 struct _SysprofProfilerAssistant
 {
@@ -314,3 +315,11 @@ sysprof_profiler_assistant_init (SysprofProfilerAssistant *self)
 
   sysprof_environ_editor_set_environ (self->environ_editor, environ);
 }
+
+void
+_sysprof_profiler_assistant_focus_record (SysprofProfilerAssistant *self)
+{
+  g_return_if_fail (SYSPROF_IS_PROFILER_ASSISTANT (self));
+
+  gtk_widget_grab_focus (GTK_WIDGET (self->record_button));
+}
diff --git a/src/libsysprof-ui/sysprof-ui-private.h b/src/libsysprof-ui/sysprof-ui-private.h
index 26e2353..f4eed56 100644
--- a/src/libsysprof-ui/sysprof-ui-private.h
+++ b/src/libsysprof-ui/sysprof-ui-private.h
@@ -21,7 +21,9 @@
 #pragma once
 
 #include "sysprof-callgraph-view.h"
+#include "sysprof-display.h"
 #include "sysprof-marks-view.h"
+#include "sysprof-profiler-assistant.h"
 #include "sysprof-visualizer-view.h"
 
 G_BEGIN_DECLS
@@ -36,18 +38,20 @@ typedef struct
   guint64  avg_count;
 } SysprofMarkStat;
 
-SysprofMarkStat *_sysprof_mark_stat_new                   (const gchar           *name);
-void             _sysprof_mark_stat_free                  (SysprofMarkStat       *self);
-void             _sysprof_marks_view_set_hadjustment      (SysprofMarksView      *self,
-                                                           GtkAdjustment         *hadjustment);
-void             _sysprof_visualizer_view_set_hadjustment (SysprofVisualizerView *self,
-                                                           GtkAdjustment         *hadjustment);
-void             _sysprof_rounded_rectangle               (cairo_t               *cr,
-                                                           const GdkRectangle    *rect,
-                                                           gint                   x_radius,
-                                                           gint                   y_radius);
-gchar           *_sysprof_format_duration                 (gint64                 duration);
-void             _sysprof_callgraph_view_set_failed       (SysprofCallgraphView  *self);
+SysprofMarkStat *_sysprof_mark_stat_new                   (const gchar              *name);
+void             _sysprof_mark_stat_free                  (SysprofMarkStat          *self);
+void             _sysprof_marks_view_set_hadjustment      (SysprofMarksView         *self,
+                                                           GtkAdjustment            *hadjustment);
+void             _sysprof_visualizer_view_set_hadjustment (SysprofVisualizerView    *self,
+                                                           GtkAdjustment            *hadjustment);
+void             _sysprof_rounded_rectangle               (cairo_t                  *cr,
+                                                           const GdkRectangle       *rect,
+                                                           gint                      x_radius,
+                                                           gint                      y_radius);
+gchar           *_sysprof_format_duration                 (gint64                    duration);
+void             _sysprof_callgraph_view_set_failed       (SysprofCallgraphView     *self);
+void             _sysprof_display_focus_record            (SysprofDisplay           *self);
+void             _sysprof_profiler_assistant_focus_record (SysprofProfilerAssistant *self);
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofMarkStat, _sysprof_mark_stat_free)
 


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