]> Pileus Git - ~andy/gtk/commitdiff
gtk/gtksettings.c gtk/gtkstyle.c: Patch from Richard Hestilow to add a
authorOwen Taylor <otaylor@redhat.com>
Sun, 24 Feb 2002 02:24:51 +0000 (02:24 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sun, 24 Feb 2002 02:24:51 +0000 (02:24 +0000)
Sat Feb 23 20:59:05 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkstyle.c gtk/gtkrc.[ch]: gtk/gtksettings.c gtk/gtkstyle.c:
        Patch from Richard Hestilow to add a gtk-font-name GtkSetting.

        * gdk/x11/gdkevents-x11.c: Add Gtk/FontName XSETTING.

13 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/gtk/tmpl/gtksettings.sgml
gdk/x11/gdkevents-x11.c
gtk/gtkrc.c
gtk/gtkrc.h
gtk/gtksettings.c
gtk/gtkstyle.c

index ded1b1d65edb34adff79fe049876dd1498a99fa9..59259f0903165c8e00a91ab846ae5e77042acc5d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Feb 23 20:59:05 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.c gtk/gtkrc.[ch]: gtk/gtksettings.c gtk/gtkstyle.c:
+       Patch from Richard Hestilow to add a gtk-font-name GtkSetting.
+
+       * gdk/x11/gdkevents-x11.c: Add Gtk/FontName XSETTING.
+
 2002-02-24  Tor Lillqvist  <tml@iki.fi>
 
        * gtk/gtkfilesel.c: Move inclusion of <windows.h> before inclusion
index ded1b1d65edb34adff79fe049876dd1498a99fa9..59259f0903165c8e00a91ab846ae5e77042acc5d 100644 (file)
@@ -1,3 +1,10 @@
+Sat Feb 23 20:59:05 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.c gtk/gtkrc.[ch]: gtk/gtksettings.c gtk/gtkstyle.c:
+       Patch from Richard Hestilow to add a gtk-font-name GtkSetting.
+
+       * gdk/x11/gdkevents-x11.c: Add Gtk/FontName XSETTING.
+
 2002-02-24  Tor Lillqvist  <tml@iki.fi>
 
        * gtk/gtkfilesel.c: Move inclusion of <windows.h> before inclusion
index ded1b1d65edb34adff79fe049876dd1498a99fa9..59259f0903165c8e00a91ab846ae5e77042acc5d 100644 (file)
@@ -1,3 +1,10 @@
+Sat Feb 23 20:59:05 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.c gtk/gtkrc.[ch]: gtk/gtksettings.c gtk/gtkstyle.c:
+       Patch from Richard Hestilow to add a gtk-font-name GtkSetting.
+
+       * gdk/x11/gdkevents-x11.c: Add Gtk/FontName XSETTING.
+
 2002-02-24  Tor Lillqvist  <tml@iki.fi>
 
        * gtk/gtkfilesel.c: Move inclusion of <windows.h> before inclusion
index ded1b1d65edb34adff79fe049876dd1498a99fa9..59259f0903165c8e00a91ab846ae5e77042acc5d 100644 (file)
@@ -1,3 +1,10 @@
+Sat Feb 23 20:59:05 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.c gtk/gtkrc.[ch]: gtk/gtksettings.c gtk/gtkstyle.c:
+       Patch from Richard Hestilow to add a gtk-font-name GtkSetting.
+
+       * gdk/x11/gdkevents-x11.c: Add Gtk/FontName XSETTING.
+
 2002-02-24  Tor Lillqvist  <tml@iki.fi>
 
        * gtk/gtkfilesel.c: Move inclusion of <windows.h> before inclusion
index ded1b1d65edb34adff79fe049876dd1498a99fa9..59259f0903165c8e00a91ab846ae5e77042acc5d 100644 (file)
@@ -1,3 +1,10 @@
+Sat Feb 23 20:59:05 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.c gtk/gtkrc.[ch]: gtk/gtksettings.c gtk/gtkstyle.c:
+       Patch from Richard Hestilow to add a gtk-font-name GtkSetting.
+
+       * gdk/x11/gdkevents-x11.c: Add Gtk/FontName XSETTING.
+
 2002-02-24  Tor Lillqvist  <tml@iki.fi>
 
        * gtk/gtkfilesel.c: Move inclusion of <windows.h> before inclusion
index ded1b1d65edb34adff79fe049876dd1498a99fa9..59259f0903165c8e00a91ab846ae5e77042acc5d 100644 (file)
@@ -1,3 +1,10 @@
+Sat Feb 23 20:59:05 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.c gtk/gtkrc.[ch]: gtk/gtksettings.c gtk/gtkstyle.c:
+       Patch from Richard Hestilow to add a gtk-font-name GtkSetting.
+
+       * gdk/x11/gdkevents-x11.c: Add Gtk/FontName XSETTING.
+
 2002-02-24  Tor Lillqvist  <tml@iki.fi>
 
        * gtk/gtkfilesel.c: Move inclusion of <windows.h> before inclusion
index ded1b1d65edb34adff79fe049876dd1498a99fa9..59259f0903165c8e00a91ab846ae5e77042acc5d 100644 (file)
@@ -1,3 +1,10 @@
+Sat Feb 23 20:59:05 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkstyle.c gtk/gtkrc.[ch]: gtk/gtksettings.c gtk/gtkstyle.c:
+       Patch from Richard Hestilow to add a gtk-font-name GtkSetting.
+
+       * gdk/x11/gdkevents-x11.c: Add Gtk/FontName XSETTING.
+
 2002-02-24  Tor Lillqvist  <tml@iki.fi>
 
        * gtk/gtkfilesel.c: Move inclusion of <windows.h> before inclusion
index 6c557f0a26096728bff89ece5781a6b69b09401f..6a40a5e3b19a4ea0bae384b9cac06399411d51cd 100644 (file)
@@ -201,6 +201,11 @@ GtkSettings
 
 </para>
 
+<!-- ##### ARG GtkSettings:gtk-font-name ##### -->
+<para>
+
+</para>
+
 <!-- ##### ARG GtkSettings:gtk-color-palette ##### -->
 <para>
 
index 2c660462079d6e439bbbf4218f9839556a6e5abd..2d1e14bd588732092948de36ac671b4dcc0fab2c 100644 (file)
@@ -2051,12 +2051,13 @@ static struct
   { "Net/DndDragThreshold", "gtk-dnd-drag-threshold" },
   { "Gtk/CanChangeAccels", "gtk-can-change-accels" },
   { "Gtk/ColorPalette", "gtk-color-palette" },
+  { "Gtk/FontName", "gtk-font-name" },
+  { "Gtk/KeyThemeName", "gtk-key-theme-name" },
   { "Gtk/ToolbarStyle", "gtk-toolbar-style" },
   { "Gtk/ToolbarIconSize", "gtk-toolbar-icon-size" },
   { "Net/CursorBlink", "gtk-cursor-blink" },
   { "Net/CursorBlinkTime", "gtk-cursor-blink-time" },
-  { "Net/ThemeName", "gtk-theme-name" },
-  { "Gtk/KeyThemeName", "gtk-key-theme-name" }
+  { "Net/ThemeName", "gtk-theme-name" }
 };
 
 static void
index 1aa56683a0cd0a52ff739ff512639e1e0f9fa309..28ef67912fe801f48937efbe52f75eab7c19d334 100644 (file)
@@ -96,6 +96,7 @@ struct _GtkRcContext
 
   gchar *theme_name;
   gchar *key_theme_name;
+  gchar *font_name;
   
   gchar *pixmap_path[GTK_RC_MAX_PIXMAP_PATHS];
 
@@ -512,6 +513,14 @@ gtk_rc_settings_changed (GtkSettings  *settings,
   g_free (new_key_theme_name);
 }
 
+static void
+gtk_rc_font_name_changed (GtkSettings  *settings,
+                          GParamSpec   *pspec,
+                          GtkRcContext *context)
+{
+  _gtk_rc_context_get_default_font_name (settings);
+}
+
 static GtkRcContext *
 gtk_rc_context_get (GtkSettings *settings)
 {
@@ -529,6 +538,7 @@ gtk_rc_context_get (GtkSettings *settings)
       g_object_get (settings,
                    "gtk-theme-name", &context->theme_name,
                    "gtk-key-theme-name", &context->key_theme_name,
+                   "gtk-font-name", &context->font_name,
                    NULL);
 
       g_signal_connect (settings,
@@ -539,6 +549,11 @@ gtk_rc_context_get (GtkSettings *settings)
                        "notify::gtk-key-theme-name",
                        G_CALLBACK (gtk_rc_settings_changed),
                        context);
+      g_signal_connect (settings,
+                       "notify::gtk-font-name",
+                       G_CALLBACK (gtk_rc_font_name_changed),
+                       context);
+
       
       context->pixmap_path[0] = NULL;
 
@@ -1234,6 +1249,62 @@ gtk_rc_reset_widgets (GtkRcContext *context)
   g_list_free (toplevels);
 }
 
+void
+gtk_rc_clear_realized_style (gpointer key,
+                            gpointer value,
+                            gpointer data)
+{
+  GSList *rc_styles = key;
+  GSList *tmp_list = rc_styles;
+
+  while (tmp_list)
+    {
+      GtkRcStyle *rc_style = tmp_list->data;
+      
+      rc_style->rc_style_lists = g_slist_remove_all (rc_style->rc_style_lists,
+                                                    rc_styles);
+      tmp_list = tmp_list->next;
+    }
+
+  g_slist_free (rc_styles);
+}
+
+const gchar*
+_gtk_rc_context_get_default_font_name (GtkSettings *settings)
+{
+  GtkRcContext *context;
+  gchar *new_font_name;
+  
+  g_return_val_if_fail (GTK_IS_SETTINGS (settings), NULL);
+
+  context = gtk_rc_context_get (settings);
+
+  g_object_get (context->settings,
+                "gtk-font-name", &new_font_name,
+                NULL);
+
+  if (new_font_name != context->font_name && !(new_font_name && strcmp (context->font_name, new_font_name) == 0))
+    {
+      g_free (context->font_name);
+      context->font_name = g_strdup (new_font_name);
+
+      /* Clear out styles that have been looked up already
+       */
+      if (realized_style_ht)
+       {
+         g_hash_table_foreach (realized_style_ht, gtk_rc_clear_realized_style, NULL);
+         g_hash_table_destroy (realized_style_ht);
+         realized_style_ht = NULL;
+         
+         gtk_rc_reset_widgets (context);
+       }
+    }
+          
+  g_free (new_font_name);
+
+  return context->font_name;
+}
+
 /**
  * gtk_rc_reparse_all_for_settings:
  * @settings: a #GtkSettings
@@ -1321,6 +1392,7 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings,
 
       g_free (context->theme_name);
       g_free (context->key_theme_name);
+
       g_object_get (context->settings,
                    "gtk-theme-name", &context->theme_name,
                    "gtk-key-theme-name", &context->key_theme_name,
@@ -3278,7 +3350,7 @@ gtk_rc_parse_module_path (GScanner *scanner)
     return G_TOKEN_STRING;
 
   g_warning ("module_path directive is now ignored\n");
-  
+
   return G_TOKEN_NONE;
 }
 
index 5bdf57b38efe636d0b3733adce53460e00d56202..8a95e1206590bc8d16167d0363102ec0028ccfde 100644 (file)
@@ -236,6 +236,7 @@ const GtkRcProperty* _gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style,
 gchar*  gtk_win32_get_installation_directory (void);
 #endif
 
+const gchar* _gtk_rc_context_get_default_font_name (GtkSettings *settings);
 
 #ifdef __cplusplus
 }
index 14f44f1cac3aab9be0d523aeb318240070be8cd4..1547f6a5296376c9abbaed3ceaf380b95316b923 100644 (file)
@@ -30,7 +30,8 @@ enum {
   PROP_THEME_NAME,
   PROP_KEY_THEME_NAME,
   PROP_MENU_BAR_ACCEL,
-  PROP_DND_DRAG_THRESHOLD
+  PROP_DND_DRAG_THRESHOLD,
+  PROP_FONT_NAME
 };
 
 
@@ -208,7 +209,16 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                                                G_PARAM_READWRITE),
                                             NULL);
   g_assert (result == PROP_DND_DRAG_THRESHOLD);
-  
+
+  result = settings_install_property_parser (class,
+                                             g_param_spec_string ("gtk-font-name",
+                                                                  _("Font Name"),
+                                                                  _("Name of default font to use"),
+                                                                 "Sans 10",
+                                                                 G_PARAM_READWRITE),
+                                             NULL);
+  g_assert (result == PROP_FONT_NAME);
 }
 
 static void
index bfee98bf311ff8ea1241fd49d48f39019f5eedbb..608f5aed6a3a1fe34f61cb739fe3b675c73bd02b 100644 (file)
@@ -485,8 +485,9 @@ static void
 gtk_style_init (GtkStyle *style)
 {
   gint i;
+  const gchar *font_name = _gtk_rc_context_get_default_font_name (gtk_settings_get_default ());
   
-  style->font_desc = pango_font_description_from_string ("Sans 10");
+  style->font_desc = pango_font_description_from_string (font_name);
 
   style->attach_count = 0;
   style->colormap = NULL;
@@ -2339,7 +2340,7 @@ gtk_default_draw_shadow (GtkStyle      *style,
          return;
        }
       if (widget && GTK_IS_SPIN_BUTTON (widget) &&
-         detail && strcmp (detail, "spinbutton") == 0)
+         detail && strcmp (detail, "spinbutton") == 0)
        {
          draw_spinbutton_shadow (style, window, state_type,
                                  gtk_widget_get_direction (widget), area, x, y, width, height);