[metacity/wip/gtk-theme: 47/52] ui: Refactor the default image lookup



commit e6d8d98dff36af94a9969b22263aff5e7b3e018d
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Dec 31 20:48:26 2014 -0800

    ui: Refactor the default image lookup

 src/ui/ui.c |   56 ++++++++++++++++----------------------------------------
 1 files changed, 16 insertions(+), 40 deletions(-)
---
diff --git a/src/ui/ui.c b/src/ui/ui.c
index ac5a2d7..2cc78ec 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -602,6 +602,20 @@ meta_ui_pop_delay_exposes  (MetaUI *ui)
   meta_frames_pop_delay_exposes (ui->frames);
 }
 
+static GdkPixbuf *
+load_default_window_icon (int size)
+{
+  GtkIconTheme *theme = gtk_icon_theme_get_default ();
+  const char *icon_name;
+
+  if (gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME))
+    icon_name = META_DEFAULT_ICON_NAME;
+  else
+    icon_name = "image-missing";
+
+  return gtk_icon_theme_load_icon (theme, icon_name, size, 0, NULL);
+}
+
 GdkPixbuf*
 meta_ui_get_default_window_icon (MetaUI *ui)
 {
@@ -609,26 +623,7 @@ meta_ui_get_default_window_icon (MetaUI *ui)
 
   if (default_icon == NULL)
     {
-      GtkIconTheme *theme;
-      gboolean icon_exists;
-
-      theme = gtk_icon_theme_get_default ();
-
-      icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME);
-
-      if (icon_exists)
-          default_icon = gtk_icon_theme_load_icon (theme,
-                                                   META_DEFAULT_ICON_NAME,
-                                                   META_ICON_WIDTH,
-                                                   0,
-                                                   NULL);
-      else
-          default_icon = gtk_icon_theme_load_icon (theme,
-                                                   "image-missing",
-                                                   META_ICON_WIDTH,
-                                                   0,
-                                                   NULL);
-
+      default_icon = load_default_window_icon (META_ICON_WIDTH);
       g_assert (default_icon);
     }
 
@@ -644,26 +639,7 @@ meta_ui_get_default_mini_icon (MetaUI *ui)
 
   if (default_icon == NULL)
     {
-      GtkIconTheme *theme;
-      gboolean icon_exists;
-
-      theme = gtk_icon_theme_get_default ();
-
-      icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME);
-
-      if (icon_exists)
-          default_icon = gtk_icon_theme_load_icon (theme,
-                                                   META_DEFAULT_ICON_NAME,
-                                                   META_MINI_ICON_WIDTH,
-                                                   0,
-                                                   NULL);
-      else
-          default_icon = gtk_icon_theme_load_icon (theme,
-                                                   "image-missing",
-                                                   META_MINI_ICON_WIDTH,
-                                                   0,
-                                                   NULL);
-
+      default_icon = load_default_window_icon (META_MINI_ICON_WIDTH);
       g_assert (default_icon);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]