st/icon-theme: Standard types

The GTK code dates back to a time when "gchar" and friends were
still considered a good idea. Replace them with standard types
except for "guint" (I'm lazy) and GtkIconCache code that relies
on glib's byte order macros.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2620>
This commit is contained in:
Florian Müllner 2023-01-26 03:32:52 +01:00 committed by Marge Bot
parent 3dc3170f92
commit 88b26996ec
4 changed files with 317 additions and 317 deletions

View File

@ -49,10 +49,10 @@
struct _GtkIconCache { struct _GtkIconCache {
gint ref_count; int ref_count;
GMappedFile *map; GMappedFile *map;
gchar *buffer; char *buffer;
guint32 last_chain_offset; guint32 last_chain_offset;
}; };
@ -80,13 +80,13 @@ _gtk_icon_cache_unref (GtkIconCache *cache)
} }
GtkIconCache * GtkIconCache *
_gtk_icon_cache_new_for_path (const gchar *path) _gtk_icon_cache_new_for_path (const char *path)
{ {
GtkIconCache *cache = NULL; GtkIconCache *cache = NULL;
GMappedFile *map; GMappedFile *map;
gchar *cache_filename; char *cache_filename;
gint fd = -1; int fd = -1;
GStatBuf st; GStatBuf st;
GStatBuf path_st; GStatBuf path_st;
@ -169,25 +169,25 @@ _gtk_icon_cache_new_for_path (const gchar *path)
} }
GtkIconCache * GtkIconCache *
_gtk_icon_cache_new (const gchar *data) _gtk_icon_cache_new (const char *data)
{ {
GtkIconCache *cache; GtkIconCache *cache;
cache = g_new0 (GtkIconCache, 1); cache = g_new0 (GtkIconCache, 1);
cache->ref_count = 1; cache->ref_count = 1;
cache->map = NULL; cache->map = NULL;
cache->buffer = (gchar *)data; cache->buffer = (char *)data;
return cache; return cache;
} }
static gint static int
get_directory_index (GtkIconCache *cache, get_directory_index (GtkIconCache *cache,
const gchar *directory) const char *directory)
{ {
guint32 dir_list_offset; guint32 dir_list_offset;
gint n_dirs; int n_dirs;
gint i; int i;
dir_list_offset = GET_UINT32 (cache->buffer, 8); dir_list_offset = GET_UINT32 (cache->buffer, 8);
@ -196,7 +196,7 @@ get_directory_index (GtkIconCache *cache,
for (i = 0; i < n_dirs; i++) for (i = 0; i < n_dirs; i++)
{ {
guint32 name_offset = GET_UINT32 (cache->buffer, dir_list_offset + 4 + 4 * i); guint32 name_offset = GET_UINT32 (cache->buffer, dir_list_offset + 4 + 4 * i);
gchar *name = cache->buffer + name_offset; char *name = cache->buffer + name_offset;
if (strcmp (name, directory) == 0) if (strcmp (name, directory) == 0)
return i; return i;
} }
@ -204,9 +204,9 @@ get_directory_index (GtkIconCache *cache,
return -1; return -1;
} }
gint int
_gtk_icon_cache_get_directory_index (GtkIconCache *cache, _gtk_icon_cache_get_directory_index (GtkIconCache *cache,
const gchar *directory) const char *directory)
{ {
return get_directory_index (cache, directory); return get_directory_index (cache, directory);
} }
@ -224,10 +224,10 @@ icon_name_hash (gconstpointer key)
return h; return h;
} }
static gint static int
find_image_offset (GtkIconCache *cache, find_image_offset (GtkIconCache *cache,
const gchar *icon_name, const char *icon_name,
gint directory_index) int directory_index)
{ {
guint32 hash_offset; guint32 hash_offset;
guint32 n_buckets; guint32 n_buckets;
@ -243,7 +243,7 @@ find_image_offset (GtkIconCache *cache,
if (chain_offset) if (chain_offset)
{ {
guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4); guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4);
gchar *name = cache->buffer + name_offset; char *name = cache->buffer + name_offset;
if (strcmp (name, icon_name) == 0) if (strcmp (name, icon_name) == 0)
goto find_dir; goto find_dir;
@ -257,7 +257,7 @@ find_image_offset (GtkIconCache *cache,
while (chain_offset != 0xffffffff) while (chain_offset != 0xffffffff)
{ {
guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4); guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4);
gchar *name = cache->buffer + name_offset; char *name = cache->buffer + name_offset;
if (strcmp (name, icon_name) == 0) if (strcmp (name, icon_name) == 0)
{ {
@ -286,10 +286,10 @@ find_dir:
return 0; return 0;
} }
gint int
_gtk_icon_cache_get_icon_flags (GtkIconCache *cache, _gtk_icon_cache_get_icon_flags (GtkIconCache *cache,
const gchar *icon_name, const char *icon_name,
gint directory_index) int directory_index)
{ {
guint32 image_offset; guint32 image_offset;
@ -303,7 +303,7 @@ _gtk_icon_cache_get_icon_flags (GtkIconCache *cache,
gboolean gboolean
_gtk_icon_cache_has_icons (GtkIconCache *cache, _gtk_icon_cache_has_icons (GtkIconCache *cache,
const gchar *directory) const char *directory)
{ {
int directory_index; int directory_index;
guint32 hash_offset, n_buckets; guint32 hash_offset, n_buckets;
@ -343,7 +343,7 @@ _gtk_icon_cache_has_icons (GtkIconCache *cache,
void void
_gtk_icon_cache_add_icons (GtkIconCache *cache, _gtk_icon_cache_add_icons (GtkIconCache *cache,
const gchar *directory, const char *directory,
GHashTable *hash_table) GHashTable *hash_table)
{ {
int directory_index; int directory_index;
@ -366,7 +366,7 @@ _gtk_icon_cache_add_icons (GtkIconCache *cache,
while (chain_offset != 0xffffffff) while (chain_offset != 0xffffffff)
{ {
guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4); guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4);
gchar *name = cache->buffer + name_offset; char *name = cache->buffer + name_offset;
image_list_offset = GET_UINT32 (cache->buffer, chain_offset + 8); image_list_offset = GET_UINT32 (cache->buffer, chain_offset + 8);
n_images = GET_UINT32 (cache->buffer, image_list_offset); n_images = GET_UINT32 (cache->buffer, image_list_offset);
@ -385,12 +385,12 @@ _gtk_icon_cache_add_icons (GtkIconCache *cache,
gboolean gboolean
_gtk_icon_cache_has_icon (GtkIconCache *cache, _gtk_icon_cache_has_icon (GtkIconCache *cache,
const gchar *icon_name) const char *icon_name)
{ {
guint32 hash_offset; guint32 hash_offset;
guint32 n_buckets; guint32 n_buckets;
guint32 chain_offset; guint32 chain_offset;
gint hash; int hash;
hash_offset = GET_UINT32 (cache->buffer, 4); hash_offset = GET_UINT32 (cache->buffer, 4);
n_buckets = GET_UINT32 (cache->buffer, hash_offset); n_buckets = GET_UINT32 (cache->buffer, hash_offset);
@ -401,7 +401,7 @@ _gtk_icon_cache_has_icon (GtkIconCache *cache,
while (chain_offset != 0xffffffff) while (chain_offset != 0xffffffff)
{ {
guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4); guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4);
gchar *name = cache->buffer + name_offset; char *name = cache->buffer + name_offset;
if (strcmp (name, icon_name) == 0) if (strcmp (name, icon_name) == 0)
return TRUE; return TRUE;
@ -414,15 +414,15 @@ _gtk_icon_cache_has_icon (GtkIconCache *cache,
gboolean gboolean
_gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache, _gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache,
const gchar *icon_name, const char *icon_name,
const gchar *directory) const char *directory)
{ {
guint32 hash_offset; guint32 hash_offset;
guint32 n_buckets; guint32 n_buckets;
guint32 chain_offset; guint32 chain_offset;
gint hash; int hash;
gboolean found_icon = FALSE; gboolean found_icon = FALSE;
gint directory_index; int directory_index;
directory_index = get_directory_index (cache, directory); directory_index = get_directory_index (cache, directory);
@ -438,7 +438,7 @@ _gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache,
while (chain_offset != 0xffffffff) while (chain_offset != 0xffffffff)
{ {
guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4); guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4);
gchar *name = cache->buffer + name_offset; char *name = cache->buffer + name_offset;
if (strcmp (name, icon_name) == 0) if (strcmp (name, icon_name) == 0)
{ {
@ -454,7 +454,7 @@ _gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache,
guint32 image_list_offset = GET_UINT32 (cache->buffer, chain_offset + 8); guint32 image_list_offset = GET_UINT32 (cache->buffer, chain_offset + 8);
guint32 n_images = GET_UINT32 (cache->buffer, image_list_offset); guint32 n_images = GET_UINT32 (cache->buffer, image_list_offset);
guint32 image_offset = image_list_offset + 4; guint32 image_offset = image_list_offset + 4;
gint i; int i;
for (i = 0; i < n_images; i++) for (i = 0; i < n_images; i++)
{ {
guint16 index = GET_UINT16 (cache->buffer, image_offset); guint16 index = GET_UINT16 (cache->buffer, image_offset);
@ -479,8 +479,8 @@ pixbuf_destroy_cb (guchar *pixels,
GdkPixbuf * GdkPixbuf *
_gtk_icon_cache_get_icon (GtkIconCache *cache, _gtk_icon_cache_get_icon (GtkIconCache *cache,
const gchar *icon_name, const char *icon_name,
gint directory_index) int directory_index)
{ {
guint32 offset, image_data_offset, pixel_data_offset; guint32 offset, image_data_offset, pixel_data_offset;
guint32 length, type; guint32 length, type;

View File

@ -22,27 +22,27 @@
typedef struct _GtkIconCache GtkIconCache; typedef struct _GtkIconCache GtkIconCache;
GtkIconCache *_gtk_icon_cache_new (const gchar *data); GtkIconCache *_gtk_icon_cache_new (const char *data);
GtkIconCache *_gtk_icon_cache_new_for_path (const gchar *path); GtkIconCache *_gtk_icon_cache_new_for_path (const char *path);
gint _gtk_icon_cache_get_directory_index (GtkIconCache *cache, int _gtk_icon_cache_get_directory_index (GtkIconCache *cache,
const gchar *directory); const char *directory);
gboolean _gtk_icon_cache_has_icon (GtkIconCache *cache, gboolean _gtk_icon_cache_has_icon (GtkIconCache *cache,
const gchar *icon_name); const char *icon_name);
gboolean _gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache, gboolean _gtk_icon_cache_has_icon_in_directory (GtkIconCache *cache,
const gchar *icon_name, const char *icon_name,
const gchar *directory); const char *directory);
gboolean _gtk_icon_cache_has_icons (GtkIconCache *cache, gboolean _gtk_icon_cache_has_icons (GtkIconCache *cache,
const gchar *directory); const char *directory);
void _gtk_icon_cache_add_icons (GtkIconCache *cache, void _gtk_icon_cache_add_icons (GtkIconCache *cache,
const gchar *directory, const char *directory,
GHashTable *hash_table); GHashTable *hash_table);
gint _gtk_icon_cache_get_icon_flags (GtkIconCache *cache, int _gtk_icon_cache_get_icon_flags (GtkIconCache *cache,
const gchar *icon_name, const char *icon_name,
gint directory_index); int directory_index);
GdkPixbuf *_gtk_icon_cache_get_icon (GtkIconCache *cache, GdkPixbuf *_gtk_icon_cache_get_icon (GtkIconCache *cache,
const gchar *icon_name, const char *icon_name,
gint directory_index); int directory_index);
GtkIconCache *_gtk_icon_cache_ref (GtkIconCache *cache); GtkIconCache *_gtk_icon_cache_ref (GtkIconCache *cache);
void _gtk_icon_cache_unref (GtkIconCache *cache); void _gtk_icon_cache_unref (GtkIconCache *cache);

File diff suppressed because it is too large Load Diff

View File

@ -175,74 +175,74 @@ void gtk_icon_theme_set_screen (GtkIconTheme
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_set_search_path (GtkIconTheme *icon_theme, void gtk_icon_theme_set_search_path (GtkIconTheme *icon_theme,
const gchar *path[], const char *path[],
gint n_elements); int n_elements);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_get_search_path (GtkIconTheme *icon_theme, void gtk_icon_theme_get_search_path (GtkIconTheme *icon_theme,
gchar **path[], char **path[],
gint *n_elements); int *n_elements);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_append_search_path (GtkIconTheme *icon_theme, void gtk_icon_theme_append_search_path (GtkIconTheme *icon_theme,
const gchar *path); const char *path);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_prepend_search_path (GtkIconTheme *icon_theme, void gtk_icon_theme_prepend_search_path (GtkIconTheme *icon_theme,
const gchar *path); const char *path);
GDK_AVAILABLE_IN_3_14 GDK_AVAILABLE_IN_3_14
void gtk_icon_theme_add_resource_path (GtkIconTheme *icon_theme, void gtk_icon_theme_add_resource_path (GtkIconTheme *icon_theme,
const gchar *path); const char *path);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_set_custom_theme (GtkIconTheme *icon_theme, void gtk_icon_theme_set_custom_theme (GtkIconTheme *icon_theme,
const gchar *theme_name); const char *theme_name);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_theme_has_icon (GtkIconTheme *icon_theme, gboolean gtk_icon_theme_has_icon (GtkIconTheme *icon_theme,
const gchar *icon_name); const char *icon_name);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gint *gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme, int *gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme,
const gchar *icon_name); const char *icon_name);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GtkIconInfo * gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme, GtkIconInfo * gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme,
const gchar *icon_name, const char *icon_name,
gint size, int size,
GtkIconLookupFlags flags); GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_3_10 GDK_AVAILABLE_IN_3_10
GtkIconInfo * gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *icon_theme, GtkIconInfo * gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *icon_theme,
const gchar *icon_name, const char *icon_name,
gint size, int size,
gint scale, int scale,
GtkIconLookupFlags flags); GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GtkIconInfo * gtk_icon_theme_choose_icon (GtkIconTheme *icon_theme, GtkIconInfo * gtk_icon_theme_choose_icon (GtkIconTheme *icon_theme,
const gchar *icon_names[], const char *icon_names[],
gint size, int size,
GtkIconLookupFlags flags); GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_3_10 GDK_AVAILABLE_IN_3_10
GtkIconInfo * gtk_icon_theme_choose_icon_for_scale (GtkIconTheme *icon_theme, GtkIconInfo * gtk_icon_theme_choose_icon_for_scale (GtkIconTheme *icon_theme,
const gchar *icon_names[], const char *icon_names[],
gint size, int size,
gint scale, int scale,
GtkIconLookupFlags flags); GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GdkPixbuf * gtk_icon_theme_load_icon (GtkIconTheme *icon_theme, GdkPixbuf * gtk_icon_theme_load_icon (GtkIconTheme *icon_theme,
const gchar *icon_name, const char *icon_name,
gint size, int size,
GtkIconLookupFlags flags, GtkIconLookupFlags flags,
GError **error); GError **error);
GDK_AVAILABLE_IN_3_10 GDK_AVAILABLE_IN_3_10
GdkPixbuf * gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme, GdkPixbuf * gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
const gchar *icon_name, const char *icon_name,
gint size, int size,
gint scale, int scale,
GtkIconLookupFlags flags, GtkIconLookupFlags flags,
GError **error); GError **error);
GDK_AVAILABLE_IN_3_10 GDK_AVAILABLE_IN_3_10
cairo_surface_t * gtk_icon_theme_load_surface (GtkIconTheme *icon_theme, cairo_surface_t * gtk_icon_theme_load_surface (GtkIconTheme *icon_theme,
const gchar *icon_name, const char *icon_name,
gint size, int size,
gint scale, int scale,
GdkWindow *for_window, GdkWindow *for_window,
GtkIconLookupFlags flags, GtkIconLookupFlags flags,
GError **error); GError **error);
@ -250,19 +250,19 @@ cairo_surface_t * gtk_icon_theme_load_surface (GtkIconTheme *icon_th
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GtkIconInfo * gtk_icon_theme_lookup_by_gicon (GtkIconTheme *icon_theme, GtkIconInfo * gtk_icon_theme_lookup_by_gicon (GtkIconTheme *icon_theme,
GIcon *icon, GIcon *icon,
gint size, int size,
GtkIconLookupFlags flags); GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_3_10 GDK_AVAILABLE_IN_3_10
GtkIconInfo * gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme, GtkIconInfo * gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme,
GIcon *icon, GIcon *icon,
gint size, int size,
gint scale, int scale,
GtkIconLookupFlags flags); GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GList * gtk_icon_theme_list_icons (GtkIconTheme *icon_theme, GList * gtk_icon_theme_list_icons (GtkIconTheme *icon_theme,
const gchar *context); const char *context);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GList * gtk_icon_theme_list_contexts (GtkIconTheme *icon_theme); GList * gtk_icon_theme_list_contexts (GtkIconTheme *icon_theme);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
@ -272,9 +272,9 @@ GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme); gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme);
GDK_DEPRECATED_IN_3_14_FOR(gtk_icon_theme_add_resource_path) GDK_DEPRECATED_IN_3_14_FOR(gtk_icon_theme_add_resource_path)
void gtk_icon_theme_add_builtin_icon (const gchar *icon_name, void gtk_icon_theme_add_builtin_icon (const char *icon_name,
gint size, int size,
GdkPixbuf *pixbuf); GdkPixbuf *pixbuf);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GType gtk_icon_info_get_type (void) G_GNUC_CONST; GType gtk_icon_info_get_type (void) G_GNUC_CONST;
@ -288,11 +288,11 @@ GtkIconInfo * gtk_icon_info_new_for_pixbuf (GtkIconTheme *icon_them
GdkPixbuf *pixbuf); GdkPixbuf *pixbuf);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gint gtk_icon_info_get_base_size (GtkIconInfo *icon_info); int gtk_icon_info_get_base_size (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_3_10 GDK_AVAILABLE_IN_3_10
gint gtk_icon_info_get_base_scale (GtkIconInfo *icon_info); int gtk_icon_info_get_base_scale (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const gchar * gtk_icon_info_get_filename (GtkIconInfo *icon_info); const char * gtk_icon_info_get_filename (GtkIconInfo *icon_info);
GDK_DEPRECATED_IN_3_14 GDK_DEPRECATED_IN_3_14
GdkPixbuf * gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info); GdkPixbuf * gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_3_12 GDK_AVAILABLE_IN_3_12
@ -367,9 +367,9 @@ gboolean gtk_icon_info_get_embedded_rect (GtkIconInfo *icon_info
GDK_DEPRECATED_IN_3_14 GDK_DEPRECATED_IN_3_14
gboolean gtk_icon_info_get_attach_points (GtkIconInfo *icon_info, gboolean gtk_icon_info_get_attach_points (GtkIconInfo *icon_info,
GdkPoint **points, GdkPoint **points,
gint *n_points); int *n_points);
GDK_DEPRECATED_IN_3_14 GDK_DEPRECATED_IN_3_14
const gchar * gtk_icon_info_get_display_name (GtkIconInfo *icon_info); const char * gtk_icon_info_get_display_name (GtkIconInfo *icon_info);
G_END_DECLS G_END_DECLS