diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-06-09 01:12:12 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-06-09 01:12:12 +0800 |
commit | 227fab86efce103776af0364cbfd3f1959f9d269 (patch) | |
tree | 195524b2ea72d5b012ca9345a3f164000b09b61c /addressbook/gui/component | |
parent | 1396db5dc3fd395059d4bbe6cd0d8422110d0b81 (diff) | |
download | gsoc2013-evolution-227fab86efce103776af0364cbfd3f1959f9d269.tar gsoc2013-evolution-227fab86efce103776af0364cbfd3f1959f9d269.tar.gz gsoc2013-evolution-227fab86efce103776af0364cbfd3f1959f9d269.tar.bz2 gsoc2013-evolution-227fab86efce103776af0364cbfd3f1959f9d269.tar.lz gsoc2013-evolution-227fab86efce103776af0364cbfd3f1959f9d269.tar.xz gsoc2013-evolution-227fab86efce103776af0364cbfd3f1959f9d269.tar.zst gsoc2013-evolution-227fab86efce103776af0364cbfd3f1959f9d269.zip |
Now this derives from GtkObject. It follows the same strategy as the
2000-06-08 Federico Mena Quintero <federico@helixcode.com>
* contact-editor/e-contact-editor.h (EContactEditor): Now this
derives from GtkObject. It follows the same strategy as the
EventEditor in the calendar.
(EContactEditor): Added an is_new_card field so that we can know
whether to add() or commit() the card.
* contact-editor/e-contact-editor.c (e_contact_editor_get_type):
Derive from GtkObject.
(e_contact_editor_class_init): Likewise.
(e_contact_editor_class_init): Added an "is_new_card" argument.
(e_contact_editor_set_arg): Handle ARG_IS_NEW_CARD.
(e_contact_editor_get_arg): Likewise.
(e_contact_editor_new): Take in an is_new_arg argument and set it
on the object.
(e_contact_editor_init): Load the app widget into the app field of
the EContactEditor structure. Create its UIHandler as well.
(e_contact_editor_class_init): New "add_card", "commit_card", and
"editor_closed" signals.
* contact-editor/test-editor.c (main): Modified for the new API.
(editor_closed_cb): Tweaked for the new API.
Since this test program does not use Bonobo, it doesn't work,
though.
* gui/component/addressbook.c (new_contact_cb): Use the new
contact editor API.
(table_double_click): Ditto.
* gui/minicard/e-minicard-view.c (e_minicard_view_event): Use the
new contact editor API.
* gui/minicard/e-minicard.c (e_minicard_event): Use the new
contact editor API.
svn path=/trunk/; revision=3479
Diffstat (limited to 'addressbook/gui/component')
-rw-r--r-- | addressbook/gui/component/addressbook.c | 114 |
1 files changed, 46 insertions, 68 deletions
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index f98ec6eb51..3026aa4811 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -102,59 +102,62 @@ card_modified_cb (EBook* book, EBookStatus status, g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__); } +/* Callback for the add_card signal from the contact editor */ +static void +add_card_cb (EContactEditor *ce, ECard *card, gpointer data) +{ + EBook *book; + + book = E_BOOK (data); + e_book_add_card (book, card, card_added_cb, NULL); +} + +/* Callback for the commit_card signal from the contact editor */ +static void +commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) +{ + EBook *book; + + book = E_BOOK (data); + e_book_commit_card (book, card, card_modified_cb, NULL); +} + +/* Callback used when the contact editor is closed */ +static void +editor_closed_cb (EContactEditor *ce, gpointer data) +{ + gtk_object_unref (GTK_OBJECT (ce)); +} + static void new_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) { - gint result; ECard *card; - GtkWidget* contact_editor; EBook *book; + EContactEditor *ce; AddressbookView *view = (AddressbookView *) user_data; GtkObject *object; - GtkWidget* dlg = gnome_dialog_new ("Contact Editor", "Save", GNOME_STOCK_BUTTON_CANCEL, NULL); card = e_card_new(""); - contact_editor = e_contact_editor_new(card); - gtk_object_sink(GTK_OBJECT(card)); - - gtk_window_set_policy(GTK_WINDOW(dlg), FALSE, TRUE, FALSE); if (view->view) object = GTK_OBJECT(view->view); else object = GTK_OBJECT(view->model); - gtk_object_get(object, "book", &book, NULL); - + gtk_object_get(object, "book", &book, NULL); g_assert (E_IS_BOOK (book)); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), - contact_editor, TRUE, TRUE, 0); - - gtk_widget_show (contact_editor); - gtk_widget_show (dlg); + ce = e_contact_editor_new (card, TRUE); - gnome_dialog_close_hides (GNOME_DIALOG (dlg), TRUE); - result = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); + gtk_signal_connect (GTK_OBJECT (ce), "add_card", + GTK_SIGNAL_FUNC (add_card_cb), book); + gtk_signal_connect (GTK_OBJECT (ce), "commit_card", + GTK_SIGNAL_FUNC (commit_card_cb), book); + gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", + GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - /* If the user clicks "okay"...*/ - if (result == 0) { - ECard *card; - g_assert (contact_editor); - g_assert (GTK_IS_OBJECT (contact_editor)); - gtk_object_get(GTK_OBJECT(contact_editor), - "card", &card, - NULL); - - /* Add the card in the contact editor to our ebook */ - e_book_add_card ( - book, - card, - card_added_cb, - NULL); - } - + gtk_object_sink(GTK_OBJECT(card)); } static void @@ -813,15 +816,8 @@ static void table_double_click(ETable *table, gint row, AddressbookView *view) { ECard *card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(view->model), row); - gint result; - GtkWidget* contact_editor; EBook *book; - GtkWidget* dlg = gnome_dialog_new ("Contact Editor", "Save", GNOME_STOCK_BUTTON_CANCEL, NULL); - - contact_editor = e_contact_editor_new(card); - gtk_object_unref(GTK_OBJECT(card)); - - gtk_window_set_policy(GTK_WINDOW(dlg), FALSE, TRUE, FALSE); + EContactEditor *ce; gtk_object_get(GTK_OBJECT(view->model), "book", &book, @@ -829,34 +825,16 @@ table_double_click(ETable *table, gint row, AddressbookView *view) g_assert (E_IS_BOOK (book)); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), - contact_editor, TRUE, TRUE, 0); - - gtk_widget_show (contact_editor); - gtk_widget_show (dlg); + ce = e_contact_editor_new (card, FALSE); - gnome_dialog_close_hides (GNOME_DIALOG (dlg), TRUE); - result = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); + gtk_signal_connect (GTK_OBJECT (ce), "add_card", + GTK_SIGNAL_FUNC (add_card_cb), book); + gtk_signal_connect (GTK_OBJECT (ce), "commit_card", + GTK_SIGNAL_FUNC (commit_card_cb), book); + gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", + GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - /* If the user clicks "okay"...*/ - if (result == 0) { - ECard *card; - g_assert (contact_editor); - g_assert (GTK_IS_OBJECT (contact_editor)); - gtk_object_get(GTK_OBJECT(contact_editor), - "card", &card, - NULL); - - /* Add the card in the contact editor to our ebook */ - e_book_commit_card ( - book, - card, - card_modified_cb, - NULL); - } - - gnome_dialog_close(GNOME_DIALOG (dlg)); + gtk_object_unref(GTK_OBJECT(card)); } static void |