Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From d25b8bed2ff4c63433c54f45bcba4347a3a5fcce Mon Sep 17 00:00:00 2001
- From: Sebastien Lafargue <slafargue@gnome.org>
- Date: Fri, 19 Dec 2014 18:22:12 +0100
- Subject: spell plugin dialog: close the dialog with Escape
- Add a binding on Escape to close the dialog
- ( it's a gtkwindow not a gtkdialog so we don't
- have it by default )
- We declare a "close" signal so the default behaviour
- can be overwritten if needed.
- ---
- plugins/spell/gedit-spell-checker-dialog.c | 23 +++++++++++++++++++++++
- plugins/spell/gedit-spell-checker-dialog.h | 2 ++
- 2 files changed, 25 insertions(+)
- diff --git a/plugins/spell/gedit-spell-checker-dialog.c b/plugins/spell/gedit-spell-checker-dialog.c
- index c9a9bf9..dcc5b2d 100644
- --- a/plugins/spell/gedit-spell-checker-dialog.c
- +++ b/plugins/spell/gedit-spell-checker-dialog.c
- @@ -62,6 +62,7 @@ enum
- CHANGE,
- CHANGE_ALL,
- ADD_WORD_TO_PERSONAL,
- + CLOSE,
- LAST_SIGNAL
- };
- @@ -127,13 +128,25 @@ gedit_spell_checker_dialog_finalize (GObject *object)
- }
- static void
- +gedit_spell_checker_dialog_close (GeditSpellCheckerDialog *dlg)
- +{
- + gtk_window_close (GTK_WINDOW (dlg));
- +}
- +
- +static void
- gedit_spell_checker_dialog_class_init (GeditSpellCheckerDialogClass * klass)
- {
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- + GtkBindingSet *binding_set;
- object_class->dispose = gedit_spell_checker_dialog_dispose;
- object_class->finalize = gedit_spell_checker_dialog_finalize;
- + klass->close = gedit_spell_checker_dialog_close;
- +
- + binding_set = gtk_binding_set_by_class (klass);
- + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
- +
- signals[IGNORE] =
- g_signal_new ("ignore",
- G_OBJECT_CLASS_TYPE (object_class),
- @@ -190,6 +203,16 @@ gedit_spell_checker_dialog_class_init (GeditSpellCheckerDialogClass * klass)
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
- +
- + signals[CLOSE] =
- + g_signal_new ("close",
- + G_OBJECT_CLASS_TYPE (klass),
- + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- + G_STRUCT_OFFSET (GeditSpellCheckerDialogClass, close),
- + NULL, NULL,
- + gedit_marshal_VOID__VOID,
- + G_TYPE_NONE,
- + 0);
- }
- static void
- diff --git a/plugins/spell/gedit-spell-checker-dialog.h b/plugins/spell/gedit-spell-checker-dialog.h
- index 39571ae..857591a 100644
- --- a/plugins/spell/gedit-spell-checker-dialog.h
- +++ b/plugins/spell/gedit-spell-checker-dialog.h
- @@ -57,6 +57,8 @@ struct _GeditSpellCheckerDialogClass
- void (*add_word_to_personal) (GeditSpellCheckerDialog *dlg,
- const gchar *word);
- + /* Keybinding signal */
- + void (*close) (GeditSpellCheckerDialog *dlg);
- };
- GType gedit_spell_checker_dialog_get_type (void) G_GNUC_CONST;
- --
- 2.2.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement