Repository: gtk-rs/gtk3-rs (language: rust)

Issue:
gtk::ImageBuilder::icon_size() should take a gtk::IconSize instead of i32



Discussion / hints:
Indeed! Unfortunately the GObject property has the wrong type, so the autogenerated code is also wrong.

This would need some changes in gir to be able to opt-out of builders for specific properties. And then that specific property could be manually implemented. CC @EPashkin @antoyo 
Why should it be a `IconSize`?
In GTK+, [it is not](https://developer.gnome.org/gtk3/stable/GtkImage.html#GtkImage--icon-size).
> Why should it be a `IconSize`?
> In GTK+, [it is not](https://developer.gnome.org/gtk3/stable/GtkImage.html#GtkImage--icon-size).

"Symbolic size to use for stock icon, icon set or named icon." says the docs. The symbolic size is exactly that, `GtkIconSize` :) The default value (4) is `GTK_ICON_SIZE_BUTTON`.

And it's a bug in GTK that it uses the wrong type for the property. Creating a MR for GTK4 now so it can at least be fixed there.
> And it's a bug in GTK that it uses the wrong type for the property. Creating a MR for GTK4 now so it can at least be fixed there.

Already fixed there, good
So, is there anyting to fix in gir?
Or would it be fixed automatically with gtk4?
Will be fixed in gtk4, but would be nice to work around for gtk3.

Fix patch:
diff --git a/atk/src/auto/versions.txt b/atk/src/auto/versions.txt
index a1ec65b08d29..4038c19eaaa6 100644
--- a/atk/src/auto/versions.txt
+++ b/atk/src/auto/versions.txt
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
-from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
+from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377)
diff --git a/atk/sys/versions.txt b/atk/sys/versions.txt
index a1ec65b08d29..4038c19eaaa6 100644
--- a/atk/sys/versions.txt
+++ b/atk/sys/versions.txt
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
-from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
+from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377)
diff --git a/gdk/src/auto/versions.txt b/gdk/src/auto/versions.txt
index a1ec65b08d29..4038c19eaaa6 100644
--- a/gdk/src/auto/versions.txt
+++ b/gdk/src/auto/versions.txt
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
-from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
+from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377)
diff --git a/gdk/sys/versions.txt b/gdk/sys/versions.txt
index a1ec65b08d29..4038c19eaaa6 100644
--- a/gdk/sys/versions.txt
+++ b/gdk/sys/versions.txt
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
-from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
+from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377)
diff --git a/gdkx11/src/auto/versions.txt b/gdkx11/src/auto/versions.txt
index a1ec65b08d29..4038c19eaaa6 100644
--- a/gdkx11/src/auto/versions.txt
+++ b/gdkx11/src/auto/versions.txt
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
-from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
+from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377)
diff --git a/gdkx11/sys/versions.txt b/gdkx11/sys/versions.txt
index a1ec65b08d29..4038c19eaaa6 100644
--- a/gdkx11/sys/versions.txt
+++ b/gdkx11/sys/versions.txt
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
-from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
+from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377)
diff --git a/gir-files b/gir-files
index 6088bb634a40..7d95377690e9 160000
--- a/gir-files
+++ b/gir-files
@@ -1,1 +1,1 @@
-Subproject commit 6088bb634a406402f308f01d2f33067951d5095b
+Subproject commit 7d95377690e9c3b75ee4d55483a4406f60e23929
diff --git a/gtk/src/auto/image.rs b/gtk/src/auto/image.rs
index bc7d305fb60b..bf529713b5a0 100644
--- a/gtk/src/auto/image.rs
+++ b/gtk/src/auto/image.rs
@@ -133,7 +133,7 @@ pub struct ImageBuilder {
     file: Option<String>,
     gicon: Option<gio::Icon>,
     icon_name: Option<String>,
-    icon_size: Option<i32>,
+    icon_size: Option<IconSize>,
     pixbuf: Option<gdk_pixbuf::Pixbuf>,
     pixbuf_animation: Option<gdk_pixbuf::PixbufAnimation>,
     pixel_size: Option<i32>,
@@ -328,7 +328,7 @@ impl ImageBuilder {
         self
     }
 
-    pub fn icon_size(mut self, icon_size: i32) -> Self {
+    pub fn icon_size(mut self, icon_size: IconSize) -> Self {
         self.icon_size = Some(icon_size);
         self
     }
@@ -592,10 +592,10 @@ pub trait ImageExt: 'static {
     fn set_icon_name(&self, icon_name: Option<&str>);
 
     #[doc(alias = "icon-size")]
-    fn icon_size(&self) -> i32;
+    fn icon_size(&self) -> IconSize;
 
     #[doc(alias = "icon-size")]
-    fn set_icon_size(&self, icon_size: i32);
+    fn set_icon_size(&self, icon_size: IconSize);
 
     fn set_pixbuf(&self, pixbuf: Option<&gdk_pixbuf::Pixbuf>);
 
@@ -823,9 +823,9 @@ impl<O: IsA<Image>> ImageExt for O {
         }
     }
 
-    fn icon_size(&self) -> i32 {
+    fn icon_size(&self) -> IconSize {
         unsafe {
-            let mut value = glib::Value::from_type(<i32 as StaticType>::static_type());
+            let mut value = glib::Value::from_type(<IconSize as StaticType>::static_type());
             glib::gobject_ffi::g_object_get_property(
                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
                 b"icon-size\0".as_ptr() as *const _,
@@ -837,7 +837,7 @@ impl<O: IsA<Image>> ImageExt for O {
         }
     }
 
-    fn set_icon_size(&self, icon_size: i32) {
+    fn set_icon_size(&self, icon_size: IconSize) {
         unsafe {
             glib::gobject_ffi::g_object_set_property(
                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
diff --git a/gtk/src/auto/stack_switcher.rs b/gtk/src/auto/stack_switcher.rs
index 00894fb5dfbf..380546c6b010 100644
--- a/gtk/src/auto/stack_switcher.rs
+++ b/gtk/src/auto/stack_switcher.rs
@@ -7,6 +7,9 @@ use crate::BaselinePosition;
 use crate::Box;
 use crate::Buildable;
 use crate::Container;
+#[cfg(any(feature = "v3_20", feature = "dox"))]
+#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
+use crate::IconSize;
 use crate::Orientable;
 use crate::Orientation;
 use crate::ResizeMode;
@@ -49,7 +52,7 @@ impl Default for StackSwitcher {
 pub struct StackSwitcherBuilder {
     #[cfg(any(feature = "v3_20", feature = "dox"))]
     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
-    icon_size: Option<i32>,
+    icon_size: Option<IconSize>,
     stack: Option<Stack>,
     baseline_position: Option<BaselinePosition>,
     homogeneous: Option<bool>,
@@ -232,7 +235,7 @@ impl StackSwitcherBuilder {
 
     #[cfg(any(feature = "v3_20", feature = "dox"))]
     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
-    pub fn icon_size(mut self, icon_size: i32) -> Self {
+    pub fn icon_size(mut self, icon_size: IconSize) -> Self {
         self.icon_size = Some(icon_size);
         self
     }
@@ -453,12 +456,12 @@ pub trait StackSwitcherExt: 'static {
     #[cfg(any(feature = "v3_20", feature = "dox"))]
     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
     #[doc(alias = "icon-size")]
-    fn icon_size(&self) -> i32;
+    fn icon_size(&self) -> IconSize;
 
     #[cfg(any(feature = "v3_20", feature = "dox"))]
     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
     #[doc(alias = "icon-size")]
-    fn set_icon_size(&self, icon_size: i32);
+    fn set_icon_size(&self, icon_size: IconSize);
 
     #[cfg(any(feature = "v3_20", feature = "dox"))]
     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
@@ -489,9 +492,9 @@ impl<O: IsA<StackSwitcher>> StackSwitcherExt for O {
 
     #[cfg(any(feature = "v3_20", feature = "dox"))]
     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
-    fn icon_size(&self) -> i32 {
+    fn icon_size(&self) -> IconSize {
         unsafe {
-            let mut value = glib::Value::from_type(<i32 as StaticType>::static_type());
+            let mut value = glib::Value::from_type(<IconSize as StaticType>::static_type());
             glib::gobject_ffi::g_object_get_property(
                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
                 b"icon-size\0".as_ptr() as *const _,
@@ -505,7 +508,7 @@ impl<O: IsA<StackSwitcher>> StackSwitcherExt for O {
 
     #[cfg(any(feature = "v3_20", feature = "dox"))]
     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
-    fn set_icon_size(&self, icon_size: i32) {
+    fn set_icon_size(&self, icon_size: IconSize) {
         unsafe {
             glib::gobject_ffi::g_object_set_property(
                 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
diff --git a/gtk/src/auto/versions.txt b/gtk/src/auto/versions.txt
index a1ec65b08d29..4038c19eaaa6 100644
--- a/gtk/src/auto/versions.txt
+++ b/gtk/src/auto/versions.txt
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
-from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
+from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377)
diff --git a/gtk/sys/versions.txt b/gtk/sys/versions.txt
index a1ec65b08d29..4038c19eaaa6 100644
--- a/gtk/sys/versions.txt
+++ b/gtk/sys/versions.txt
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 41ab88c)
-from gir-files (https://github.com/gtk-rs/gir-files @ 6088bb6)
+from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377)


Test patch: