summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2019-07-29 09:43:15 -0700
committerJohn Stebbins <[email protected]>2019-07-29 09:43:15 -0700
commita848a396fd3beb1fe8f0610baff8f5dfe838fe4f (patch)
tree985edf79843b3661f6df78e96fd18f1cd87bc813 /gtk
parentf4182ee6df9c38a229eb2c1e507dc58fdf037cea (diff)
LinGui: add queue row delete key handling for gtk4
Event handling in gtk4 is substantially different than gtk3. This restores handling of delete key on queue rows in gtk4 port
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/queuehandler.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index c5885180a..8d522075d 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -56,6 +56,11 @@ G_MODULE_EXPORT void
queue_drag_data_get_cb(GtkWidget * widget, GdkDrag * context,
GtkSelectionData * selection_data,
signal_user_data_t * ud);
+
+G_MODULE_EXPORT gboolean
+queue_row_key_cb(GtkEventControllerKey * keycon, guint keyval,
+ guint keycode, GdkModifierType state,
+ signal_user_data_t * ud);
#else
G_MODULE_EXPORT void
queue_drag_begin_cb(GtkWidget * widget, GdkDragContext * context,
@@ -1523,6 +1528,13 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *queueDict)
g_signal_connect(ebox, "drag-end", G_CALLBACK(queue_drag_end_cb), NULL);
g_signal_connect(ebox, "drag-data-get",
G_CALLBACK(queue_drag_data_get_cb), NULL);
+
+#if GTK_CHECK_VERSION(3, 90, 0)
+ // connect key event controller to capture "delete" key press on row
+ GtkEventController * econ = gtk_event_controller_key_new();
+ gtk_widget_add_controller(row, econ);
+ g_signal_connect(econ, "key-pressed", G_CALLBACK(queue_row_key_cb), ud);
+#endif
}
static void
@@ -2475,6 +2487,32 @@ queue_key_press_cb(
return FALSE;
}
+G_MODULE_EXPORT gboolean
+queue_row_key_cb(
+ GtkEventControllerKey * keycon,
+ guint keyval,
+ guint keycode,
+ GdkModifierType state,
+ signal_user_data_t * ud)
+{
+ GtkListBoxRow * row;
+ gint index;
+
+ if (keyval != GDK_KEY_Delete)
+ return FALSE;
+
+ row = GTK_LIST_BOX_ROW(gtk_event_controller_get_widget(
+ GTK_EVENT_CONTROLLER(keycon)));
+ if (row != NULL)
+ {
+ index = gtk_list_box_row_get_index(row);
+ ghb_queue_remove_row_internal(ud, index);
+ ghb_save_queue(ud->queue);
+ return TRUE;
+ }
+ return FALSE;
+}
+
G_MODULE_EXPORT void
show_queue_action_cb(GSimpleAction *action, GVariant *value,
signal_user_data_t *ud)