Skip to content

gtk4-prep: stop using GtkButton image API (#15920)#21541

Open
Arecsu wants to merge 1 commit into
darktable-org:masterfrom
Arecsu:gtk4/no-button-image-api
Open

gtk4-prep: stop using GtkButton image API (#15920)#21541
Arecsu wants to merge 1 commit into
darktable-org:masterfrom
Arecsu:gtk4/no-button-image-api

Conversation

@Arecsu

@Arecsu Arecsu commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Replace:

  • gtk_button_set_image()
  • gtk_button_set_always_show_image()
  • gtk_button_set_image_position()
  • gtk_button_get_image()
  • gtk_button_get_image_position()

with manual GtkBox packing for the Lua button widget. These are all removed in GTK4.

Guard against gtk_button_set_label() replacing our box (GTK3 creates a new label child and destroys the custom child), show newly replaced images, and force relayout after orientation changes.

Also refactored the code to clean things up.

I used this lua script to test it, no errors. Even solved some pre existent assertion errors:

local dt = require "darktable"
local logo = "./build/share/darktable/pixmaps/dt_logo_128x128.png"
local cb = function() print("ok") end
local b1 = dt.new_widget("button"){label="a", image=logo}
b1.image = logo  -- set same image again
local b2 = dt.new_widget("button"){label="b"}
b2.image = logo
b2.label = "b2"  -- set label after image
b2.image_position = "right"
local b3 = dt.new_widget("button"){image=logo, label="c"}
b3.image_position = "left"
b3.image_position = "top"  -- change position twice
local b4 = dt.new_widget("button"){label="", image=logo}
dt.register_lib("test_final","test final",true,false,{[dt.gui.views.lighttable]={"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",5}},
  dt.new_widget("box"){orientation="vertical",
    dt.new_widget("button"){label="no image", clicked_callback=cb},
    dt.new_widget("button"){label="left", image=logo, image_position="left", clicked_callback=cb},
    dt.new_widget("button"){label="right", image=logo, image_position="right", clicked_callback=cb},
    dt.new_widget("button"){label="top", image=logo, image_position="top", clicked_callback=cb},
    dt.new_widget("button"){label="bottom", image=logo, image_position="bottom", clicked_callback=cb},
    dt.new_widget("button"){image=logo, clicked_callback=cb},
    b1, b2, b3, b4
  }
)

Related: #15920 #20433

Replace:
- `gtk_button_set_image()`
- `gtk_button_set_always_show_image()`
- `gtk_button_set_image_position()`
- `gtk_button_get_image()`
- `gtk_button_get_image_position()`

with manual GtkBox packing for the Lua button widget. These are all
removed in GTK4.

Guard against `gtk_button_set_label()` replacing our box (GTK3
creates a new label child and destroys the custom child), show
newly replaced images, and force relayout after orientation changes.
@Arecsu Arecsu changed the title gtk4-prep: stop using GtkButton image API (#15920) gtk4-prep: stop using GtkButton image API (#15920) Jul 13, 2026
@ralfbrown ralfbrown added the gtk4 label Jul 14, 2026
@wpferguson

Copy link
Copy Markdown
Member

@Arecsu should the actual widget code such as dt_lua_button_get_widget_in_box, be in gui/dtgtk.c wthout the lua in the function name, and then just called from lua/wiodget/button.c?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants