Advertisement
Guest User

spell escape binding

a guest
Dec 19th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. From d25b8bed2ff4c63433c54f45bcba4347a3a5fcce Mon Sep 17 00:00:00 2001
  2. From: Sebastien Lafargue <slafargue@gnome.org>
  3. Date: Fri, 19 Dec 2014 18:22:12 +0100
  4. Subject: spell plugin dialog: close the dialog with Escape
  5.  
  6. Add a binding on Escape to close the dialog
  7. ( it's a gtkwindow not a gtkdialog so we don't
  8. have it by default )
  9.  
  10. We declare a "close" signal so the default behaviour
  11. can be overwritten if needed.
  12. ---
  13. plugins/spell/gedit-spell-checker-dialog.c | 23 +++++++++++++++++++++++
  14. plugins/spell/gedit-spell-checker-dialog.h | 2 ++
  15. 2 files changed, 25 insertions(+)
  16.  
  17. diff --git a/plugins/spell/gedit-spell-checker-dialog.c b/plugins/spell/gedit-spell-checker-dialog.c
  18. index c9a9bf9..dcc5b2d 100644
  19. --- a/plugins/spell/gedit-spell-checker-dialog.c
  20. +++ b/plugins/spell/gedit-spell-checker-dialog.c
  21. @@ -62,6 +62,7 @@ enum
  22. CHANGE,
  23. CHANGE_ALL,
  24. ADD_WORD_TO_PERSONAL,
  25. + CLOSE,
  26. LAST_SIGNAL
  27. };
  28.  
  29. @@ -127,13 +128,25 @@ gedit_spell_checker_dialog_finalize (GObject *object)
  30. }
  31.  
  32. static void
  33. +gedit_spell_checker_dialog_close (GeditSpellCheckerDialog *dlg)
  34. +{
  35. + gtk_window_close (GTK_WINDOW (dlg));
  36. +}
  37. +
  38. +static void
  39. gedit_spell_checker_dialog_class_init (GeditSpellCheckerDialogClass * klass)
  40. {
  41. GObjectClass *object_class = G_OBJECT_CLASS (klass);
  42. + GtkBindingSet *binding_set;
  43.  
  44. object_class->dispose = gedit_spell_checker_dialog_dispose;
  45. object_class->finalize = gedit_spell_checker_dialog_finalize;
  46.  
  47. + klass->close = gedit_spell_checker_dialog_close;
  48. +
  49. + binding_set = gtk_binding_set_by_class (klass);
  50. + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
  51. +
  52. signals[IGNORE] =
  53. g_signal_new ("ignore",
  54. G_OBJECT_CLASS_TYPE (object_class),
  55. @@ -190,6 +203,16 @@ gedit_spell_checker_dialog_class_init (GeditSpellCheckerDialogClass * klass)
  56. G_TYPE_NONE,
  57. 1,
  58. G_TYPE_STRING);
  59. +
  60. + signals[CLOSE] =
  61. + g_signal_new ("close",
  62. + G_OBJECT_CLASS_TYPE (klass),
  63. + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
  64. + G_STRUCT_OFFSET (GeditSpellCheckerDialogClass, close),
  65. + NULL, NULL,
  66. + gedit_marshal_VOID__VOID,
  67. + G_TYPE_NONE,
  68. + 0);
  69. }
  70.  
  71. static void
  72. diff --git a/plugins/spell/gedit-spell-checker-dialog.h b/plugins/spell/gedit-spell-checker-dialog.h
  73. index 39571ae..857591a 100644
  74. --- a/plugins/spell/gedit-spell-checker-dialog.h
  75. +++ b/plugins/spell/gedit-spell-checker-dialog.h
  76. @@ -57,6 +57,8 @@ struct _GeditSpellCheckerDialogClass
  77. void (*add_word_to_personal) (GeditSpellCheckerDialog *dlg,
  78. const gchar *word);
  79.  
  80. + /* Keybinding signal */
  81. + void (*close) (GeditSpellCheckerDialog *dlg);
  82. };
  83.  
  84. GType gedit_spell_checker_dialog_get_type (void) G_GNUC_CONST;
  85. --
  86. 2.2.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement