1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- 2 * 3 * Copyright (C) 2014-2017 Richard Hughes <richard@hughsie.com> 4 * 5 * SPDX-License-Identifier: LGPL-2.1+ 6 */ 7 8 #pragma once 9 10 #if !defined (__APPSTREAM_GLIB_H_INSIDE__) && !defined (AS_COMPILATION) 11 #error "Only <appstream-glib.h> can be included directly." 12 #endif 13 14 #include <glib-object.h> 15 #include <gdk-pixbuf/gdk-pixbuf.h> 16 17 G_BEGIN_DECLS 18 19 #define AS_TYPE_ICON (as_icon_get_type ()) 20 G_DECLARE_DERIVABLE_TYPE (AsIcon, as_icon, AS, ICON, GObject) 21 22 struct _AsIconClass 23 { 24 GObjectClass parent_class; 25 /*< private >*/ 26 void (*_as_reserved1) (void); 27 void (*_as_reserved2) (void); 28 void (*_as_reserved3) (void); 29 void (*_as_reserved4) (void); 30 void (*_as_reserved5) (void); 31 void (*_as_reserved6) (void); 32 void (*_as_reserved7) (void); 33 void (*_as_reserved8) (void); 34 }; 35 36 /** 37 * AsIconError: 38 * @AS_ICON_ERROR_FAILED: Generic failure 39 * 40 * The error type. 41 **/ 42 typedef enum { 43 AS_ICON_ERROR_FAILED, 44 /*< private >*/ 45 AS_ICON_ERROR_LAST 46 } AsIconError; 47 48 /** 49 * AsIconKind: 50 * @AS_ICON_KIND_UNKNOWN: Type invalid or not known 51 * @AS_ICON_KIND_STOCK: Stock icon or present in the generic icon theme 52 * @AS_ICON_KIND_CACHED: An icon shipped with the AppStream metadata 53 * @AS_ICON_KIND_REMOTE: An icon referenced by a remote URL 54 * @AS_ICON_KIND_EMBEDDED: An embedded Base64 icon 55 * @AS_ICON_KIND_LOCAL: An icon with absolute path and filename 56 * 57 * The icon type. 58 **/ 59 typedef enum { 60 AS_ICON_KIND_UNKNOWN, /* Since: 0.1.0 */ 61 AS_ICON_KIND_STOCK, /* Since: 0.1.0 */ 62 AS_ICON_KIND_CACHED, /* Since: 0.1.0 */ 63 AS_ICON_KIND_REMOTE, /* Since: 0.1.0 */ 64 AS_ICON_KIND_EMBEDDED, /* Since: 0.3.1 */ 65 AS_ICON_KIND_LOCAL, /* Since: 0.3.1 */ 66 /*< private >*/ 67 AS_ICON_KIND_LAST 68 } AsIconKind; 69 70 /** 71 * AsIconLoadFlags: 72 * @AS_ICON_LOAD_FLAG_NONE: No extra flags to use 73 * @AS_ICON_LOAD_FLAG_SEARCH_SIZE: Search first in a size-specific directory 74 * 75 * The flags to use when loading icons. 76 **/ 77 typedef enum { 78 AS_ICON_LOAD_FLAG_NONE = 0, /* Since: 0.3.1 */ 79 AS_ICON_LOAD_FLAG_SEARCH_SIZE = 1, /* Since: 0.3.1 */ 80 /*< private >*/ 81 AS_ICON_LOAD_FLAG_LAST 82 } AsIconLoadFlags; 83 84 #define AS_ICON_ERROR as_icon_error_quark () 85 86 AsIcon *as_icon_new (void); 87 GQuark as_icon_error_quark (void); 88 89 /* helpers */ 90 const gchar *as_icon_kind_to_string (AsIconKind icon_kind); 91 AsIconKind as_icon_kind_from_string (const gchar *icon_kind); 92 93 /* getters */ 94 const gchar *as_icon_get_name (AsIcon *icon); 95 const gchar *as_icon_get_url (AsIcon *icon); 96 const gchar *as_icon_get_filename (AsIcon *icon); 97 const gchar *as_icon_get_prefix (AsIcon *icon); 98 guint as_icon_get_width (AsIcon *icon); 99 guint as_icon_get_height (AsIcon *icon); 100 guint as_icon_get_scale (AsIcon *icon); 101 AsIconKind as_icon_get_kind (AsIcon *icon); 102 GdkPixbuf *as_icon_get_pixbuf (AsIcon *icon); 103 104 /* setters */ 105 void as_icon_set_name (AsIcon *icon, 106 const gchar *name); 107 void as_icon_set_url (AsIcon *icon, 108 const gchar *url); 109 void as_icon_set_filename (AsIcon *icon, 110 const gchar *filename); 111 void as_icon_set_prefix (AsIcon *icon, 112 const gchar *prefix); 113 void as_icon_set_width (AsIcon *icon, 114 guint width); 115 void as_icon_set_height (AsIcon *icon, 116 guint height); 117 void as_icon_set_scale (AsIcon *icon, 118 guint scale); 119 void as_icon_set_kind (AsIcon *icon, 120 AsIconKind kind); 121 void as_icon_set_pixbuf (AsIcon *icon, 122 GdkPixbuf *pixbuf); 123 124 /* object methods */ 125 gboolean as_icon_load (AsIcon *icon, 126 AsIconLoadFlags flags, 127 GError **error); 128 gboolean as_icon_convert_to_kind (AsIcon *icon, 129 AsIconKind kind, 130 GError **error); 131 132 G_END_DECLS 133