From 227fab86efce103776af0364cbfd3f1959f9d269 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Thu, 8 Jun 2000 17:12:12 +0000 Subject: Now this derives from GtkObject. It follows the same strategy as the 2000-06-08 Federico Mena Quintero * 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 --- addressbook/contact-editor/test-editor.c | 74 +++++++++++++------------------- 1 file changed, 29 insertions(+), 45 deletions(-) (limited to 'addressbook/contact-editor/test-editor.c') diff --git a/addressbook/contact-editor/test-editor.c b/addressbook/contact-editor/test-editor.c index 5b48c1a92f..80db2fe848 100644 --- a/addressbook/contact-editor/test-editor.c +++ b/addressbook/contact-editor/test-editor.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* +/* * test-editor.c * Copyright (C) 2000 Helix Code, Inc. * Author: Chris Lahey @@ -75,21 +75,23 @@ read_file (char *name) return g_strdup (buff); } -/* This is a horrible thing to do, but it is just a test. */ -GtkWidget *editor; - -static void destroy_callback(GtkWidget *app, gpointer data) +/* Callback used when a contact editor is closed */ +static void +editor_closed_cb (EContactEditor *ce, gpointer data) { static int count = 2; - count --; - if ( count <= 0 ) - exit(0); + + count--; + gtk_object_unref (GTK_OBJECT (ce)); + + if (count == 0) + exit (0); } #if 0 static void about_callback( GtkWidget *widget, gpointer data ) { - + const gchar *authors[] = { "Christopher James Lahey ", @@ -102,57 +104,39 @@ static void about_callback( GtkWidget *widget, gpointer data ) authors, _( "This should test the contact editor canvas item" ), NULL); - gtk_widget_show (about); + gtk_widget_show (about); } #endif int main( int argc, char *argv[] ) { char *cardstr; - GtkWidget *app; - + EContactEditor *ce; + /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); textdomain (PACKAGE);*/ - + gnome_init( "Contact Editor Test", VERSION, argc, argv); - + glade_gnome_init (); - - app = gnome_app_new("Contact Editor Test", NULL); - + cardstr = NULL; if (argc == 2) cardstr = read_file (argv [1]); - + if (cardstr == NULL) cardstr = TEST_VCARD; - - editor = e_contact_editor_new(e_card_new(cardstr)); - - gnome_app_set_contents( GNOME_APP( app ), editor ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - app = gnome_app_new("Contact Editor Test", NULL); - - editor = e_contact_editor_new(e_card_new(cardstr)); - - gnome_app_set_contents( GNOME_APP( app ), editor ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - + + ce = e_contact_editor_new (e_card_new (cardstr), TRUE); + gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", + GTK_SIGNAL_FUNC (editor_closed_cb), NULL); + + ce = e_contact_editor_new (e_card_new (cardstr), TRUE); + gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", + GTK_SIGNAL_FUNC (editor_closed_cb), NULL); + + gtk_main(); + /* Not reached. */ return 0; } -- cgit v1.2.3