[geany/geany] 4c504c: Reorganize select callback
pik
git-noreply at xxxxx
Mon Apr 20 20:16:35 UTC 2015
Branch: refs/heads/master
Author: pik <alexander.maznev at gmail.com>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Mon, 20 Apr 2015 20:16:35 UTC
Commit: 4c504c2be245e3860ad546948f64553263c2fe79
https://github.com/geany/geany/commit/4c504c2be245e3860ad546948f64553263c2fe79
Log Message:
-----------
Reorganize select callback
* select_all now works with splitwindow
* select_all now works with file-browser pane
* menu_select_all now works everywhere select_all hotkey does
Modified Paths:
--------------
src/callbacks.c
src/keybindings.c
Modified: src/callbacks.c
22 lines changed, 20 insertions(+), 2 deletions(-)
===================================================================
@@ -1187,9 +1187,27 @@ void on_print1_activate(GtkMenuItem *menuitem, gpointer user_data)
void on_menu_select_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
- g_return_if_fail(IS_SCINTILLA(focusw));
- sci_select_all(SCINTILLA(focusw));
+ /* special case for Select All in the scribble widget */
+ if (focusw == msgwindow.scribble)
+ {
+ g_signal_emit_by_name(msgwindow.scribble, "select-all", TRUE);
+ }
+ /* special case for Select All in the VTE widget */
+#ifdef HAVE_VTE
+ else if (vte_info.have_vte && focusw == vc->vte)
+ {
+ vte_select_all();
+ }
+#endif
+ else if (GTK_IS_EDITABLE(focusw))
+ {
+ gtk_editable_select_region(GTK_EDITABLE(focusw), 0, -1);
+ }
+ else if (IS_SCINTILLA(focusw))
+ {
+ sci_select_all(SCINTILLA(focusw));
+ }
}
Modified: src/keybindings.c
54 lines changed, 12 insertions(+), 42 deletions(-)
===================================================================
@@ -2358,46 +2358,11 @@ static gboolean cb_func_format_action(guint key_id)
}
-/* common function for select keybindings, only valid when scintilla has focus. */
+/* common function for select keybindings, valid for scintilla and/or gtk_editable objects. */
static gboolean cb_func_select_action(guint key_id)
{
- GeanyDocument *doc;
- ScintillaObject *sci;
+ GeanyDocument *doc = document_get_current();
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
- GtkWidget *toolbar_search_entry = toolbar_get_widget_child_by_name("SearchEntry");
- GtkWidget *toolbar_goto_entry = toolbar_get_widget_child_by_name("GotoEntry");
-
- /* special case for Select All in the scribble widget */
- if (key_id == GEANY_KEYS_SELECT_ALL && focusw == msgwindow.scribble)
- {
- g_signal_emit_by_name(msgwindow.scribble, "select-all", TRUE);
- return TRUE;
- }
- /* special case for Select All in the VTE widget */
-#ifdef HAVE_VTE
- else if (key_id == GEANY_KEYS_SELECT_ALL && vte_info.have_vte && focusw == vc->vte)
- {
- vte_select_all();
- return TRUE;
- }
-#endif
- /* special case for Select All in the toolbar search widget */
- else if (key_id == GEANY_KEYS_SELECT_ALL && focusw == toolbar_search_entry)
- {
- gtk_editable_select_region(GTK_EDITABLE(toolbar_search_entry), 0, -1);
- return TRUE;
- }
- else if (key_id == GEANY_KEYS_SELECT_ALL && focusw == toolbar_goto_entry)
- {
- gtk_editable_select_region(GTK_EDITABLE(toolbar_goto_entry), 0, -1);
- return TRUE;
- }
-
- doc = document_get_current();
- /* keybindings only valid when scintilla widget has focus */
- if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
- return TRUE;
- sci = doc->editor->sci;
switch (key_id)
{
@@ -2405,19 +2370,24 @@ static gboolean cb_func_select_action(guint key_id)
on_menu_select_all1_activate(NULL, NULL);
break;
case GEANY_KEYS_SELECT_WORD:
- editor_select_word(doc->editor);
+ if (doc != NULL)
+ editor_select_word(doc->editor);
break;
case GEANY_KEYS_SELECT_LINE:
- editor_select_lines(doc->editor, FALSE);
+ if (doc != NULL)
+ editor_select_lines(doc->editor, FALSE);
break;
case GEANY_KEYS_SELECT_PARAGRAPH:
- editor_select_paragraph(doc->editor);
+ if (doc != NULL)
+ editor_select_paragraph(doc->editor);
break;
case GEANY_KEYS_SELECT_WORDPARTLEFT:
- sci_send_command(sci, SCI_WORDPARTLEFTEXTEND);
+ if (IS_SCINTILLA(focusw))
+ sci_send_command(SCINTILLA(focusw), SCI_WORDPARTLEFTEXTEND);
break;
case GEANY_KEYS_SELECT_WORDPARTRIGHT:
- sci_send_command(sci, SCI_WORDPARTRIGHTEXTEND);
+ if (IS_SCINTILLA(focusw))
+ sci_send_command(SCINTILLA(focusw), SCI_WORDPARTRIGHTEXTEND);
break;
}
return TRUE;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list