#include "gdk/gdktextureprivate.h"
#include "gdk/gdkprofilerprivate.h"
-/* this is in case round() is not provided by the compiler,
+/* this is in case round() is not provided by the compiler,
* such as in the case of C89 compilers, like MSVC
*/
#include "fallback-c89.c"
typedef enum
{
- ICON_THEME_DIR_FIXED,
- ICON_THEME_DIR_SCALABLE,
+ ICON_THEME_DIR_FIXED,
+ ICON_THEME_DIR_SCALABLE,
ICON_THEME_DIR_THRESHOLD,
ICON_THEME_DIR_UNTHEMED
} IconThemeDirType;
gchar *dir;
gchar *subdir;
gint subdir_index;
-
+
GtkIconCache *cache;
-
+
GHashTable *icons;
} IconThemeDir;
gboolean is_resource;
} UnthemedIcon;
-typedef struct
+typedef struct
{
gchar *dir;
time_t mtime;
/**
* gtk_icon_theme_new:
- *
+ *
* Creates a new icon theme object. Icon theme objects are used
* to lookup up an icon by name in a particular icon theme.
* Usually, you’ll want to use gtk_icon_theme_get_default()
* or gtk_icon_theme_get_for_display() rather than creating
* a new icon theme object for scratch.
- *
+ *
* Returns: the newly created #GtkIconTheme object.
*/
GtkIconTheme *
/**
* gtk_icon_theme_get_default:
- *
+ *
* Gets the icon theme for the default display. See
* gtk_icon_theme_get_for_display().
*
/**
* gtk_icon_theme_get_for_display:
* @display: a #GdkDisplay
- *
+ *
* Gets the icon theme object associated with @display; if this
* function has not previously been called for the given
* display, a new icon theme object will be created and
* gtk_icon_theme_set_display:
* @self: a #GtkIconTheme
* @display: a #GdkDisplay
- *
+ *
* Sets the display for an icon theme; the display is used
* to track the user’s currently configured icon theme,
* which might be different for different displays.
formats = gdk_pixbuf_get_formats ();
- found_svg = FALSE;
+ found_svg = FALSE;
for (tmp_list = formats; tmp_list && !found_svg; tmp_list = tmp_list->next)
{
gchar **mime_types = gdk_pixbuf_format_get_mime_types (tmp_list->data);
gchar **mime_type;
-
+
for (mime_type = mime_types; *mime_type && !found_svg; mime_type++)
{
if (strcmp (*mime_type, "image/svg") == 0)
}
g_slist_free (formats);
-
+
return found_svg;
}
for (i = 0; xdg_data_dirs[i]; i++) ;
self->search_path_len = 2 * i + 2;
-
+
self->search_path = g_new (char *, self->search_path_len);
-
+
i = 0;
self->search_path[i++] = g_build_filename (g_get_user_data_dir (), "icons", NULL);
self->search_path[i++] = g_build_filename (g_get_home_dir (), ".icons", NULL);
-
- for (j = 0; xdg_data_dirs[j]; j++)
+
+ for (j = 0; xdg_data_dirs[j]; j++)
self->search_path[i++] = g_build_filename (xdg_data_dirs[j], "icons", NULL);
- for (j = 0; xdg_data_dirs[j]; j++)
+ for (j = 0; xdg_data_dirs[j]; j++)
self->search_path[i++] = g_build_filename (xdg_data_dirs[j], "pixmaps", NULL);
self->resource_paths = g_list_append (NULL, g_strdup ("/org/gtk/libgtk/icons/"));
* @path: (array length=n_elements) (element-type filename): array of
* directories that are searched for icon themes
* @n_elements: number of elements in @path.
- *
+ *
* Sets the search path for the icon theme object. When looking
* for an icon theme, GTK+ will search for a subdirectory of
* one or more of the directories in @path with the same name
* gtk_icon_theme_append_search_path:
* @self: a #GtkIconTheme
* @path: (type filename): directory name to append to the icon path
- *
- * Appends a directory to the search path.
- * See gtk_icon_theme_set_search_path().
+ *
+ * Appends a directory to the search path.
+ * See gtk_icon_theme_set_search_path().
*/
void
gtk_icon_theme_append_search_path (GtkIconTheme *self,
* gtk_icon_theme_prepend_search_path:
* @self: a #GtkIconTheme
* @path: (type filename): directory name to prepend to the icon path
- *
- * Prepends a directory to the search path.
+ *
+ * Prepends a directory to the search path.
* See gtk_icon_theme_set_search_path().
*/
void
* @self: a #GtkIconTheme
* @theme_name: (allow-none): name of icon theme to use instead of
* configured theme, or %NULL to unset a previously set custom theme
- *
+ *
* Sets the name of the icon theme that the #GtkIconTheme object uses
* overriding system configuration. This function cannot be called
* on the icon theme objects returned from gtk_icon_theme_get_default()
if (strcmp (theme->name, theme_name) == 0)
return;
}
-
+
for (i = 0; i < self->search_path_len; i++)
{
path = g_build_filename (self->search_path[i],
theme_name,
"index.theme",
NULL);
- if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
{
theme_file = g_key_file_new ();
g_key_file_set_list_separator (theme_file, ',');
if (theme_file == NULL)
return;
- theme->display_name =
+ theme->display_name =
g_key_file_get_locale_string (theme_file, "Icon Theme", "Name", NULL, NULL);
if (!theme->display_name)
g_warning ("Theme file for %s has no name", theme_name);
scaled_dirs = g_key_file_get_string_list (theme_file, "Icon Theme", "ScaledDirectories", NULL, NULL);
- theme->comment =
- g_key_file_get_locale_string (theme_file,
+ theme->comment =
+ g_key_file_get_locale_string (theme_file,
"Icon Theme", "Comment",
NULL, NULL);
nonsymbolic_icon_name = g_strndup (icon_name, icon_name_len - strlen ("-symbolic"));
else
nonsymbolic_icon_name = g_strdup (icon_name);
-
+
dashes = 0;
for (p = (gchar *) nonsymbolic_icon_name; *p; p++)
if (*p == '-')
* @size: desired icon size
* @scale: desired scale
* @flags: flags modifying the behavior of the icon lookup
- *
+ *
* Looks up a named icon for a particular window scale and returns
* a #GtkIcon containing information such as the filename of the
* icon. The icon can then be rendered into a pixbuf using
* gtk_icon_load_icon(). (gtk_icon_theme_load_icon()
* combines these two steps if all you need is the pixbuf.)
*
- * If @icon_names contains more than one name, this function
- * tries them all in the given order before falling back to
+ * If @icon_names contains more than one name, this function
+ * tries them all in the given order before falling back to
* inherited icon themes.
*
* Returns: (nullable) (transfer full): a #GtkIcon object
* Returns: %TRUE if @self includes an
* icon for @icon_name.
*/
-gboolean
+gboolean
gtk_icon_theme_has_icon (GtkIconTheme *self,
const gchar *icon_name)
{
* gtk_icon_theme_get_icon_sizes:
* @self: a #GtkIconTheme
* @icon_name: the name of an icon
- *
+ *
* Returns an array of integers describing the sizes at which
- * the icon is available without scaling. A size of -1 means
- * that the icon is available in a scalable format. The array
+ * the icon is available without scaling. A size of -1 means
+ * that the icon is available in a scalable format. The array
* is zero-terminated.
*
* Returns: (array zero-terminated=1) (transfer full): A newly
context_quark = 0;
icons = g_hash_table_new (g_str_hash, g_str_equal);
-
+
l = self->themes;
while (l != NULL)
{
icons);
list = NULL;
-
+
g_hash_table_foreach (icons,
add_key_to_list,
&list);
/**
* gtk_icon_theme_rescan_if_needed:
* @self: a #GtkIconTheme
- *
+ *
* Checks to see if the icon theme has changed; if it has, any
* currently cached information is discarded and will be reloaded
* next time @self is accessed.
- *
+ *
* Returns: %TRUE if the icon theme has changed and needed
* to be reloaded.
*/
g_free (theme->name);
g_list_free_full (theme->dirs, (GDestroyNotify) theme_dir_destroy);
-
+
g_free (theme);
}
gtk_icon_cache_unref (dir->cache);
if (dir->icons)
g_hash_table_destroy (dir->icons);
-
+
g_free (dir->dir);
g_free (dir->subdir);
g_free (dir);
else
return ICON_SUFFIX_NONE;
}
-
+
static IconSuffix
theme_dir_get_icon_suffix (IconThemeDir *dir,
const gchar *icon_name)
{
if (difference_b != 0)
return TRUE;
-
+
/* a and b both exact matches */
}
else
if (dir_a->size < requested_size &&
dir_b->size >= requested_size)
return FALSE;
-
+
/* Otherwise prefer the closest match */
if (difference_a < difference_b)
if (dir_a->type == ICON_THEME_DIR_SCALABLE &&
dir_b->type != ICON_THEME_DIR_SCALABLE)
return FALSE;
-
+
/* a and b both are scalable */
diff_a = abs (requested_size * requested_scale - dir_a->size * dir_a->scale);
}
static void
-theme_list_icons (IconTheme *theme,
+theme_list_icons (IconTheme *theme,
GHashTable *icons,
GQuark context)
{
GList *l = theme->dirs;
IconThemeDir *dir;
-
+
while (l != NULL)
{
dir = l->data;
/**
* gtk_icon_get_base_size:
* @self: a #GtkIcon
- *
+ *
* Gets the base size for the icon. The base size
* is a size for the icon that was specified by
* the icon theme creator. This may be different
/**
* gtk_icon_get_filename:
* @self: a #GtkIcon
- *
+ *
* Gets the filename for the icon. If the %GTK_ICON_LOOKUP_USE_BUILTIN
* flag was passed to gtk_icon_theme_lookup_icon(), there may be no
* filename if a builtin icon is returned; in this case, you should
* use gtk_icon_get_builtin_pixbuf().
- *
+ *
* Returns: (nullable) (type filename): the filename for the icon, or %NULL
* if gtk_icon_get_builtin_pixbuf() should be used instead.
* The return value is owned by GTK+ and should not be modified