[gtk+] emoji chooser: break out a helper function



commit 49d02eff931a43f88d4efb31be249742fe3be6f7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Nov 19 22:40:07 2017 -0500

    emoji chooser: break out a helper function
    
    This is just a small cleanup.

 gtk/gtkemojichooser.c |   42 +++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index ce9708f..596c92e 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -221,26 +221,12 @@ emoji_activated (GtkFlowBox      *box,
   g_free (text);
 }
 
-static void
-show_variations (GtkEmojiChooser *chooser,
-                 GtkWidget       *child)
+static gboolean
+has_variations (GVariant *emoji_data)
 {
-  GtkWidget *popover;
-  GtkWidget *view;
-  GtkWidget *box;
-  GVariant *emoji_data;
-  GtkWidget *parent_popover;
   GVariant *codes;
   int i;
   gboolean has_variations;
-  gunichar modifier;
-
-  if (!child)
-    return;
-
-  emoji_data = (GVariant*) g_object_get_data (G_OBJECT (child), "emoji-data");
-  if (!emoji_data)
-    return;
 
   has_variations = FALSE;
   codes = g_variant_get_child_value (emoji_data, 0);
@@ -255,7 +241,29 @@ show_variations (GtkEmojiChooser *chooser,
         }
     }
   g_variant_unref (codes);
-  if (!has_variations)
+
+  return has_variations;
+}
+
+static void
+show_variations (GtkEmojiChooser *chooser,
+                 GtkWidget       *child)
+{
+  GtkWidget *popover;
+  GtkWidget *view;
+  GtkWidget *box;
+  GVariant *emoji_data;
+  GtkWidget *parent_popover;
+  gunichar modifier;
+
+  if (!child)
+    return;
+
+  emoji_data = (GVariant*) g_object_get_data (G_OBJECT (child), "emoji-data");
+  if (!emoji_data)
+    return;
+
+  if (!has_variations (emoji_data))
     return;
 
   parent_popover = gtk_widget_get_ancestor (child, GTK_TYPE_POPOVER);


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