GTK2 -> GTK3 Upgrade GtkObjectClass

Hello y’all,

I’m working on an upgrade going from GTK2 to GTK3 but I’m running into an issue where the code I’m upgrading is using GtkObjectClass and assigning its set_arg and get_arg function pointers. I can’t find an equivalent for GTK3 as the GTK2 to GTK3 article says that GtkWidgetClass should replace GtkObjectClass but GtkWidgetClass doesn’t appear to have an equivalent of get_arg and set_arg.

Is there somewhere that details this more? Should I be replacing GtkObjectClass with GObject in this case?

The equivalent of GtkObjectClass.set_arg() and GtkObjectClass.get_arg() are GObjectClass.set_property() and GObjectClass.get_property(), respectively. The semantics are slightly different, so you really want to read the GObject tutorial first.

Now that I’m using get_property() and set_property() to update fields, what would be the best way to update a GtkAdjustment field inside of a GObjectClass?

The class was previously updating horizontal adjustment and vertical adjustment fields with the get_arg() and set_arg() but set_property() and get_property() doesn’t seem like a good fit for it anymore.

Use gtk_adjustment_configure() to set more than one field at a time.

Or you can use g_object_set() with multiple GObject properties, e.g.

g_object_set (adjustment,
              "lower", lower_value,
              "upper", upper_value,
              "value", current_value,
              NULL);
1 Like