[gnome-control-center/gnome-2-32: 6/7] font-viewer: create the preview pixmap after the drawing area is realized



commit 7f689166b2df65a30fec93163bca08196d2cd832
Author: Thomas Wood <thos gnome org>
Date:   Sun Jul 18 22:36:35 2010 +0100

    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.

 font-viewer/font-view.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/font-viewer/font-view.c b/font-viewer/font-view.c
index a807361..56c557a 100644
--- a/font-viewer/font-view.c
+++ b/font-viewer/font-view.c
@@ -93,6 +93,9 @@ check_font_contain_text (FT_Face face, const gchar *text)
     return TRUE;
 }
 
+
+static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, GdkPixmap *pixmap);
+
 static GdkPixmap *
 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);
 
-    /* create pixmap */
-    gtk_widget_realize(drawing_area);
-
     /* create the XftDraw */
     xdisplay = GDK_PIXMAP_XDISPLAY(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);
     }
 
+    g_signal_connect(drawing_area, "expose-event", G_CALLBACK(expose_event),
+                     pixmap);
+
  end:
     g_free(sizes);
     FcCharSetDestroy (charset);
@@ -504,7 +507,6 @@ main(int argc, char **argv)
     GtkWidget *window, *hbox, *table, *swin, *drawing_area;
     GdkPixmap *pixmap;
     GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
-    gint height;
     GtkWidget *button, *align;
 
     bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
@@ -565,16 +567,12 @@ main(int argc, char **argv)
     gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &white);
     gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin),
 					  drawing_area);
-
-    pixmap = create_text_pixmap(drawing_area, face);
+    g_signal_connect (drawing_area, "realize", create_text_pixmap, face);
 
     /* set the minimum size on the scrolled window to prevent
      * unnecessary scrolling */
-    gdk_drawable_get_size (GDK_DRAWABLE (pixmap), NULL, &height);
-    gtk_widget_set_size_request(swin, 500, height + 30);
+    gtk_widget_set_size_request(swin, 500, -1);
 
-    g_signal_connect(drawing_area, "expose_event",
-		     G_CALLBACK(expose_event), pixmap);
     g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
     table = gtk_table_new(1, 2, FALSE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]