font-viewer: create the preview pixmap after the drawing area is realized
The drawing area needs to be realized before the preview pixmap is created to ensure the X resources are available to create the font information.
This commit is contained in:
parent
175ed06b94
commit
7c1e4cf526
1 changed files with 8 additions and 10 deletions
|
@ -93,6 +93,9 @@ check_font_contain_text (FT_Face face, const gchar *text)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, GdkPixmap *pixmap);
|
||||||
|
|
||||||
static GdkPixmap *
|
static GdkPixmap *
|
||||||
create_text_pixmap(GtkWidget *drawing_area, FT_Face face)
|
create_text_pixmap(GtkWidget *drawing_area, FT_Face face)
|
||||||
{
|
{
|
||||||
|
@ -119,9 +122,6 @@ create_text_pixmap(GtkWidget *drawing_area, FT_Face face)
|
||||||
|
|
||||||
textlen = strlen(text);
|
textlen = strlen(text);
|
||||||
|
|
||||||
/* create pixmap */
|
|
||||||
gtk_widget_realize(drawing_area);
|
|
||||||
|
|
||||||
/* create the XftDraw */
|
/* create the XftDraw */
|
||||||
xdisplay = GDK_PIXMAP_XDISPLAY(window);
|
xdisplay = GDK_PIXMAP_XDISPLAY(window);
|
||||||
xvisual = GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(window));
|
xvisual = GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(window));
|
||||||
|
@ -214,6 +214,9 @@ create_text_pixmap(GtkWidget *drawing_area, FT_Face face)
|
||||||
XftFontClose(xdisplay, font);
|
XftFontClose(xdisplay, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_signal_connect(drawing_area, "expose-event", G_CALLBACK(expose_event),
|
||||||
|
pixmap);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
g_free(sizes);
|
g_free(sizes);
|
||||||
FcCharSetDestroy (charset);
|
FcCharSetDestroy (charset);
|
||||||
|
@ -504,7 +507,6 @@ main(int argc, char **argv)
|
||||||
GtkWidget *window, *hbox, *table, *swin, *drawing_area;
|
GtkWidget *window, *hbox, *table, *swin, *drawing_area;
|
||||||
GdkPixmap *pixmap;
|
GdkPixmap *pixmap;
|
||||||
GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
|
GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
|
||||||
gint height;
|
|
||||||
GtkWidget *button, *align;
|
GtkWidget *button, *align;
|
||||||
|
|
||||||
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
||||||
|
@ -565,16 +567,12 @@ main(int argc, char **argv)
|
||||||
gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &white);
|
gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &white);
|
||||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin),
|
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin),
|
||||||
drawing_area);
|
drawing_area);
|
||||||
|
g_signal_connect (drawing_area, "realize", create_text_pixmap, face);
|
||||||
pixmap = create_text_pixmap(drawing_area, face);
|
|
||||||
|
|
||||||
/* set the minimum size on the scrolled window to prevent
|
/* set the minimum size on the scrolled window to prevent
|
||||||
* unnecessary scrolling */
|
* unnecessary scrolling */
|
||||||
gdk_drawable_get_size (GDK_DRAWABLE (pixmap), NULL, &height);
|
gtk_widget_set_size_request(swin, 500, -1);
|
||||||
gtk_widget_set_size_request(swin, 500, height + 30);
|
|
||||||
|
|
||||||
g_signal_connect(drawing_area, "expose_event",
|
|
||||||
G_CALLBACK(expose_event), pixmap);
|
|
||||||
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
||||||
|
|
||||||
table = gtk_table_new(1, 2, FALSE);
|
table = gtk_table_new(1, 2, FALSE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue