]> Pileus Git - ~andy/gtk/commitdiff
Get rid of gtk_style_get_font_for_display(), make gtk_style_get_font()
authorOwen Taylor <otaylor@redhat.com>
Thu, 20 Jun 2002 19:29:16 +0000 (19:29 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 20 Jun 2002 19:29:16 +0000 (19:29 +0000)
Thu Jun 20 15:17:14 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkstyle.[ch]: Get rid of gtk_style_get_font_for_display(),
        make gtk_style_get_font() warn for multihead if called
        on an unattached style.

        * gtk/gtktext.c: Remove use of gtk_style_get_font_for_display();
        this makes gtktext not multihead safe, but it doesn't matter;
        it's ENABLE_BROKEN anyways.

        * gtk/gtkmain.c gtk/gtkdebug.h: Add GTK_NOTE(MULTIHEAD,[])

gtk/gtkdebug.h
gtk/gtkmain.c
gtk/gtkstyle.c
gtk/gtkstyle.h
gtk/gtktext.c

index 7aa18463eeb900ee4a63c12d97f5fa57c599319e..5a5a1ec230c65da69a30e9d68b79a62db07ddbf0 100644 (file)
@@ -37,7 +37,8 @@ typedef enum {
   GTK_DEBUG_TEXT        = 1 << 2,
   GTK_DEBUG_TREE        = 1 << 3,
   GTK_DEBUG_UPDATES     = 1 << 4,
-  GTK_DEBUG_KEYBINDINGS = 1 << 5
+  GTK_DEBUG_KEYBINDINGS = 1 << 5,
+  GTK_DEBUG_MULTIHEAD   = 1 << 6
 } GtkDebugFlag;
 
 #ifdef G_ENABLE_DEBUG
index e710b37bbc2887b69bf1fe67728b9888300a4eb0..eb33e039f227c035b8fe286099fadf1fd0388df0 100644 (file)
@@ -150,7 +150,8 @@ static const GDebugKey gtk_debug_keys[] = {
   {"text", GTK_DEBUG_TEXT},
   {"tree", GTK_DEBUG_TREE},
   {"updates", GTK_DEBUG_UPDATES},
-  {"keybindings", GTK_DEBUG_KEYBINDINGS}
+  {"keybindings", GTK_DEBUG_KEYBINDINGS},
+  {"multihead", GTK_DEBUG_MULTIHEAD}
 };
 
 static const guint gtk_ndebug_keys = sizeof (gtk_debug_keys) / sizeof (GDebugKey);
index 41d9a75eaae782850572f97a7301a2a15383f373..7bb662115a31d298646dda74b694f8b094811f22 100644 (file)
@@ -811,7 +811,19 @@ gtk_style_detach (GtkStyle *style)
       
       gdk_colormap_unref (style->colormap);
       style->colormap = NULL;
-      
+
+      if (style->private_font_desc)
+       {
+         if (style->private_font)
+           {
+             gdk_font_unref (style->private_font);
+             style->private_font = NULL;
+           }
+         
+         pango_font_description_free (style->private_font_desc);
+         style->private_font_desc = NULL;
+       }
+
       g_object_unref (style);
     }
 }
@@ -3110,11 +3122,11 @@ gtk_default_draw_string (GtkStyle      *style,
 
   if (state_type == GTK_STATE_INSENSITIVE)
     gdk_draw_string (window,
-                    gtk_style_get_font_for_display (display, style),
+                    gtk_style_get_font (style),
                     style->white_gc, x + 1, y + 1, string);
 
   gdk_draw_string (window,
-                  gtk_style_get_font_for_display (display, style),
+                  gtk_style_get_font (style),
                   style->fg_gc[state_type], x, y, string);
 
   if (area)
@@ -5599,24 +5611,21 @@ gtk_border_get_type (void)
 }
 
 /**
- * gtk_style_get_font_for_display:
- * @display : a #GdkDisplay
+ * gtk_style_get_font:
  * @style: a #GtkStyle
  * 
  * Gets the #GdkFont to use for the given style. This is
- * meant only as a replacement for direct access to style->font
+ * meant only as a replacement for direct access to @style->font
  * and should not be used in new code. New code should
- * use style->font_desc instead.
+ * use @style->font_desc instead.
  * 
  * Return value: the #GdkFont for the style. This font is owned
  *   by the style; if you want to keep around a copy, you must
  *   call gdk_font_ref().
  **/
 GdkFont *
-gtk_style_get_font_for_display (GdkDisplay *display,
-                               GtkStyle   *style)
+gtk_style_get_font (GtkStyle *style)
 {
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
   g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
 
   if (style->private_font && style->private_font_desc)
@@ -5637,9 +5646,21 @@ gtk_style_get_font_for_display (GdkDisplay *display,
   
   if (!style->private_font)
     {
+      GdkDisplay *display;
+
+      if (style->colormap)
+       {
+         display = gdk_screen_get_display (gdk_colormap_get_screen (style->colormap));
+       }
+      else
+       {
+         display = gdk_get_default_display ();
+         GTK_NOTE (MULTIHEAD,
+                   g_warning ("gtk_style_get_font() should not be called on an unattached style"));
+       }
+      
       if (style->font_desc)
        {
-         /* no colormap, no screen */
          style->private_font = gdk_font_from_description_for_display (display, style->font_desc);
          style->private_font_desc = pango_font_description_copy (style->font_desc);
        }
@@ -5654,27 +5675,6 @@ gtk_style_get_font_for_display (GdkDisplay *display,
   return style->private_font;
 }
 
-/**
- * gtk_style_get_font:
- * @style: a #GtkStyle
- * 
- * Gets the #GdkFont to use for the given style. This is
- * meant only as a replacement for direct access to @style->font
- * and should not be used in new code. New code should
- * use @style->font_desc instead.
- * 
- * Return value: the #GdkFont for the style. This font is owned
- *   by the style; if you want to keep around a copy, you must
- *   call gdk_font_ref().
- **/
-GdkFont *
-gtk_style_get_font (GtkStyle *style)
-{
-  g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
-
-  return gtk_style_get_font_for_display (gdk_get_default_display (), style);
-}
-
 /**
  * gtk_style_set_font:
  * @style: a #GtkStyle.
index d07a126d37751259be4fdf276696ffb25988fd4b..ce4c3901c1cb75cf91cf9ba85afc4adbe9455a41 100644 (file)
@@ -435,11 +435,7 @@ void         gtk_style_detach                   (GtkStyle     *style);
 GtkStyle* gtk_style_ref                             (GtkStyle     *style);
 void     gtk_style_unref                    (GtkStyle     *style);
 
-#ifndef GDK_MULTIHEAD_SAFE
 GdkFont * gtk_style_get_font                 (GtkStyle     *style);
-#endif
-GdkFont * gtk_style_get_font_for_display     (GdkDisplay   *display,
-                                             GtkStyle     *style);
 void      gtk_style_set_font                 (GtkStyle     *style,
                                              GdkFont      *font);
 #endif /* GTK_DISABLE_DEPRECATED */
index b9eff75392f485db49e99b1ab7defc1ed12902d8..4d17b791d04219960eb61a10a68360459bb95de0 100644 (file)
@@ -73,8 +73,7 @@
 #define MARK_CURRENT_FONT(text, mark) \
   ((MARK_CURRENT_PROPERTY(mark)->flags & PROPERTY_FONT) ? \
          MARK_CURRENT_PROPERTY(mark)->font->gdk_font : \
-         gtk_style_get_font_for_display (gtk_widget_get_display (GTK_WIDGET (text)), \
-                                        GTK_WIDGET (text)->style))
+         gtk_style_get_font (GTK_WIDGET (text)->style))
 #define MARK_CURRENT_FORE(text, mark) \
   ((MARK_CURRENT_PROPERTY(mark)->flags & PROPERTY_FOREGROUND) ? \
          &MARK_CURRENT_PROPERTY(mark)->fore_color : \
@@ -1000,7 +999,7 @@ gtk_text_insert (GtkText    *text,
       
       gtk_widget_ensure_style (widget);
       if ((widget->style) &&
-         (gtk_style_get_font_for_display (gtk_widget_get_display (widget), widget->style)->type == GDK_FONT_FONTSET))
+         (gtk_style_get_font (widget->style)->type == GDK_FONT_FONTSET))
        {
          text->use_wchar = TRUE;
          g_free (text->text.ch);
@@ -1410,7 +1409,7 @@ gtk_text_style_set (GtkWidget *widget,
   
   if (text->current_font)
     text_font_unref (text->current_font);
-  text->current_font = get_text_font (gtk_style_get_font_for_display (gtk_widget_get_display (widget), widget->style));
+  text->current_font = get_text_font (gtk_style_get_font (widget->style));
 }
 
 static void
@@ -1574,8 +1573,7 @@ gtk_text_size_request (GtkWidget      *widget,
   xthickness = widget->style->xthickness + TEXT_BORDER_ROOM;
   ythickness = widget->style->ythickness + TEXT_BORDER_ROOM;
 
-  font = gtk_style_get_font_for_display (gtk_widget_get_display (widget),
-                                        widget->style);
+  font = gtk_style_get_font (widget->style);
   
   char_height = MIN_TEXT_HEIGHT_LINES * (font->ascent +
                                         font->descent);