Skip to content

Commit 05d4726

Browse files
committed
gtk4 compile
1 parent 8dd05bf commit 05d4726

40 files changed

+1388
-295
lines changed

DefineOptions.cmake

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
option(USE_CAMERA_SUPPORT "Detect and use camera support if available." ON)
2-
option(USE_COLORD "Enable colord support" ON)
3-
option(USE_MAP "Build Map View parts" ON)
4-
option(USE_LUA "Build lua scripting support" ON)
1+
option(USE_CAMERA_SUPPORT "Detect and use camera support if available." OFF)
2+
option(USE_COLORD "Enable colord support" OFF)
3+
option(USE_MAP "Build Map View parts" OFF)
4+
option(USE_LUA "Build lua scripting support" OFF)
55
option(DONT_USE_INTERNAL_LUA "Never fall back to the intree copy of lua" ON)
6-
option(USE_KWALLET "Build kwallet password storage back-end" ON)
7-
option(USE_LIBSECRET "Build libsecret password storage back-end" ON)
6+
option(USE_KWALLET "Build kwallet password storage back-end" OFF)
7+
option(USE_LIBSECRET "Build libsecret password storage back-end" OFF)
88
option(USE_UNITY "Use libunity to report progress in the launcher" OFF)
99
option(USE_OPENMP "Use OpenMP threading support." ON)
1010
option(USE_OPENCL "Use OpenCL support." ON)
11-
option(USE_GRAPHICSMAGICK "Use GraphicsMagick library for image import." ON)
11+
option(USE_GRAPHICSMAGICK "Use GraphicsMagick library for image import." OFF)
1212
option(USE_IMAGEMAGICK "Use ImageMagick library for image import." OFF)
1313
option(USE_DARKTABLE_PROFILING OFF)
1414
option(CUSTOM_CFLAGS "Don't override compiler optimization flags." OFF)
1515
option(BINARY_PACKAGE_BUILD "Sets march optimization to generic" OFF)
1616
option(USE_XMLLINT "Run xmllint to test if darktableconfig.xml is valid" ON)
17-
option(USE_PORTMIDI "Enable MIDI device support using PortMidi" ON)
17+
option(USE_PORTMIDI "Enable MIDI device support using PortMidi" OFF)
1818
option(USE_OPENJPEG "Enable JPEG 2000 support" ON)
1919
option(USE_JXL "Enable JPEG XL support" ON)
2020
option(USE_WEBP "Enable WebP support" ON)
@@ -26,17 +26,17 @@ option(USE_LIBRAW "Enable LibRaw support" ON)
2626
option(DONT_USE_INTERNAL_LIBRAW "If possible, use system instead of intree copy of LibRaw" OFF)
2727
option(BUILD_CMSTEST "Build a test program to check your system's color management setup" ON)
2828
option(USE_OPENEXR "Enable OpenEXR support" ON)
29-
option(BUILD_PRINT "Build the print module" ON)
29+
option(BUILD_PRINT "Build the print module" OFF)
3030
option(BUILD_RS_IDENTIFY "Build the darktable-rs-identify debug aid" ON)
3131
option(BUILD_SSE2_CODEPATHS "(EXPERIMENTAL OPTION, DO NOT DISABLE) Building SSE2-optimized codepaths" ON)
3232
option(VALIDATE_APPDATA_FILE "Use appstream-util (if found) to validate the .appdata file" OFF)
3333
option(BUILD_MSYS2_INSTALL "Build an MSYS2 version of the install, aka for Windows platform, but without dependency installs" OFF)
3434
option(BUILD_NOISE_TOOLS "Build tools for generating noise profiles" OFF)
3535
option(BUILD_CURVE_TOOLS "Build tools for generating base and tone curves" OFF)
36-
option(USE_GMIC "Use G'MIC image processing framework." ON)
36+
option(USE_GMIC "Use G'MIC image processing framework." OFF)
3737
option(USE_ICU "Use ICU - International Components for Unicode." ON)
3838
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF)
39-
option(USE_SDL2 "Enable SDL2 support" ON)
39+
option(USE_SDL2 "Enable SDL2 support" OFF)
4040

4141
if (USE_OPENCL)
4242
option(TESTBUILD_OPENCL_PROGRAMS "Test-compile OpenCL programs (needs LLVM and Clang 7+)" ON)

cmake/modules/FindGTK4.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake_minimum_required(VERSION 3.18)
2+
3+
find_package(PkgConfig REQUIRED)
4+
pkg_check_modules(GTK4 REQUIRED IMPORTED_TARGET gtk4)

src/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ include_directories(SYSTEM ${Glib_INCLUDE_DIRS})
293293
list(APPEND LIBS ${Glib_LIBRARIES})
294294

295295
# GTK3 pulls in ATK, GDK, GDK-PIXBUF, CAIRO, GLIB, PANGO
296-
find_package(GTK3 3.24.15 REQUIRED)
297-
add_definitions("-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_24")
298-
#add_definitions("-DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_MIN_REQUIRED")
299-
include_directories(SYSTEM ${GTK3_INCLUDE_DIRS})
300-
list(APPEND LIBS ${GTK3_LIBRARIES})
296+
find_package(GTK4 4.8.3 REQUIRED)
297+
add_definitions("-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_4_0")
298+
add_definitions("-DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_4_18")
299+
include_directories(SYSTEM ${GTK4_INCLUDE_DIRS})
300+
list(APPEND LIBS ${GTK4_LIBRARIES})
301301

302302
# Check for libxml2 / broken cmake module can't be included in the foreach() below
303303
find_package(LibXml2 2.6 REQUIRED)

src/bauhaus/bauhaus.c

Lines changed: 68 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@
2323
#include "control/conf.h"
2424
#include "develop/develop.h"
2525
#include "develop/imageop.h"
26+
#include "dtgtk/drawingarea.h"
2627
#include "gui/accelerators.h"
2728
#include "gui/color_picker_proxy.h"
2829
#include "gui/gtk.h"
2930
#ifdef GDK_WINDOWING_QUARTZ
3031
#include "osx/osx.h"
3132
#endif
32-
#ifdef GDK_WINDOWING_WAYLAND
33-
#include <gdk/gdkwayland.h>
34-
#endif
3533

3634
#include <strings.h>
3735

@@ -766,7 +764,7 @@ static void _widget_finalize(GObject *widget)
766764
void dt_bauhaus_load_theme()
767765
{
768766
GtkWidget *root_window = dt_ui_main_window(darktable.gui->ui);
769-
GtkStyleContext *ctx = gtk_style_context_new();
767+
GtkStyleContext *ctx = gtk_widget_get_style_context(root_window);
770768
GtkWidgetPath *path = gtk_widget_path_new();
771769
const int pos = gtk_widget_path_append_type(path, GTK_TYPE_WIDGET);
772770
gtk_widget_path_iter_add_class(path, pos, "dt_bauhaus");
@@ -1128,7 +1126,7 @@ gchar *dt_bauhaus_widget_get_tooltip_markup(GtkWidget *widget,
11281126
&& DT_IS_BAUHAUS_WIDGET(widget)
11291127
&& DT_BAUHAUS_WIDGET(widget)->tooltip
11301128
? g_markup_escape_text(DT_BAUHAUS_WIDGET(widget)->tooltip, -1)
1131-
: gtk_widget_get_tooltip_markup(widget);
1129+
: g_strdup(gtk_widget_get_tooltip_markup(widget));
11321130
if(!darktable.control->mapping_widget
11331131
&& dt_bauhaus_widget_get_type(widget) == DT_BAUHAUS_SLIDER)
11341132
{
@@ -2606,11 +2604,17 @@ static gboolean _popup_draw(GtkWidget *widget,
26062604
return TRUE;
26072605
}
26082606

2609-
static gboolean _widget_draw(GtkWidget *widget,
2610-
cairo_t *cr)
2607+
2608+
static void _widget_snapshot(GtkWidget* widget,
2609+
GtkSnapshot* snapshot)
26112610
{
26122611
GtkAllocation allocation;
26132612
gtk_widget_get_allocation(widget, &allocation);
2613+
2614+
graphene_rect_t bounds;
2615+
graphene_rect_init(&bounds, 0, 0, allocation.width, allocation.height);
2616+
cairo_t* cr = gtk_snapshot_append_cairo(snapshot, &bounds);
2617+
26142618
dt_bauhaus_widget_t *w = DT_BAUHAUS_WIDGET(widget);
26152619
const int width = allocation.width, height = allocation.height;
26162620
GtkStyleContext *context = gtk_widget_get_style_context(widget);
@@ -2624,7 +2628,9 @@ static gboolean _widget_draw(GtkWidget *widget,
26242628
gtk_style_context_get_color(context, state, text_color);
26252629

26262630
gtk_style_context_get_color(context, state, fg_color);
2627-
gtk_style_context_get(context, state, "background-color", &bg_color, NULL);
2631+
// gtk_style_context_get(context, state, "background-color", &bg_color, NULL);
2632+
GdkRGBA color = {.red = 0.0f, .green = 0.0f, .blue = 0.0f, .alpha = 1.0f};
2633+
bg_color = gdk_rgba_copy(&color);
26282634

26292635
// translate to account for the widget spacing
26302636
const int h2 = height - w->margin.top - w->margin.bottom;
@@ -2759,8 +2765,6 @@ static gboolean _widget_draw(GtkWidget *widget,
27592765
gdk_rgba_free(text_color);
27602766
gdk_rgba_free(fg_color);
27612767
gdk_rgba_free(bg_color);
2762-
2763-
return TRUE;
27642768
}
27652769

27662770
static gint _natural_width(GtkWidget *widget,
@@ -2832,34 +2836,35 @@ static gint _natural_width(GtkWidget *widget,
28322836
return natural_size;
28332837
}
28342838

2835-
static void _widget_get_preferred_width(GtkWidget *widget,
2836-
gint *minimum_width,
2837-
gint *natural_width)
2838-
{
2839-
dt_bauhaus_widget_t *w = (dt_bauhaus_widget_t *)widget;
2840-
_margins_retrieve(w);
2841-
2842-
*natural_width = _natural_width(widget, FALSE)
2843-
+ w->margin.left + w->margin.right + w->padding.left + w->padding.right;
2844-
}
2845-
2846-
static void _widget_get_preferred_height(GtkWidget *widget,
2847-
gint *minimum_height,
2848-
gint *natural_height)
2839+
static void _widget_measure(GtkWidget* widget,
2840+
GtkOrientation orientation,
2841+
int for_size,
2842+
int* minimum,
2843+
int* natural,
2844+
int* minimum_baseline,
2845+
int* natural_baseline)
28492846
{
28502847
dt_bauhaus_widget_t *w = (dt_bauhaus_widget_t *)widget;
28512848
_margins_retrieve(w);
2852-
2853-
*minimum_height = w->margin.top + w->margin.bottom + w->padding.top + w->padding.bottom
2854-
+ darktable.bauhaus->line_height;
2855-
if(w->type == DT_BAUHAUS_SLIDER)
2849+
if(orientation == GTK_ORIENTATION_HORIZONTAL)
28562850
{
2857-
// the lower thing to draw is indicator. See _draw_baseline for compute details
2858-
*minimum_height += INNER_PADDING
2859-
+ darktable.bauhaus->baseline_size + 1.5f * darktable.bauhaus->border_width;
2851+
2852+
*natural = _natural_width(widget, FALSE)
2853+
+ w->margin.left + w->margin.right + w->padding.left + w->padding.right;
28602854
}
2855+
else
2856+
{
2857+
*minimum = w->margin.top + w->margin.bottom + w->padding.top + w->padding.bottom
2858+
+ darktable.bauhaus->line_height;
2859+
if(w->type == DT_BAUHAUS_SLIDER)
2860+
{
2861+
// the lower thing to draw is indicator. See _draw_baseline for compute details
2862+
*minimum += INNER_PADDING
2863+
+ darktable.bauhaus->baseline_size + 1.5f * darktable.bauhaus->border_width;
2864+
}
28612865

2862-
*natural_height = *minimum_height;
2866+
*natural = *minimum;
2867+
}
28632868
}
28642869

28652870
static void _popup_hide()
@@ -2886,6 +2891,7 @@ static void _popup_hide()
28862891

28872892
static void _popup_show(GtkWidget *widget)
28882893
{
2894+
return; // GTK4
28892895
dt_bauhaus_widget_t *w = DT_BAUHAUS_WIDGET(widget);
28902896
dt_bauhaus_t *bh = darktable.bauhaus;
28912897
dt_bauhaus_popup_t *pop = &bh->popup;
@@ -3064,19 +3070,21 @@ static void _slider_add_step(GtkWidget *widget,
30643070
dt_bauhaus_slider_set(widget, CLAMP(value + delta, d->min, d->max));
30653071
}
30663072

3067-
static gboolean _widget_scroll(GtkWidget *widget,
3068-
GdkEventScroll *event)
3073+
static gboolean _widget_scroll(GtkEventControllerScroll* self,
3074+
gdouble dx,
3075+
gdouble dy,
3076+
GtkWidget *widget)
30693077
{
3070-
if(dt_gui_ignore_scroll(event)) return FALSE;
3078+
// GTK4
3079+
// if(dt_gui_ignore_scroll(event)) return FALSE;
30713080

3072-
// handle speed adjustment in mapping mode in dispatcher
3073-
if(darktable.control->mapping_widget)
3074-
return dt_shortcut_dispatcher(widget, (GdkEvent*)event, NULL);
3081+
// // handle speed adjustment in mapping mode in dispatcher
3082+
// if(darktable.control->mapping_widget)
3083+
// return dt_shortcut_dispatcher(widget, (GdkEvent*)event, NULL);
30753084

30763085
gtk_widget_grab_focus(widget);
30773086

3078-
int delta_y = 0;
3079-
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
3087+
int delta_y = dx + dy;
30803088
{
30813089
if(delta_y == 0) return TRUE;
30823090

@@ -3085,15 +3093,17 @@ static gboolean _widget_scroll(GtkWidget *widget,
30853093

30863094
if(w->type == DT_BAUHAUS_SLIDER)
30873095
{
3088-
gboolean force = darktable.control->element == DT_ACTION_ELEMENT_FORCE
3089-
&& event->window == gtk_widget_get_window(widget);
3090-
if(force && dt_modifier_is(event->state, GDK_SHIFT_MASK | GDK_CONTROL_MASK))
3091-
{
3092-
_slider_zoom_range(w, delta_y);
3093-
_slider_zoom_toast(w);
3094-
}
3095-
else
3096-
_slider_add_step(widget, - delta_y, event->state, force);
3096+
// GTK4
3097+
// gboolean force = darktable.control->element == DT_ACTION_ELEMENT_FORCE
3098+
// && event->window == gtk_widget_get_window(widget);
3099+
// if(force && dt_modifier_is(event->state, GDK_SHIFT_MASK | GDK_CONTROL_MASK))
3100+
// {
3101+
// _slider_zoom_range(w, delta_y);
3102+
// _slider_zoom_toast(w);
3103+
// }
3104+
// else
3105+
// _slider_add_step(widget, - delta_y, event->state, force);
3106+
_slider_add_step(widget, - delta_y, gtk_event_controller_get_current_event_state(GTK_EVENT_CONTROLLER(self)), FALSE);
30973107
}
30983108
else
30993109
_combobox_next_sensitive(w, delta_y, 0, FALSE);
@@ -3556,7 +3566,7 @@ static void _widget_button_press(GtkGestureSingle *gesture,
35563566
}
35573567
else if(button == GDK_BUTTON_SECONDARY || w->type == DT_BAUHAUS_COMBOBOX)
35583568
{
3559-
bh->opentime = gdk_event_get_time(gtk_get_current_event());
3569+
bh->opentime = gtk_event_controller_get_current_event_time(GTK_EVENT_CONTROLLER(gesture));
35603570
bh->mouse_x = x;
35613571
bh->mouse_y = y;
35623572
_popup_show(widget);
@@ -3669,20 +3679,17 @@ static void dt_bh_class_init(DtBauhausWidgetClass *class)
36693679
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
36703680

36713681
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
3672-
widget_class->draw = _widget_draw;
3673-
// widget_class->snapshot = _widget_snapshot;
3674-
widget_class->scroll_event = _widget_scroll;
3675-
widget_class->key_press_event = _widget_key_press;
3676-
widget_class->get_preferred_width = _widget_get_preferred_width;
3677-
widget_class->get_preferred_height = _widget_get_preferred_height;
3678-
// widget_class->measure = _widget_measure;
3682+
widget_class->snapshot = _widget_snapshot;
3683+
// widget_class->scroll_event = _widget_scroll;
3684+
// widget_class->key_press_event = _widget_key_press;
3685+
widget_class->measure = _widget_measure;
36793686
G_OBJECT_CLASS(class)->finalize = _widget_finalize;
36803687

36813688
// for histogram -> exposure proxy
36823689
bh->press = _widget_button_press;
36833690
bh->release = _widget_button_release;
36843691
bh->motion = _widget_motion;
3685-
bh->scroll = _widget_scroll;
3692+
// bh->scroll = _widget_scroll; GTK4
36863693
}
36873694

36883695
static void dt_bh_init(DtBauhausWidget *w)
@@ -3707,9 +3714,9 @@ static void dt_bh_init(DtBauhausWidget *w)
37073714

37083715
dt_gui_connect_motion(w, _widget_motion, _widget_enter, _widget_leave, widget);
37093716

3710-
// GtkEventController *controller = gtk_event_controller_scroll_new(GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES | GTK_EVENT_CONTROLLER_SCROLL_DISCRETE);
3711-
// gtk_widget_add_controller(GTK_WIDGET(w), GTK_EVENT_CONTROLLER(controller));
3712-
// g_signal_connect(controller, "scroll", G_CALLBACK(_widget_scroll), w);
3717+
GtkEventController *controller = gtk_event_controller_scroll_new(GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES | GTK_EVENT_CONTROLLER_SCROLL_DISCRETE);
3718+
gtk_widget_add_controller(GTK_WIDGET(w), GTK_EVENT_CONTROLLER(controller));
3719+
g_signal_connect(controller, "scroll", G_CALLBACK(_widget_scroll), w);
37133720

37143721
gtk_widget_set_can_focus(widget, TRUE);
37153722
dt_gui_add_class(widget, "dt_bauhaus");

0 commit comments

Comments
 (0)