From 4443fe3e24d3a08aa29cac8d164824b36412da68 Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Thu, 20 Dec 2001 05:35:48 +0000 Subject: Add cut/copy/paste to right-click menu. 2001-12-19 Jon Trowbridge * gui/widgets/e-addressbook-reflow-adapter.c (e_addressbook_reflow_adapter_right_click): Add cut/copy/paste to right-click menu. * gui/widgets/e-addressbook-view.c (table_right_click): Add cut/copy/paste to right-click menu. (Fixes bug #14528.) Also, disable some right-click options if our addressbook isn't editable. svn path=/trunk/; revision=15190 --- .../gui/widgets/e-addressbook-reflow-adapter.c | 26 +++++++++++ addressbook/gui/widgets/e-addressbook-view.c | 50 +++++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c index 66f21dbc9d..8c4507a5e3 100644 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c @@ -5,6 +5,7 @@ #include "e-addressbook-reflow-adapter.h" #include "e-addressbook-model.h" +#include "e-addressbook-view.h" #include "e-addressbook-util.h" #include @@ -197,6 +198,28 @@ card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) d(g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status)); } +static void +copy (GtkWidget *widget, ModelAndSelection *mns) +{ + EAddressbookView *view = gtk_object_get_data (GTK_OBJECT (mns->adapter), "view"); + e_addressbook_view_copy (view); +} + +static void +cut (GtkWidget *widget, ModelAndSelection *mns) +{ + EAddressbookView *view = gtk_object_get_data (GTK_OBJECT (mns->adapter), "view"); + e_addressbook_view_copy (view); + e_addressbook_view_delete_selection (view); +} + +static void +paste (GtkWidget *widget, ModelAndSelection *mns) +{ + EAddressbookView *view = gtk_object_get_data (GTK_OBJECT (mns->adapter), "view"); + e_addressbook_view_paste (view); +} + static void delete (GtkWidget *widget, ModelAndSelection *mns) { @@ -272,6 +295,9 @@ e_addressbook_reflow_adapter_right_click (EAddressbookReflowAdapter *adapter, Gd #if 0 /* Envelope printing is disabled for Evolution 1.0. */ {N_("Print Envelope"), NULL, GTK_SIGNAL_FUNC(print_envelope), NULL, 0}, #endif + {N_("Cut"), NULL, GTK_SIGNAL_FUNC (cut), NULL, POPUP_READONLY_MASK}, + {N_("Copy"), NULL, GTK_SIGNAL_FUNC (copy), NULL, 0}, + {N_("Paste"), NULL, GTK_SIGNAL_FUNC (paste), NULL, POPUP_READONLY_MASK}, {N_("Delete"), NULL, GTK_SIGNAL_FUNC(delete), NULL, POPUP_READONLY_MASK}, {NULL, NULL, NULL, 0}}; diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index f52dd321e5..f478a1d40c 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -556,6 +556,9 @@ create_minicard_view (EAddressbookView *view) adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(e_addressbook_reflow_adapter_new (view->model)); minicard_view = e_minicard_view_widget_new(adapter); + /* A hack */ + gtk_object_set_data (GTK_OBJECT (adapter), "view", view); + gtk_signal_connect(GTK_OBJECT(minicard_view), "selection_change", GTK_SIGNAL_FUNC(minicard_selection_change), view); @@ -703,6 +706,43 @@ print_envelope (GtkWidget *widget, CardAndBook *card_and_book) } #endif +static void +copy (GtkWidget *widget, CardAndBook *card_and_book) +{ +#if 0 + card_and_book->view->clipboard_cards = g_list_append (NULL, card_and_book->card); + gtk_object_ref (GTK_OBJECT (card_and_book->card)); + gtk_selection_owner_set (card_and_book->view->invisible, clipboard_atom, GDK_CURRENT_TIME); +#endif + + e_addressbook_view_copy (card_and_book->view); + card_and_book_free (card_and_book); +} + +static void +paste (GtkWidget *widget, CardAndBook *card_and_book) +{ + e_addressbook_view_paste (card_and_book->view); + card_and_book_free (card_and_book); +} + +static void +cut (GtkWidget *widget, CardAndBook *card_and_book) +{ +#if 0 + /* copy */ + card_and_book->view->clipboard_cards = g_list_append (NULL, card_and_book->card); + gtk_object_ref (GTK_OBJECT (card_and_book->card)); + gtk_selection_owner_set (card_and_book->view->invisible, clipboard_atom, GDK_CURRENT_TIME); + + /* delete */ + e_book_remove_card (card_and_book->book, card_and_book->card, NULL, NULL); +#endif + + e_addressbook_view_cut (card_and_book->view); + card_and_book_free (card_and_book); +} + static void delete (GtkWidget *widget, CardAndBook *card_and_book) { @@ -722,6 +762,7 @@ delete (GtkWidget *widget, CardAndBook *card_and_book) card_and_book_free(card_and_book); } +#define POPUP_READONLY_MASK 0x1 static gint table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EAddressbookView *view) { @@ -737,7 +778,10 @@ table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EA #if 0 /* Envelope printing is disabled for Evolution 1.0. */ {N_("Print Envelope"), NULL, GTK_SIGNAL_FUNC(print_envelope), NULL, 0}, #endif - {N_("Delete"), NULL, GTK_SIGNAL_FUNC(delete), NULL, 0}, + {N_("Cut"), NULL, GTK_SIGNAL_FUNC (cut), NULL, POPUP_READONLY_MASK}, + {N_("Copy"), NULL, GTK_SIGNAL_FUNC (copy), NULL, 0}, + {N_("Paste"), NULL, GTK_SIGNAL_FUNC (paste), NULL, POPUP_READONLY_MASK}, + {N_("Delete"), NULL, GTK_SIGNAL_FUNC(delete), NULL, POPUP_READONLY_MASK}, {NULL, NULL, NULL, NULL, 0} }; @@ -752,7 +796,9 @@ table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EA gtk_object_ref(GTK_OBJECT(card_and_book->book)); gtk_object_ref(GTK_OBJECT(card_and_book->view)); - e_popup_menu_run (menu, event, 0, 0, card_and_book); + e_popup_menu_run (menu, event, + e_addressbook_model_editable (model) ? 0 : POPUP_READONLY_MASK, + 0, card_and_book); return TRUE; } else return FALSE; -- cgit