st/icon-theme: Change namespace to ST

We are still linking to GTK, and extensions may import GTK for
whatever reason, so avoid conflicts by moving the copied GTK
code into our namespace.

With that and the previous adjustments, the new code is now
finally buildable.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2620>
This commit is contained in:
Florian Müllner 2023-01-26 03:36:03 +01:00 committed by Marge Bot
parent 934faaacef
commit bf00a7957b
5 changed files with 726 additions and 807 deletions

View File

@ -122,7 +122,9 @@ st_sources = [
'st-focus-manager.c',
'st-generic-accessible.c',
'st-icon.c',
'st-icon-cache.c',
'st-icon-colors.c',
'st-icon-theme.c',
'st-image-content.c',
'st-label.c',
'st-password-entry.c',

View File

@ -42,7 +42,7 @@
#define GET_UINT32(cache, offset) (GUINT32_FROM_BE (*(guint32 *)((cache) + (offset))))
struct _GtkIconCache {
struct _StIconCache {
int ref_count;
GMappedFile *map;
@ -51,15 +51,15 @@ struct _GtkIconCache {
guint32 last_chain_offset;
};
GtkIconCache *
_gtk_icon_cache_ref (GtkIconCache *cache)
StIconCache *
st_icon_cache_ref (StIconCache *cache)
{
cache->ref_count++;
return cache;
}
void
_gtk_icon_cache_unref (GtkIconCache *cache)
st_icon_cache_unref (StIconCache *cache)
{
cache->ref_count --;
@ -73,10 +73,10 @@ _gtk_icon_cache_unref (GtkIconCache *cache)
}
}
GtkIconCache *
_gtk_icon_cache_new_for_path (const char *path)
StIconCache *
st_icon_cache_new_for_path (const char *path)
{
GtkIconCache *cache = NULL;
StIconCache *cache = NULL;
GMappedFile *map;
char *cache_filename;
@ -115,7 +115,7 @@ _gtk_icon_cache_new_for_path (const char *path)
g_debug ("found icon cache for %s", path);
cache = g_new0 (GtkIconCache, 1);
cache = g_new0 (StIconCache, 1);
cache->ref_count = 1;
cache->map = map;
cache->buffer = g_mapped_file_get_contents (map);
@ -128,12 +128,12 @@ _gtk_icon_cache_new_for_path (const char *path)
return cache;
}
GtkIconCache *
_gtk_icon_cache_new (const char *data)
StIconCache *
st_icon_cache_new (const char *data)
{
GtkIconCache *cache;
StIconCache *cache;
cache = g_new0 (GtkIconCache, 1);
cache = g_new0 (StIconCache, 1);
cache->ref_count = 1;
cache->map = NULL;
cache->buffer = (char *)data;
@ -142,7 +142,7 @@ _gtk_icon_cache_new (const char *data)
}
static int
get_directory_index (GtkIconCache *cache,
get_directory_index (StIconCache *cache,
const char *directory)
{
guint32 dir_list_offset;
@ -165,7 +165,7 @@ get_directory_index (GtkIconCache *cache,
}
int
_gtk_icon_cache_get_directory_index (GtkIconCache *cache,
st_icon_cache_get_directory_index (StIconCache *cache,
const char *directory)
{
return get_directory_index (cache, directory);
@ -185,7 +185,7 @@ icon_name_hash (gconstpointer key)
}
static int
find_image_offset (GtkIconCache *cache,
find_image_offset (StIconCache *cache,
const char *icon_name,
int directory_index)
{
@ -247,7 +247,7 @@ find_dir:
}
int
_gtk_icon_cache_get_icon_flags (GtkIconCache *cache,
st_icon_cache_get_icon_flags (StIconCache *cache,
const char *icon_name,
int directory_index)
{
@ -262,7 +262,7 @@ _gtk_icon_cache_get_icon_flags (GtkIconCache *cache,
}
gboolean
_gtk_icon_cache_has_icons (GtkIconCache *cache,
st_icon_cache_has_icons (StIconCache *cache,
const char *directory)
{
int directory_index;
@ -302,7 +302,7 @@ _gtk_icon_cache_has_icons (GtkIconCache *cache,
}
void
_gtk_icon_cache_add_icons (GtkIconCache *cache,
st_icon_cache_add_icons (StIconCache *cache,
const char *directory,
GHashTable *hash_table)
{
@ -344,7 +344,7 @@ _gtk_icon_cache_add_icons (GtkIconCache *cache,
}
gboolean
_gtk_icon_cache_has_icon (GtkIconCache *cache,
st_icon_cache_has_icon (StIconCache *cache,
const char *icon_name)
{
guint32 hash_offset;
@ -373,7 +373,7 @@ _gtk_icon_cache_has_icon (GtkIconCache *cache,
}
gboolean
_gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache,
st_icon_cache_has_icon_in_directory (StIconCache *cache,
const char *icon_name,
const char *directory)
{
@ -432,13 +432,13 @@ static void
pixbuf_destroy_cb (guchar *pixels,
gpointer data)
{
GtkIconCache *cache = data;
StIconCache *cache = data;
_gtk_icon_cache_unref (cache);
st_icon_cache_unref (cache);
}
GdkPixbuf *
_gtk_icon_cache_get_icon (GtkIconCache *cache,
st_icon_cache_get_icon (StIconCache *cache,
const char *icon_name,
int directory_index)
{
@ -495,7 +495,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
return NULL;
}
_gtk_icon_cache_ref (cache);
st_icon_cache_ref (cache);
return pixbuf;
}

View File

@ -14,38 +14,36 @@
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ICON_CACHE_H__
#define __GTK_ICON_CACHE_H__
#ifndef __ST_ICON_CACHE_H__
#define __ST_ICON_CACHE_H__
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
typedef struct _GtkIconCache GtkIconCache;
typedef struct _StIconCache StIconCache;
GtkIconCache *_gtk_icon_cache_new (const char *data);
GtkIconCache *_gtk_icon_cache_new_for_path (const char *path);
int _gtk_icon_cache_get_directory_index (GtkIconCache *cache,
StIconCache *st_icon_cache_new (const char *data);
StIconCache *st_icon_cache_new_for_path (const char *path);
int st_icon_cache_get_directory_index (StIconCache *cache,
const char *directory);
gboolean _gtk_icon_cache_has_icon (GtkIconCache *cache,
gboolean st_icon_cache_has_icon (StIconCache *cache,
const char *icon_name);
gboolean _gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache,
gboolean st_icon_cache_has_icon_in_directory (StIconCache *cache,
const char *icon_name,
const char *directory);
gboolean _gtk_icon_cache_has_icons (GtkIconCache *cache,
gboolean st_icon_cache_has_icons (StIconCache *cache,
const char *directory);
void _gtk_icon_cache_add_icons (GtkIconCache *cache,
void st_icon_cache_add_icons (StIconCache *cache,
const char *directory,
GHashTable *hash_table);
int _gtk_icon_cache_get_icon_flags (GtkIconCache *cache,
int st_icon_cache_get_icon_flags (StIconCache *cache,
const char *icon_name,
int directory_index);
GdkPixbuf *_gtk_icon_cache_get_icon (GtkIconCache *cache,
GdkPixbuf * st_icon_cache_get_icon (StIconCache *cache,
const char *icon_name,
int directory_index);
GtkIconCache *_gtk_icon_cache_ref (GtkIconCache *cache);
void _gtk_icon_cache_unref (GtkIconCache *cache);
StIconCache *st_icon_cache_ref (StIconCache *cache);
void st_icon_cache_unref (StIconCache *cache);
#endif /* __GTK_ICON_CACHE_H__ */
#endif /* __ST_ICON_CACHE_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* GtkIconTheme - a loader for icon themes
/* StIconTheme - a loader for icon themes
* gtk-icon-loader.h Copyright (C) 2002, 2003 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
@ -15,203 +15,191 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ICON_THEME_H__
#define __GTK_ICON_THEME_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
#error "Only <st/st.h> can be included directly.h"
#endif
#pragma once
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
G_BEGIN_DECLS
#define GTK_TYPE_ICON_INFO (gtk_icon_info_get_type ())
G_DECLARE_FINAL_TYPE (GtkIconInfo, gtk_icon_info, GTK, ICON_INFO, GObject)
#define ST_TYPE_ICON_INFO (st_icon_info_get_type ())
G_DECLARE_FINAL_TYPE (StIconInfo, st_icon_info, ST, ICON_INFO, GObject)
#define GTK_TYPE_ICON_THEME (gtk_icon_theme_get_type ())
G_DECLARE_FINAL_TYPE (GtkIconTheme, gtk_icon_theme, GTK, ICON_THEME, GOBject)
#define ST_TYPE_ICON_THEME (st_icon_theme_get_type ())
G_DECLARE_FINAL_TYPE (StIconTheme, st_icon_theme, ST, ICON_THEME, GObject)
/**
* GtkIconLookupFlags:
* @GTK_ICON_LOOKUP_NO_SVG: Never get SVG icons, even if gdk-pixbuf
* supports them. Cannot be used together with %GTK_ICON_LOOKUP_FORCE_SVG.
* @GTK_ICON_LOOKUP_FORCE_SVG: Get SVG icons, even if gdk-pixbuf
* StIconLookupFlags:
* @ST_ICON_LOOKUP_NO_SVG: Never get SVG icons, even if gdk-pixbuf
* supports them. Cannot be used together with %ST_ICON_LOOKUP_FORCE_SVG.
* @ST_ICON_LOOKUP_FORCE_SVG: Get SVG icons, even if gdk-pixbuf
* doesnt support them.
* Cannot be used together with %GTK_ICON_LOOKUP_NO_SVG.
* @GTK_ICON_LOOKUP_GENERIC_FALLBACK: Try to shorten icon name at '-'
* Cannot be used together with %ST_ICON_LOOKUP_NO_SVG.
* @ST_ICON_LOOKUP_GENERIC_FALLBACK: Try to shorten icon name at '-'
* characters before looking at inherited themes. This flag is only
* supported in functions that take a single icon name. For more general
* fallback, see gtk_icon_theme_choose_icon(). Since 2.12.
* @GTK_ICON_LOOKUP_FORCE_SIZE: Always get the icon scaled to the
* requested size. Since 2.14.
* @GTK_ICON_LOOKUP_FORCE_REGULAR: Try to always load regular icons, even
* when symbolic icon names are given. Since 3.14.
* @GTK_ICON_LOOKUP_FORCE_SYMBOLIC: Try to always load symbolic icons, even
* when regular icon names are given. Since 3.14.
* @GTK_ICON_LOOKUP_DIR_LTR: Try to load a variant of the icon for left-to-right
* text direction. Since 3.14.
* @GTK_ICON_LOOKUP_DIR_RTL: Try to load a variant of the icon for right-to-left
* text direction. Since 3.14.
* fallback, see st_icon_theme_choose_icon().
* @ST_ICON_LOOKUP_FORCE_SIZE: Always get the icon scaled to the
* requested size.
* @ST_ICON_LOOKUP_FORCE_REGULAR: Try to always load regular icons, even
* when symbolic icon names are given.
* @ST_ICON_LOOKUP_FORCE_SYMBOLIC: Try to always load symbolic icons, even
* when regular icon names are given.
* @ST_ICON_LOOKUP_DIR_LTR: Try to load a variant of the icon for left-to-right
* text direction.
* @ST_ICON_LOOKUP_DIR_RTL: Try to load a variant of the icon for right-to-left
* text direction.
*
* Used to specify options for gtk_icon_theme_lookup_icon()
* Used to specify options for st_icon_theme_lookup_icon()
*/
typedef enum
{
GTK_ICON_LOOKUP_NO_SVG = 1 << 0,
GTK_ICON_LOOKUP_FORCE_SVG = 1 << 1,
GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 2,
GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 3,
GTK_ICON_LOOKUP_FORCE_REGULAR = 1 << 4,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC = 1 << 5,
GTK_ICON_LOOKUP_DIR_LTR = 1 << 6,
GTK_ICON_LOOKUP_DIR_RTL = 1 << 7
} GtkIconLookupFlags;
ST_ICON_LOOKUP_NO_SVG = 1 << 0,
ST_ICON_LOOKUP_FORCE_SVG = 1 << 1,
ST_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 2,
ST_ICON_LOOKUP_FORCE_SIZE = 1 << 3,
ST_ICON_LOOKUP_FORCE_REGULAR = 1 << 4,
ST_ICON_LOOKUP_FORCE_SYMBOLIC = 1 << 5,
ST_ICON_LOOKUP_DIR_LTR = 1 << 6,
ST_ICON_LOOKUP_DIR_RTL = 1 << 7
} StIconLookupFlags;
/**
* GTK_ICON_THEME_ERROR:
* ST_ICON_THEME_ERROR:
*
* The #GQuark used for #GtkIconThemeError errors.
* The #GQuark used for #StIconThemeError errors.
*/
#define GTK_ICON_THEME_ERROR gtk_icon_theme_error_quark ()
#define ST_ICON_THEME_ERROR st_icon_theme_error_quark ()
/**
* GtkIconThemeError:
* @GTK_ICON_THEME_NOT_FOUND: The icon specified does not exist in the theme
* @GTK_ICON_THEME_FAILED: An unspecified error occurred.
* StIconThemeError:
* @ST_ICON_THEME_NOT_FOUND: The icon specified does not exist in the theme
* @ST_ICON_THEME_FAILED: An unspecified error occurred.
*
* Error codes for GtkIconTheme operations.
* Error codes for StIconTheme operations.
**/
typedef enum {
GTK_ICON_THEME_NOT_FOUND,
GTK_ICON_THEME_FAILED
} GtkIconThemeError;
ST_ICON_THEME_NOT_FOUND,
ST_ICON_THEME_FAILED
} StIconThemeError;
GDK_AVAILABLE_IN_ALL
GQuark gtk_icon_theme_error_quark (void);
GQuark st_icon_theme_error_quark (void);
GDK_AVAILABLE_IN_ALL
GtkIconTheme *gtk_icon_theme_new (void);
StIconTheme *st_icon_theme_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_set_search_path (GtkIconTheme *icon_theme,
void st_icon_theme_set_search_path (StIconTheme *icon_theme,
const char *path[],
int n_elements);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_get_search_path (GtkIconTheme *icon_theme,
void st_icon_theme_get_search_path (StIconTheme *icon_theme,
char **path[],
int *n_elements);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_append_search_path (GtkIconTheme *icon_theme,
const char *path);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_prepend_search_path (GtkIconTheme *icon_theme,
void st_icon_theme_append_search_path (StIconTheme *icon_theme,
const char *path);
GDK_AVAILABLE_IN_3_14
void gtk_icon_theme_add_resource_path (GtkIconTheme *icon_theme,
void st_icon_theme_prepend_search_path (StIconTheme *icon_theme,
const char *path);
GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_theme_has_icon (GtkIconTheme *icon_theme,
void st_icon_theme_add_resource_path (StIconTheme *icon_theme,
const char *path);
gboolean st_icon_theme_has_icon (StIconTheme *icon_theme,
const char *icon_name);
GDK_AVAILABLE_IN_ALL
int *gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme,
int * st_icon_theme_get_icon_sizes (StIconTheme *icon_theme,
const char *icon_name);
GDK_AVAILABLE_IN_ALL
GtkIconInfo * gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme,
StIconInfo * st_icon_theme_lookup_icon (StIconTheme *icon_theme,
const char *icon_name,
int size,
GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_3_10
GtkIconInfo * gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *icon_theme,
StIconLookupFlags flags);
StIconInfo * st_icon_theme_lookup_icon_for_scale (StIconTheme *icon_theme,
const char *icon_name,
int size,
int scale,
GtkIconLookupFlags flags);
StIconLookupFlags flags);
GDK_AVAILABLE_IN_ALL
GtkIconInfo * gtk_icon_theme_choose_icon (GtkIconTheme *icon_theme,
StIconInfo * st_icon_theme_choose_icon (StIconTheme *icon_theme,
const char *icon_names[],
int size,
GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_3_10
GtkIconInfo * gtk_icon_theme_choose_icon_for_scale (GtkIconTheme *icon_theme,
StIconLookupFlags flags);
StIconInfo * st_icon_theme_choose_icon_for_scale (StIconTheme *icon_theme,
const char *icon_names[],
int size,
int scale,
GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_ALL
GdkPixbuf * gtk_icon_theme_load_icon (GtkIconTheme *icon_theme,
StIconLookupFlags flags);
GdkPixbuf * st_icon_theme_load_icon (StIconTheme *icon_theme,
const char *icon_name,
int size,
GtkIconLookupFlags flags,
StIconLookupFlags flags,
GError **error);
GDK_AVAILABLE_IN_3_10
GdkPixbuf * gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
GdkPixbuf * st_icon_theme_load_icon_for_scale (StIconTheme *icon_theme,
const char *icon_name,
int size,
int scale,
GtkIconLookupFlags flags,
StIconLookupFlags flags,
GError **error);
GDK_AVAILABLE_IN_ALL
GtkIconInfo * gtk_icon_theme_lookup_by_gicon (GtkIconTheme *icon_theme,
StIconInfo * st_icon_theme_lookup_by_gicon (StIconTheme *icon_theme,
GIcon *icon,
int size,
GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_3_10
GtkIconInfo * gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme,
StIconLookupFlags flags);
StIconInfo * st_icon_theme_lookup_by_gicon_for_scale (StIconTheme *icon_theme,
GIcon *icon,
int size,
int scale,
GtkIconLookupFlags flags);
StIconLookupFlags flags);
GDK_AVAILABLE_IN_ALL
GList * gtk_icon_theme_list_icons (GtkIconTheme *icon_theme,
GList * st_icon_theme_list_icons (StIconTheme *icon_theme,
const char *context);
GDK_AVAILABLE_IN_ALL
GList * gtk_icon_theme_list_contexts (GtkIconTheme *icon_theme);
GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme);
GList * st_icon_theme_list_contexts (StIconTheme *icon_theme);
GDK_AVAILABLE_IN_ALL
GtkIconInfo * gtk_icon_info_new_for_pixbuf (GtkIconTheme *icon_theme,
gboolean st_icon_theme_rescan_if_needed (StIconTheme *icon_theme);
StIconInfo * st_icon_info_new_for_pixbuf (StIconTheme *icon_theme,
GdkPixbuf *pixbuf);
GDK_AVAILABLE_IN_ALL
int gtk_icon_info_get_base_size (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_3_10
int gtk_icon_info_get_base_scale (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_ALL
const char * gtk_icon_info_get_filename (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_3_12
gboolean gtk_icon_info_is_symbolic (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_ALL
GdkPixbuf * gtk_icon_info_load_icon (GtkIconInfo *icon_info,
int st_icon_info_get_base_size (StIconInfo *icon_info);
int st_icon_info_get_base_scale (StIconInfo *icon_info);
const char * st_icon_info_get_filename (StIconInfo *icon_info);
gboolean st_icon_info_is_symbolic (StIconInfo *icon_info);
GdkPixbuf * st_icon_info_load_icon (StIconInfo *icon_info,
GError **error);
GDK_AVAILABLE_IN_3_8
void gtk_icon_info_load_icon_async (GtkIconInfo *icon_info,
void st_icon_info_load_icon_async (StIconInfo *icon_info,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_3_8
GdkPixbuf * gtk_icon_info_load_icon_finish (GtkIconInfo *icon_info,
GdkPixbuf * st_icon_info_load_icon_finish (StIconInfo *icon_info,
GAsyncResult *res,
GError **error);
GDK_AVAILABLE_IN_ALL
GdkPixbuf * gtk_icon_info_load_symbolic (GtkIconInfo *icon_info,
GdkPixbuf * st_icon_info_load_symbolic (StIconInfo *icon_info,
const GdkRGBA *fg,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color,
gboolean *was_symbolic,
GError **error);
GDK_AVAILABLE_IN_3_8
void gtk_icon_info_load_symbolic_async (GtkIconInfo *icon_info,
void st_icon_info_load_symbolic_async (StIconInfo *icon_info,
const GdkRGBA *fg,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
@ -219,11 +207,9 @@ void gtk_icon_info_load_symbolic_async (GtkIconInfo *icon_inf
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_3_8
GdkPixbuf * gtk_icon_info_load_symbolic_finish (GtkIconInfo *icon_info,
GdkPixbuf * st_icon_info_load_symbolic_finish (StIconInfo *icon_info,
GAsyncResult *res,
gboolean *was_symbolic,
GError **error);
G_END_DECLS
#endif /* __GTK_ICON_THEME_H__ */