From d4405d585671c609da0c8af5c9c978b985e526d9 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sun, 25 Jun 2006 19:57:07 +0000 Subject: [PATCH] Add clipboard functionality for find and go to line widgets git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@484 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 2 ++ src/callbacks.c | 24 ++++++++++++++++++++---- src/utils.c | 10 +++++++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e2ee667..8f6413c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ Add notebook_new_tab and update document_create_new_sci to use it; also remove on_tab_close_clicked. * src/notebook.c: Fix close tab button bug introduced in last commit. + * src/callbacks.c, src/utils.c: + Add clipboard functionality for find and go to line widgets. 2006-06-24 Enrico Troeger diff --git a/src/callbacks.c b/src/callbacks.c index e4b05030..8b78bc9e 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -376,8 +376,12 @@ on_cut1_activate (GtkMenuItem *menuitem, gpointer user_data) { gint idx = document_get_cur_idx(); + GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(app->window)); - if (idx >= 0) + if (GTK_IS_EDITABLE(focusw)) + gtk_editable_cut_clipboard(GTK_EDITABLE(focusw)); + else + if (IS_SCINTILLA(focusw) && idx >= 0) sci_cut(doc_list[idx].sci); } @@ -387,8 +391,12 @@ on_copy1_activate (GtkMenuItem *menuitem, gpointer user_data) { gint idx = document_get_cur_idx(); + GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(app->window)); - if (idx >= 0) + if (GTK_IS_EDITABLE(focusw)) + gtk_editable_copy_clipboard(GTK_EDITABLE(focusw)); + else + if (IS_SCINTILLA(focusw) && idx >= 0) sci_copy(doc_list[idx].sci); } @@ -398,8 +406,12 @@ on_paste1_activate (GtkMenuItem *menuitem, gpointer user_data) { gint idx = document_get_cur_idx(); + GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(app->window)); - if (idx >= 0) + if (GTK_IS_EDITABLE(focusw)) + gtk_editable_paste_clipboard(GTK_EDITABLE(focusw)); + else + if (IS_SCINTILLA(focusw) && idx >= 0) sci_paste(doc_list[idx].sci); } @@ -409,8 +421,12 @@ on_delete1_activate (GtkMenuItem *menuitem, gpointer user_data) { gint idx = document_get_cur_idx(); + GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(app->window)); - if (idx >= 0) + if (GTK_IS_EDITABLE(focusw)) + gtk_editable_delete_selection(GTK_EDITABLE(focusw)); + else + if (IS_SCINTILLA(focusw) && idx >= 0) sci_clear(doc_list[idx].sci); } diff --git a/src/utils.c b/src/utils.c index d582923e..bae73e82 100644 --- a/src/utils.c +++ b/src/utils.c @@ -172,11 +172,15 @@ void utils_update_popup_copy_items(gint index) void utils_update_menu_copy_items(gint idx) { - gboolean enable; + gboolean enable = FALSE; guint i; + GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(app->window)); - if (idx == -1) enable = FALSE; - else enable = sci_can_copy(doc_list[idx].sci); + if (IS_SCINTILLA(focusw)) + enable = (idx == -1) ? FALSE : sci_can_copy(doc_list[idx].sci); + else + if (GTK_IS_EDITABLE(focusw)) + enable = gtk_editable_get_selection_bounds(GTK_EDITABLE(focusw), NULL, NULL); for(i = 0; i < (sizeof(app->menu_copy_items)/sizeof(GtkWidget*)); i++) gtk_widget_set_sensitive(app->menu_copy_items[i], enable);