[gtk/wip/otte/icontheme: 23/26] icontheme: Remove contexts



commit f7a5dd7b8b5e879b5bb2b8522d7f3b24d51d4c0a
Author: Benjamin Otte <otte redhat com>
Date:   Sun Feb 2 01:19:50 2020 +0100

    icontheme: Remove contexts
    
    There is no way to query contexts or do anything useful with them.
    
    So don't keep track of them and don't make them an argument in public
    APIs with the docs saying "I don't know what to use here, maybe read
    some spec somewhere".

 demos/gtk-demo/fishbowl.c |  2 +-
 gtk/gtkicontheme.c        | 91 ++++++++---------------------------------------
 gtk/gtkicontheme.h        |  3 +-
 tests/testicontheme.c     |  9 +----
 testsuite/gtk/icontheme.c |  2 +-
 5 files changed, 19 insertions(+), 88 deletions(-)
---
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index dd3619df73..111d6a199e 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -28,7 +28,7 @@ init_icon_names (GtkIconTheme *theme)
   if (icon_names)
     return;
 
-  icon_list = gtk_icon_theme_list_icons (theme, NULL);
+  icon_list = gtk_icon_theme_list_icons (theme);
   icons = g_ptr_array_new ();
 
   for (l = icon_list; l; l = l->next)
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 8f0331b4c9..f23572070d 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -341,7 +341,6 @@ typedef struct
 
 typedef struct
 {
-  GQuark context;
   gboolean is_resource;
   char *path;  /* e.g. "/usr/share/icons/hicolor/32x32/apps" */
 } IconThemeDir;
@@ -374,8 +373,7 @@ static GtkIcon *     theme_lookup_icon                     (IconTheme        *th
                                                             gint              scale,
                                                             gboolean          allow_svg);
 static void          theme_list_icons                      (IconTheme        *theme,
-                                                            GHashTable       *icons,
-                                                            GQuark            context);
+                                                            GHashTable       *icons);
 static gboolean      theme_has_icon                        (IconTheme        *theme,
                                                             const gchar      *icon_name);
 static void          theme_subdir_load                     (GtkIconTheme     *self,
@@ -397,8 +395,6 @@ static void          update_current_theme__mainthread      (GtkIconTheme     *se
 static gboolean      ensure_valid_themes                   (GtkIconTheme     *self,
                                                             gboolean          non_blocking);
 
-
-
 static guint signal_changed = 0;
 
 /* This is like a weak ref with a lock, anyone doing
@@ -2510,17 +2506,8 @@ add_key_to_list (gpointer key,
 /**
  * gtk_icon_theme_list_icons:
  * @self: a #GtkIconTheme
- * @context: (allow-none): a string identifying a particular type of
- *           icon, or %NULL to list all icons.
  *
- * Lists the icons in the current icon theme. Only a subset
- * of the icons can be listed by providing a context string.
- * The set of values for the context string is system dependent,
- * but will typically include such values as “Applications” and
- * “MimeTypes”. Contexts are explained in the
- * [Icon Theme Specification](http://www.freedesktop.org/wiki/Specifications/icon-theme-spec).
- * The standard contexts are listed in the
- * [Icon Naming Specification](http://www.freedesktop.org/wiki/Specifications/icon-naming-spec).
+ * Lists the icons in the current icon theme.
  *
  * Returns: (element-type utf8) (transfer full): a #GList list
  *     holding the names of all the icons in the theme. You must
@@ -2528,40 +2515,27 @@ add_key_to_list (gpointer key,
  *     free the list itself with g_list_free().
  */
 GList *
-gtk_icon_theme_list_icons (GtkIconTheme *self,
-                           const gchar  *context)
+gtk_icon_theme_list_icons (GtkIconTheme *self)
 {
   GHashTable *icons;
   GList *list, *l;
-  GQuark context_quark;
 
   gtk_icon_theme_lock (self);
 
   ensure_valid_themes (self, FALSE);
 
-  if (context)
-    {
-      context_quark = g_quark_try_string (context);
-
-      if (!context_quark)
-        goto out;
-    }
-  else
-    context_quark = 0;
-
   icons = g_hash_table_new (g_str_hash, g_str_equal);
 
   l = self->themes;
   while (l != NULL)
     {
-      theme_list_icons (l->data, icons, context_quark);
+      theme_list_icons (l->data, icons);
       l = l->next;
     }
 
-  if (context_quark == 0)
-    g_hash_table_foreach (self->unthemed_icons,
-                          add_key_to_hash,
-                          icons);
+  g_hash_table_foreach (self->unthemed_icons,
+                        add_key_to_hash,
+                        icons);
 
   list = NULL;
 
@@ -2571,8 +2545,6 @@ gtk_icon_theme_list_icons (GtkIconTheme *self,
 
   g_hash_table_destroy (icons);
 
- out:
-
   gtk_icon_theme_unlock (self);
 
   return list;
@@ -2919,34 +2891,16 @@ theme_lookup_icon (IconTheme   *theme,
 
 static void
 theme_list_icons (IconTheme  *theme,
-                  GHashTable *icons,
-                  GQuark      context)
+                  GHashTable *icons)
 {
-  int i;
+  GHashTableIter iter;
+  gpointer key;
 
-  for (i = 0; i < theme->dir_sizes->len; i++)
+  g_hash_table_iter_init (&iter, theme->icons);
+  while (g_hash_table_iter_next (&iter, &key, NULL))
     {
-      IconThemeDirSize *dir_size = &g_array_index (theme->dir_sizes, IconThemeDirSize, i);
-      GHashTableIter iter;
-      gpointer key, value;
-
-      g_hash_table_iter_init (&iter, dir_size->icon_hash);
-      while (g_hash_table_iter_next (&iter, &key, &value))
-        {
-          char *icon_name = key;
-          gint file_index = GPOINTER_TO_INT (value);
-
-          if (context != 0)
-            {
-              IconThemeFile *file = &g_array_index (dir_size->icon_files, IconThemeFile, file_index);
-              IconThemeDir *dir = &g_array_index (theme->dirs, IconThemeDir, file->dir_index);
-
-              if (dir->context != context)
-                continue;
-            }
-
-          g_hash_table_insert (icons, icon_name, NULL);
-        }
+      char *icon_name = key;
+      g_hash_table_insert (icons, icon_name, NULL);
     }
 }
 
@@ -3084,14 +3038,12 @@ theme_ensure_dir_size (IconTheme *theme,
 
 static guint32
 theme_add_icon_dir (IconTheme *theme,
-                    GQuark context,
                     gboolean is_resource,
                     char *path /* takes ownership */)
 {
   IconThemeDir new_dir = { 0 };
   guint32 dir_index;
 
-  new_dir.context = context;
   new_dir.is_resource = is_resource;
   new_dir.path = path;
 
@@ -3135,7 +3087,6 @@ theme_add_icon_file (IconTheme *theme,
 static void
 theme_add_dir_with_icons (IconTheme *theme,
                           IconThemeDirSize *dir_size,
-                          GQuark context,
                           gboolean is_resource,
                           char *path /* takes ownership */,
                           GHashTable *icons)
@@ -3144,7 +3095,7 @@ theme_add_dir_with_icons (IconTheme *theme,
   gpointer key, value;
   guint32 dir_index;
 
-  dir_index = theme_add_icon_dir (theme, context, is_resource, path);
+  dir_index = theme_add_icon_dir (theme, is_resource, path);
 
   g_hash_table_iter_init (&iter, icons);
   while (g_hash_table_iter_next (&iter, &key, &value))
@@ -3164,8 +3115,6 @@ theme_subdir_load (GtkIconTheme *self,
   GList *d;
   gchar *type_string;
   IconThemeDirType type;
-  gchar *context_string;
-  GQuark context;
   gint size;
   gint min_size;
   gint max_size;
@@ -3222,14 +3171,6 @@ theme_subdir_load (GtkIconTheme *self,
   dir_size_index = theme_ensure_dir_size (theme, type, size, min_size, max_size, threshold, scale);
   dir_size = &g_array_index (theme->dir_sizes, IconThemeDirSize, dir_size_index);
 
-  context = 0;
-  context_string = g_key_file_get_string (theme_file, subdir, "Context", NULL);
-  if (context_string)
-    {
-      context = g_quark_from_string (context_string);
-      g_free (context_string);
-    }
-
   for (d = self->dir_mtimes; d; d = d->next)
     {
       gchar *full_dir;
@@ -3260,7 +3201,6 @@ theme_subdir_load (GtkIconTheme *self,
             {
               theme_add_dir_with_icons (theme,
                                         dir_size,
-                                        context,
                                         FALSE,
                                         g_steal_pointer (&full_dir),
                                         icons);
@@ -3287,7 +3227,6 @@ theme_subdir_load (GtkIconTheme *self,
             {
               theme_add_dir_with_icons (theme,
                                         dir_size,
-                                        context,
                                         TRUE,
                                         g_steal_pointer (&full_dir),
                                         icons);
diff --git a/gtk/gtkicontheme.h b/gtk/gtkicontheme.h
index 2f98e44295..2a54f5bbf6 100644
--- a/gtk/gtkicontheme.h
+++ b/gtk/gtkicontheme.h
@@ -145,8 +145,7 @@ GtkIcon *   gtk_icon_theme_lookup_by_gicon         (GtkIconTheme
                                                     GtkTextDirection             direction,
                                                     GtkIconLookupFlags           flags);
 GDK_AVAILABLE_IN_ALL
-GList *       gtk_icon_theme_list_icons            (GtkIconTheme                *self,
-                                                    const gchar                 *context);
+GList *       gtk_icon_theme_list_icons            (GtkIconTheme                *self);
 
 
 GDK_AVAILABLE_IN_ALL
diff --git a/tests/testicontheme.c b/tests/testicontheme.c
index 21acb2b9ed..f142e30220 100644
--- a/tests/testicontheme.c
+++ b/tests/testicontheme.c
@@ -37,7 +37,6 @@ main (int argc, char *argv[])
 {
   GtkIconTheme *icon_theme;
   GtkIcon *icon;
-  char *context;
   char *themename;
   GList *list;
   int size = 48;
@@ -105,13 +104,7 @@ main (int argc, char *argv[])
     }
   else if (strcmp (argv[1], "list") == 0)
     {
-      if (argc >= 4)
-       context = argv[3];
-      else
-       context = NULL;
-
-      list = gtk_icon_theme_list_icons (icon_theme,
-                                          context);
+      list = gtk_icon_theme_list_icons (icon_theme);
       
       while (list)
        {
diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c
index 081acbec1e..88e4afd4cf 100644
--- a/testsuite/gtk/icontheme.c
+++ b/testsuite/gtk/icontheme.c
@@ -596,7 +596,7 @@ test_list (void)
   GList *icons;
 
   theme = get_test_icontheme (TRUE);
-  icons = gtk_icon_theme_list_icons (theme, NULL);
+  icons = gtk_icon_theme_list_icons (theme);
 
   g_assert (g_list_find_custom (icons, "size-test", (GCompareFunc)g_strcmp0));
   g_assert (g_list_find_custom (icons, "simple", (GCompareFunc)g_strcmp0));


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