[gtk+] GtkIconInfo: add gtk_icon_info_is_symbolic()
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkIconInfo: add gtk_icon_info_is_symbolic()
- Date: Wed, 8 Jan 2014 07:20:29 +0000 (UTC)
commit fd137132307fc623b3bdc471f96ab1e36d527c1f
Author: William Hua <william attente ca>
Date: Sat Dec 14 21:41:49 2013 -0500
GtkIconInfo: add gtk_icon_info_is_symbolic()
https://bugzilla.gnome.org/show_bug.cgi?id=710351
docs/reference/gtk/gtk3-sections.txt | 1 +
gtk/gtkicontheme.c | 62 ++++++++++++++++++---------------
gtk/gtkicontheme.h | 2 +
3 files changed, 37 insertions(+), 28 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 758fd42..d425a7c 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -6679,6 +6679,7 @@ gtk_icon_info_set_raw_coordinates
gtk_icon_info_get_embedded_rect
gtk_icon_info_get_attach_points
gtk_icon_info_get_display_name
+gtk_icon_info_is_symbolic
<SUBSECTION Standard>
GtkIconThemeClass
GTK_ICON_THEME
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 5061cfe..e34430e 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -3544,6 +3544,36 @@ gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info)
return icon_info->cache_pixbuf;
}
+/**
+ * gtk_icon_info_is_symbolic:
+ * @icon_info: a #GtkIconInfo structure
+ *
+ * Checks if the icon is symbolic or not. This currently uses only
+ * the file name and not the file contents for determining this.
+ * This behaviour may change in the future.
+ *
+ * Return value: %TRUE if the icon is symbolic, %FALSE otherwise.
+ *
+ * Since: 3.12
+ **/
+gboolean
+gtk_icon_info_is_symbolic (GtkIconInfo *icon_info)
+{
+ gchar *icon_uri;
+ gboolean is_symbolic;
+
+ g_return_val_if_fail (GTK_IS_ICON_INFO (icon_info), FALSE);
+
+ icon_uri = NULL;
+ if (icon_info->icon_file)
+ icon_uri = g_file_get_uri (icon_info->icon_file);
+
+ is_symbolic = (icon_uri != NULL) && (g_str_has_suffix (icon_uri, "-symbolic.svg"));
+ g_free (icon_uri);
+
+ return is_symbolic;
+}
+
static gboolean icon_info_ensure_scale_and_pixbuf (GtkIconInfo*, gboolean);
/* Combine the icon with all emblems, the first emblem is placed
@@ -4329,18 +4359,12 @@ gtk_icon_info_load_symbolic (GtkIconInfo *icon_info,
gboolean *was_symbolic,
GError **error)
{
- gchar *icon_uri;
gboolean is_symbolic;
g_return_val_if_fail (icon_info != NULL, NULL);
g_return_val_if_fail (fg != NULL, NULL);
- icon_uri = NULL;
- if (icon_info->icon_file)
- icon_uri = g_file_get_uri (icon_info->icon_file);
-
- is_symbolic = (icon_uri != NULL) && (g_str_has_suffix (icon_uri, "-symbolic.svg"));
- g_free (icon_uri);
+ is_symbolic = gtk_icon_info_is_symbolic (icon_info);
if (was_symbolic)
*was_symbolic = is_symbolic;
@@ -4396,18 +4420,12 @@ gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info,
GdkRGBA error_color;
GdkRGBA *error_colorp;
GtkStateFlags state;
- gchar *icon_uri;
gboolean is_symbolic;
g_return_val_if_fail (icon_info != NULL, NULL);
g_return_val_if_fail (context != NULL, NULL);
- icon_uri = NULL;
- if (icon_info->icon_file)
- icon_uri = g_file_get_uri (icon_info->icon_file);
-
- is_symbolic = (icon_uri != NULL) && (g_str_has_suffix (icon_uri, "-symbolic.svg"));
- g_free (icon_uri);
+ is_symbolic = gtk_icon_info_is_symbolic (icon_info);
if (was_symbolic)
*was_symbolic = is_symbolic;
@@ -4542,7 +4560,6 @@ gtk_icon_info_load_symbolic_async (GtkIconInfo *icon_info,
{
GTask *task;
AsyncSymbolicData *data;
- gchar *icon_uri;
SymbolicPixbufCache *symbolic_cache;
GdkPixbuf *pixbuf;
@@ -4554,12 +4571,7 @@ gtk_icon_info_load_symbolic_async (GtkIconInfo *icon_info,
data = g_slice_new0 (AsyncSymbolicData);
g_task_set_task_data (task, data, (GDestroyNotify) async_symbolic_data_free);
- icon_uri = NULL;
- if (icon_info->icon_file)
- icon_uri = g_file_get_uri (icon_info->icon_file);
-
- data->is_symbolic = (icon_uri != NULL) && (g_str_has_suffix (icon_uri, "-symbolic.svg"));
- g_free (icon_uri);
+ data->is_symbolic = gtk_icon_info_is_symbolic (icon_info);
if (!data->is_symbolic)
{
@@ -4814,18 +4826,12 @@ gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info,
GdkRGBA *warning_colorp;
GdkRGBA error_color;
GdkRGBA *error_colorp;
- gchar *icon_uri;
gboolean is_symbolic;
g_return_val_if_fail (icon_info != NULL, NULL);
g_return_val_if_fail (style != NULL, NULL);
- icon_uri = NULL;
- if (icon_info->icon_file)
- icon_uri = g_file_get_uri (icon_info->icon_file);
-
- is_symbolic = (icon_uri != NULL) && (g_str_has_suffix (icon_uri, "-symbolic.svg"));
- g_free (icon_uri);
+ is_symbolic = gtk_icon_info_is_symbolic (icon_info);
if (was_symbolic)
*was_symbolic = is_symbolic;
diff --git a/gtk/gtkicontheme.h b/gtk/gtkicontheme.h
index 255eb2f..b95b03b 100644
--- a/gtk/gtkicontheme.h
+++ b/gtk/gtkicontheme.h
@@ -267,6 +267,8 @@ GDK_AVAILABLE_IN_ALL
const gchar * gtk_icon_info_get_filename (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_ALL
GdkPixbuf * gtk_icon_info_get_builtin_pixbuf (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,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]