From 4b9e72c7564ad29be7c5df64fa11cc9a2491f20d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 11 Feb 2003 23:31:00 +0000 Subject: [PATCH] Fix for #82734 and #78216: 2003-02-12 Matthias Clasen Fix for #82734 and #78216: * gtk/gtktextview.c (delete_cb): (select_all_cb): New callbacks for context menu items. (popup_targets_received): Add "Delete" and "Select All" to context menu, mnemonics and title caps for all items. * gtk/gtkentry.c (gtk_entry_delete_cb): New callback for "Delete" context menu item. (popup_targets_received): Add "Delete" to context menu, mnemonics and title caps for all items. --- ChangeLog | 14 ++++++++++++++ ChangeLog.pre-2-10 | 14 ++++++++++++++ ChangeLog.pre-2-4 | 14 ++++++++++++++ ChangeLog.pre-2-6 | 14 ++++++++++++++ ChangeLog.pre-2-8 | 14 ++++++++++++++ gtk/gtkentry.c | 30 +++++++++++++++++++++++++++--- gtk/gtktextview.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 139 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63044273c7..35922a7a0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2003-02-12 Matthias Clasen + + Fix for #82734 and #78216: + + * gtk/gtktextview.c (delete_cb): + (select_all_cb): New callbacks for context menu items. + (popup_targets_received): Add "Delete" and "Select All" to context + menu, mnemonics and title caps for all items. + + * gtk/gtkentry.c (gtk_entry_delete_cb): New callback for "Delete" + context menu item. + (popup_targets_received): Add "Delete" to context menu, mnemonics + and title caps for all items. + 2003-02-09 Tor Lillqvist * gtk/gtkfilesel.c (win32_gtk_add_drives_to_dir_list): Use diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 63044273c7..35922a7a0d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +2003-02-12 Matthias Clasen + + Fix for #82734 and #78216: + + * gtk/gtktextview.c (delete_cb): + (select_all_cb): New callbacks for context menu items. + (popup_targets_received): Add "Delete" and "Select All" to context + menu, mnemonics and title caps for all items. + + * gtk/gtkentry.c (gtk_entry_delete_cb): New callback for "Delete" + context menu item. + (popup_targets_received): Add "Delete" to context menu, mnemonics + and title caps for all items. + 2003-02-09 Tor Lillqvist * gtk/gtkfilesel.c (win32_gtk_add_drives_to_dir_list): Use diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 63044273c7..35922a7a0d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +2003-02-12 Matthias Clasen + + Fix for #82734 and #78216: + + * gtk/gtktextview.c (delete_cb): + (select_all_cb): New callbacks for context menu items. + (popup_targets_received): Add "Delete" and "Select All" to context + menu, mnemonics and title caps for all items. + + * gtk/gtkentry.c (gtk_entry_delete_cb): New callback for "Delete" + context menu item. + (popup_targets_received): Add "Delete" to context menu, mnemonics + and title caps for all items. + 2003-02-09 Tor Lillqvist * gtk/gtkfilesel.c (win32_gtk_add_drives_to_dir_list): Use diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 63044273c7..35922a7a0d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +2003-02-12 Matthias Clasen + + Fix for #82734 and #78216: + + * gtk/gtktextview.c (delete_cb): + (select_all_cb): New callbacks for context menu items. + (popup_targets_received): Add "Delete" and "Select All" to context + menu, mnemonics and title caps for all items. + + * gtk/gtkentry.c (gtk_entry_delete_cb): New callback for "Delete" + context menu item. + (popup_targets_received): Add "Delete" to context menu, mnemonics + and title caps for all items. + 2003-02-09 Tor Lillqvist * gtk/gtkfilesel.c (win32_gtk_add_drives_to_dir_list): Use diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 63044273c7..35922a7a0d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +2003-02-12 Matthias Clasen + + Fix for #82734 and #78216: + + * gtk/gtktextview.c (delete_cb): + (select_all_cb): New callbacks for context menu items. + (popup_targets_received): Add "Delete" and "Select All" to context + menu, mnemonics and title caps for all items. + + * gtk/gtkentry.c (gtk_entry_delete_cb): New callback for "Delete" + context menu item. + (popup_targets_received): Add "Delete" to context menu, mnemonics + and title caps for all items. + 2003-02-09 Tor Lillqvist * gtk/gtkfilesel.c (win32_gtk_add_drives_to_dir_list): Use diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 92041098a8..7943d8c05c 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -2249,6 +2249,19 @@ gtk_entry_paste_clipboard (GtkEntry *entry) gtk_entry_paste (entry, GDK_NONE); } +static void +gtk_entry_delete_cb (GtkEntry *entry) +{ + GtkEditable *editable = GTK_EDITABLE (entry); + gint start, end; + + if (entry->editable) + { + if (gtk_editable_get_selection_bounds (editable, &start, &end)) + gtk_editable_delete_text (editable, start, end); + } +} + static void gtk_entry_toggle_overwrite (GtkEntry *entry) { @@ -3956,7 +3969,18 @@ popup_targets_received (GtkClipboard *clipboard, append_action_signal (entry, entry->popup_menu, GTK_STOCK_PASTE, "paste_clipboard", entry->editable && clipboard_contains_text); - menuitem = gtk_menu_item_new_with_label (_("Select All")); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_DELETE, NULL); + gtk_widget_set_sensitive (menuitem, entry->current_pos != entry->selection_bound); + g_signal_connect_swapped (menuitem, "activate", + G_CALLBACK (gtk_entry_delete_cb), entry); + gtk_widget_show (menuitem); + gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem); + + menuitem = gtk_separator_menu_item_new (); + gtk_widget_show (menuitem); + gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem); + + menuitem = gtk_menu_item_new_with_mnemonic (_("Select _All")); g_signal_connect_swapped (menuitem, "activate", G_CALLBACK (gtk_entry_select_all), entry); gtk_widget_show (menuitem); @@ -3966,7 +3990,7 @@ popup_targets_received (GtkClipboard *clipboard, gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (entry->popup_menu), menuitem); - menuitem = gtk_menu_item_new_with_label (_("Input Methods")); + menuitem = gtk_menu_item_new_with_mnemonic (_("Input _Methods")); gtk_widget_show (menuitem); submenu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu); @@ -3976,7 +4000,7 @@ popup_targets_received (GtkClipboard *clipboard, gtk_im_multicontext_append_menuitems (GTK_IM_MULTICONTEXT (entry->im_context), GTK_MENU_SHELL (submenu)); - menuitem = gtk_menu_item_new_with_mnemonic (_("_Insert Unicode control character")); + menuitem = gtk_menu_item_new_with_mnemonic (_("_Insert Unicode Control Character")); gtk_widget_show (menuitem); submenu = gtk_menu_new (); diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index c643efdcbb..00646102f6 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -6398,6 +6398,27 @@ append_action_signal (GtkTextView *text_view, gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); } +static void +select_all_cb (GtkWidget *menuitem, + GtkTextView *text_view) +{ + GtkTextBuffer *buffer; + GtkTextIter start_iter, end_iter; + + buffer = text_view->buffer; + gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter); + gtk_text_buffer_move_mark_by_name (buffer, "insert", &start_iter); + gtk_text_buffer_move_mark_by_name (buffer, "selection_bound", &end_iter); + gtk_text_buffer_copy_clipboard (buffer, gtk_clipboard_get (GDK_NONE)); +} + +static void +delete_cb (GtkTextView *text_view) +{ + gtk_text_buffer_delete_selection (get_buffer (text_view), TRUE, + text_view->editable); +} + static void popup_menu_detach (GtkWidget *attach_widget, GtkMenu *menu) @@ -6553,6 +6574,26 @@ popup_targets_received (GtkClipboard *clipboard, append_action_signal (text_view, text_view->popup_menu, GTK_STOCK_PASTE, "paste_clipboard", can_insert && clipboard_contains_text); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_DELETE, NULL); + gtk_widget_set_sensitive (menuitem, + have_selection && + range_contains_editable_text (&sel_start, &sel_end, + text_view->editable)); + g_signal_connect_swapped (menuitem, "activate", + G_CALLBACK (delete_cb), text_view); + gtk_widget_show (menuitem); + gtk_menu_shell_append (GTK_MENU_SHELL (text_view->popup_menu), menuitem); + + menuitem = gtk_separator_menu_item_new (); + gtk_widget_show (menuitem); + gtk_menu_shell_append (GTK_MENU_SHELL (text_view->popup_menu), menuitem); + + menuitem = gtk_menu_item_new_with_mnemonic (_("Select _All")); + g_signal_connect (GTK_OBJECT (menuitem), "activate", + GTK_SIGNAL_FUNC (select_all_cb), text_view); + gtk_widget_show (menuitem); + gtk_menu_shell_append (GTK_MENU_SHELL (text_view->popup_menu), menuitem); + menuitem = gtk_separator_menu_item_new (); gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (text_view->popup_menu), menuitem); @@ -6566,7 +6607,7 @@ popup_targets_received (GtkClipboard *clipboard, gtk_im_multicontext_append_menuitems (GTK_IM_MULTICONTEXT (text_view->im_context), GTK_MENU_SHELL (submenu)); - menuitem = gtk_menu_item_new_with_mnemonic (_("_Insert Unicode control character")); + menuitem = gtk_menu_item_new_with_mnemonic (_("_Insert Unicode Control Character")); gtk_widget_show (menuitem); gtk_widget_set_sensitive (menuitem, can_insert);