[gtk+] icontheme: Simplify lookup_size()



commit a9bcd05a148a7296677d36b271f5955d0066ead5
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Oct 19 14:04:00 2016 +0100

    icontheme: Simplify lookup_size()
    
    No need to use an internal function, and no need to store the icon size
    id, since we're using the id as the offset.

 gtk/gtkicontheme.c |   49 ++++++++++++++++---------------------------------
 1 files changed, 16 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index e31c75a..bf03117 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -5557,8 +5557,6 @@ typedef struct _IconSize IconSize;
 
 struct _IconSize
 {
-  int size;
-
   const char *name;
 
   int width;
@@ -5567,72 +5565,42 @@ struct _IconSize
 
 static const IconSize icon_sizes[] = {
   [GTK_ICON_SIZE_INVALID] = {
-    .size = 0,
     .name = NULL,
     .width = 0,
     .height = 0,
   },
   [GTK_ICON_SIZE_MENU] = {
-    .size = GTK_ICON_SIZE_MENU,
     .name = "gtk-menu",
     .width = 16,
     .height = 16,
   },
   [GTK_ICON_SIZE_BUTTON] = {
-    .size = GTK_ICON_SIZE_BUTTON,
     .name = "gtk-button",
     .width = 16,
     .height = 16,
   },
   [GTK_ICON_SIZE_SMALL_TOOLBAR] = {
-    .size = GTK_ICON_SIZE_SMALL_TOOLBAR,
     .name = "gtk-small-toolbar",
     .width = 16,
     .height = 16,
   },
   [GTK_ICON_SIZE_LARGE_TOOLBAR] = {
-    .size = GTK_ICON_SIZE_LARGE_TOOLBAR,
     .name = "gtk-large-toolbar",
     .width = 24,
     .height = 24,
   },
   [GTK_ICON_SIZE_DND] = {
-    .size = GTK_ICON_SIZE_DND,
     .name = "gtk-dnd",
     .width = 32,
     .height = 32,
   },
   [GTK_ICON_SIZE_DIALOG] = {
-    .size = GTK_ICON_SIZE_DIALOG,
     .name = "gtk-dialog",
     .width = 48,
     .height = 48,
   },
 };
 
-static gboolean
-icon_size_lookup_intern (GtkIconSize  size,
-                         gint        *widthp,
-                         gint        *heightp)
-{
-  if (size == (GtkIconSize)-1)
-    return FALSE;
-
-  if (size >= G_N_ELEMENTS (icon_sizes))
-    return FALSE;
-
-  if (size == GTK_ICON_SIZE_INVALID)
-    return FALSE;
-
-  if (widthp)
-    *widthp = icon_sizes[size].width;
-
-  if (heightp)
-    *heightp = icon_sizes[size].height;
-
-  return TRUE;
-}
-
 /**
  * gtk_icon_size_lookup:
  * @size: (type int): an icon size (#GtkIconSize)
@@ -5658,5 +5626,20 @@ gtk_icon_size_lookup (GtkIconSize  size,
   GTK_NOTE (MULTIHEAD,
             g_warning ("gtk_icon_size_lookup ()) is not multihead safe"));
 
-  return icon_size_lookup_intern (size, widthp, heightp);
+  if (size == (GtkIconSize)-1)
+    return FALSE;
+
+  if (size >= G_N_ELEMENTS (icon_sizes))
+    return FALSE;
+
+  if (size == GTK_ICON_SIZE_INVALID)
+    return FALSE;
+
+  if (widthp)
+    *widthp = icon_sizes[size].width;
+
+  if (heightp)
+    *heightp = icon_sizes[size].height;
+
+  return TRUE;
 }


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