@@ -3595,28 +3595,26 @@ static void _notebook_size_callback(GtkNotebook *notebook,
35953595// GTK_STATE_FLAG_PRELIGHT does not seem to get set on the label on
35963596// hover so state-flags-changed cannot update
35973597// darktable.control->element for shortcut mapping
3598- static gboolean _notebook_motion_notify_callback (GtkWidget * widget ,
3599- const GdkEventMotion * event ,
3600- gpointer user_data )
3598+ static void _notebook_motion_notify_callback (GtkEventControllerMotion * controller ,
3599+ double x ,
3600+ double y ,
3601+ GtkNotebook * notebook )
36013602{
36023603 GtkAllocation notebook_alloc , label_alloc ;
3603- gtk_widget_get_allocation (widget , & notebook_alloc );
3604+ gtk_widget_get_allocation (GTK_WIDGET ( notebook ) , & notebook_alloc );
36043605
3605- GtkNotebook * notebook = GTK_NOTEBOOK (widget );
36063606 const int n = gtk_notebook_get_n_pages (notebook );
36073607 for (int i = 0 ; i < n ; i ++ )
36083608 {
36093609 gtk_widget_get_allocation (gtk_notebook_get_tab_label
36103610 (notebook , gtk_notebook_get_nth_page (notebook , i )),
36113611 & label_alloc );
3612- if (event -> x + notebook_alloc .x < label_alloc .x + label_alloc .width )
3612+ if (x + notebook_alloc .x < label_alloc .x + label_alloc .width )
36133613 {
36143614 darktable .control -> element = i ;
36153615 break ;
36163616 }
36173617 }
3618-
3619- return FALSE;
36203618}
36213619
36223620static float _action_process_tabs (const gpointer target ,
@@ -3739,7 +3737,7 @@ static gboolean _notebook_button_press_callback(GtkNotebook *notebook,
37393737 const GdkEventButton * event ,
37403738 gpointer user_data )
37413739{
3742- if (event -> type == GDK_2BUTTON_PRESS )
3740+ if (event -> type == GDK_2BUTTON_PRESS && gtk_get_event_widget (( GdkEvent * ) event ) == GTK_WIDGET ( notebook ) )
37433741 _reset_all_bauhaus (notebook , gtk_notebook_get_nth_page (notebook , gtk_notebook_get_current_page (notebook )));
37443742
37453743 return FALSE;
@@ -3770,8 +3768,7 @@ GtkWidget *dt_ui_notebook_page(GtkNotebook *notebook,
37703768 {
37713769 g_signal_connect (G_OBJECT (notebook ), "size-allocate" ,
37723770 G_CALLBACK (_notebook_size_callback ), NULL );
3773- g_signal_connect (G_OBJECT (notebook ), "motion-notify-event" ,
3774- G_CALLBACK (_notebook_motion_notify_callback ), NULL );
3771+ dt_gui_connect_motion (notebook , _notebook_motion_notify_callback , NULL , NULL , notebook );
37753772 g_signal_connect (G_OBJECT (notebook ), "scroll-event" ,
37763773 G_CALLBACK (_notebook_scroll_callback ), NULL );
37773774 g_signal_connect (G_OBJECT (notebook ), "button-press-event" ,
@@ -4396,6 +4393,43 @@ gboolean dt_gui_long_click(const guint second,
43964393 return second - delay > first ;
43974394}
43984395
4396+ GtkGestureSingle * (dt_gui_connect_click )(GtkWidget * widget ,
4397+ GCallback pressed ,
4398+ GCallback released ,
4399+ gpointer data )
4400+ {
4401+ GtkGesture * gesture = gtk_gesture_multi_press_new (widget );
4402+ g_object_weak_ref (G_OBJECT (widget ), (GWeakNotify ) g_object_unref , gesture );
4403+ // GTK4 GtkGesture *gesture = gtk_gesture_click_new();
4404+ // gtk_widget_add_controller(widget, GTK_EVENT_CONTROLLER(gesture));
4405+
4406+ if (pressed ) g_signal_connect (gesture , "pressed" , pressed , data );
4407+ if (released ) g_signal_connect (gesture , "released" , released , data );
4408+
4409+ return (GtkGestureSingle * )gesture ;
4410+ }
4411+
4412+ GtkEventController * (dt_gui_connect_motion )(GtkWidget * widget ,
4413+ GCallback motion ,
4414+ GCallback enter ,
4415+ GCallback leave ,
4416+ gpointer data )
4417+ {
4418+ GtkEventController * controller = gtk_event_controller_motion_new (widget );
4419+ gtk_event_controller_set_propagation_phase (controller , GTK_PHASE_TARGET );
4420+ g_object_weak_ref (G_OBJECT (widget ), (GWeakNotify ) g_object_unref , controller );
4421+ // GTK4 gtk_widget_add_controller(widget, GTK_EVENT_CONTROLLER(controller));
4422+
4423+ gtk_widget_add_events (widget , GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK ); // still needed for now by _main_do_event_keymap
4424+
4425+ if (motion ) g_signal_connect (controller , "motion" , motion , data );
4426+ if (enter ) g_signal_connect (controller , "enter" , enter , data );
4427+ if (leave ) g_signal_connect (controller , "leave" , leave , data );
4428+
4429+ return controller ;
4430+ }
4431+
4432+
43994433static int busy_nest_count = 0 ;
44004434static GdkCursor * busy_prev_cursor = NULL ;
44014435
@@ -4498,7 +4532,7 @@ GtkWidget *(dt_gui_box_add)(const char *file, const int line, const char *functi
44984532 else if (gtk_widget_get_parent (* list ))
44994533 dt_print (DT_DEBUG_ALWAYS , "%s:%d %s: trying to add widget that already has a parent to box (#%d)" , file , line , function , i );
45004534 else
4501- gtk_container_add (GTK_CONTAINER (box ), GTK_WIDGET (* list ));
4535+ gtk_container_add (GTK_CONTAINER (box ), GTK_WIDGET (* list )); // GTK4 gtk_box_append
45024536 }
45034537
45044538 return GTK_WIDGET (box );
0 commit comments