[sysprof/wip/chergert/sysprof-3] libsysprof-ui: add lateral movements with keyboard
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof-ui: add lateral movements with keyboard
- Date: Thu, 16 May 2019 02:07:45 +0000 (UTC)
commit bb5e16983add9de2fc6a1d4b75ddc99af25990c6
Author: Christian Hergert <chergert redhat com>
Date: Wed May 15 19:07:37 2019 -0700
libsysprof-ui: add lateral movements with keyboard
src/libsysprof-ui/sysprof-marks-view.c | 48 ++++++++++++++++++++++++++++
src/libsysprof-ui/ui/sysprof-capture-view.ui | 4 ++-
2 files changed, 51 insertions(+), 1 deletion(-)
---
diff --git a/src/libsysprof-ui/sysprof-marks-view.c b/src/libsysprof-ui/sysprof-marks-view.c
index ab11029..1e720d1 100644
--- a/src/libsysprof-ui/sysprof-marks-view.c
+++ b/src/libsysprof-ui/sysprof-marks-view.c
@@ -51,6 +51,48 @@ static GParamSpec *properties [N_PROPS];
G_DEFINE_TYPE_WITH_PRIVATE (SysprofMarksView, sysprof_marks_view, GTK_TYPE_BIN)
+static gboolean
+sysprof_marks_view_tree_view_key_press_event_cb (SysprofMarksView *self,
+ const GdkEventKey *key,
+ GtkTreeView *tree_view)
+{
+ SysprofMarksViewPrivate *priv = sysprof_marks_view_get_instance_private (self);
+ gint dir = 0;
+
+ g_assert (SYSPROF_MARKS_VIEW (self));
+ g_assert (key != NULL);
+
+ if (key->state == 0)
+ {
+ switch (key->keyval)
+ {
+ case GDK_KEY_Left:
+ dir = -1;
+ break;
+
+ case GDK_KEY_Right:
+ dir = 1;
+ break;
+
+ default:
+ break;
+ }
+
+ if (dir)
+ {
+ GtkAdjustment *adj = gtk_scrolled_window_get_hadjustment (priv->scroller);
+ gdouble step = gtk_adjustment_get_step_increment (adj);
+ gdouble val = CLAMP (gtk_adjustment_get_value (adj) + (step * dir),
+ gtk_adjustment_get_lower (adj),
+ gtk_adjustment_get_upper (adj));
+ gtk_adjustment_set_value (adj, val);
+ return GDK_EVENT_STOP;
+ }
+ }
+
+ return GDK_EVENT_PROPAGATE;
+}
+
static void
sysprof_marks_view_selection_changed_cb (SysprofMarksView *self,
GtkTreeSelection *selection)
@@ -192,6 +234,12 @@ sysprof_marks_view_init (SysprofMarksView *self)
gtk_widget_init_template (GTK_WIDGET (self));
+ g_signal_connect_object (priv->tree_view,
+ "key-press-event",
+ G_CALLBACK (sysprof_marks_view_tree_view_key_press_event_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
g_signal_connect_object (gtk_tree_view_get_selection (priv->tree_view),
"changed",
G_CALLBACK (sysprof_marks_view_selection_changed_cb),
diff --git a/src/libsysprof-ui/ui/sysprof-capture-view.ui b/src/libsysprof-ui/ui/sysprof-capture-view.ui
index 09c7cb8..6e862ed 100644
--- a/src/libsysprof-ui/ui/sysprof-capture-view.ui
+++ b/src/libsysprof-ui/ui/sysprof-capture-view.ui
@@ -144,5 +144,7 @@
</child>
</template>
<object class="SysprofZoomManager" id="zoom_manager"/>
- <object class="GtkAdjustment" id="time_adj"/>
+ <object class="GtkAdjustment" id="time_adj">
+ <property name="step-increment">20</property>
+ </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]