[gtk+/wip/quartzwork: 3/9] GtkIconInfo: add gtk_icon_info_is_symbol()



commit 3396c6634696fefb2a7f86db04a4c84d3f2ad488
Author: William Hua <william attente ca>
Date:   Sat Dec 14 21:41:49 2013 -0500

    GtkIconInfo: add gtk_icon_info_is_symbol()

 docs/reference/gtk/gtk3-sections.txt |    1 +
 gtk/gtkicontheme.c                   |   60 ++++++++++++++++++----------------
 gtk/gtkicontheme.h                   |    2 +
 3 files changed, 35 insertions(+), 28 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 1be171d..f381b71 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -6677,6 +6677,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..c8eab0a 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -3544,6 +3544,34 @@ 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.
+ *
+ * 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 +4357,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 +4418,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 +4558,6 @@ gtk_icon_info_load_symbolic_async (GtkIconInfo   *icon_info,
 {
   GTask *task;
   AsyncSymbolicData *data;
-  gchar *icon_uri;
   SymbolicPixbufCache *symbolic_cache;
   GdkPixbuf *pixbuf;
 
@@ -4554,12 +4569,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 +4824,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]