[gnome-builder] spellchecker: restore previous state when closing the panel



commit ad3d46b1e2e38ffc412d0648f848d5de4429dfc7
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Sun Jul 30 17:44:07 2017 +0200

    spellchecker: restore previous state when closing the panel

 plugins/spellcheck/gbp-spell-private.h |    1 +
 plugins/spellcheck/gbp-spell-widget.c  |   16 ++++++++++++++++
 plugins/spellcheck/gbp-spell-widget.ui |    2 +-
 3 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/plugins/spellcheck/gbp-spell-private.h b/plugins/spellcheck/gbp-spell-private.h
index e4bfa02..273d88a 100644
--- a/plugins/spellcheck/gbp-spell-private.h
+++ b/plugins/spellcheck/gbp-spell-private.h
@@ -60,6 +60,7 @@ struct _GbpSpellWidget
   GtkWidget               *dict_add_button;
   GtkWidget               *dict_words_list;
   GtkButton               *language_chooser_button;
+  GtkButton               *close_button;
   GtkWidget               *placeholder;
 
   /* GSource identifiers */
diff --git a/plugins/spellcheck/gbp-spell-widget.c b/plugins/spellcheck/gbp-spell-widget.c
index 7648f92..c8f24e4 100644
--- a/plugins/spellcheck/gbp-spell-widget.c
+++ b/plugins/spellcheck/gbp-spell-widget.c
@@ -829,6 +829,16 @@ gbp_spell_widget__word_label_notify_cb (GbpSpellWidget *self,
 }
 
 static void
+gbp_spell_widget__close_button_clicked_cb (GbpSpellWidget *self,
+                                           GtkButton      *close_button)
+{
+  g_assert (GBP_IS_SPELL_WIDGET (self));
+  g_assert (GTK_IS_BUTTON (close_button));
+
+  gbp_spell_widget_set_editor (self, NULL);
+}
+
+static void
 gbp_spell_widget_constructed (GObject *object)
 {
   GbpSpellWidget *self = (GbpSpellWidget *)object;
@@ -871,6 +881,11 @@ gbp_spell_widget_constructed (GObject *object)
                             G_CALLBACK (gbp_spell_widget__dict_word_entry_changed_cb),
                             self);
 
+  g_signal_connect_swapped (self->close_button,
+                            "clicked",
+                            G_CALLBACK (gbp_spell_widget__close_button_clicked_cb),
+                            self);
+
   self->placeholder = gtk_label_new (NULL);
   gtk_widget_set_visible (self->placeholder, TRUE);
   gtk_list_box_set_placeholder (self->suggestions_box, self->placeholder);
@@ -1025,6 +1040,7 @@ gbp_spell_widget_class_init (GbpSpellWidgetClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GbpSpellWidget, dict_add_button);
   gtk_widget_class_bind_template_child (widget_class, GbpSpellWidget, dict_words_list);
   gtk_widget_class_bind_template_child (widget_class, GbpSpellWidget, count_box);
+  gtk_widget_class_bind_template_child (widget_class, GbpSpellWidget, close_button);
 
   g_type_ensure (GBP_TYPE_SPELL_LANGUAGE_POPOVER);
 }
diff --git a/plugins/spellcheck/gbp-spell-widget.ui b/plugins/spellcheck/gbp-spell-widget.ui
index c16ef64..8e165c7 100644
--- a/plugins/spellcheck/gbp-spell-widget.ui
+++ b/plugins/spellcheck/gbp-spell-widget.ui
@@ -51,7 +51,7 @@
               </object>
             </child>
             <child>
-              <object class="GtkButton">
+              <object class="GtkButton" id="close_button">
                 <property name="action-name">dockbin.right-visible</property>
                 <property name="visible">true</property>
                 <style>


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