I pass some type names to a function to instantiate the matching Gtk+ widget.
I am looking for something like this: GtkScale[@orientation=“vertical”]
And here is the matching factory:
GtkWidget*
my_factory_create(gchar *widget_type_name)
{
GtkWidget *widget;
widget = NULL;
if(g_str_has_prefix(widget_type_name, "GtkScale")){
if(g_strstr_len(widget_type_name, -1, "@orientation=\"horizontal\"") != NULL){
widget = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL);
}else{
widget = gtk_scale_new(GTK_ORIENTATION_VERTICAL, NULL);
}
}
return(widget);
}
Sine I have got a plugin browser allowing you to choose the desired control:
Prior, I was able to just use g_type_from_name()
.
GtkWidget*
my_factory_create(gchar *widget_type_name)
{
GtkWidget *widget;
GType widget_type;
widget_type = g_type_from_name(widget_type_name);
widget = g_object_new(widget_type, NULL);
return(widget);
}
regards, Joël