]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkrc.c
new default color scheme based on the GNOME stock icon palette. (#80691,
[~andy/gtk] / gtk / gtkrc.c
index 298bd83a0497e8b2d3ff517bd2c1eb2562962628..82700ebf47e1ee3db5c0222509b187a6fe231a00 100644 (file)
@@ -661,11 +661,33 @@ _gtk_rc_init (void)
   
   /* Default RC string */
   gtk_rc_parse_string ("style \"gtk-default-tooltips-style\" {\n"
-                      "  bg[NORMAL] = \"#ffffc0\"\n"
+                      "  bg[NORMAL] = \"#eee1b3\"\n"
                       "  fg[NORMAL] = \"#000000\"\n"
                       "}\n"
                       "\n"
-                      "widget \"gtk-tooltips*\" style : gtk \"gtk-default-tooltips-style\"\n");
+                      "style \"gtk-default-progress-bar-style\" {\n"
+                      "  bg[PRELIGHT] = \"#4b6983\"\n"
+                      "  fg[PRELIGHT] = \"#ffffff\"\n"
+                      "  bg[NORMAL]   = \"#bab5ab\"\n"
+                      "}\n"
+                      "\n"
+                      "style \"gtk-default-menu-item-style\" {\n"
+                      "  bg[PRELIGHT] = \"#4b6983\"\n"
+                      "  fg[PRELIGHT] = \"#ffffff\"\n"
+                      "  base[PRELIGHT] = \"#4b6983\"\n"
+                      "  text[PRELIGHT] = \"#ffffff\"\n"
+                      "}\n"
+                      "\n"
+                      "class \"GtkProgressBar\" style : gtk \"gtk-default-progress-bar-style\"\n"
+                      "widget \"gtk-tooltips*\" style : gtk \"gtk-default-tooltips-style\"\n"
+                      "class \"GtkMenuItem\" style : gtk \"gtk-default-menu-item-style\"\n"
+                      "widget_class \"*.GtkMenuItem.*\" style : gtk \"gtk-default-menu-item-style\"\n"
+                      "widget_class \"*.GtkAccelMenuItem.*\" style : gtk \"gtk-default-menu-item-style\"\n"
+                      "widget_class \"*.GtkRadioMenuItem.*\" style : gtk \"gtk-default-menu-item-style\"\n"
+                      "widget_class \"*.GtkCheckMenuItem.*\" style : gtk \"gtk-default-menu-item-style\"\n"
+                      "widget_class \"*.GtkImageMenuItem.*\" style : gtk \"gtk-default-menu-item-style\"\n"
+                      "widget_class \"*.GtkSeparatorMenuItem.*\" style : gtk \"gtk-default-menu-item-style\"\n"
+      );
 }
   
 static void
@@ -885,11 +907,11 @@ gtk_rc_parse (const gchar *filename)
 GType
 gtk_rc_style_get_type (void)
 {
-  static GType object_type = 0;
+  static GType rc_style_type = 0;
 
-  if (!object_type)
+  if (!rc_style_type)
     {
-      static const GTypeInfo object_info =
+      static const GTypeInfo rc_style_info =
       {
         sizeof (GtkRcStyleClass),
         (GBaseInitFunc) NULL,
@@ -902,12 +924,11 @@ gtk_rc_style_get_type (void)
         (GInstanceInitFunc) gtk_rc_style_init,
       };
       
-      object_type = g_type_register_static (G_TYPE_OBJECT,
-                                            "GtkRcStyle",
-                                            &object_info, 0);
+      rc_style_type = g_type_register_static (G_TYPE_OBJECT, "GtkRcStyle",
+                                             &rc_style_info, 0);
     }
   
-  return object_type;
+  return rc_style_type;
 }
 
 static void
@@ -978,7 +999,7 @@ gtk_rc_style_finalize (GObject *object)
     {
       GSList *rc_styles = tmp_list1->data;
       GtkStyle *style = g_hash_table_lookup (realized_style_ht, rc_styles);
-      gtk_style_unref (style);
+      g_object_unref (style);
 
       /* Remove the list of styles from the other rc_styles
        * in the list
@@ -1021,8 +1042,7 @@ gtk_rc_style_finalize (GObject *object)
   tmp_list1 = rc_style->icon_factories;
   while (tmp_list1)
     {
-      g_object_unref (G_OBJECT (tmp_list1->data));
-
+      g_object_unref (tmp_list1->data);
       tmp_list1 = tmp_list1->next;
     }
   g_slist_free (rc_style->icon_factories);
@@ -1064,19 +1084,19 @@ gtk_rc_style_copy (GtkRcStyle *orig)
 }
 
 void      
-gtk_rc_style_ref (GtkRcStyle  *rc_style)
+gtk_rc_style_ref (GtkRcStyle *rc_style)
 {
   g_return_if_fail (GTK_IS_RC_STYLE (rc_style));
 
-  g_object_ref (G_OBJECT (rc_style));
+  g_object_ref (rc_style);
 }
 
 void      
-gtk_rc_style_unref (GtkRcStyle  *rc_style)
+gtk_rc_style_unref (GtkRcStyle *rc_style)
 {
   g_return_if_fail (GTK_IS_RC_STYLE (rc_style));
 
-  g_object_unref (G_OBJECT (rc_style));
+  g_object_unref (rc_style);
 }
 
 static GtkRcStyle *
@@ -1269,10 +1289,10 @@ gtk_rc_clear_styles (GtkRcContext *context)
  * icon sets so they get re-rendered.
  */
 static void
-gtk_rc_reset_widgets (GtkRcContext *context)
+gtk_rc_reset_widgets (GtkSettings *settings)
 {
   GList *list, *toplevels;
-  
+
   _gtk_icon_set_invalidate_caches ();
   
   toplevels = gtk_window_list_toplevels ();
@@ -1280,8 +1300,11 @@ gtk_rc_reset_widgets (GtkRcContext *context)
   
   for (list = toplevels; list; list = list->next)
     {
-      gtk_widget_reset_rc_styles (list->data);
-      gtk_widget_unref (list->data);
+      if (gtk_widget_get_screen (list->data) == settings->screen)
+       {
+         gtk_widget_reset_rc_styles (list->data);
+         g_object_unref (list->data);
+       }
     }
   g_list_free (toplevels);
 }
@@ -1306,6 +1329,53 @@ gtk_rc_clear_realized_style (gpointer key,
   g_slist_free (rc_styles);
 }
 
+/**
+ * _gtk_rc_reset_styles:
+ * @settings: a #GtkSettings
+ * 
+ * This setting resets all of our styles; we use it when the font
+ * rendering parameters or the icon sizes have changed. It's both less
+ * and more comprehensive then we actually need:
+ *
+ * Less comprehensive: it doesn't affect widgets that have a style
+ *   set on them.
+ *
+ * More comprehensive: it resets the styles, but the styles haven't
+ *   changed. The main reason for resetting the styles is becaues
+ *   most widgets will redo all their font stuff when their style
+ *   change.
+ **/
+void
+_gtk_rc_reset_styles (GtkSettings *settings)
+{
+  GtkRcContext *context;
+  gboolean reset = FALSE;
+
+  g_return_if_fail (GTK_IS_SETTINGS (settings));
+
+  context = gtk_rc_context_get (settings);
+  
+  if (context->default_style)
+    {
+      g_object_unref (G_OBJECT (context->default_style));
+      context->default_style = NULL;
+      reset = TRUE;
+    }
+  
+  /* 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;
+      reset = TRUE;
+    }
+  
+  if (reset)
+    gtk_rc_reset_widgets (settings);
+}
+
 const gchar*
 _gtk_rc_context_get_default_font_name (GtkSettings *settings)
 {
@@ -1322,29 +1392,10 @@ _gtk_rc_context_get_default_font_name (GtkSettings *settings)
 
   if (new_font_name != context->font_name && !(new_font_name && strcmp (context->font_name, new_font_name) == 0))
     {
-      gboolean reset = FALSE;
-      g_free (context->font_name);
-      context->font_name = g_strdup (new_font_name);
-
-      if (context->default_style)
-        {
-         g_object_unref (G_OBJECT (context->default_style));
-         context->default_style = NULL;
-         reset = TRUE;
-        }
-
-      /* 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;
-         reset = TRUE;
-       }
-
-      if (reset)
-       gtk_rc_reset_widgets (context);
+       g_free (context->font_name);
+       context->font_name = g_strdup (new_font_name);
+       _gtk_rc_reset_styles (settings);
     }
           
   g_free (new_font_name);
@@ -1408,6 +1459,7 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings,
       gtk_rc_clear_styles (context);
       g_object_freeze_notify (G_OBJECT (context->settings));
 
+      _gtk_settings_reset_rc_values (context->settings);
       tmp_list = context->rc_files;
       while (tmp_list)
        {
@@ -1454,7 +1506,7 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings,
       
       g_object_thaw_notify (G_OBJECT (context->settings));
 
-      gtk_rc_reset_widgets (context);
+      gtk_rc_reset_widgets (context->settings);
     }
 
   return force_load || mtime_modified;
@@ -1607,16 +1659,16 @@ gtk_rc_get_style (GtkWidget *widget)
 
   if (context->rc_sets_class)
     {
-      GtkType type;
+      GType type;
 
-      type = GTK_OBJECT_TYPE (widget);
+      type = G_TYPE_FROM_INSTANCE (widget);
       while (type)
        {
          const gchar *path;
           gchar *path_reversed;
          guint path_length;
 
-         path = gtk_type_name (type);
+         path = g_type_name (type);
          path_length = strlen (path);
          path_reversed = g_strdup (path);
          g_strreverse (path_reversed);
@@ -1624,14 +1676,13 @@ gtk_rc_get_style (GtkWidget *widget)
          rc_styles = gtk_rc_styles_match (rc_styles, context->rc_sets_class, path_length, path, path_reversed);
          g_free (path_reversed);
       
-         type = gtk_type_parent (type);
+         type = g_type_parent (type);
        }
     }
   
   rc_styles = sort_and_dereference_sets (rc_styles);
   
-  widget_rc_style = gtk_object_get_data_by_id (GTK_OBJECT (widget),
-                                              rc_style_key_id);
+  widget_rc_style = g_object_get_qdata (G_OBJECT (widget), rc_style_key_id);
 
   if (widget_rc_style)
     rc_styles = g_slist_prepend (rc_styles, widget_rc_style);
@@ -2057,7 +2108,7 @@ gtk_rc_init_style (GtkRcContext *context,
               iter = factories;
               while (iter != NULL)
                 {
-                  g_object_ref (G_OBJECT (iter->data));
+                  g_object_ref (iter->data);
                   iter = g_slist_next (iter);
                 }
 
@@ -2388,9 +2439,9 @@ gtk_rc_parse_statement (GtkRcContext *context,
              svalue.origin = prop.origin;
              memcpy (&svalue.value, &prop.value, sizeof (prop.value));
              g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
-             gtk_settings_set_property_value (context->settings,
-                                              name,
-                                              &svalue);
+             _gtk_settings_set_property_value_from_rc (context->settings,
+                                                       name,
+                                                       &svalue);
            }
          g_free (prop.origin);
          if (G_VALUE_TYPE (&prop.value))
@@ -2554,7 +2605,7 @@ gtk_rc_parse_style (GtkRcContext *context,
               factories = parent_style->icon_factories;
               while (factories != NULL)
                 {
-                  g_object_ref (G_OBJECT (factories->data));
+                  g_object_ref (factories->data);
                   factories = factories->next;
                 }
             }
@@ -3134,7 +3185,7 @@ gtk_rc_parse_engine (GtkRcContext *context,
              
              if (result != G_TOKEN_NONE)
                {
-                 g_object_unref (G_OBJECT (new_style));
+                 g_object_unref (new_style);
                  new_style = NULL;
                }
            }
@@ -3166,8 +3217,8 @@ gtk_rc_parse_engine (GtkRcContext *context,
   if (new_style)
     {
       new_style->engine_specified = TRUE;
-      
-      g_object_unref (G_OBJECT (*rc_style));
+
+      g_object_unref (*rc_style);
       *rc_style = new_style;
     }