mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
tools: test expand/collapse with GtkEventControllerKey
This ensures that we can maintain our expand/collapse keybindings that we have with GtkTreeView using GtkListView.
This commit is contained in:
@ -38,11 +38,36 @@ typedef struct _Augment
|
|||||||
guint32 total;
|
guint32 total;
|
||||||
} Augment;
|
} Augment;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
on_key_pressed_cb (GtkEventControllerKey *key,
|
||||||
|
guint keyval,
|
||||||
|
guint keycode,
|
||||||
|
GdkModifierType state,
|
||||||
|
GtkTreeExpander *expander)
|
||||||
|
{
|
||||||
|
GtkTreeListRow *row = gtk_tree_expander_get_list_row (expander);
|
||||||
|
|
||||||
|
if (keyval == GDK_KEY_Right)
|
||||||
|
{
|
||||||
|
gtk_tree_list_row_set_expanded (row, TRUE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyval == GDK_KEY_Left)
|
||||||
|
{
|
||||||
|
gtk_tree_list_row_set_expanded (row, FALSE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
function_setup (GtkSignalListItemFactory *factory,
|
function_setup (GtkSignalListItemFactory *factory,
|
||||||
GtkListItem *list_item,
|
GtkListItem *list_item,
|
||||||
SysprofCallgraph *callgraph)
|
SysprofCallgraph *callgraph)
|
||||||
{
|
{
|
||||||
|
GtkEventController *controller;
|
||||||
GtkWidget *expander;
|
GtkWidget *expander;
|
||||||
GtkWidget *text;
|
GtkWidget *text;
|
||||||
|
|
||||||
@ -56,6 +81,13 @@ function_setup (GtkSignalListItemFactory *factory,
|
|||||||
NULL);
|
NULL);
|
||||||
gtk_tree_expander_set_child (GTK_TREE_EXPANDER (expander), text);
|
gtk_tree_expander_set_child (GTK_TREE_EXPANDER (expander), text);
|
||||||
gtk_list_item_set_child (list_item, expander);
|
gtk_list_item_set_child (list_item, expander);
|
||||||
|
|
||||||
|
controller = gtk_event_controller_key_new ();
|
||||||
|
g_signal_connect (controller,
|
||||||
|
"key-pressed",
|
||||||
|
G_CALLBACK (on_key_pressed_cb),
|
||||||
|
expander);
|
||||||
|
gtk_widget_add_controller (GTK_WIDGET (expander), controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user