[gtk/emoji-chooser-fixes: 1/3] emoji chooser: Fix handling of no recent Emoji



commit 7b6f652630aff73b61b59ab1849b19df44695883
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat May 4 16:19:43 2019 +0000

    emoji chooser: Fix handling of no recent Emoji
    
    If the recent section is empty, we want to hide
    it, make its button insensitive, and select the
    next section, initially. This was not working
    properly, since nothing was ever setting the
    section box to invisible.

 gtk/gtkemojichooser.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index e2630abb92..0f8763c4f0 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -153,11 +153,9 @@ populate_recent_section (GtkEmojiChooser *chooser)
       empty = FALSE;
     }
 
-  if (!empty)
-    {
-      gtk_widget_show (chooser->recent.box);
-      gtk_widget_set_sensitive (chooser->recent.button, TRUE);
-    }
+  gtk_widget_set_visible (chooser->recent.box, !empty);
+  gtk_widget_set_sensitive (chooser->recent.button, !empty);
+
   g_variant_unref (variant);
 }
 
@@ -458,15 +456,12 @@ populate_emoji_chooser (gpointer data)
         return G_SOURCE_CONTINUE;
     }
 
-  /* We scroll to the top on show, so check the right button for the 1st time */
-  gtk_widget_set_state_flags (chooser->recent.button, GTK_STATE_FLAG_CHECKED, FALSE);
-
   g_variant_iter_free (chooser->iter);
   chooser->iter = NULL;
   chooser->box = NULL;
   chooser->populate_idle = 0;
 
-  return G_SOURCE_REMOVE; 
+  return G_SOURCE_REMOVE;
 }
 
 static void
@@ -496,6 +491,9 @@ adj_value_changed (GtkAdjustment *adj,
       EmojiSection const *section = sections[i];
       GtkAllocation alloc;
 
+      if (!gtk_widget_get_visible (section->box))
+        continue;
+
       if (section->heading)
         gtk_widget_get_allocation (section->heading, &alloc);
       else
@@ -693,6 +691,7 @@ gtk_emoji_chooser_show (GtkWidget *widget)
 
   adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window));
   gtk_adjustment_set_value (adj, 0);
+  adj_value_changed (adj, chooser);
 
   gtk_editable_set_text (GTK_EDITABLE (chooser->search_entry), "");
 }


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