[gnome-flashback] input-sources: don't show button if not needed



commit c26571152a45faac9bf970abfe9cd0095ff6383f
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Mar 25 23:03:55 2020 +0200

    input-sources: don't show button if not needed

 .../libinput-sources/gf-input-sources-button.c        | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/gnome-flashback/libinput-sources/gf-input-sources-button.c 
b/gnome-flashback/libinput-sources/gf-input-sources-button.c
index 0df3bff..cd811a8 100644
--- a/gnome-flashback/libinput-sources/gf-input-sources-button.c
+++ b/gnome-flashback/libinput-sources/gf-input-sources-button.c
@@ -137,6 +137,21 @@ gf_input_sources_button_set_property (GObject      *object,
     }
 }
 
+static void
+gf_input_sources_button_show (GtkWidget *widget)
+{
+  GfInputSourcesButton *self;
+  GList *input_sources;
+
+  self = GF_INPUT_SOURCES_BUTTON (widget);
+  input_sources = gf_input_source_manager_get_input_sources (self->manager);
+
+  if (g_list_length (input_sources) <= 1)
+    return;
+
+  GTK_WIDGET_CLASS (gf_input_sources_button_parent_class)->show (widget);
+}
+
 static void
 gf_input_sources_button_clicked (GtkButton *button)
 {
@@ -166,15 +181,19 @@ static void
 gf_input_sources_button_class_init (GfInputSourcesButtonClass *self_class)
 {
   GObjectClass *object_class;
+  GtkWidgetClass *widget_class;
   GtkButtonClass *button_class;
 
   object_class = G_OBJECT_CLASS (self_class);
+  widget_class = GTK_WIDGET_CLASS (self_class);
   button_class = GTK_BUTTON_CLASS (self_class);
 
   object_class->constructed = gf_input_sources_button_constructed;
   object_class->dispose = gf_input_sources_button_dispose;
   object_class->set_property = gf_input_sources_button_set_property;
 
+  widget_class->show = gf_input_sources_button_show;
+
   button_class->clicked = gf_input_sources_button_clicked;
 
   install_properties (object_class);


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