mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-ui: add lateral movements with keyboard
This commit is contained in:
@ -51,6 +51,48 @@ static GParamSpec *properties [N_PROPS];
|
|||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (SysprofMarksView, sysprof_marks_view, GTK_TYPE_BIN)
|
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
|
static void
|
||||||
sysprof_marks_view_selection_changed_cb (SysprofMarksView *self,
|
sysprof_marks_view_selection_changed_cb (SysprofMarksView *self,
|
||||||
GtkTreeSelection *selection)
|
GtkTreeSelection *selection)
|
||||||
@ -192,6 +234,12 @@ sysprof_marks_view_init (SysprofMarksView *self)
|
|||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (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),
|
g_signal_connect_object (gtk_tree_view_get_selection (priv->tree_view),
|
||||||
"changed",
|
"changed",
|
||||||
G_CALLBACK (sysprof_marks_view_selection_changed_cb),
|
G_CALLBACK (sysprof_marks_view_selection_changed_cb),
|
||||||
|
|||||||
@ -144,5 +144,7 @@
|
|||||||
</child>
|
</child>
|
||||||
</template>
|
</template>
|
||||||
<object class="SysprofZoomManager" id="zoom_manager"/>
|
<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>
|
</interface>
|
||||||
|
|||||||
Reference in New Issue
Block a user