Recently I wanted to test if my app is easily convertible to GTK4 from GTK3, but looks that there are a lot of problems with conversion.
I checked and found only a few entries from Gtk – 4.0: Migrating from GTK 3.x to GTK 4, so it is possible that I missed some.
I prepared some conversion tips for my project but not know if all things are proper, and errors which I couldn’t fix.
Errors
What happened to gtk4::WindowPosition ? - missing in gtk4-rs source
gtk4::main
and gtk4::main_quit
don’t exits, use ApplicationWindow
now?
resize
is missing, xlib is required now(not sure about api) - TODO I used this for fitting window size to content, maybe similar method exists?
run
is missing in Dialog - probably needs to implemented as closure
children
dialog no longer returns childrens, can’t find alternative version of this function
connect_key_release_event
and connect_button_release_event
in Button are missing
FileChooserDialog::with_buttons
is missing
connect_delete_event
missing in Window
set_relative_to
is missing in Popup (probably should exists but only for MenuButton widgets)
with_label_from_widget
missing in CheckButton
hide_on_delete
missing on Window
connect_clicked
missing on CheckButton
add
in Box, cannot add grid (append
will work?)
Refactor
show_all
method is missing - all widgets are visible by default so remove all occurrences of this - TODO Probably some usages of show_all should be changed to only show
Treepath no longer can be displayed with {}
set_select_function
don’t need to be boxed
buffer.text()
returns valid text, so match
can be removed around such statements
Replace
gtk::
with gtk4::
RadioButton
with CheckButton
, groups needs to be implemented manually
ButtonBox
with Box
use gtk4::prelude::*;
with use gtk4::prelude::*;use gtk4::prelude::*;use gtk::Inhibit;
- looks that now this isn’t in prelude, probably can be added also in GTK3
.value(
with .get(
- TreeModel - this will broke examples from below
scale_similarity_similar_images.get()
with scale_similarity_similar_images.value()
scale_similarity_similar_videos.get()
with scale_similarity_similar_videos.value()
.buffer().unwrap()
with .buffer()
- TextView always return valid thing
.path(&iter).unwrap()
with .path(&iter)
- Treemodel, looks that always return valid thing
model.path(¤t_iter).unwrap()
with model.path(¤t_iter)
as above
model.path(&next_iter).unwrap()
with model.path(&next_iter)
window_main.set_title("Czkawka")
with window_main.set_title(Some("Czkawka"))
- title can be empty