diff --git a/ChangeLog b/ChangeLog index 9b77c70e..bc8d89eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-06-02 Enrico Tröger + + * src/document.c, src/document.h, src/ui_utils.c, src/ui_utils.h: + Add ui_focus_current_document() and document_grab_focus(). + + 2011-05-30 Enrico Tröger * data/filetypes.java: diff --git a/src/document.c b/src/document.c index 971936b7..d3696fae 100644 --- a/src/document.c +++ b/src/document.c @@ -3129,3 +3129,9 @@ gint document_compare_by_tab_order_reverse(gconstpointer a, gconstpointer b) } +void document_grab_focus(GeanyDocument *doc) +{ + g_return_if_fail(doc != NULL); + + gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci)); +} diff --git a/src/document.h b/src/document.h index 39d90f20..4c74dfc0 100644 --- a/src/document.h +++ b/src/document.h @@ -267,4 +267,6 @@ gint document_compare_by_tab_order(gconstpointer a, gconstpointer b); gint document_compare_by_tab_order_reverse(gconstpointer a, gconstpointer b); +void document_grab_focus(GeanyDocument *doc); + #endif diff --git a/src/ui_utils.c b/src/ui_utils.c index d9ba84aa..15fab5e4 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -2572,3 +2572,11 @@ GdkPixbuf *ui_get_mime_icon(const gchar *mime_type, GtkIconSize size) return icon; } + +void ui_focus_current_document(void) +{ + GeanyDocument *doc = document_get_current(); + + if (doc != NULL) + document_grab_focus(doc); +} diff --git a/src/ui_utils.h b/src/ui_utils.h index e9b83242..267a1cb9 100644 --- a/src/ui_utils.h +++ b/src/ui_utils.h @@ -327,4 +327,7 @@ gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value) GdkPixbuf *ui_get_mime_icon(const gchar *mime_type, GtkIconSize size); +void ui_focus_current_document(void); + + #endif