int string_width(const char *text)
{
- GtkWidget *label = gtk_label_new(text);
- GtkRequisition req;
- gtk_widget_size_request(label, &req);
- g_object_ref_sink(G_OBJECT(label));
- return req.width;
+ int ret;
+ get_label_text_dimensions(text, &ret, NULL);
+ return ret;
}
int reallyclose(void *frontend)
return TRUE;
}
-static void get_label_text_dimensions(const char *text,
- int *width, int *height)
+void get_label_text_dimensions(const char *text, int *width, int *height)
{
/*
* Determine the dimensions of a piece of text in the standard
PangoLayout *layout = gtk_label_get_layout(GTK_LABEL(label));
PangoRectangle logrect;
pango_layout_get_extents(layout, NULL, &logrect);
- *width = logrect.width / PANGO_SCALE;
- *height = logrect.height / PANGO_SCALE;
+ if (width)
+ *width = logrect.width / PANGO_SCALE;
+ if (height)
+ *height = logrect.height / PANGO_SCALE;
#else
GtkRequisition req;
gtk_widget_size_request(label, &req);
- *width = req.width;
- *height = req.height;
+ if (width)
+ *width = req.width;
+ if (height)
+ *height = req.height;
#endif
g_object_ref_sink(G_OBJECT(label));
/* gtkcfg.c */
void gtk_setup_config_box(struct controlbox *b, int midsession, void *window);
+/* Helper function which happens to be in gtkfont.c at the moment */
+void get_label_text_dimensions(const char *text, int *width, int *height);
+
/*
* In the Unix Unicode layer, DEFAULT_CODEPAGE is a special value
* which causes mb_to_wc and wc_to_mb to call _libc_ rather than