aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-04-24 03:42:37 +0800
committerChris Lahey <clahey@src.gnome.org>2002-04-24 03:42:37 +0800
commit5df4d67be220866f4dd6121cb26158cf5299193f (patch)
treee4b847b3c9883c4e4cb62c2fcd260006b286aa9d /addressbook
parent619f8c41a390d40d074ace283e4d6c374a142766 (diff)
downloadgsoc2013-evolution-5df4d67be220866f4dd6121cb26158cf5299193f.tar.gz
gsoc2013-evolution-5df4d67be220866f4dd6121cb26158cf5299193f.tar.zst
gsoc2013-evolution-5df4d67be220866f4dd6121cb26158cf5299193f.zip
Removed e_addressbook_reflow_adapter_right_click and
2002-04-23 Christopher James Lahey <clahey@ximian.com> * gui/widgets/e-addressbook-reflow-adapter.c, gui/widgets/e-addressbook-reflow-adapter.h: Removed e_addressbook_reflow_adapter_right_click and e_addressbook_reflow_adapter_base_right_click. * gui/widgets/e-addressbook-view.c: Handle right click menu for both types of view. Merged right click on white space with right click on main area. General clean up. * gui/widgets/e-minicard-view-widget.c, gui/widgets/e-minicard-view-widget.h: Removed a couple unnecessary functions. Added e_minicard_view_widget_get_view. Added right_click signal. * gui/widgets/e-minicard-view.c, gui/widgets/e-minicard-view.h: Added the right_click signal and the e_minicard_view_get_card_list function. svn path=/trunk/; revision=16567
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog20
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.c303
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.h5
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c562
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.c95
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.h16
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c147
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h17
8 files changed, 474 insertions, 691 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 20df7ffba8..77a54158a3 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,23 @@
+2002-04-23 Christopher James Lahey <clahey@ximian.com>
+
+ * gui/widgets/e-addressbook-reflow-adapter.c,
+ gui/widgets/e-addressbook-reflow-adapter.h: Removed
+ e_addressbook_reflow_adapter_right_click and
+ e_addressbook_reflow_adapter_base_right_click.
+
+ * gui/widgets/e-addressbook-view.c: Handle right click menu for
+ both types of view. Merged right click on white space with right
+ click on main area. General clean up.
+
+ * gui/widgets/e-minicard-view-widget.c,
+ gui/widgets/e-minicard-view-widget.h: Removed a couple unnecessary
+ functions. Added e_minicard_view_widget_get_view. Added
+ right_click signal.
+
+ * gui/widgets/e-minicard-view.c, gui/widgets/e-minicard-view.h:
+ Added the right_click signal and the e_minicard_view_get_card_list
+ function.
+
2002-04-22 Christopher James Lahey <clahey@ximian.com>
* gui/component/select-names/e-select-names.h: Removed an unused
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
index 793a9a4bc5..16e61a2d89 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
@@ -94,309 +94,6 @@ text_height (GnomeCanvas *canvas, const gchar *text)
return height;
}
-typedef struct {
- EAddressbookReflowAdapter *adapter;
- ESelectionModel *selection;
- GtkWidget *widget;
-} ModelAndSelection;
-
-static void
-model_and_selection_free (ModelAndSelection *mns)
-{
- if (mns->adapter)
- gtk_object_unref(GTK_OBJECT(mns->adapter));
- if (mns->selection) {
- e_selection_model_right_click_up(mns->selection);
- gtk_object_unref(GTK_OBJECT(mns->selection));
- }
- if (mns->widget)
- gtk_object_unref(GTK_OBJECT(mns->widget));
- g_free(mns);
-}
-
-static void
-add_to_list (int model_row, gpointer closure)
-{
- GList **list = closure;
- *list = g_list_prepend (*list, GINT_TO_POINTER (model_row));
-}
-
-static GList *
-get_card_list (ModelAndSelection *mns)
-{
- EAddressbookReflowAdapterPrivate *priv = mns->adapter->priv;
- GList *list;
- GList *iterator;
-
- list = NULL;
- e_selection_model_foreach (mns->selection, add_to_list, &list);
-
- for (iterator = list; iterator; iterator = iterator->next) {
- iterator->data = e_addressbook_model_card_at (priv->model, GPOINTER_TO_INT (iterator->data));
- gtk_object_ref (GTK_OBJECT (iterator->data));
- }
- list = g_list_reverse (list);
- return list;
-}
-
-static void
-save_as (GtkWidget *widget, ModelAndSelection *mns)
-{
- GList *list;
-
- list = get_card_list (mns);
- if (list)
- e_contact_list_save_as (_("Save as VCard"), list);
- e_free_object_list (list);
-}
-
-static void
-send_as (GtkWidget *widget, ModelAndSelection *mns)
-{
- GList *list;
-
- list = get_card_list (mns);
- if (list)
- e_card_list_send (list, E_CARD_DISPOSITION_AS_ATTACHMENT);
- e_free_object_list (list);
-}
-
-static void
-send_to (GtkWidget *widget, ModelAndSelection *mns)
-{
- GList *list;
-
- list = get_card_list (mns);
- if (list)
- e_card_list_send (list, E_CARD_DISPOSITION_AS_TO);
- e_free_object_list (list);
-}
-
-static void
-print (GtkWidget *widget, ModelAndSelection *mns)
-{
- GList *list;
-
- list = get_card_list (mns);
- if (list)
- gtk_widget_show (e_contact_print_card_list_dialog_new (list));
- e_free_object_list (list);
-}
-
-#if 0 /* Envelope printing is disabled for Evolution 1.0. */
-static void
-print_envelope (GtkWidget *widget, ModelAndSelection *mns)
-{
- GList *list;
-
- list = get_card_list (mns);
- if (list)
- gtk_widget_show (e_contact_print_envelope_list_dialog_new (list));
- e_free_object_list (list);
-}
-#endif
-
-static void
-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)
-{
- EAddressbookReflowAdapterPrivate *priv = mns->adapter->priv;
- GList *list;
-
- list = get_card_list (mns);
- if (list) {
-
- if (e_contact_editor_confirm_delete(NULL)) { /*FIXME: Give a GtkWindow here. */
- GList *iterator;
- EBook *book = e_addressbook_model_get_ebook(priv->model);
-
- for (iterator = list; iterator; iterator = iterator->next) {
- ECard *card = iterator->data;
-
- gtk_object_ref(GTK_OBJECT(card));
-
- e_book_remove_card (book,
- card,
- card_changed_cb,
- NULL);
-
- gtk_object_unref(GTK_OBJECT(card));
- }
- }
- }
-
- e_free_object_list (list);
-}
-
-static void
-open_card (GtkWidget *widget, ModelAndSelection *mns)
-{
- EAddressbookReflowAdapterPrivate *priv = mns->adapter->priv;
- GList *list;
- EBook *book = e_addressbook_model_get_ebook(priv->model);
-
- list = get_card_list (mns);
-
- e_addressbook_show_multiple_cards (book, list, e_addressbook_model_editable (priv->model));
- e_free_object_list (list);
-}
-
-static void
-transfer_cards (ModelAndSelection *mns, gboolean delete_from_source)
-{
- EBook *book;
- GList *cards;
- GtkWindow *parent_window;
-
- book = e_addressbook_model_get_ebook(mns->adapter->priv->model);
- cards = get_card_list (mns);
- if (mns->widget)
- parent_window = GTK_WINDOW (gtk_widget_get_toplevel (mns->widget));
- else
- parent_window = NULL;
-
- e_addressbook_transfer_cards (book, cards, delete_from_source, parent_window);
-}
-
-static void
-copy_to_folder (GtkWidget *widget, ModelAndSelection *mns)
-{
- transfer_cards (mns, FALSE);
-}
-
-static void
-move_to_folder (GtkWidget *widget, ModelAndSelection *mns)
-{
- transfer_cards (mns, TRUE);
-}
-
-static void
-free_popup_info (GtkWidget *w, ModelAndSelection *mns)
-{
- model_and_selection_free (mns);
-}
-
-#define POPUP_READONLY_MASK 0x01
-gint
-e_addressbook_reflow_adapter_right_click (EAddressbookReflowAdapter *adapter, GdkEvent *event, ESelectionModel *selection)
-{
- EAddressbookReflowAdapterPrivate *priv = adapter->priv;
- ModelAndSelection *mns = g_new(ModelAndSelection, 1);
- GtkMenu *popup;
- EPopupMenu menu[] = {
- E_POPUP_ITEM (N_("Open"), GTK_SIGNAL_FUNC(open_card), 0),
- E_POPUP_ITEM (N_("Save as VCard"), GTK_SIGNAL_FUNC(save_as), 0),
- E_POPUP_ITEM (N_("Forward Contact"), GTK_SIGNAL_FUNC(send_as), 0),
- E_POPUP_ITEM (N_("Send Message to Contact"), GTK_SIGNAL_FUNC(send_to), 0),
- E_POPUP_ITEM (N_("Print"), GTK_SIGNAL_FUNC(print), 0),
-#if 0 /* Envelope printing is disabled for Evolution 1.0. */
- E_POPUP_ITEM (N_("Print Envelope"), GTK_SIGNAL_FUNC(print_envelope), 0),
-#endif
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("Copy to folder..."), GTK_SIGNAL_FUNC(copy_to_folder), 0),
- E_POPUP_ITEM (N_("Move to folder..."), GTK_SIGNAL_FUNC(move_to_folder), POPUP_READONLY_MASK),
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("Cut"), GTK_SIGNAL_FUNC (cut), POPUP_READONLY_MASK),
- E_POPUP_ITEM (N_("Copy"), GTK_SIGNAL_FUNC (copy), 0),
- E_POPUP_ITEM (N_("Paste"), GTK_SIGNAL_FUNC (paste), POPUP_READONLY_MASK),
- E_POPUP_ITEM (N_("Delete"), GTK_SIGNAL_FUNC (delete), POPUP_READONLY_MASK),
- E_POPUP_TERMINATOR
- };
-
- mns->adapter = adapter;
- mns->selection = selection;
- mns->widget = gtk_get_event_widget (event);
- gtk_object_ref(GTK_OBJECT(mns->adapter));
- gtk_object_ref(GTK_OBJECT(mns->selection));
- if (mns->widget)
- gtk_object_ref(GTK_OBJECT(mns->widget));
- popup = e_popup_menu_create (menu, e_addressbook_model_editable(priv->model) ? 0 : POPUP_READONLY_MASK, 0, mns);
-
- gtk_signal_connect (GTK_OBJECT (popup), "selection-done",
- GTK_SIGNAL_FUNC (free_popup_info), mns);
- e_popup_menu (popup, event);
-
- return TRUE;
-}
-
-static void
-new_card (GtkWidget *widget, ModelAndSelection *mns)
-{
- EBook *book;
-
- book = e_addressbook_model_get_ebook(mns->adapter->priv->model);
-
- e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, TRUE);
-}
-
-static void
-new_list (GtkWidget *widget, ModelAndSelection *mns)
-{
- EBook *book;
-
- book = e_addressbook_model_get_ebook(mns->adapter->priv->model);
-
- e_addressbook_show_contact_list_editor (book, e_card_new(""), TRUE, TRUE);
-}
-
-gint
-e_addressbook_reflow_adapter_base_right_click (EAddressbookReflowAdapter *adapter, GdkEvent *event)
-{
- EAddressbookReflowAdapterPrivate *priv = adapter->priv;
- ModelAndSelection *mns = g_new(ModelAndSelection, 1);
- GtkMenu *popup;
- EPopupMenu menu[] = {
- E_POPUP_ITEM (N_("New Contact..."), GTK_SIGNAL_FUNC(new_card), POPUP_READONLY_MASK),
- E_POPUP_ITEM (N_("New Contact List..."), GTK_SIGNAL_FUNC(new_list), POPUP_READONLY_MASK),
- E_POPUP_SEPARATOR,
- E_POPUP_ITEM (N_("Paste"), GTK_SIGNAL_FUNC (paste), POPUP_READONLY_MASK),
- E_POPUP_TERMINATOR
- };
-
- mns->adapter = adapter;
- mns->selection = NULL;
- mns->widget = gtk_get_event_widget (event);
- gtk_object_ref(GTK_OBJECT(mns->adapter));
- if (mns->widget)
- gtk_object_ref(GTK_OBJECT(mns->widget));
- popup = e_popup_menu_create (menu, e_addressbook_model_editable(priv->model) ? 0 : POPUP_READONLY_MASK, 0, mns);
-
- gtk_signal_connect (GTK_OBJECT (popup), "selection-done",
- GTK_SIGNAL_FUNC (free_popup_info), mns);
- e_popup_menu (popup, event);
-
- return TRUE;
-}
-
static void
addressbook_finalize(GtkObject *object)
{
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h b/addressbook/gui/widgets/e-addressbook-reflow-adapter.h
index bdb575737b..b3f6ab9c0d 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.h
@@ -44,9 +44,4 @@ EReflowModel *e_addressbook_reflow_adapter_new (EAddressbookModel
/* Returns object with ref count of 1. */
ECard *e_addressbook_reflow_adapter_get_card (EAddressbookReflowAdapter *adapter,
int index);
-gint e_addressbook_reflow_adapter_right_click (EAddressbookReflowAdapter *emvm,
- GdkEvent *event,
- ESelectionModel *selection);
-gint e_addressbook_reflow_adapter_base_right_click (EAddressbookReflowAdapter *adapter,
- GdkEvent *event);
#endif /* _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ */
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 33f7ccc3be..1cb1b888bf 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -576,6 +576,296 @@ e_addressbook_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
}
+/* Popup menu stuff */
+typedef struct {
+ EAddressbookView *view;
+ EPopupMenu *submenu;
+ gpointer closure;
+} CardAndBook;
+
+static void
+card_and_book_free (CardAndBook *card_and_book)
+{
+ EAddressbookView *view = card_and_book->view;
+
+ if (card_and_book->submenu)
+ gal_view_instance_free_popup_menu (card_and_book->view->view_instance,
+ card_and_book->submenu);
+
+ if (E_IS_TABLE_SCROLLED (view->widget)) {
+ ETable *table = e_table_scrolled_get_table (E_TABLE_SCROLLED (view->widget));
+
+ e_table_right_click_up (table);
+ } else if (E_IS_MINICARD_VIEW_WIDGET (view->object)) {
+ EMinicardViewWidget *minicard_view_widget =
+ E_MINICARD_VIEW_WIDGET (view->object);
+ ESelectionModel *selection =
+ e_minicard_view_widget_get_selection_model (minicard_view_widget);
+
+ e_selection_model_right_click_up(selection);
+ }
+
+ gtk_object_unref(GTK_OBJECT(card_and_book->view));
+}
+
+static void
+table_get_card_list_1(gint model_row,
+ gpointer closure)
+{
+ CardAndBook *card_and_book;
+ GList **list;
+ EAddressbookView *view;
+ ECard *card;
+
+ card_and_book = closure;
+ list = card_and_book->closure;
+ view = card_and_book->view;
+
+ card = e_addressbook_model_get_card(view->model, model_row);
+ *list = g_list_prepend(*list, card);
+}
+
+static GList *
+get_card_list (CardAndBook *card_and_book)
+{
+ GList *list = NULL;
+ EAddressbookView *view = card_and_book->view;
+
+ if (E_IS_TABLE_SCROLLED (view->widget)) {
+ ETable *table;
+ ETableScrolled *scrolled = E_TABLE_SCROLLED (view->widget);
+ table = e_table_scrolled_get_table (scrolled);
+ card_and_book->closure = &list;
+ e_table_selected_row_foreach(table,
+ table_get_card_list_1,
+ card_and_book);
+ } else if (E_IS_MINICARD_VIEW_WIDGET (view->object)) {
+ EMinicardViewWidget *view_widget =
+ E_MINICARD_VIEW_WIDGET (view->object);
+ EMinicardView *view =
+ e_minicard_view_widget_get_view (view_widget);
+
+ list = e_minicard_view_get_card_list (view);
+ }
+
+ return list;
+}
+
+static void
+save_as (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ GList *cards = get_card_list (card_and_book);
+ if (cards) {
+ e_contact_list_save_as(_("Save as VCard"), cards);
+ e_free_object_list(cards);
+ }
+}
+
+static void
+send_as (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ GList *cards = get_card_list (card_and_book);
+ if (cards) {
+ e_card_list_send(cards, E_CARD_DISPOSITION_AS_ATTACHMENT);
+ e_free_object_list(cards);
+ }
+}
+
+static void
+send_to (GtkWidget *widget, CardAndBook *card_and_book)
+
+{
+ GList *cards = get_card_list (card_and_book);
+ if (cards) {
+ e_card_list_send(cards, E_CARD_DISPOSITION_AS_TO);
+ e_free_object_list(cards);
+ }
+}
+
+static void
+print (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ GList *cards = get_card_list (card_and_book);
+ if (cards) {
+ if (cards->next)
+ gtk_widget_show(e_contact_print_card_list_dialog_new(cards));
+ else
+ gtk_widget_show(e_contact_print_card_dialog_new(cards->data));
+ e_free_object_list(cards);
+ }
+}
+
+#if 0 /* Envelope printing is disabled for Evolution 1.0. */
+static void
+print_envelope (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ GList *cards = get_card_list (card_and_book);
+ if (cards) {
+ gtk_widget_show(e_contact_list_print_envelope_dialog_new(card_and_book->card));
+ e_free_object_list(cards);
+ }
+}
+#endif
+
+static void
+copy (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ e_addressbook_view_copy (card_and_book->view);
+}
+
+static void
+paste (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ e_addressbook_view_paste (card_and_book->view);
+}
+
+static void
+cut (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ e_addressbook_view_cut (card_and_book->view);
+}
+
+static void
+delete (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ if (e_contact_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(card_and_book->view->widget)))) {
+ EBook *book;
+
+ GList *list = get_card_list(card_and_book);
+ GList *iterator;
+
+ gtk_object_get(GTK_OBJECT(card_and_book->view->model),
+ "book", &book,
+ NULL);
+
+ for (iterator = list; iterator; iterator = iterator->next) {
+ ECard *card = iterator->data;
+ /* Remove the card. */
+ e_book_remove_card (book,
+ card,
+ NULL,
+ NULL);
+ }
+ e_free_object_list(list);
+ }
+}
+
+static void
+copy_to_folder (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ e_addressbook_view_copy_to_folder (card_and_book->view);
+}
+
+static void
+move_to_folder (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ e_addressbook_view_move_to_folder (card_and_book->view);
+}
+
+static void
+free_popup_info (GtkWidget *w, CardAndBook *card_and_book)
+{
+ card_and_book_free (card_and_book);
+}
+
+static void
+new_card (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ EBook *book;
+
+ gtk_object_get(GTK_OBJECT(card_and_book->view->model),
+ "book", &book,
+ NULL);
+ e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, TRUE);
+}
+
+static void
+new_list (GtkWidget *widget, CardAndBook *card_and_book)
+{
+ EBook *book;
+
+ gtk_object_get(GTK_OBJECT(card_and_book->view->model),
+ "book", &book,
+ NULL);
+ e_addressbook_show_contact_list_editor (book, e_card_new(""), TRUE, TRUE);
+}
+
+#define POPUP_READONLY_MASK 0x1
+#define POPUP_NOSELECTION_MASK 0x2
+
+static void
+do_popup_menu(EAddressbookView *view, GdkEvent *event)
+{
+ CardAndBook *card_and_book;
+ GtkMenu *popup;
+ EPopupMenu *submenu = NULL;
+ gboolean selection;
+
+ EPopupMenu menu[] = {
+ E_POPUP_ITEM (N_("New Contact..."), GTK_SIGNAL_FUNC(new_card), POPUP_READONLY_MASK),
+ E_POPUP_ITEM (N_("New Contact List..."), GTK_SIGNAL_FUNC(new_list), POPUP_READONLY_MASK),
+ E_POPUP_SEPARATOR,
+#if 0
+ E_POPUP_ITEM (N_("Go to Folder..."), GTK_SIGNAL_FUNC (goto_folder), 0),
+ E_POPUP_ITEM (N_("Import..."), GTK_SIGNAL_FUNC (import), POPUP_READONLY_MASK),
+ E_POPUP_SEPARATOR,
+ E_POPUP_ITEM (N_("Search for Contacts..."), GTK_SIGNAL_FUNC (search), 0),
+ E_POPUP_ITEM (N_("Addressbook Sources..."), GTK_SIGNAL_FUNC (sources), 0),
+ E_POPUP_SEPARATOR,
+ E_POPUP_ITEM (N_("Pilot Settings..."), GTK_SIGNAL_FUNC (pilot_settings), 0),
+#endif
+ E_POPUP_SEPARATOR,
+ E_POPUP_ITEM (N_("Save as VCard"), GTK_SIGNAL_FUNC(save_as), POPUP_NOSELECTION_MASK),
+ E_POPUP_ITEM (N_("Forward Contact"), GTK_SIGNAL_FUNC(send_as), POPUP_NOSELECTION_MASK),
+ E_POPUP_ITEM (N_("Send Message to Contact"), GTK_SIGNAL_FUNC(send_to), POPUP_NOSELECTION_MASK),
+ E_POPUP_ITEM (N_("Print"), GTK_SIGNAL_FUNC(print), POPUP_NOSELECTION_MASK),
+#if 0 /* Envelope printing is disabled for Evolution 1.0. */
+ E_POPUP_ITEM (N_("Print Envelope"), GTK_SIGNAL_FUNC(print_envelope), POPUP_NOSELECTION_MASK),
+#endif
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_ITEM (N_("Copy to folder..."), GTK_SIGNAL_FUNC(copy_to_folder), POPUP_NOSELECTION_MASK),
+ E_POPUP_ITEM (N_("Move to folder..."), GTK_SIGNAL_FUNC(move_to_folder), POPUP_READONLY_MASK | POPUP_NOSELECTION_MASK),
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_ITEM (N_("Cut"), GTK_SIGNAL_FUNC (cut), POPUP_READONLY_MASK | POPUP_NOSELECTION_MASK),
+ E_POPUP_ITEM (N_("Copy"), GTK_SIGNAL_FUNC (copy), POPUP_NOSELECTION_MASK),
+ E_POPUP_ITEM (N_("Paste"), GTK_SIGNAL_FUNC (paste), POPUP_READONLY_MASK),
+ E_POPUP_ITEM (N_("Delete"), GTK_SIGNAL_FUNC(delete), POPUP_READONLY_MASK | POPUP_NOSELECTION_MASK),
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_SUBMENU (N_("Current View"), submenu = gal_view_instance_get_popup_menu (view->view_instance), 0),
+ E_POPUP_TERMINATOR
+ };
+
+ if (E_IS_TABLE_SCROLLED(view->widget)) {
+ selection = e_table_selected_count(e_table_scrolled_get_table (E_TABLE_SCROLLED (view->widget))) > 0;
+ } else if (E_IS_MINICARD_VIEW_WIDGET (view->object)) {
+ EMinicardViewWidget *minicard_view_widget = E_MINICARD_VIEW_WIDGET (view->object);
+ ESelectionModel *selection_model = e_minicard_view_widget_get_selection_model (minicard_view_widget);
+ selection = e_selection_model_selected_count(selection_model) > 0;
+ } else {
+ selection = FALSE;
+ }
+ card_and_book = g_new(CardAndBook, 1);
+ card_and_book->view = view;
+ card_and_book->submenu = submenu;
+
+ gtk_object_ref(GTK_OBJECT(card_and_book->view));
+
+ popup = e_popup_menu_create (menu,
+ (e_addressbook_model_editable (view->model) ? 0 : POPUP_READONLY_MASK) +
+ (selection ? 0 : POPUP_NOSELECTION_MASK),
+ 0, card_and_book);
+
+ gtk_signal_connect (GTK_OBJECT (popup), "selection-done",
+ GTK_SIGNAL_FUNC (free_popup_info), card_and_book);
+ e_popup_menu (popup, event);
+
+}
+
+
+/* Minicard view stuff */
/* Translators: put here a list of labels you want to see on buttons in
addressbook. You may use any character to separate labels but it must
@@ -777,6 +1067,12 @@ minicard_button_press (GtkWidget *widget, GdkEventButton *event, EAddressbookVie
}
static void
+minicard_right_click (EMinicardView *minicard_view_item, GdkEvent *event, EAddressbookView *view)
+{
+ do_popup_menu(view, event);
+}
+
+static void
create_minicard_view (EAddressbookView *view)
{
GtkWidget *scrollframe;
@@ -802,6 +1098,9 @@ create_minicard_view (EAddressbookView *view)
gtk_signal_connect(GTK_OBJECT(minicard_view), "button_press_event",
GTK_SIGNAL_FUNC(minicard_button_press), view);
+ gtk_signal_connect(GTK_OBJECT(minicard_view), "right_click",
+ GTK_SIGNAL_FUNC(minicard_right_click), view);
+
view->object = GTK_OBJECT(minicard_view);
view->widget = minicard_hbox;
@@ -861,273 +1160,18 @@ table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, E
}
}
-typedef struct {
- EBook *book;
- ECard *card;
- EAddressbookView *view;
- GtkWidget *widget;
- EPopupMenu *submenu;
- gpointer closure;
-} CardAndBook;
-
-static void
-card_and_book_free (CardAndBook *card_and_book)
-{
- if (card_and_book->submenu)
- gal_view_instance_free_popup_menu (card_and_book->view->view_instance,
- card_and_book->submenu);
-
- gtk_object_unref(GTK_OBJECT(card_and_book->card));
- gtk_object_unref(GTK_OBJECT(card_and_book->book));
- gtk_object_unref(GTK_OBJECT(card_and_book->view));
-}
-
-static void
-get_card_list_1(gint model_row,
- gpointer closure)
-{
- CardAndBook *card_and_book;
- GList **list;
- EAddressbookView *view;
- ECard *card;
-
- card_and_book = closure;
- list = card_and_book->closure;
- view = card_and_book->view;
-
- card = e_addressbook_model_get_card(view->model, model_row);
- *list = g_list_prepend(*list, card);
-}
-
-static GList *
-get_card_list (CardAndBook *card_and_book)
-{
- GList *list = NULL;
- ETable *table;
-
- table = E_TABLE(card_and_book->widget);
- card_and_book->closure = &list;
- e_table_selected_row_foreach(table,
- get_card_list_1,
- card_and_book);
- return list;
-}
-
-static void
-save_as (GtkWidget *widget, CardAndBook *card_and_book)
-{
- e_contact_save_as(_("Save as VCard"), card_and_book->card);
-}
-
-static void
-send_as (GtkWidget *widget, CardAndBook *card_and_book)
-{
- e_card_send(card_and_book->card, E_CARD_DISPOSITION_AS_ATTACHMENT);
-}
-
-static void
-send_to (GtkWidget *widget, CardAndBook *card_and_book)
-
-{
- e_card_send(card_and_book->card, E_CARD_DISPOSITION_AS_TO);
-}
-
-static void
-print (GtkWidget *widget, CardAndBook *card_and_book)
-{
- gtk_widget_show(e_contact_print_card_dialog_new(card_and_book->card));
-}
-
-#if 0 /* Envelope printing is disabled for Evolution 1.0. */
-static void
-print_envelope (GtkWidget *widget, CardAndBook *card_and_book)
-{
- gtk_widget_show(e_contact_print_envelope_dialog_new(card_and_book->card));
-}
-#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);
-}
-
-static void
-paste (GtkWidget *widget, CardAndBook *card_and_book)
-{
- e_addressbook_view_paste (card_and_book->view);
-}
-
-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);
-}
-
-static void
-delete (GtkWidget *widget, CardAndBook *card_and_book)
-{
- if (e_contact_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(card_and_book->widget)))) {
- GList *list = get_card_list(card_and_book);
- GList *iterator;
- for (iterator = list; iterator; iterator = iterator->next) {
- ECard *card = iterator->data;
- /* Add the card in the contact editor to our ebook */
- e_book_remove_card (card_and_book->book,
- card,
- NULL,
- NULL);
- }
- e_free_object_list(list);
- }
-}
-
-static void
-copy_to_folder (GtkWidget *widget, CardAndBook *card_and_book)
-{
- e_addressbook_view_copy_to_folder (card_and_book->view);
-}
-
-static void
-move_to_folder (GtkWidget *widget, CardAndBook *card_and_book)
-{
- e_addressbook_view_move_to_folder (card_and_book->view);
-}
-
-static void
-free_popup_info (GtkWidget *w, 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)
{
- if (E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) {
- EAddressbookModel *model = view->model;
- CardAndBook *card_and_book;
- GtkMenu *popup;
- EPopupMenu *submenu;
-
- EPopupMenu menu[] = {
- E_POPUP_ITEM (N_("Save as VCard"), GTK_SIGNAL_FUNC(save_as), 0),
- E_POPUP_ITEM (N_("Forward Contact"), GTK_SIGNAL_FUNC(send_as), 0),
- E_POPUP_ITEM (N_("Send Message to Contact"), GTK_SIGNAL_FUNC(send_to), 0),
- E_POPUP_ITEM (N_("Print"), GTK_SIGNAL_FUNC(print), 0),
-#if 0 /* Envelope printing is disabled for Evolution 1.0. */
- E_POPUP_ITEM (N_("Print Envelope"), GTK_SIGNAL_FUNC(print_envelope), 0),
-#endif
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("Copy to folder..."), GTK_SIGNAL_FUNC(copy_to_folder), 0),
- E_POPUP_ITEM (N_("Move to folder..."), GTK_SIGNAL_FUNC(move_to_folder), POPUP_READONLY_MASK),
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("Cut"), GTK_SIGNAL_FUNC (cut), POPUP_READONLY_MASK),
- E_POPUP_ITEM (N_("Copy"), GTK_SIGNAL_FUNC (copy), 0),
- E_POPUP_ITEM (N_("Paste"), GTK_SIGNAL_FUNC (paste), POPUP_READONLY_MASK),
- E_POPUP_ITEM (N_("Delete"), GTK_SIGNAL_FUNC(delete), POPUP_READONLY_MASK),
- E_POPUP_SEPARATOR,
-
- E_POPUP_SUBMENU (N_("Current View"), submenu = gal_view_instance_get_popup_menu (view->view_instance), 0),
- E_POPUP_TERMINATOR
- };
-
- card_and_book = g_new(CardAndBook, 1);
- card_and_book->card = e_addressbook_model_get_card(model, row);
- card_and_book->widget = GTK_WIDGET(table);
- card_and_book->view = view;
- card_and_book->submenu = submenu;
-
- gtk_object_get(GTK_OBJECT(model),
- "book", &(card_and_book->book),
- NULL);
-
- gtk_object_ref(GTK_OBJECT(card_and_book->book));
- gtk_object_ref(GTK_OBJECT(card_and_book->view));
-
- popup = e_popup_menu_create (menu,
- e_addressbook_model_editable (model) ? 0 : POPUP_READONLY_MASK,
- 0, card_and_book);
-
- gtk_signal_connect (GTK_OBJECT (popup), "selection-done",
- GTK_SIGNAL_FUNC (free_popup_info), card_and_book);
- e_popup_menu (popup, event);
-
- return TRUE;
- } else
- return FALSE;
-}
-
-static void
-new_card (GtkWidget *widget, CardAndBook *card_and_book)
-{
- e_addressbook_show_contact_editor (card_and_book->book, e_card_new(""), TRUE, TRUE);
-}
-
-static void
-new_list (GtkWidget *widget, CardAndBook *card_and_book)
-{
- e_addressbook_show_contact_list_editor (card_and_book->book, e_card_new(""), TRUE, TRUE);
+ do_popup_menu(view, event);
+ return TRUE;
}
static gint
table_white_space_event(ETableScrolled *table, GdkEvent *event, EAddressbookView *view)
{
- if (event->type == GDK_BUTTON_PRESS && ((GdkEventButton *)event)->button == 3 &&
- E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) {
- EAddressbookModel *model = view->model;
- CardAndBook *card_and_book;
- GtkMenu *popup;
- EPopupMenu *submenu;
-
- EPopupMenu menu[] = {
- E_POPUP_ITEM (N_("New Contact..."), GTK_SIGNAL_FUNC(new_card), POPUP_READONLY_MASK),
- E_POPUP_ITEM (N_("New Contact List..."), GTK_SIGNAL_FUNC(new_list), POPUP_READONLY_MASK),
- E_POPUP_SEPARATOR,
- E_POPUP_ITEM (N_("Paste"), GTK_SIGNAL_FUNC (paste), POPUP_READONLY_MASK),
- E_POPUP_SEPARATOR,
- E_POPUP_SUBMENU (N_("Current View"), submenu = gal_view_instance_get_popup_menu (view->view_instance), 0),
- E_POPUP_TERMINATOR
- };
-
- card_and_book = g_new(CardAndBook, 1);
- card_and_book->card = NULL;
- card_and_book->widget = GTK_WIDGET(table);
- card_and_book->view = view;
- card_and_book->submenu = submenu;
- gtk_object_get(GTK_OBJECT(model),
- "book", &(card_and_book->book),
- NULL);
-
- gtk_object_ref(GTK_OBJECT(card_and_book->book));
- gtk_object_ref(GTK_OBJECT(card_and_book->view));
-
- popup = e_popup_menu_create (menu,
- e_addressbook_model_editable (model) ? 0 : POPUP_READONLY_MASK,
- 0, card_and_book);
-
- gtk_signal_connect (GTK_OBJECT (popup), "selection-done",
- GTK_SIGNAL_FUNC (free_popup_info), card_and_book);
- e_popup_menu (popup, event);
-
+ if (event->type == GDK_BUTTON_PRESS && ((GdkEventButton *)event)->button == 3) {
+ do_popup_menu(view, event);
return TRUE;
} else {
return FALSE;
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c
index 2f58db4882..1f6e1bd26b 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.c
+++ b/addressbook/gui/widgets/e-minicard-view-widget.c
@@ -36,9 +36,6 @@ static void e_minicard_view_widget_reflow (ECanvas *canvas);
static void e_minicard_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
static void e_minicard_view_widget_realize (GtkWidget *widget);
-static void selection_change (ESelectionModel *esm, EMinicardViewWidget *widget);
-static void column_width_changed (ESelectionModel *esm, double width, EMinicardViewWidget *widget);
-
static ECanvasClass *parent_class = NULL;
/* The arguments we take */
@@ -53,10 +50,11 @@ enum {
enum {
SELECTION_CHANGE,
COLUMN_WIDTH_CHANGED,
+ RIGHT_CLICK,
LAST_SIGNAL
};
-static guint e_minicard_view_widget_signals [LAST_SIGNAL] = {0, };
+static guint signals [LAST_SIGNAL] = {0, };
GtkType
e_minicard_view_widget_get_type (void)
@@ -105,7 +103,7 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
gtk_object_add_arg_type ("EMinicardViewWidget::column_width", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_COLUMN_WIDTH);
- e_minicard_view_widget_signals [SELECTION_CHANGE] =
+ signals [SELECTION_CHANGE] =
gtk_signal_new ("selection_change",
GTK_RUN_LAST,
object_class->type,
@@ -113,7 +111,7 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
- e_minicard_view_widget_signals [COLUMN_WIDTH_CHANGED] =
+ signals [COLUMN_WIDTH_CHANGED] =
gtk_signal_new ("column_width_changed",
GTK_RUN_LAST,
object_class->type,
@@ -121,7 +119,15 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
e_marshal_NONE__DOUBLE,
GTK_TYPE_NONE, 1, GTK_TYPE_DOUBLE);
- gtk_object_class_add_signals (object_class, e_minicard_view_widget_signals, LAST_SIGNAL);
+ signals [RIGHT_CLICK] =
+ gtk_signal_new ("right_click",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EMinicardViewWidgetClass, right_click),
+ gtk_marshal_INT__POINTER,
+ GTK_TYPE_INT, 1, GTK_TYPE_GDK_EVENT);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
object_class->set_arg = e_minicard_view_widget_set_arg;
object_class->get_arg = e_minicard_view_widget_get_arg;
@@ -134,6 +140,7 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
klass->selection_change = NULL;
klass->column_width_changed = NULL;
+ klass->right_click = NULL;
}
static void
@@ -246,6 +253,30 @@ e_minicard_view_widget_destroy (GtkObject *object)
}
static void
+selection_change (ESelectionModel *esm, EMinicardViewWidget *widget)
+{
+ gtk_signal_emit (GTK_OBJECT(widget),
+ signals [SELECTION_CHANGE]);
+}
+
+static void
+column_width_changed (ESelectionModel *esm, double width, EMinicardViewWidget *widget)
+{
+ gtk_signal_emit (GTK_OBJECT(widget),
+ signals [COLUMN_WIDTH_CHANGED], width);
+}
+
+static guint
+right_click (EMinicardView *view, GdkEvent *event, EMinicardViewWidget *widget)
+{
+ guint ret_val;
+ gtk_signal_emit (GTK_OBJECT(widget),
+ signals [RIGHT_CLICK],
+ event, &ret_val);
+ return ret_val;
+}
+
+static void
e_minicard_view_widget_realize (GtkWidget *widget)
{
EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget);
@@ -270,6 +301,9 @@ e_minicard_view_widget_realize (GtkWidget *widget)
gtk_signal_connect (GTK_OBJECT (view->emv),
"column_width_changed",
column_width_changed, view);
+ gtk_signal_connect (GTK_OBJECT (view->emv),
+ "right_click",
+ GTK_SIGNAL_FUNC (right_click), view);
if (GTK_WIDGET_CLASS(parent_class)->realize)
GTK_WIDGET_CLASS(parent_class)->realize (widget);
@@ -315,51 +349,20 @@ e_minicard_view_widget_reflow(ECanvas *canvas)
gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas), 0, 0, width - 1, GTK_WIDGET(canvas)->allocation.height - 1);
}
-static void
-selection_change (ESelectionModel *esm, EMinicardViewWidget *widget)
-{
- gtk_signal_emit (GTK_OBJECT(widget),
- e_minicard_view_widget_signals [SELECTION_CHANGE]);
-}
-
-static void
-column_width_changed (ESelectionModel *esm, double width, EMinicardViewWidget *widget)
-{
- gtk_signal_emit (GTK_OBJECT(widget),
- e_minicard_view_widget_signals [COLUMN_WIDTH_CHANGED], width);
-}
-
-gint
-e_minicard_view_widget_selected_count (EMinicardViewWidget *view)
-{
- if (!view->emv)
- return 0;
- else
- return e_selection_model_selected_count (E_REFLOW (view->emv)->selection);
-}
-
-void
-e_minicard_view_widget_remove_selection(EMinicardViewWidget *view,
- EBookCallback cb,
- gpointer closure)
-{
- if (view->emv)
- e_minicard_view_remove_selection(E_MINICARD_VIEW(view->emv), cb, closure);
-}
-
-void
-e_minicard_view_widget_jump_to_letter (EMinicardViewWidget *view,
- gunichar letter)
+ESelectionModel *
+e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view)
{
if (view->emv)
- e_minicard_view_jump_to_letter(E_MINICARD_VIEW(view->emv), letter);
+ return E_SELECTION_MODEL (E_REFLOW (view->emv)->selection);
+ else
+ return NULL;
}
-ESelectionModel *
-e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view)
+EMinicardView *
+e_minicard_view_widget_get_view (EMinicardViewWidget *view)
{
if (view->emv)
- return E_SELECTION_MODEL (E_REFLOW (view->emv)->selection);
+ return E_MINICARD_VIEW (view->emv);
else
return NULL;
}
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h
index 7df63c26e4..c55bb6e636 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.h
+++ b/addressbook/gui/widgets/e-minicard-view-widget.h
@@ -60,18 +60,16 @@ struct _EMinicardViewWidgetClass
ECanvasClass parent_class;
void (*selection_change) (EMinicardViewWidget *emvw);
void (*column_width_changed) (EMinicardViewWidget *emvw, double width);
+ guint (*right_click) (EMinicardViewWidget *emvw);
};
-GtkType e_minicard_view_widget_get_type (void);
-gint e_minicard_view_widget_selected_count (EMinicardViewWidget *view);
-void e_minicard_view_widget_remove_selection (EMinicardViewWidget *view,
- EBookCallback cb,
- gpointer closure);
-void e_minicard_view_widget_jump_to_letter (EMinicardViewWidget *view,
- gunichar letter);
-GtkWidget *e_minicard_view_widget_new (EAddressbookReflowAdapter *adapter);
-ESelectionModel *e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view);
+GtkType e_minicard_view_widget_get_type (void);
+GtkWidget *e_minicard_view_widget_new (EAddressbookReflowAdapter *adapter);
+
+/* Get parts of the view widget. */
+ESelectionModel *e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view);
+EMinicardView *e_minicard_view_widget_get_view (EMinicardViewWidget *view);
#ifdef __cplusplus
}
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 40cd4409be..8c758bb746 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -50,6 +50,14 @@ enum {
ARG_EDITABLE
};
+
+enum {
+ RIGHT_CLICK,
+ LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = {0, };
+
enum DndTargetType {
DND_TARGET_TYPE_VCARD_LIST,
};
@@ -89,32 +97,6 @@ e_minicard_view_drag_data_get(GtkWidget *widget,
view->drag_list = NULL;
}
-typedef struct {
- GList *list;
- EAddressbookReflowAdapter *adapter;
-} ModelAndList;
-
-static void
-add_to_list (int index, gpointer closure)
-{
- ModelAndList *mal = closure;
- mal->list = g_list_prepend (mal->list, e_addressbook_reflow_adapter_get_card (mal->adapter, index));
-}
-
-static GList *
-get_card_list (EAddressbookReflowAdapter *adapter, ESelectionModel *selection)
-{
- ModelAndList mal;
-
- mal.adapter = adapter;
- mal.list = NULL;
-
- e_selection_model_foreach (selection, add_to_list, &mal);
-
- mal.list = g_list_reverse (mal.list);
- return mal.list;
-}
-
static int
e_minicard_view_drag_begin (EAddressbookReflowAdapter *adapter, GdkEvent *event, EMinicardView *view)
{
@@ -122,7 +104,7 @@ e_minicard_view_drag_begin (EAddressbookReflowAdapter *adapter, GdkEvent *event,
GtkTargetList *target_list;
GdkDragAction actions = GDK_ACTION_MOVE | GDK_ACTION_COPY;
- view->drag_list = get_card_list (adapter, E_REFLOW (view)->selection);
+ view->drag_list = e_minicard_view_get_card_list (view);
g_print ("dragging %d card(s)\n", g_list_length (view->drag_list));
@@ -307,6 +289,15 @@ e_minicard_view_destroy (GtkObject *object)
GTK_OBJECT_CLASS(parent_class)->destroy (object);
}
+static guint
+e_minicard_view_right_click (EMinicardView *view, GdkEvent *event)
+{
+ guint ret_val = 0;
+ gtk_signal_emit (GTK_OBJECT (view), signals[RIGHT_CLICK],
+ event, &ret_val);
+ return ret_val;
+}
+
static gboolean
e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event)
{
@@ -331,7 +322,7 @@ e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event)
}
case GDK_BUTTON_PRESS:
if (event->button.button == 3) {
- return e_addressbook_reflow_adapter_base_right_click (view->adapter, event);
+ e_minicard_view_right_click (view, event);
}
break;
default:
@@ -369,9 +360,9 @@ e_minicard_view_selection_event (EReflow *reflow, GnomeCanvasItem *item, GdkEven
break;
case GDK_BUTTON_PRESS:
if (event->button.button == 3) {
- return_val = e_addressbook_reflow_adapter_right_click (view->adapter, event, reflow->selection);
+ return_val = e_minicard_view_right_click (view, event);
if (!return_val)
- e_selection_model_right_click_up(E_SELECTION_MODEL (view->selection));
+ e_selection_model_right_click_up(reflow->selection);
}
break;
default:
@@ -407,21 +398,6 @@ do_remove (int i, gpointer user_data)
gtk_object_unref (GTK_OBJECT (card));
}
-void
-e_minicard_view_remove_selection(EMinicardView *view,
- EBookCallback cb,
- gpointer closure)
-{
- ViewCbClosure viewcbclosure;
- viewcbclosure.view = view;
- viewcbclosure.cb = cb;
- viewcbclosure.closure = closure;
-
- e_selection_model_foreach (E_REFLOW (view)->selection,
- do_remove,
- &viewcbclosure);
-}
-
#if 0
static int
compare_to_utf_str (EMinicard *card, const char *utf_str)
@@ -448,22 +424,6 @@ compare_to_utf_str (EMinicard *card, const char *utf_str)
}
#endif
-
-
-void
-e_minicard_view_jump_to_letter (EMinicardView *view,
- gunichar letter)
-{
-#if 0
- char uft_str[6 + 1];
-
- utf_str [g_unichar_to_utf8 (letter, utf_str)] = '\0';
- e_reflow_sorted_jump (E_REFLOW_SORTED (view),
- (GCompareFunc) compare_to_utf_str,
- utf_str);
-#endif
-}
-
static void
e_minicard_view_class_init (EMinicardViewClass *klass)
{
@@ -486,6 +446,16 @@ e_minicard_view_class_init (EMinicardViewClass *klass)
gtk_object_add_arg_type ("EMinicardView::editable", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_EDITABLE);
+ signals [RIGHT_CLICK] =
+ gtk_signal_new ("right_click",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EMinicardViewClass, right_click),
+ gtk_marshal_INT__POINTER,
+ GTK_TYPE_INT, 1, GTK_TYPE_GDK_EVENT);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+
object_class->set_arg = e_minicard_view_set_arg;
object_class->get_arg = e_minicard_view_get_arg;
object_class->destroy = e_minicard_view_destroy;
@@ -528,3 +498,58 @@ e_minicard_view_get_type (void)
return reflow_type;
}
+
+void
+e_minicard_view_remove_selection(EMinicardView *view,
+ EBookCallback cb,
+ gpointer closure)
+{
+ ViewCbClosure viewcbclosure;
+ viewcbclosure.view = view;
+ viewcbclosure.cb = cb;
+ viewcbclosure.closure = closure;
+
+ e_selection_model_foreach (E_REFLOW (view)->selection,
+ do_remove,
+ &viewcbclosure);
+}
+
+void
+e_minicard_view_jump_to_letter (EMinicardView *view,
+ gunichar letter)
+{
+#if 0
+ char uft_str[6 + 1];
+
+ utf_str [g_unichar_to_utf8 (letter, utf_str)] = '\0';
+ e_reflow_sorted_jump (E_REFLOW_SORTED (view),
+ (GCompareFunc) compare_to_utf_str,
+ utf_str);
+#endif
+}
+
+typedef struct {
+ GList *list;
+ EAddressbookReflowAdapter *adapter;
+} ModelAndList;
+
+static void
+add_to_list (int index, gpointer closure)
+{
+ ModelAndList *mal = closure;
+ mal->list = g_list_prepend (mal->list, e_addressbook_reflow_adapter_get_card (mal->adapter, index));
+}
+
+GList *
+e_minicard_view_get_card_list (EMinicardView *view)
+{
+ ModelAndList mal;
+
+ mal.adapter = view->adapter;
+ mal.list = NULL;
+
+ e_selection_model_foreach (E_REFLOW (view)->selection, add_to_list, &mal);
+
+ mal.list = g_list_reverse (mal.list);
+ return mal.list;
+}
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
index e13dd08c05..1f23c62754 100644
--- a/addressbook/gui/widgets/e-minicard-view.h
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -70,8 +70,6 @@ struct _EMinicardView
/* item specific fields */
- ESelectionModelSimple *selection;
-
GList *drag_list;
guint canvas_drag_data_get_id;
@@ -82,14 +80,17 @@ struct _EMinicardView
struct _EMinicardViewClass
{
EReflowClass parent_class;
+
+ void (*right_click) (EMinicardView *view, GdkEvent *event);
};
-GtkType e_minicard_view_get_type (void);
-void e_minicard_view_remove_selection (EMinicardView *view,
- EBookCallback cb,
- gpointer closure);
-void e_minicard_view_jump_to_letter (EMinicardView *view,
- gunichar letter);
+GtkType e_minicard_view_get_type (void);
+void e_minicard_view_remove_selection (EMinicardView *view,
+ EBookCallback cb,
+ gpointer closure);
+void e_minicard_view_jump_to_letter (EMinicardView *view,
+ gunichar letter);
+GList *e_minicard_view_get_card_list (EMinicardView *view);
#ifdef __cplusplus
}