Implementation of gtk3's new Height-for-width Geometry Management method

不打扰是莪最后的温柔 提交于 2019-12-11 04:55:35

问题


In continuation of my previous question

Drag and drop on a fixed container changes its size

I followed the advice given from ergosys and read the info in the link he provided.
If I understood correctly, the new way of declaring

/* LEFT FRAME */

frame1= gtk_frame_new(NULL);
gtk_table_attach(GTK_TABLE(table), frame1, 0,14,0,49,GTK_SHRINK,GTK_SHRINK,0,0);
gtk_widget_set_size_request(frame1, 360,570);    

is (ignore the height for the time being)

static void
my_widget_get_preferred_width (GtkWidget *widget,
                               gint      *minimal_width,
                               gint      *natural_width)
{
  GtkRequisition requisition;

  gtk_widget_get_requisition (widget, &requisition);

  *minimal_width = *natural_width = requisition.width;
}

....

/* LEFT FRAME */

frame1= gtk_frame_new(NULL);
gtk_table_attach(GTK_TABLE(table), frame1, 0,14,0,49,GTK_SHRINK,GTK_SHRINK,0,0);

gint min_width=360;
gint nat_width=360;

GTK_WIDGET_GET_CLASS(frame1)->get_preferred_width=my_widget_get_preferred_width;
my_widget_get_preferred_width(frame1,&min_width,&nat_width);    

It compiles OK, but, when run, it gives me this error:

(conky_companion:19700): Gtk-WARNING **: GtkFrame 0xa00e660: widget tried to     gtk_widget_get_width inside  GtkWidget     ::get_width implementation. Should just invoke GTK_WIDGET_GET_CLASS(widget)->get_width directly rather than using gtk_widget_get_width     

without ever drawing the window and it segfaults after a while.

What am I missing here?
Or, TL;DR, what is the equivalent of

gtk_widget_set_size_request(frame1, 360,570);     

in gtk3?

来源:https://stackoverflow.com/questions/11941707/implementation-of-gtk3s-new-height-for-width-geometry-management-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!