]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkicontheme.c
[Bug 675501] gtkquartz.h is not in the gtk+-3.5.2.tar.xz archive
[~andy/gtk] / gtk / gtkicontheme.c
index 1845adb5ae252a9522af43a3a1ffa9648858d746..3eb333ff987621e07259106ca9dd21f0d9623513 100644 (file)
@@ -12,9 +12,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 #include "gtksettings.h"
 #include "gtkprivate.h"
 
+#undef GDK_DEPRECATED
+#undef GDK_DEPRECATED_FOR
+#define GDK_DEPRECATED
+#define GDK_DEPRECATED_FOR(f)
+
+#include "deprecated/gtkstyle.h"
+
 
 /**
  * SECTION:gtkicontheme
@@ -423,7 +428,7 @@ gtk_icon_theme_class_init (GtkIconThemeClass *klass)
   gobject_class->finalize = gtk_icon_theme_finalize;
 
 /**
- * GtkIconTheme::changed
+ * GtkIconTheme::changed:
  * @icon_theme: the icon theme
  * 
  * Emitted when the current icon theme is switched or GTK+ detects
@@ -655,8 +660,8 @@ gtk_icon_theme_init (GtkIconTheme *icon_theme)
   priv->search_path = g_new (char *, priv->search_path_len);
   
   i = 0;
-  priv->search_path[i++] = g_build_filename (g_get_home_dir (), ".icons", NULL);
   priv->search_path[i++] = g_build_filename (g_get_user_data_dir (), "icons", NULL);
+  priv->search_path[i++] = g_build_filename (g_get_home_dir (), ".icons", NULL);
   
   for (j = 0; xdg_data_dirs[j]; j++) 
     priv->search_path[i++] = g_build_filename (xdg_data_dirs[j], "icons", NULL);
@@ -726,10 +731,8 @@ blow_themes (GtkIconTheme *icon_theme)
   if (priv->themes_valid)
     {
       g_hash_table_destroy (priv->all_icons);
-      g_list_foreach (priv->themes, (GFunc)theme_destroy, NULL);
-      g_list_free (priv->themes);
-      g_list_foreach (priv->dir_mtimes, (GFunc)free_dir_mtime, NULL);
-      g_list_free (priv->dir_mtimes);
+      g_list_free_full (priv->themes, (GDestroyNotify) theme_destroy);
+      g_list_free_full (priv->dir_mtimes, (GDestroyNotify) free_dir_mtime);
       g_hash_table_destroy (priv->unthemed_icons);
     }
   priv->themes = NULL;
@@ -979,7 +982,7 @@ insert_theme (GtkIconTheme *icon_theme, const char *theme_name)
   GKeyFile *theme_file;
   GError *error = NULL;
   IconThemeDirMtime *dir_mtime;
-  struct stat stat_buf;
+  GStatBuf stat_buf;
   
   priv = icon_theme->priv;
 
@@ -1123,7 +1126,7 @@ load_themes (GtkIconTheme *icon_theme)
   IconSuffix old_suffix, new_suffix;
   GTimeVal tv;
   IconThemeDirMtime *dir_mtime;
-  struct stat stat_buf;
+  GStatBuf stat_buf;
   
   priv = icon_theme->priv;
 
@@ -1215,9 +1218,10 @@ load_themes (GtkIconTheme *icon_theme)
                  else
                    unthemed_icon->no_svg_filename = abs_file;
 
-                 g_hash_table_insert (priv->unthemed_icons,
-                                      base_name,
-                                      unthemed_icon);
+                 /* takes ownership of base_name */
+                 g_hash_table_replace (priv->unthemed_icons,
+                                       base_name,
+                                       unthemed_icon);
                  g_hash_table_insert (priv->all_icons,
                                       base_name, NULL);
                }
@@ -1326,6 +1330,23 @@ choose_icon (GtkIconTheme       *icon_theme,
   
   ensure_valid_themes (icon_theme);
 
+  /* for symbolic icons, do a search in all registered themes first;
+   * a theme that inherits them from a parent theme might provide
+   * an alternative highcolor version, but still expect the symbolic icon
+   * to show up instead.
+   */
+  if (icon_names[0] &&
+      g_str_has_suffix (icon_names[0], "-symbolic"))
+    {
+      for (l = priv->themes; l; l = l->next)
+        {
+          IconTheme *theme = l->data;
+          icon_info = theme_lookup_icon (theme, icon_names[0], size, allow_svg, use_builtin);
+          if (icon_info)
+            goto out;
+        }
+    }
+
   for (l = priv->themes; l; l = l->next)
     {
       IconTheme *theme = l->data;
@@ -1419,10 +1440,10 @@ choose_icon (GtkIconTheme       *icon_theme,
 
          if (!found)
            {
-             g_warning (_("Could not find the icon '%s'. The '%s' theme\n"
-                          "was not found either, perhaps you need to install it.\n"
-                          "You can get a copy from:\n"
-                          "\t%s"),
+             g_warning ("Could not find the icon '%s'. The '%s' theme\n"
+                        "was not found either, perhaps you need to install it.\n"
+                        "You can get a copy from:\n"
+                        "\t%s",
                         icon_names[0], DEFAULT_THEME_NAME, "http://icon-theme.freedesktop.org/releases");
            }
        }
@@ -1947,7 +1968,7 @@ rescan_themes (GtkIconTheme *icon_theme)
   IconThemeDirMtime *dir_mtime;
   GList *d;
   int stat_res;
-  struct stat stat_buf;
+  GStatBuf stat_buf;
   GTimeVal tv;
 
   priv = icon_theme->priv;
@@ -2012,8 +2033,7 @@ theme_destroy (IconTheme *theme)
   g_free (theme->name);
   g_free (theme->example);
 
-  g_list_foreach (theme->dirs, (GFunc)theme_dir_destroy, NULL);
-  g_list_free (theme->dirs);
+  g_list_free_full (theme->dirs, (GDestroyNotify) theme_dir_destroy);
   
   g_free (theme);
 }
@@ -2412,6 +2432,7 @@ load_icon_data (IconThemeDir *dir, const char *path, const char *name)
       base_name = strip_suffix (name);
       
       data = g_slice_new0 (GtkIconData);
+      /* takes ownership of base_name */
       g_hash_table_replace (dir->icon_data, base_name, data);
       
       ivalues = g_key_file_get_integer_list (icon_file, 
@@ -2510,6 +2531,7 @@ scan_directory (GtkIconThemePrivate *icon_theme,
 
       hash_suffix = GPOINTER_TO_INT (g_hash_table_lookup (dir->icons, base_name));
       g_hash_table_replace (icon_theme->all_icons, base_name, NULL);
+      /* takes ownership of base_name */
       g_hash_table_replace (dir->icons, base_name, GUINT_TO_POINTER (hash_suffix| suffix));
     }
   
@@ -2567,32 +2589,20 @@ theme_subdir_load (GtkIconTheme *icon_theme,
       g_free (context_string);
     }
 
-  max_size = g_key_file_get_integer (theme_file, subdir, "MaxSize", &error);
-  if (error)
-    {
-      max_size = size;
-
-      g_error_free (error);
-      error = NULL;
-    }
-
-  min_size = g_key_file_get_integer (theme_file, subdir, "MinSize", &error);
-  if (error)
-    {
-      min_size = size;
+  if (g_key_file_has_key (theme_file, subdir, "MaxSize", NULL))
+    max_size = g_key_file_get_integer (theme_file, subdir, "MaxSize", NULL);
+  else
+    max_size = size;
 
-      g_error_free (error);
-      error = NULL;
-    }
-  
-  threshold = g_key_file_get_integer (theme_file, subdir, "Threshold", &error);
-  if (error)
-    {
-      threshold = 2;
+  if (g_key_file_has_key (theme_file, subdir, "MinSize", NULL))
+    min_size = g_key_file_get_integer (theme_file, subdir, "MinSize", NULL);
+  else
+    min_size = size;
 
-      g_error_free (error);
-      error = NULL;
-    }
+  if (g_key_file_has_key (theme_file, subdir, "Threshold", NULL))
+    threshold = g_key_file_get_integer (theme_file, subdir, "Threshold", NULL);
+  else
+    threshold = 2;
 
   for (d = icon_theme->priv->dir_mtimes; d; d = d->next)
     {
@@ -2722,8 +2732,7 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
   g_free (icon_info->filename);
   if (icon_info->loadable)
     g_object_unref (icon_info->loadable);
-  g_slist_foreach (icon_info->emblem_infos, (GFunc)gtk_icon_info_free, NULL);
-  g_slist_free (icon_info->emblem_infos);
+  g_slist_free_full (icon_info->emblem_infos, (GDestroyNotify) gtk_icon_info_free);
   if (icon_info->pixbuf)
     g_object_unref (icon_info->pixbuf);
   if (icon_info->cache_pixbuf)
@@ -2774,7 +2783,7 @@ gtk_icon_info_get_base_size (GtkIconInfo *icon_info)
  *
  * Since: 2.4
  **/
-G_CONST_RETURN gchar *
+const gchar *
 gtk_icon_info_get_filename (GtkIconInfo *icon_info)
 {
   g_return_val_if_fail (icon_info != NULL, NULL);
@@ -3650,7 +3659,7 @@ gtk_icon_info_get_attach_points (GtkIconInfo *icon_info,
  *
  * Since: 2.4
  **/
-G_CONST_RETURN gchar *
+const gchar *
 gtk_icon_info_get_display_name (GtkIconInfo *icon_info)
 {
   g_return_val_if_fail (icon_info != NULL, NULL);