diff options
-rw-r--r-- | src/interface-gtk.cpp | 57 | ||||
-rw-r--r-- | src/interface-gtk.h | 9 |
2 files changed, 34 insertions, 32 deletions
diff --git a/src/interface-gtk.cpp b/src/interface-gtk.cpp index 965bdca..3253139 100644 --- a/src/interface-gtk.cpp +++ b/src/interface-gtk.cpp @@ -46,9 +46,9 @@ namespace SciTECO { extern "C" { static void scintilla_notify(ScintillaObject *sci, uptr_t idFrom, - SCNotification *notify, gpointer user_data); + SCNotification *notify, gpointer user_data); static gboolean cmdline_key_pressed(GtkWidget *widget, GdkEventKey *event, - gpointer user_data); + gpointer user_data); static gboolean exit_app(GtkWidget *w, GdkEventAny *e, gpointer p); } @@ -283,30 +283,8 @@ InterfaceGtk::widget_set_font(GtkWidget *widget, const gchar *font_name) pango_font_description_free(font_desc); } -InterfaceGtk::~InterfaceGtk() -{ - g_free(info_current); - if (popup_widget) - gtk_widget_destroy(popup_widget); - if (window) - gtk_widget_destroy(window); - - scintilla_release_resources(); -} - -/* - * GTK+ callbacks - */ - -static void -scintilla_notify(ScintillaObject *sci, uptr_t idFrom, - SCNotification *notify, gpointer user_data) -{ - interface.process_notify(notify); -} - -static inline void -handle_key_press(bool is_shift, bool is_ctl, guint keyval) +void +InterfaceGtk::handle_key_press(bool is_shift, bool is_ctl, guint keyval) { switch (keyval) { case GDK_Escape: @@ -379,8 +357,29 @@ handle_key_press(bool is_shift, bool is_ctl, guint keyval) * So we set it here once after every keypress even if the * info line did not change. */ - gtk_window_set_title(GTK_WINDOW(interface.window), - interface.info_current); + gtk_window_set_title(GTK_WINDOW(window), info_current); +} + +InterfaceGtk::~InterfaceGtk() +{ + g_free(info_current); + if (popup_widget) + gtk_widget_destroy(popup_widget); + if (window) + gtk_widget_destroy(window); + + scintilla_release_resources(); +} + +/* + * GTK+ callbacks + */ + +static void +scintilla_notify(ScintillaObject *sci, uptr_t idFrom, + SCNotification *notify, gpointer user_data) +{ + interface.process_notify(notify); } static gboolean @@ -397,7 +396,7 @@ cmdline_key_pressed(GtkWidget *widget, GdkEventKey *event, #endif try { - handle_key_press(is_shift, is_ctl, event->keyval); + interface.handle_key_press(is_shift, is_ctl, event->keyval); } catch (Quit) { /* * SciTECO should terminate, so we exit diff --git a/src/interface-gtk.h b/src/interface-gtk.h index 389b096..31deaf6 100644 --- a/src/interface-gtk.h +++ b/src/interface-gtk.h @@ -141,13 +141,16 @@ public: gtk_main(); } + /* + * FIXME: This is for internal use only and could be + * hidden in a nested forward-declared friend struct. + */ + void handle_key_press(bool is_shift, bool is_ctl, guint keyval); + private: static void widget_set_font(GtkWidget *widget, const gchar *font_name); void cmdline_insert_chr(gint &pos, gchar chr); - - friend static inline void handle_key_press(bool is_shift, bool is_ctl, - guint keyval); } InterfaceCurrent; } /* namespace SciTECO */ |