diff options
Diffstat (limited to 'addressbook/gui/widgets')
34 files changed, 0 insertions, 8164 deletions
diff --git a/addressbook/gui/widgets/.cvsignore b/addressbook/gui/widgets/.cvsignore deleted file mode 100644 index 472fd2593f..0000000000 --- a/addressbook/gui/widgets/.cvsignore +++ /dev/null @@ -1,12 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -minicard-label-test -minicard-test -minicard-view-test -minicard-widget-test -reflow-test diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am deleted file mode 100644 index f031b284e5..0000000000 --- a/addressbook/gui/widgets/Makefile.am +++ /dev/null @@ -1,140 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"e-minicard\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_IMAGESDIR=\""$(datadir)"/images/evolution\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend/ebook \ - -I$(top_srcdir)/addressbook/gui/contact-editor \ - -I$(top_srcdir)/addressbook/gui/merging \ - -I$(top_srcdir)/widgets/misc \ - -I$(top_builddir)/shell \ - $(BONOBO_GNOME_CFLAGS) \ - $(EXTRA_GNOME_CFLAGS) - -noinst_LIBRARIES = \ - libeminicard.a - -libeminicard_a_SOURCES = \ - e-addressbook-reflow-adapter.c \ - e-addressbook-reflow-adapter.h \ - e-addressbook-table-adapter.c \ - e-addressbook-table-adapter.h \ - e-addressbook-model.c \ - e-addressbook-model.h \ - e-addressbook-util.c \ - e-addressbook-util.h \ - e-addressbook-view.c \ - e-addressbook-view.h \ - e-minicard-control.c \ - e-minicard-control.h \ - e-minicard-label.c \ - e-minicard-label.h \ - e-minicard-view-widget.c \ - e-minicard-view-widget.h \ - e-minicard-view.c \ - e-minicard-view.h \ - e-minicard-widget.c \ - e-minicard-widget.h \ - e-minicard.c \ - e-minicard.h \ - gal-view-factory-minicard.c \ - gal-view-factory-minicard.h \ - gal-view-minicard.c \ - gal-view-minicard.h - -#noinst_PROGRAMS = \ -# minicard-widget-test \ -# minicard-label-test \ -# minicard-test -## reflow-test -## minicard-view-test -# -#minicard_label_test_SOURCES = \ -# test-minicard-label.c -# -#minicard_label_test_LDADD = \ -# libeminicard.a \ -# $(EXTRA_GNOME_LIBS) \ -# $(BONOBO_GNOME_LIBS) \ -# $(top_builddir)/e-util/libeutil.la -# -#minicard_test_SOURCES = \ -# test-minicard.c -# -#minicard_test_LDADD = \ -# libeminicard.a \ -# $(top_builddir)/addressbook/backend/ebook/libebook.la \ -# $(top_builddir)/e-util/libeutil.la \ -# $(top_builddir)/libversit/libversit.la \ -# $(top_builddir)/e-util/ename/libename.la \ -# $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ -# $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ -# $(top_builddir)/addressbook/printing/libecontactprint.a \ -# $(top_builddir)/addressbook/gui/merging/libecardmerging.a \ -# $(top_builddir)/widgets/misc/libemiscwidgets.a \ -# $(top_builddir)/addressbook/gui/component/select-names/libeselectnames.la \ -# $(top_builddir)/e-util/libeutil.la \ -# $(EXTRA_GNOME_LIBS) \ -# $(BONOBO_GNOME_LIBS) \ -# $(GNOME_PRINT_LIBS) \ -# libeminicard.a -# -#reflow_test_SOURCES = \ -# test-reflow.c -# -#reflow_test_LDADD = \ -# libeminicard.a \ -# $(top_builddir)/addressbook/backend/ebook/libebook.la \ -# $(top_builddir)/e-util/libeutil.la \ -# $(top_builddir)/libversit/libversit.la \ -# $(top_builddir)/e-util/ename/libename.la \ -# $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ -# $(top_builddir)/addressbook/printing/libecontactprint.a \ -# $(top_builddir)/widgets/misc/libemiscwidgets.a \ -# $(top_builddir)/e-util/libeutil.la \ -# $(EXTRA_GNOME_LIBS) \ -# $(BONOBO_GNOME_LIBS) \ -# $(GNOME_PRINT_LIBS) - -#minicard_view_test_SOURCES = \ -# test-minicard-view.c - -#minicard_view_test_LDADD = \ -# $(EXTRA_GNOME_LIBS) \ -# $(BONOBO_GNOME_LIBS) \ -# libeminicard.a \ -# $(top_builddir)/addressbook/backend/ebook/libebook.la \ -# $(top_builddir)/e-util/libeutil.la \ -# $(top_builddir)/libversit/libversit.la \ -# $(top_builddir)/addressbook/ename/libename.la \ -# $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ -# $(top_builddir)/addressbook/printing/libecontactprint.a \ -# $(top_builddir)/widgets/misc/libemiscwidgets.a \ -# $(top_builddir)/e-util/libeutil.la -# -#minicard_widget_test_SOURCES = \ -# e-minicard-widget-test.c -# -#minicard_widget_test_LDADD = \ -# libeminicard.a \ -# $(top_builddir)/addressbook/backend/ebook/libebook.la \ -# $(top_builddir)/e-util/libeutil.la \ -# $(top_builddir)/libversit/libversit.la \ -# $(top_builddir)/e-util/ename/libename.la \ -# $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ -# $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ -# $(top_builddir)/addressbook/gui/component/select-names/libeselectnames.la \ -# $(top_builddir)/addressbook/printing/libecontactprint.a \ -# $(top_builddir)/widgets/misc/libemiscwidgets.a \ -# $(top_builddir)/e-util/libeutil.la \ -# $(top_builddir)/addressbook/gui/merging/libecardmerging.a \ -# $(EXTRA_GNOME_LIBS) \ -# $(BONOBO_GNOME_LIBS) \ -# $(GNOME_PRINT_LIBS) - -gladedir = $(datadir)/evolution/glade -glade_DATA = alphabet.glade - -EXTRA_DIST = \ - $(glade_DATA) diff --git a/addressbook/gui/widgets/alphabet.glade b/addressbook/gui/widgets/alphabet.glade deleted file mode 100644 index dc6ee33966..0000000000 --- a/addressbook/gui/widgets/alphabet.glade +++ /dev/null @@ -1,355 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>alphabet</name> - <program_name>alphabet</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>True</use_widget_names> - <output_main_file>False</output_main_file> - <output_support_files>False</output_support_files> - <output_build_files>False</output_build_files> - <gnome_help_support>True</gnome_help_support> -</project> - -<widget> - <class>GtkWindow</class> - <name>window2</name> - <visible>False</visible> - <title>window2</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow-top</name> - <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - - <widget> - <class>GtkViewport</class> - <name>viewport1</name> - <border_width>4</border_width> - <shadow_type>GTK_SHADOW_NONE</shadow_type> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <width>27</width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkButton</class> - <name>button-1</name> - <label>123</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-a</name> - <label>a</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-b</name> - <label>b</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-c</name> - <label>c</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-d</name> - <label>d</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-e</name> - <label>e</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-f</name> - <label>f</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-g</name> - <label>g</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-h</name> - <label>h</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-i</name> - <label>i</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-j</name> - <label>j</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-k</name> - <label>k</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-l</name> - <label>l</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-m</name> - <label>m</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-n</name> - <label>n</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-o</name> - <label>o</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-p</name> - <label>p</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-q</name> - <label>q</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-r</name> - <label>r</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-s</name> - <label>s</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-t</name> - <label>t</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-u</name> - <label>u</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-v</name> - <label>v</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-w</name> - <can_focus>True</can_focus> - <label>w</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-x</name> - <label>x</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-y</name> - <label>y</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-z</name> - <label>z</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c deleted file mode 100644 index a44c066d4f..0000000000 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ /dev/null @@ -1,522 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Christopher James Lahey <clahey@ximian.com> - * - * (C) 1999 Ximian, Inc. - */ - -#include <config.h> -#include "e-addressbook-model.h" -#include <gnome-xml/tree.h> -#include <gnome-xml/parser.h> -#include <gnome-xml/xmlmemory.h> -#include <gnome.h> - -#define PARENT_TYPE gtk_object_get_type() -GtkObjectClass *parent_class; - -/* - * EAddressbookModel callbacks - * These are the callbacks that define the behavior of our custom model. - */ -static void e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_addressbook_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - - -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY, - ARG_EDITABLE, -}; - -enum { - WRITABLE_STATUS, - STATUS_MESSAGE, - CARD_ADDED, - CARD_REMOVED, - CARD_CHANGED, - MODEL_CHANGED, - STOP_STATE_CHANGED, - LAST_SIGNAL -}; - -#define COLS (E_CARD_SIMPLE_FIELD_LAST) - -static guint e_addressbook_model_signals [LAST_SIGNAL] = {0, }; - -static void -remove_book_view(EAddressbookModel *model) -{ - if (model->book_view && model->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->create_card_id); - if (model->book_view && model->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->remove_card_id); - if (model->book_view && model->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->modify_card_id); - if (model->book_view && model->status_message_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->status_message_id); - if (model->book_view && model->sequence_complete_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->sequence_complete_id); - - model->create_card_id = 0; - model->remove_card_id = 0; - model->modify_card_id = 0; - model->status_message_id = 0; - model->sequence_complete_id = 0; - - model->search_in_progress = FALSE; - - if (model->book_view) - gtk_object_unref(GTK_OBJECT(model->book_view)); - - model->book_view = NULL; -} - -static void -addressbook_destroy(GtkObject *object) -{ - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object); - int i; - - if (model->get_view_idle) - g_source_remove(model->get_view_idle); - - remove_book_view(model); - - if (model->book) { - if (model->writable_status_id) - gtk_signal_disconnect(GTK_OBJECT (model->book), - model->writable_status_id); - - model->writable_status_id = 0; - - gtk_object_unref(GTK_OBJECT(model->book)); - } - - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - g_free(model->data); -} - -static void -create_card(EBookView *book_view, - const GList *cards, - EAddressbookModel *model) -{ - int old_count = model->data_count; - int length = g_list_length ((GList *)cards); - - if (model->data_count + length > model->allocated_count) { - while (model->data_count + length > model->allocated_count) - model->allocated_count += 256; - model->data = g_renew(ECard *, model->data, model->allocated_count); - } - - for ( ; cards; cards = cards->next) { - model->data[model->data_count++] = cards->data; - gtk_object_ref (cards->data); - } - - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [CARD_ADDED], - old_count, model->data_count - old_count); -} - -static void -remove_card(EBookView *book_view, - const char *id, - EAddressbookModel *model) -{ - int i; - - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_get_id(model->data[i]), id) ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *)); - model->data_count--; - - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [CARD_REMOVED], - i); - break; - } - } -} - -static void -modify_card(EBookView *book_view, - const GList *cards, - EAddressbookModel *model) -{ - for ( ; cards; cards = cards->next) { - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_get_id(model->data[i]), e_card_get_id(E_CARD(cards->data))) ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - model->data[i] = e_card_duplicate(E_CARD(cards->data)); - gtk_object_ref(GTK_OBJECT(model->data[i])); - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [CARD_CHANGED], - i); - break; - } - } - } -} - -static void -status_message (EBookView *book_view, - char* status, - EAddressbookModel *model) -{ - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [STATUS_MESSAGE], - status); -} - -static void -sequence_complete (EBookView *book_view, - EAddressbookModel *model) -{ - model->search_in_progress = FALSE; - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [STOP_STATE_CHANGED]); -} - -static void -writable_status (EBook *book, - gboolean writable, - EAddressbookModel *model) -{ - if (!model->editable_set) { - model->editable = writable; - - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [WRITABLE_STATUS], - writable); - } -} - -static void -e_addressbook_model_class_init (GtkObjectClass *object_class) -{ - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = addressbook_destroy; - object_class->set_arg = e_addressbook_model_set_arg; - object_class->get_arg = e_addressbook_model_get_arg; - - gtk_object_add_arg_type ("EAddressbookModel::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EAddressbookModel::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - gtk_object_add_arg_type ("EAddressbookModel::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - - e_addressbook_model_signals [WRITABLE_STATUS] = - gtk_signal_new ("writable_status", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookModelClass, writable_status), - gtk_marshal_NONE__BOOL, - GTK_TYPE_NONE, 1, GTK_TYPE_BOOL); - - e_addressbook_model_signals [STATUS_MESSAGE] = - gtk_signal_new ("status_message", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookModelClass, status_message), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); - - e_addressbook_model_signals [CARD_ADDED] = - gtk_signal_new ("card_added", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookModelClass, card_added), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); - - e_addressbook_model_signals [CARD_REMOVED] = - gtk_signal_new ("card_removed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookModelClass, card_removed), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - e_addressbook_model_signals [CARD_CHANGED] = - gtk_signal_new ("card_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookModelClass, card_changed), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - e_addressbook_model_signals [MODEL_CHANGED] = - gtk_signal_new ("model_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookModelClass, model_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - e_addressbook_model_signals [STOP_STATE_CHANGED] = - gtk_signal_new ("stop_state_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookModelClass, stop_state_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_addressbook_model_signals, LAST_SIGNAL); -} - -static void -e_addressbook_model_init (GtkObject *object) -{ - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object); - model->book = NULL; - model->query = g_strdup("(contains \"x-evolution-any-field\" \"\")"); - model->book_view = NULL; - model->get_view_idle = 0; - model->create_card_id = 0; - model->remove_card_id = 0; - model->modify_card_id = 0; - model->status_message_id = 0; - model->writable_status_id = 0; - model->sequence_complete_id = 0; - model->data = NULL; - model->data_count = 0; - model->allocated_count = 0; - model->search_in_progress = FALSE; - model->editable = FALSE; - model->editable_set = FALSE; - model->first_get_view = TRUE; -} - -static void -book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure) -{ - EAddressbookModel *model = closure; - int i; - remove_book_view(model); - model->book_view = book_view; - if (model->book_view) - gtk_object_ref(GTK_OBJECT(model->book_view)); - model->create_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_added", - GTK_SIGNAL_FUNC(create_card), - model); - model->remove_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_removed", - GTK_SIGNAL_FUNC(remove_card), - model); - model->modify_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_changed", - GTK_SIGNAL_FUNC(modify_card), - model); - model->status_message_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "status_message", - GTK_SIGNAL_FUNC(status_message), - model); - model->sequence_complete_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "sequence_complete", - GTK_SIGNAL_FUNC(sequence_complete), - model); - - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - - g_free(model->data); - model->data = NULL; - model->data_count = 0; - model->allocated_count = 0; - model->search_in_progress = TRUE; - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [MODEL_CHANGED]); - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [STOP_STATE_CHANGED]); -} - -static gboolean -get_view (EAddressbookModel *model) -{ - if (model->book && model->query) { - if (model->first_get_view) { - char *capabilities; - capabilities = e_book_get_static_capabilities (model->book); - if (capabilities && strstr (capabilities, "local")) { - e_book_get_book_view (model->book, model->query, book_view_loaded, model); - } - model->first_get_view = FALSE; - } - else - e_book_get_book_view (model->book, model->query, book_view_loaded, model); - } - - model->get_view_idle = 0; - return FALSE; -} - -ECard * -e_addressbook_model_get_card(EAddressbookModel *model, - int row) -{ - if (model->data && row < model->data_count) { - ECard *card; - card = e_card_duplicate (model->data[row]); - gtk_object_ref (GTK_OBJECT (card)); - return card; - } - return NULL; -} - -static void -e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EAddressbookModel *model; - - model = E_ADDRESSBOOK_MODEL (o); - - switch (arg_id){ - case ARG_BOOK: - if (model->book) { - if (model->writable_status_id) - gtk_signal_disconnect(GTK_OBJECT (model->book), - model->writable_status_id); - - model->writable_status_id = 0; - - gtk_object_unref(GTK_OBJECT(model->book)); - } - model->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - if (model->book) { - gtk_object_ref(GTK_OBJECT(model->book)); - if (model->get_view_idle == 0) - model->get_view_idle = g_idle_add((GSourceFunc)get_view, model); - gtk_signal_connect (GTK_OBJECT(model->book), - "writable_status", - writable_status, model); - } - break; - case ARG_QUERY: - if (model->query) - g_free(model->query); - model->query = g_strdup(GTK_VALUE_STRING (*arg)); - if (model->get_view_idle == 0) - model->get_view_idle = g_idle_add((GSourceFunc)get_view, model); - break; - case ARG_EDITABLE: - model->editable = GTK_VALUE_BOOL (*arg); - model->editable_set = TRUE; - break; - } -} - -static void -e_addressbook_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EAddressbookModel *e_addressbook_model; - - e_addressbook_model = E_ADDRESSBOOK_MODEL (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_addressbook_model->book); - break; - case ARG_QUERY: - GTK_VALUE_STRING (*arg) = g_strdup(e_addressbook_model->query); - break; - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = e_addressbook_model->editable; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -GtkType -e_addressbook_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "EAddressbookModel", - sizeof (EAddressbookModel), - sizeof (EAddressbookModelClass), - (GtkClassInitFunc) e_addressbook_model_class_init, - (GtkObjectInitFunc) e_addressbook_model_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -EAddressbookModel* -e_addressbook_model_new (void) -{ - EAddressbookModel *et; - - et = gtk_type_new (e_addressbook_model_get_type ()); - - return et; -} - -void e_addressbook_model_stop (EAddressbookModel *model) -{ - remove_book_view(model); - model->search_in_progress = FALSE; - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [STOP_STATE_CHANGED]); - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [STATUS_MESSAGE], - "Search Interrupted."); -} - -gboolean -e_addressbook_model_can_stop (EAddressbookModel *model) -{ - return model->search_in_progress; -} - -int -e_addressbook_model_card_count (EAddressbookModel *model) -{ - return model->data_count; -} - -ECard * -e_addressbook_model_card_at (EAddressbookModel *model, int index) -{ - return model->data[index]; -} - -gboolean -e_addressbook_model_editable (EAddressbookModel *model) -{ - return model->editable; -} - -EBook * -e_addressbook_model_get_ebook (EAddressbookModel *model) -{ - return model->book; -} diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h deleted file mode 100644 index a0956d7003..0000000000 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_ADDRESSBOOK_MODEL_H_ -#define _E_ADDRESSBOOK_MODEL_H_ - -#include "addressbook/backend/ebook/e-book.h" -#include "addressbook/backend/ebook/e-book-view.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#define E_ADDRESSBOOK_MODEL_TYPE (e_addressbook_model_get_type ()) -#define E_ADDRESSBOOK_MODEL(o) (GTK_CHECK_CAST ((o), E_ADDRESSBOOK_MODEL_TYPE, EAddressbookModel)) -#define E_ADDRESSBOOK_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_ADDRESSBOOK_MODEL_TYPE, EAddressbookModelClass)) -#define E_IS_ADDRESSBOOK_MODEL(o) (GTK_CHECK_TYPE ((o), E_ADDRESSBOOK_MODEL_TYPE)) -#define E_IS_ADDRESSBOOK_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_ADDRESSBOOK_MODEL_TYPE)) - -typedef struct _EAddressbookModel EAddressbookModel; -typedef struct _EAddressbookModelClass EAddressbookModelClass; - -struct _EAddressbookModel { - GtkObject parent; - - /* item specific fields */ - EBook *book; - char *query; - EBookView *book_view; - - int get_view_idle; - - ECard **data; - int data_count; - int allocated_count; - - int create_card_id, remove_card_id, modify_card_id, status_message_id, writable_status_id, sequence_complete_id; - - guint search_in_progress : 1; - guint editable : 1; - guint editable_set : 1; - guint first_get_view : 1; -}; - - -struct _EAddressbookModelClass { - GtkObjectClass parent_class; - - /* - * Signals - */ - void (*writable_status) (EAddressbookModel *model, gboolean writable); - void (*status_message) (EAddressbookModel *model, const gchar *message); - void (*card_added) (EAddressbookModel *model, gint index, gint count); - void (*card_removed) (EAddressbookModel *model, gint index); - void (*card_changed) (EAddressbookModel *model, gint index); - void (*model_changed) (EAddressbookModel *model); - void (*stop_state_changed) (EAddressbookModel *model); -}; - - -GtkType e_addressbook_model_get_type (void); -EAddressbookModel *e_addressbook_model_new (void); - -/* Returns object with ref count of 1. */ -ECard *e_addressbook_model_get_card (EAddressbookModel *model, - int row); -EBook *e_addressbook_model_get_ebook (EAddressbookModel *model); - -void e_addressbook_model_stop (EAddressbookModel *model); -gboolean e_addressbook_model_can_stop (EAddressbookModel *model); - -int e_addressbook_model_card_count (EAddressbookModel *model); -ECard *e_addressbook_model_card_at (EAddressbookModel *model, int index); -gboolean e_addressbook_model_editable (EAddressbookModel *model); - -#endif /* _E_ADDRESSBOOK_MODEL_H_ */ diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c deleted file mode 100644 index 04f17fd074..0000000000 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c +++ /dev/null @@ -1,610 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - - -#include <config.h> - -#include "e-addressbook-reflow-adapter.h" -#include "e-addressbook-model.h" - -#include <gal/util/e-i18n.h> - -#include "e-minicard.h" -#include <gal/widgets/e-unicode.h> -#include <gal/widgets/e-font.h> -#include <gal/widgets/e-popup-menu.h> -#include "e-contact-save-as.h" -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/printing/e-contact-print-envelope.h" - -struct _EAddressbookReflowAdapterPrivate { - EAddressbookModel *model; - - int create_card_id, remove_card_id, modify_card_id, model_changed_id; -}; - -#define PARENT_TYPE e_reflow_model_get_type() -EReflowModel *parent_class; - -#define d(x) - -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY, - ARG_EDITABLE, -}; - -enum { - DRAG_BEGIN, - LAST_SIGNAL -}; - -static guint e_addressbook_reflow_adapter_signals [LAST_SIGNAL] = {0, }; - -static void -unlink_model(EAddressbookReflowAdapter *adapter) -{ - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - gtk_signal_disconnect(GTK_OBJECT (priv->model), - priv->create_card_id); - gtk_signal_disconnect(GTK_OBJECT (priv->model), - priv->remove_card_id); - gtk_signal_disconnect(GTK_OBJECT (priv->model), - priv->modify_card_id); - - priv->create_card_id = 0; - priv->remove_card_id = 0; - priv->modify_card_id = 0; - - gtk_object_unref(GTK_OBJECT(priv->model)); - - priv->model = NULL; -} - - -static int -count_lines (const gchar *text) -{ - int num_lines = 1; - gunichar unival; - - for (text = e_unicode_get_utf8 (text, &unival); (unival && text); text = e_unicode_get_utf8 (text, &unival)) { - if (unival == '\n') { - num_lines ++; - } - } - - return num_lines; -} - -static int -text_height (GnomeCanvas *canvas, const gchar *text) -{ - EFont *font = e_font_from_gdk_font (((GtkWidget *) canvas)->style->font); - gint height = e_font_height (font) * count_lines (text) / canvas->pixels_per_unit; - - e_font_unref (font); - return height; -} - -typedef struct { - EAddressbookReflowAdapter *adapter; - ESelectionModel *selection; -} ModelAndSelection; - -static void -model_and_selection_free (ModelAndSelection *mns) -{ - gtk_object_unref(GTK_OBJECT(mns->adapter)); - gtk_object_unref(GTK_OBJECT(mns->selection)); - 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)); - } - 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); - g_list_free (list); - model_and_selection_free (mns); -} - -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); - g_list_free (list); - model_and_selection_free (mns); -} - -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); - g_list_free (list); - model_and_selection_free (mns); -} - -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)); - g_list_free (list); - model_and_selection_free (mns); -} - -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)); - g_list_free (list); - model_and_selection_free (mns); -} - -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 -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)); - } - } - } - - g_list_free (list); - model_and_selection_free (mns); -} - -gint -e_addressbook_reflow_adapter_right_click (EAddressbookReflowAdapter *adapter, GdkEvent *event, ESelectionModel *selection) -{ - ModelAndSelection *mns = g_new(ModelAndSelection, 1); - EPopupMenu menu[] = { {N_("Save as VCard"), NULL, GTK_SIGNAL_FUNC(save_as), NULL, 0}, - {N_("Send contact to other"), NULL, GTK_SIGNAL_FUNC(send_as), NULL, 0}, - {N_("Send message to contact"), NULL, GTK_SIGNAL_FUNC(send_to), NULL, 0}, - {N_("Print"), NULL, GTK_SIGNAL_FUNC(print), NULL, 0}, - {N_("Print Envelope"), NULL, GTK_SIGNAL_FUNC(print_envelope), NULL, 0}, - {N_("Delete"), NULL, GTK_SIGNAL_FUNC(delete), NULL, 0}, - {NULL, NULL, NULL, 0}}; - - mns->adapter = adapter; - mns->selection = selection; - gtk_object_ref(GTK_OBJECT(mns->adapter)); - gtk_object_ref(GTK_OBJECT(mns->selection)); - e_popup_menu_run (menu, event, 0, 0, mns); - return TRUE; -} - -static void -addressbook_finalize(GtkObject *object) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object); - - unlink_model (adapter); -} - -static void -addressbook_set_width (EReflowModel *erm, int width) -{ -} - -/* This function returns the number of items in our EReflowModel. */ -static int -addressbook_count (EReflowModel *erm) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - return e_addressbook_model_card_count (priv->model); -} - -/* This function returns the number of items in our EReflowModel. */ -static int -addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - /* FIXME */ - ECardSimpleField field; - int count = 0; - int height; - char *string; - ECardSimple *simple = e_card_simple_new (e_addressbook_model_card_at (priv->model, i)); - - string = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FILE_AS); - height = text_height (GNOME_CANVAS_ITEM (parent)->canvas, string ? string : "") + 10.0; - g_free(string); - - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST - 2 && count < 5; field++) { - - if (field == E_CARD_SIMPLE_FIELD_FAMILY_NAME) - continue; - - string = e_card_simple_get(simple, field); - if (string && *string) { - int this_height; - int field_text_height; - - this_height = text_height (GNOME_CANVAS_ITEM (parent)->canvas, e_card_simple_get_name(simple, field)); - - field_text_height = text_height (GNOME_CANVAS_ITEM (parent)->canvas, string); - if (this_height < field_text_height) - this_height = field_text_height; - - this_height += 3; - - height += this_height; - count ++; - } - g_free (string); - } - height += 2; - - gtk_object_unref (GTK_OBJECT (simple)); - - return height; -} - -static int -addressbook_compare (EReflowModel *erm, int n1, int n2) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - ECard *card1, *card2; - - card1 = e_addressbook_model_card_at (priv->model, n1); - card2 = e_addressbook_model_card_at (priv->model, n2); - - if (card1 && card2) { - char *file_as1, *file_as2; - file_as1 = card1->file_as; - file_as2 = card2->file_as; - if (file_as1 && file_as2) - return strcasecmp(file_as1, file_as2); - if (file_as1) - return -1; - if (file_as2) - return 1; - return strcmp(e_card_get_id(card1), e_card_get_id(card2)); - } - if (card1) - return -1; - if (card2) - return 1; - return 0; -} - -static int -adapter_drag_begin (EMinicard *card, GdkEvent *event, EAddressbookReflowAdapter *adapter) -{ - gint ret_val = 0; - - gtk_signal_emit (GTK_OBJECT(adapter), - e_addressbook_reflow_adapter_signals[DRAG_BEGIN], - event, &ret_val); - - return ret_val; -} - -static GnomeCanvasItem * -addressbook_incarnate (EReflowModel *erm, int i, GnomeCanvasGroup *parent) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - GnomeCanvasItem *item; - - item = gnome_canvas_item_new(parent, - e_minicard_get_type(), - "card", e_addressbook_model_card_at (priv->model, i), - "editable", e_addressbook_model_editable (priv->model), - NULL); - -#if 0 - gtk_signal_connect (GTK_OBJECT (item), "selected", - GTK_SIGNAL_FUNC(card_selected), emvm); -#endif - - gtk_signal_connect (GTK_OBJECT (item), "drag_begin", - GTK_SIGNAL_FUNC(adapter_drag_begin), adapter); - - return item; -} - -static void -addressbook_reincarnate (EReflowModel *erm, int i, GnomeCanvasItem *item) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - gnome_canvas_item_set(item, - "card", e_addressbook_model_card_at (priv->model, i), - NULL); -} - - - -static void -create_card(EAddressbookModel *model, - gint index, gint count, - EAddressbookReflowAdapter *adapter) -{ - e_reflow_model_items_inserted (E_REFLOW_MODEL (adapter), - index, - count); -} - -static void -remove_card(EAddressbookModel *model, - gint index, - EAddressbookReflowAdapter *adapter) -{ - e_reflow_model_changed (E_REFLOW_MODEL (adapter)); -} - -static void -modify_card(EAddressbookModel *model, - gint index, - EAddressbookReflowAdapter *adapter) -{ - e_reflow_model_item_changed (E_REFLOW_MODEL (adapter), index); -} - -static void -model_changed(EAddressbookModel *model, - EAddressbookReflowAdapter *adapter) -{ - e_reflow_model_changed (E_REFLOW_MODEL (adapter)); -} - -static void -addressbook_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(o); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - switch (arg_id){ - case ARG_BOOK: - gtk_object_set (GTK_OBJECT (priv->model), - "book", GTK_VALUE_OBJECT (*arg), - NULL); - break; - case ARG_QUERY: - gtk_object_set (GTK_OBJECT (priv->model), - "query", GTK_VALUE_STRING (*arg), - NULL); - break; - case ARG_EDITABLE: - gtk_object_set (GTK_OBJECT (priv->model), - "editable", GTK_VALUE_BOOL (*arg), - NULL); - break; - } -} - -static void -addressbook_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(o); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - switch (arg_id) { - case ARG_BOOK: { - EBook *book; - gtk_object_get (GTK_OBJECT (priv->model), - "book", &book, - NULL); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(book); - break; - } - case ARG_QUERY: { - char *query; - gtk_object_get (GTK_OBJECT (priv->model), - "query", &query, - NULL); - GTK_VALUE_STRING (*arg) = query; - break; - } - case ARG_EDITABLE: { - gboolean editable; - gtk_object_get (GTK_OBJECT (priv->model), - "editable", &editable, - NULL); - GTK_VALUE_BOOL (*arg) = editable; - break; - } - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_addressbook_reflow_adapter_class_init (GtkObjectClass *object_class) -{ - EReflowModelClass *model_class = (EReflowModelClass *) object_class; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->set_arg = addressbook_set_arg; - object_class->get_arg = addressbook_get_arg; - object_class->finalize = addressbook_finalize; - - gtk_object_add_arg_type ("EAddressbookReflowAdapter::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EAddressbookReflowAdapter::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - gtk_object_add_arg_type ("EAddressbookReflowAdapter::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - - e_addressbook_reflow_adapter_signals [DRAG_BEGIN] = - gtk_signal_new ("drag_begin", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookReflowAdapterClass, drag_begin), - gtk_marshal_INT__POINTER, - GTK_TYPE_INT, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER); - - - gtk_object_class_add_signals (object_class, e_addressbook_reflow_adapter_signals, LAST_SIGNAL); - - model_class->set_width = addressbook_set_width; - model_class->count = addressbook_count; - model_class->height = addressbook_height; - model_class->compare = addressbook_compare; - model_class->incarnate = addressbook_incarnate; - model_class->reincarnate = addressbook_reincarnate; -} - -static void -e_addressbook_reflow_adapter_init (GtkObject *object) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object); - EAddressbookReflowAdapterPrivate *priv; - - priv = adapter->priv = g_new0 (EAddressbookReflowAdapterPrivate, 1); - - priv->create_card_id = 0; - priv->remove_card_id = 0; - priv->modify_card_id = 0; - priv->model_changed_id = 0; -} - -GtkType -e_addressbook_reflow_adapter_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "EAddressbookReflowAdapter", - sizeof (EAddressbookReflowAdapter), - sizeof (EAddressbookReflowAdapterClass), - (GtkClassInitFunc) e_addressbook_reflow_adapter_class_init, - (GtkObjectInitFunc) e_addressbook_reflow_adapter_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -void -e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter, - EAddressbookModel *model) -{ - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - priv->model = model; - gtk_object_ref (GTK_OBJECT (priv->model)); - - priv->create_card_id = gtk_signal_connect(GTK_OBJECT(priv->model), - "card_added", - GTK_SIGNAL_FUNC(create_card), - adapter); - priv->remove_card_id = gtk_signal_connect(GTK_OBJECT(priv->model), - "card_removed", - GTK_SIGNAL_FUNC(remove_card), - adapter); - priv->modify_card_id = gtk_signal_connect(GTK_OBJECT(priv->model), - "card_changed", - GTK_SIGNAL_FUNC(modify_card), - adapter); - priv->model_changed_id = gtk_signal_connect(GTK_OBJECT(priv->model), - "model_changed", - GTK_SIGNAL_FUNC(model_changed), - adapter); -} - -EReflowModel * -e_addressbook_reflow_adapter_new (EAddressbookModel *model) -{ - EAddressbookReflowAdapter *et; - - et = gtk_type_new (e_addressbook_reflow_adapter_get_type ()); - - e_addressbook_reflow_adapter_construct (et, model); - - return E_REFLOW_MODEL(et); -} - - -ECard * -e_addressbook_reflow_adapter_get_card (EAddressbookReflowAdapter *adapter, - int index) -{ - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - return e_addressbook_model_get_card (priv->model, index); -} diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h b/addressbook/gui/widgets/e-addressbook-reflow-adapter.h deleted file mode 100644 index 1614a65064..0000000000 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ -#define _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ - -#include <gal/widgets/e-reflow-model.h> -#include <gal/widgets/e-selection-model.h> -#include "e-addressbook-model.h" -#include "addressbook/backend/ebook/e-book.h" -#include "addressbook/backend/ebook/e-book-view.h" -#include "addressbook/backend/ebook/e-card.h" - -#define E_ADDRESSBOOK_REFLOW_ADAPTER_TYPE (e_addressbook_reflow_adapter_get_type ()) -#define E_ADDRESSBOOK_REFLOW_ADAPTER(o) (GTK_CHECK_CAST ((o), E_ADDRESSBOOK_REFLOW_ADAPTER_TYPE, EAddressbookReflowAdapter)) -#define E_ADDRESSBOOK_REFLOW_ADAPTER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_ADDRESSBOOK_REFLOW_ADAPTER_TYPE, EAddressbookReflowAdapterClass)) -#define E_IS_ADDRESSBOOK_REFLOW_ADAPTER(o) (GTK_CHECK_TYPE ((o), E_ADDRESSBOOK_REFLOW_ADAPTER_TYPE)) -#define E_IS_ADDRESSBOOK_REFLOW_ADAPTER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_ADDRESSBOOK_REFLOW_ADAPTER_TYPE)) - -typedef struct _EAddressbookReflowAdapter EAddressbookReflowAdapter; -typedef struct _EAddressbookReflowAdapterPrivate EAddressbookReflowAdapterPrivate; -typedef struct _EAddressbookReflowAdapterClass EAddressbookReflowAdapterClass; - -struct _EAddressbookReflowAdapter { - EReflowModel parent; - - EAddressbookReflowAdapterPrivate *priv; -}; - - -struct _EAddressbookReflowAdapterClass { - EReflowModelClass parent_class; - - /* - * Signals - */ - gint (* drag_begin) (EAddressbookReflowAdapter *adapter, GdkEvent *event); -}; - - -GtkType e_addressbook_reflow_adapter_get_type (void); -void e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter, - EAddressbookModel *model); -EReflowModel *e_addressbook_reflow_adapter_new (EAddressbookModel *model); - -/* 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); - -#endif /* _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ */ diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c deleted file mode 100644 index 3fa92d2300..0000000000 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ /dev/null @@ -1,391 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include "e-addressbook-model.h" -#include "e-addressbook-table-adapter.h" -#include "e-card-merging.h" -#include "e-addressbook-util.h" -#include <gnome-xml/tree.h> -#include <gnome-xml/parser.h> -#include <gnome-xml/xmlmemory.h> -#include <gnome.h> - -struct _EAddressbookTableAdapterPrivate { - EAddressbookModel *model; - - ECardSimple **simples; - int count; - - int create_card_id, remove_card_id, modify_card_id, model_changed_id; -}; - -#define PARENT_TYPE e_table_model_get_type() -ETableModelClass *parent_class; - -#define COLS (E_CARD_SIMPLE_FIELD_LAST) - -static void -unlink_model(EAddressbookTableAdapter *adapter) -{ - EAddressbookTableAdapterPrivate *priv = adapter->priv; - int i; - - gtk_signal_disconnect(GTK_OBJECT (priv->model), - priv->create_card_id); - gtk_signal_disconnect(GTK_OBJECT (priv->model), - priv->remove_card_id); - gtk_signal_disconnect(GTK_OBJECT (priv->model), - priv->modify_card_id); - gtk_signal_disconnect(GTK_OBJECT (priv->model), - priv->model_changed_id); - - priv->create_card_id = 0; - priv->remove_card_id = 0; - priv->modify_card_id = 0; - priv->model_changed_id = 0; - - /* free up the existing mapping if there is one */ - if (priv->simples) { - for (i = 0; i < priv->count; i ++) - gtk_object_unref (GTK_OBJECT (priv->simples[i])); - g_free (priv->simples); - priv->simples = NULL; - } - - gtk_object_unref(GTK_OBJECT(priv->model)); - - priv->model = NULL; -} - -static void -build_simple_mapping(EAddressbookTableAdapter *adapter) -{ - EAddressbookTableAdapterPrivate *priv = adapter->priv; - int i; - - /* free up the existing mapping if there is one */ - if (priv->simples) { - for (i = 0; i < priv->count; i ++) - gtk_object_unref (GTK_OBJECT (priv->simples[i])); - g_free (priv->simples); - } - - /* build up our mapping to ECardSimple*'s */ - priv->count = e_addressbook_model_card_count (priv->model); - priv->simples = g_new (ECardSimple*, priv->count); - for (i = 0; i < priv->count; i ++) { - priv->simples[i] = e_card_simple_new (e_addressbook_model_card_at (priv->model, i)); - gtk_object_ref (GTK_OBJECT (priv->simples[i])); - } -} - -static void -addressbook_destroy(GtkObject *object) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(object); - - unlink_model(adapter); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -addressbook_col_count (ETableModel *etc) -{ - return COLS; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -addressbook_row_count (ETableModel *etc) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - - return e_addressbook_model_card_count (priv->model); -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -addressbook_value_at (ETableModel *etc, int col, int row) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - const char *value; - if ( col >= COLS || row >= e_addressbook_model_card_count (priv->model) ) - return NULL; - - value = e_card_simple_get_const(priv->simples[row], col); - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -card_modified_cb (EBook* book, EBookStatus status, - gpointer user_data) -{ - g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__); - if (status != E_BOOK_STATUS_SUCCESS) - e_addressbook_error_dialog (_("Error modifying card"), status); -} -static void -addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - if (e_addressbook_model_editable (priv->model)) { - ECard *card; - - if ( col >= COLS|| row >= e_addressbook_model_card_count (priv->model) ) - return; - - e_card_simple_set(priv->simples[row], - col, - val); - gtk_object_get(GTK_OBJECT(priv->simples[row]), - "card", &card, - NULL); - - e_card_merging_book_commit_card(e_addressbook_model_get_ebook(priv->model), - card, card_modified_cb, NULL); - - /* XXX do we need this? shouldn't the commit_card generate a changed signal? */ - e_table_model_cell_changed(etc, col, row); - } -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -addressbook_is_cell_editable (ETableModel *etc, int col, int row) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - ECard *card; - - if (row >= 0 && row < e_addressbook_model_card_count (priv->model)) - card = e_addressbook_model_card_at (priv->model, row); - else - card = NULL; - - if (!e_addressbook_model_editable(priv->model)) - return FALSE; - else if (card && e_card_evolution_list (card)) - /* we only allow editing of the name and file as for - lists */ - return col == E_CARD_SIMPLE_FIELD_FULL_NAME || col == E_CARD_SIMPLE_FIELD_FILE_AS; - else - return col < E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING; -} - -static void -addressbook_append_row (ETableModel *etm, ETableModel *source, gint row) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etm); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - ECard *card; - ECardSimple *simple; - int col; - - card = e_card_new(""); - simple = e_card_simple_new(card); - - for (col = 0; col < E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING; col++) { - const void *val = e_table_model_value_at(source, col, row); - e_card_simple_set(simple, col, val); - } - e_card_simple_sync_card(simple); - e_card_merging_book_add_card (e_addressbook_model_get_ebook (priv->model), card, NULL, NULL); - gtk_object_unref(GTK_OBJECT(simple)); - gtk_object_unref(GTK_OBJECT(card)); -} - -/* This function duplicates the value passed to it. */ -static void * -addressbook_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -addressbook_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -addressbook_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -addressbook_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -addressbook_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -static void -e_addressbook_table_adapter_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = addressbook_destroy; - - model_class->column_count = addressbook_col_count; - model_class->row_count = addressbook_row_count; - model_class->value_at = addressbook_value_at; - model_class->set_value_at = addressbook_set_value_at; - model_class->is_cell_editable = addressbook_is_cell_editable; - model_class->append_row = addressbook_append_row; - model_class->duplicate_value = addressbook_duplicate_value; - model_class->free_value = addressbook_free_value; - model_class->initialize_value = addressbook_initialize_value; - model_class->value_is_empty = addressbook_value_is_empty; - model_class->value_to_string = addressbook_value_to_string; -} - -static void -e_addressbook_table_adapter_init (GtkObject *object) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(object); - EAddressbookTableAdapterPrivate *priv; - - priv = adapter->priv = g_new0 (EAddressbookTableAdapterPrivate, 1); - - priv->create_card_id = 0; - priv->remove_card_id = 0; - priv->modify_card_id = 0; - priv->model_changed_id = 0; - priv->simples = NULL; - priv->count = 0; -} - - -static void -create_card (EAddressbookModel *model, - gint index, gint count, - EAddressbookTableAdapter *adapter) -{ - EAddressbookTableAdapterPrivate *priv = adapter->priv; - int i; - - priv->count += count; - priv->simples = g_renew(ECardSimple *, priv->simples, priv->count); - memmove (priv->simples + index + count, priv->simples + index, (priv->count - index - count) * sizeof (ECardSimple *)); - - e_table_model_pre_change (E_TABLE_MODEL (adapter)); - for (i = 0; i < count; i ++) { - priv->simples[index + i] = e_card_simple_new (e_addressbook_model_card_at (priv->model, index + i)); - } - e_table_model_rows_inserted (E_TABLE_MODEL (adapter), index, count); -} - -static void -remove_card (EAddressbookModel *model, - gint index, - EAddressbookTableAdapter *adapter) -{ - EAddressbookTableAdapterPrivate *priv = adapter->priv; - - e_table_model_pre_change (E_TABLE_MODEL (adapter)); - - gtk_object_unref (GTK_OBJECT (priv->simples[index])); - memmove (priv->simples + index, priv->simples + index + 1, (priv->count - index - 1) * sizeof (ECardSimple *)); - priv->count --; - e_table_model_rows_deleted (E_TABLE_MODEL (adapter), index, 1); -} - -static void -modify_card (EAddressbookModel *model, - gint index, - EAddressbookTableAdapter *adapter) -{ - EAddressbookTableAdapterPrivate *priv = adapter->priv; - - e_table_model_pre_change (E_TABLE_MODEL (adapter)); - - gtk_object_unref (GTK_OBJECT (priv->simples[index])); - priv->simples[index] = e_card_simple_new (e_addressbook_model_card_at (priv->model, index)); - gtk_object_ref (GTK_OBJECT (priv->simples[index])); - e_table_model_row_changed (E_TABLE_MODEL (adapter), index); -} - -static void -model_changed (EAddressbookModel *model, - EAddressbookTableAdapter *adapter) -{ - build_simple_mapping (adapter); - e_table_model_changed (E_TABLE_MODEL (adapter)); -} - -GtkType -e_addressbook_table_adapter_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "EAddressbookTableAdapter", - sizeof (EAddressbookTableAdapter), - sizeof (EAddressbookTableAdapterClass), - (GtkClassInitFunc) e_addressbook_table_adapter_class_init, - (GtkObjectInitFunc) e_addressbook_table_adapter_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -void -e_addressbook_table_adapter_construct (EAddressbookTableAdapter *adapter, - EAddressbookModel *model) -{ - EAddressbookTableAdapterPrivate *priv = adapter->priv; - - priv->model = model; - gtk_object_ref (GTK_OBJECT (priv->model)); - - priv->create_card_id = gtk_signal_connect(GTK_OBJECT(priv->model), - "card_added", - GTK_SIGNAL_FUNC(create_card), - adapter); - priv->remove_card_id = gtk_signal_connect(GTK_OBJECT(priv->model), - "card_removed", - GTK_SIGNAL_FUNC(remove_card), - adapter); - priv->modify_card_id = gtk_signal_connect(GTK_OBJECT(priv->model), - "card_changed", - GTK_SIGNAL_FUNC(modify_card), - adapter); - priv->model_changed_id = gtk_signal_connect(GTK_OBJECT(priv->model), - "model_changed", - GTK_SIGNAL_FUNC(model_changed), - adapter); - - build_simple_mapping (adapter); -} - -ETableModel * -e_addressbook_table_adapter_new (EAddressbookModel *model) -{ - EAddressbookTableAdapter *et; - - et = gtk_type_new (e_addressbook_table_adapter_get_type ()); - - e_addressbook_table_adapter_construct (et, model); - - return E_TABLE_MODEL(et); -} diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.h b/addressbook/gui/widgets/e-addressbook-table-adapter.h deleted file mode 100644 index d76434e80a..0000000000 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_ADDRESSBOOK_TABLE_ADAPTER_H_ -#define _E_ADDRESSBOOK_TABLE_ADAPTER_H_ - -#include <gal/e-table/e-table-model.h> -#include "addressbook/backend/ebook/e-book.h" -#include "addressbook/backend/ebook/e-book-view.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#define E_ADDRESSBOOK_TABLE_ADAPTER_TYPE (e_addressbook_table_adapter_get_type ()) -#define E_ADDRESSBOOK_TABLE_ADAPTER(o) (GTK_CHECK_CAST ((o), E_ADDRESSBOOK_TABLE_ADAPTER_TYPE, EAddressbookTableAdapter)) -#define E_ADDRESSBOOK_TABLE_ADAPTER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_ADDRESSBOOK_TABLE_ADAPTER_TYPE, EAddressbookTableAdapterClass)) -#define E_IS_ADDRESSBOOK_TABLE_ADAPTER(o) (GTK_CHECK_TYPE ((o), E_ADDRESSBOOK_TABLE_ADAPTER_TYPE)) -#define E_IS_ADDRESSBOOK_TABLE_ADAPTER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_ADDRESSBOOK_TABLE_ADAPTER_TYPE)) - -/* Virtual Column list: - 0 Email - 1 Full Name - 2 Street - 3 Phone -*/ - -typedef struct _EAddressbookTableAdapter EAddressbookTableAdapter; -typedef struct _EAddressbookTableAdapterPrivate EAddressbookTableAdapterPrivate; -typedef struct _EAddressbookTableAdapterClass EAddressbookTableAdapterClass; - -struct _EAddressbookTableAdapter { - ETableModel parent; - - EAddressbookTableAdapterPrivate *priv; -}; - - -struct _EAddressbookTableAdapterClass { - ETableModelClass parent_class; -}; - - -GtkType e_addressbook_table_adapter_get_type (void); -void e_addressbook_table_adapter_construct (EAddressbookTableAdapter *adapter, - EAddressbookModel *model); -ETableModel *e_addressbook_table_adapter_new (EAddressbookModel *model); - -#endif /* _E_ADDRESSBOOK_TABLE_ADAPTER_H_ */ diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/e-addressbook-util.c deleted file mode 100644 index 9aaa554547..0000000000 --- a/addressbook/gui/widgets/e-addressbook-util.c +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-table-field-chooser.c - * Copyright (C) 2001 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <gnome.h> - -#include "e-addressbook-util.h" -#include "e-card-merging.h" - -void -e_addressbook_error_dialog (const gchar *msg, EBookStatus status) -{ - static char *status_to_string[] = { - N_("Success"), - N_("Unknown error"), - N_("Repository offline"), - N_("Permission denied"), - N_("Card not found"), - N_("Card ID already exists"), - N_("Protocol not supported"), - N_("Canceled"), - N_("Other error") - }; - char *error_msg; - - error_msg = g_strdup_printf ("%s: %s", msg, status_to_string [status]); - - gtk_widget_show (gnome_error_dialog (error_msg)); - - g_free (error_msg); -} - - -static void -added_cb (EBook* book, EBookStatus status, const char *id, - gboolean is_list) -{ - if (status != E_BOOK_STATUS_SUCCESS) { - e_addressbook_error_dialog (is_list ? _("Error adding list") : _("Error adding card"), status); - } -} - -static void -modified_cb (EBook* book, EBookStatus status, - gboolean is_list) -{ - if (status != E_BOOK_STATUS_SUCCESS) { - e_addressbook_error_dialog (is_list ? _("Error modifying list") : _("Error modifying card"), - status); - } -} - -static void -deleted_cb (EBook* book, EBookStatus status, - gboolean is_list) -{ - if (status != E_BOOK_STATUS_SUCCESS) { - e_addressbook_error_dialog (is_list ? _("Error removing list") : _("Error removing card"), - status); - } -} - -static void -editor_closed_cb (GtkObject *editor, gpointer data) -{ - gtk_object_unref (editor); -} - -EContactEditor * -e_addressbook_show_contact_editor (EBook *book, ECard *card, - gboolean is_new_card, - gboolean editable) -{ - EContactEditor *ce; - - ce = e_contact_editor_new (book, card, is_new_card, editable); - - gtk_signal_connect (GTK_OBJECT (ce), "card_added", - GTK_SIGNAL_FUNC (added_cb), GINT_TO_POINTER (FALSE)); - gtk_signal_connect (GTK_OBJECT (ce), "card_modified", - GTK_SIGNAL_FUNC (modified_cb), GINT_TO_POINTER (FALSE)); - gtk_signal_connect (GTK_OBJECT (ce), "card_deleted", - GTK_SIGNAL_FUNC (deleted_cb), GINT_TO_POINTER (FALSE)); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - return ce; -} - -EContactListEditor * -e_addressbook_show_contact_list_editor (EBook *book, ECard *card, - gboolean is_new_card, - gboolean editable) -{ - EContactListEditor *ce; - - ce = e_contact_list_editor_new (book, card, is_new_card, editable); - - gtk_signal_connect (GTK_OBJECT (ce), "list_added", - GTK_SIGNAL_FUNC (added_cb), GINT_TO_POINTER (TRUE)); - gtk_signal_connect (GTK_OBJECT (ce), "list_modified", - GTK_SIGNAL_FUNC (modified_cb), GINT_TO_POINTER (TRUE)); - gtk_signal_connect (GTK_OBJECT (ce), "list_deleted", - GTK_SIGNAL_FUNC (deleted_cb), GINT_TO_POINTER (TRUE)); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), GINT_TO_POINTER (TRUE)); - - e_contact_list_editor_show (ce); - - return ce; -} diff --git a/addressbook/gui/widgets/e-addressbook-util.h b/addressbook/gui/widgets/e-addressbook-util.h deleted file mode 100644 index 1f3ffe074d..0000000000 --- a/addressbook/gui/widgets/e-addressbook-util.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-addressbook-util.h - * Copyright (C) 2001 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_ADDRESSBOOK_UTIL_H__ -#define __E_ADDRESSBOOK_UTIL_H__ - -#include "addressbook/backend/ebook/e-book.h" -#include "addressbook/gui/contact-editor/e-contact-editor.h" -#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -void e_addressbook_error_dialog (const gchar *msg, - EBookStatus status); -EContactEditor* e_addressbook_show_contact_editor (EBook *book, ECard *card, - gboolean is_new_card, - gboolean editable); -EContactListEditor * e_addressbook_show_contact_list_editor (EBook *book, ECard *card, - gboolean is_new_card, - gboolean editable); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_ADDRESSBOOK_UTIL_H__ */ diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c deleted file mode 100644 index 4f39360045..0000000000 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ /dev/null @@ -1,1329 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-table-field-chooser.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <gtk/gtkinvisible.h> - -#include <libgnome/gnome-paper.h> -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-util.h> -#include <gal/e-table/e-table-scrolled.h> -#include <gal/e-table/e-table-model.h> -#include <gal/widgets/e-scroll-frame.h> -#include <gal/widgets/e-popup-menu.h> -#include <gal/menus/gal-view-factory-etable.h> -#include <gal/menus/gal-view-etable.h> -#include <libgnomeui/gnome-dialog-util.h> - -#include <libgnomeprint/gnome-print.h> -#include <libgnomeprint/gnome-print-dialog.h> -#include <libgnomeprint/gnome-print-master.h> -#include <libgnomeprint/gnome-print-master-preview.h> - -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/printing/e-contact-print-envelope.h" - -#include "gal-view-factory-minicard.h" -#include "gal-view-minicard.h" - -#include "e-addressbook-view.h" -#include "e-addressbook-model.h" -#include "e-addressbook-util.h" -#include "e-addressbook-table-adapter.h" -#include "e-addressbook-reflow-adapter.h" -#include "e-minicard-view-widget.h" -#include "e-contact-save-as.h" -#include "e-card-merging.h" - -#include "e-contact-editor.h" - -static void e_addressbook_view_init (EAddressbookView *card); -static void e_addressbook_view_class_init (EAddressbookViewClass *klass); -static void e_addressbook_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_addressbook_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_addressbook_view_destroy (GtkObject *object); -static void change_view_type (EAddressbookView *view, EAddressbookViewType view_type); - -static void status_message (GtkObject *object, const gchar *status, EAddressbookView *eav); -static void stop_state_changed (GtkObject *object, EAddressbookView *eav); -static void writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav); -static void command_state_change (EAddressbookView *eav); - -static void selection_clear_event (GtkWidget *invisible, GdkEventSelection *event, - EAddressbookView *view); -static void selection_received (GtkWidget *invisible, GtkSelectionData *selection_data, - guint time, EAddressbookView *view); -static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_data, - guint info, guint time_stamp, EAddressbookView *view); -static void invisible_destroyed (GtkWidget *invisible, EAddressbookView *view); - -static GtkTableClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY, - ARG_TYPE, -}; - -enum { - STATUS_MESSAGE, - COMMAND_STATE_CHANGE, - LAST_SIGNAL -}; - -enum DndTargetType { - DND_TARGET_TYPE_VCARD, -}; -#define VCARD_TYPE "text/x-vcard" -static GtkTargetEntry drag_types[] = { - { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD }, -}; -static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); - -static guint e_addressbook_view_signals [LAST_SIGNAL] = {0, }; - -static GdkAtom clipboard_atom = GDK_NONE; - -GtkType -e_addressbook_view_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GtkTypeInfo info = - { - "EAddressbookView", - sizeof (EAddressbookView), - sizeof (EAddressbookViewClass), - (GtkClassInitFunc) e_addressbook_view_class_init, - (GtkObjectInitFunc) e_addressbook_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_table_get_type (), &info); - } - - return type; -} - -static void -e_addressbook_view_class_init (EAddressbookViewClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - parent_class = gtk_type_class (gtk_table_get_type ()); - - object_class->set_arg = e_addressbook_view_set_arg; - object_class->get_arg = e_addressbook_view_get_arg; - object_class->destroy = e_addressbook_view_destroy; - - gtk_object_add_arg_type ("EAddressbookView::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EAddressbookView::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - gtk_object_add_arg_type ("EAddressbookView::type", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_TYPE); - - e_addressbook_view_signals [STATUS_MESSAGE] = - gtk_signal_new ("status_message", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookViewClass, status_message), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); - - e_addressbook_view_signals [COMMAND_STATE_CHANGE] = - gtk_signal_new ("command_state_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookViewClass, command_state_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_addressbook_view_signals, LAST_SIGNAL); - - if (!clipboard_atom) - clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); -} - -static void -e_addressbook_view_init (EAddressbookView *eav) -{ - eav->view_type = E_ADDRESSBOOK_VIEW_NONE; - - eav->model = e_addressbook_model_new (); - - gtk_signal_connect (GTK_OBJECT(eav->model), - "status_message", - GTK_SIGNAL_FUNC (status_message), - eav); - - gtk_signal_connect (GTK_OBJECT(eav->model), - "stop_state_changed", - GTK_SIGNAL_FUNC (stop_state_changed), - eav); - - gtk_signal_connect (GTK_OBJECT(eav->model), - "writable_status", - GTK_SIGNAL_FUNC (writable_status), - eav); - - eav->editable = FALSE; - eav->book = NULL; - eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")"); - - eav->object = NULL; - eav->widget = NULL; - - eav->view_collection = NULL; - eav->view_menus = NULL; - - eav->invisible = gtk_invisible_new (); - - gtk_selection_add_target (eav->invisible, - clipboard_atom, - GDK_SELECTION_TYPE_STRING, - 0); - - gtk_signal_connect (GTK_OBJECT(eav->invisible), "selection_get", - GTK_SIGNAL_FUNC (selection_get), - eav); - gtk_signal_connect (GTK_OBJECT(eav->invisible), "selection_clear_event", - GTK_SIGNAL_FUNC (selection_clear_event), - eav); - gtk_signal_connect (GTK_OBJECT(eav->invisible), "selection_received", - GTK_SIGNAL_FUNC (selection_received), - eav); - gtk_signal_connect (GTK_OBJECT(eav->invisible), "destroy", - GTK_SIGNAL_FUNC (invisible_destroyed), - eav); -} - -static void -e_addressbook_view_destroy (GtkObject *object) -{ - EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object); - - if (eav->model) - gtk_object_unref(GTK_OBJECT(eav->model)); - - if (eav->book) - gtk_object_unref(GTK_OBJECT(eav->book)); - g_free(eav->query); - - if (eav->view_collection) { - gtk_object_unref (GTK_OBJECT (eav->view_collection)); - eav->view_collection = NULL; - } - - if (eav->view_menus) { - gtk_object_unref (GTK_OBJECT (eav->view_menus)); - eav->view_menus = NULL; - } - - if (eav->clipboard_cards) { - g_list_foreach (eav->clipboard_cards, (GFunc)gtk_object_unref, NULL); - g_list_free (eav->clipboard_cards); - eav->clipboard_cards = NULL; - } - - if (eav->invisible) - gtk_widget_destroy (eav->invisible); - - if (GTK_OBJECT_CLASS(parent_class)->destroy) - GTK_OBJECT_CLASS(parent_class)->destroy(object); -} - -GtkWidget* -e_addressbook_view_new (void) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_addressbook_view_get_type ())); - return widget; -} - -static void -book_writable_cb (EBook *book, gboolean writable, EAddressbookView *eav) -{ - eav->editable = writable; - gtk_object_set (GTK_OBJECT (eav->model), - "editable", eav->editable, - NULL); -} - -static void -e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object); - - switch (arg_id){ - case ARG_BOOK: - if (eav->book) { - gtk_object_unref(GTK_OBJECT(eav->book)); - } - if (GTK_VALUE_OBJECT(*arg)) { - eav->book = E_BOOK(GTK_VALUE_OBJECT(*arg)); - gtk_object_ref(GTK_OBJECT(eav->book)); - gtk_signal_connect (GTK_OBJECT (eav->book), - "writable_status", - book_writable_cb, eav); - } - else - eav->book = NULL; - gtk_object_set(GTK_OBJECT(eav->model), - "book", eav->book, - "editable", eav->editable, - NULL); - - break; - case ARG_QUERY: - g_free(eav->query); - eav->query = g_strdup(GTK_VALUE_STRING(*arg)); - if (!eav->query) - eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")"); - gtk_object_set(GTK_OBJECT(eav->model), - "query", eav->query, - NULL); - break; - case ARG_TYPE: - change_view_type(eav, GTK_VALUE_ENUM(*arg)); - break; - default: - break; - } -} - -static void -e_addressbook_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object); - - switch (arg_id) { - case ARG_BOOK: - if (eav->book) - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(eav->book); - else - GTK_VALUE_OBJECT (*arg) = NULL; - break; - case ARG_QUERY: - GTK_VALUE_STRING (*arg) = eav->query; - break; - case ARG_TYPE: - GTK_VALUE_ENUM (*arg) = eav->view_type; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - - - -typedef struct { - EAddressbookView *view; - char letter; -} LetterClosure; - -static void -jump_to_letter(GtkWidget *button, LetterClosure *closure) -{ - if (closure->view->widget && E_IS_MINICARD_VIEW_WIDGET(closure->view->widget)) - e_minicard_view_widget_jump_to_letter(E_MINICARD_VIEW_WIDGET(closure->view->widget), closure->letter); -} - -static void -free_closure(GtkWidget *button, LetterClosure *closure) -{ - g_free(closure); -} - -static void -connect_button (EAddressbookView *view, GladeXML *gui, char letter) -{ - char *name; - GtkWidget *button; - LetterClosure *closure; - name = g_strdup_printf("button-%c", letter); - button = glade_xml_get_widget(gui, name); - g_free(name); - if (!button) - return; - closure = g_new(LetterClosure, 1); - closure->view = view; - closure->letter = letter; - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(jump_to_letter), closure); - gtk_signal_connect(GTK_OBJECT(button), "destroy", - GTK_SIGNAL_FUNC(free_closure), closure); -} - -static GtkWidget * -create_alphabet (EAddressbookView *view) -{ - GtkWidget *widget; - char letter; - GladeXML *gui = glade_xml_new (EVOLUTION_GLADEDIR "/alphabet.glade", NULL); - - widget = glade_xml_get_widget(gui, "scrolledwindow-top"); - if (!widget) { - return NULL; - } - - connect_button(view, gui, '1'); - for (letter = 'a'; letter <= 'z'; letter ++) { - connect_button(view, gui, letter); - } - - gtk_object_unref(GTK_OBJECT(gui)); - return widget; -} - -static void -minicard_selection_change (EMinicardViewWidget *widget, EAddressbookView *view) -{ - command_state_change (view); -} - -static void -create_minicard_view (EAddressbookView *view) -{ - GtkWidget *scrollframe; - GtkWidget *alphabet; - GtkWidget *minicard_view; - GtkWidget *minicard_hbox; - EAddressbookReflowAdapter *adapter; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - minicard_hbox = gtk_hbox_new(FALSE, 0); - - adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(e_addressbook_reflow_adapter_new (view->model)); - minicard_view = e_minicard_view_widget_new(adapter); - - gtk_signal_connect(GTK_OBJECT(minicard_view), "selection_change", - GTK_SIGNAL_FUNC(minicard_selection_change), view); - - - view->object = GTK_OBJECT(minicard_view); - view->widget = minicard_hbox; - - scrollframe = e_scroll_frame_new (NULL, NULL); - e_scroll_frame_set_policy (E_SCROLL_FRAME (scrollframe), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - gtk_container_add (GTK_CONTAINER (scrollframe), minicard_view); - - - gtk_box_pack_start(GTK_BOX(minicard_hbox), scrollframe, TRUE, TRUE, 0); - - alphabet = create_alphabet(view); - if (alphabet) { - gtk_object_ref(GTK_OBJECT(alphabet)); - gtk_widget_unparent(alphabet); - gtk_box_pack_start(GTK_BOX(minicard_hbox), alphabet, FALSE, FALSE, 0); - gtk_object_unref(GTK_OBJECT(alphabet)); - } - - gtk_table_attach(GTK_TABLE(view), minicard_hbox, - 0, 1, - 0, 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, - 0, 0); - - gtk_widget_show_all( GTK_WIDGET(minicard_hbox) ); - - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); - - e_reflow_model_changed (E_REFLOW_MODEL (adapter)); - - gtk_object_unref (GTK_OBJECT (adapter)); -} - -static void -table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EAddressbookView *view) -{ - if (E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) { - EAddressbookModel *model = view->model; - ECard *card = e_addressbook_model_get_card(model, row); - EBook *book; - - gtk_object_get(GTK_OBJECT(model), - "book", &book, - NULL); - - g_assert (E_IS_BOOK (book)); - - if (e_card_evolution_list (card)) - e_addressbook_show_contact_list_editor (book, card, FALSE, view->editable); - else - e_addressbook_show_contact_editor (book, card, FALSE, view->editable); - } -} - -typedef struct { - EBook *book; - ECard *card; - EAddressbookView *view; - GtkWidget *widget; - gpointer closure; -} CardAndBook; - -static void -card_and_book_free (CardAndBook *card_and_book) -{ - 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); - card_and_book_free(card_and_book); -} - -static void -send_as (GtkWidget *widget, CardAndBook *card_and_book) -{ - e_card_send(card_and_book->card, E_CARD_DISPOSITION_AS_ATTACHMENT); - card_and_book_free(card_and_book); -} - -static void -send_to (GtkWidget *widget, CardAndBook *card_and_book) - -{ - e_card_send(card_and_book->card, E_CARD_DISPOSITION_AS_TO); - card_and_book_free(card_and_book); -} - -static void -print (GtkWidget *widget, CardAndBook *card_and_book) -{ - gtk_widget_show(e_contact_print_card_dialog_new(card_and_book->card)); - card_and_book_free(card_and_book); -} - -static void -print_envelope (GtkWidget *widget, CardAndBook *card_and_book) -{ - gtk_widget_show(e_contact_print_envelope_dialog_new(card_and_book->card)); - card_and_book_free(card_and_book); -} - -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); - } - card_and_book_free(card_and_book); -} - -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; - - EPopupMenu menu[] = { - {N_("Save as VCard"), NULL, GTK_SIGNAL_FUNC(save_as), NULL, 0}, - {N_("Send contact to other"), NULL, GTK_SIGNAL_FUNC(send_as), NULL, 0}, - {N_("Send message to contact"), NULL, GTK_SIGNAL_FUNC(send_to), NULL, 0}, - {N_("Print"), NULL, GTK_SIGNAL_FUNC(print), NULL, 0}, - {N_("Print Envelope"), NULL, GTK_SIGNAL_FUNC(print_envelope), NULL, 0}, - {N_("Delete"), NULL, GTK_SIGNAL_FUNC(delete), NULL, 0}, - {NULL, NULL, NULL, NULL, 0} - }; - - 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; - 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)); - - e_popup_menu_run (menu, event, 0, 0, card_and_book); - return TRUE; - } else - return FALSE; -} - -static void -table_selection_change(ETableScrolled *table, EAddressbookView *view) -{ - command_state_change (view); -} - -static void -table_drag_data_get (ETable *table, - int row, - int col, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - gpointer user_data) -{ - EAddressbookView *view = user_data; - - printf ("table_drag_data_get (row %d, col %d)\n", row, col); - - if (!E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) - return; - - switch (info) { - case DND_TARGET_TYPE_VCARD: { - char *value; - - row = e_table_view_to_model_row (table, row); - value = e_card_get_vcard(view->model->data[row]); - - gtk_selection_data_set (selection_data, - selection_data->target, - 8, - value, strlen (value)); - break; - } - } -} - -static void -emit_status_message (EAddressbookView *eav, const gchar *status) -{ - gtk_signal_emit (GTK_OBJECT (eav), - e_addressbook_view_signals [STATUS_MESSAGE], - status); -} - -static void -status_message (GtkObject *object, const gchar *status, EAddressbookView *eav) -{ - emit_status_message (eav, status); -} - -static void -stop_state_changed (GtkObject *object, EAddressbookView *eav) -{ - command_state_change (eav); -} - -static void -writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav) -{ - command_state_change (eav); -} - -static void -command_state_change (EAddressbookView *eav) -{ - gtk_signal_emit (GTK_OBJECT (eav), - e_addressbook_view_signals [COMMAND_STATE_CHANGE]); -} - -#ifdef JUST_FOR_TRANSLATORS -static char *list [] = { - N_("* Click here to add a contact *"), - N_("File As"), - N_("Full Name"), - N_("Email"), - N_("Primary Phone"), - N_("Assistant Phone"), - N_("Business Phone"), - N_("Callback Phone"), - N_("Company Phone"), - N_("Home Phone"), - N_("Organization"), - N_("Business Address"), - N_("Home Address"), - N_("Mobile Phone"), - N_("Car Phone"), - N_("Business Fax"), - N_("Home Fax"), - N_("Business Phone 2"), - N_("Home Phone 2"), - N_("ISDN"), - N_("Other Phone"), - N_("Other Fax"), - N_("Pager"), - N_("Radio"), - N_("Telex"), - N_("TTY"), - N_("Other Address"), - N_("Email 2"), - N_("Email 3"), - N_("Web Site"), - N_("Department"), - N_("Office"), - N_("Title"), - N_("Profession"), - N_("Manager"), - N_("Assistant"), - N_("Nickname"), - N_("Spouse"), - N_("Note"), - N_("Free-busy URL"), -}; -#endif - -#define SPEC "<?xml version=\"1.0\"?> \ -<ETableSpecification click-to-add=\"true\" draw-grid=\"true\" _click-to-add-message=\"* Click here to add a contact *\"> \ - <ETableColumn model_col= \"0\" _title=\"File As\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col= \"1\" _title=\"Full Name\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col= \"3\" _title=\"Email\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col= \"4\" _title=\"Primary Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col= \"5\" _title=\"Assistant Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col= \"6\" _title=\"Business Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col= \"7\" _title=\"Callback Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col= \"8\" _title=\"Company Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col= \"9\" _title=\"Home Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"10\" _title=\"Organization\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"11\" _title=\"Business Address\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"12\" _title=\"Home Address\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"13\" _title=\"Mobile Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"14\" _title=\"Car Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"15\" _title=\"Business Fax\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"16\" _title=\"Home Fax\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"17\" _title=\"Business Phone 2\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"18\" _title=\"Home Phone 2\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"19\" _title=\"ISDN\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"20\" _title=\"Other Phone\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"21\" _title=\"Other Fax\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"22\" _title=\"Pager\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"23\" _title=\"Radio\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"24\" _title=\"Telex\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"25\" _title=\"TTY\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"26\" _title=\"Other Address\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"27\" _title=\"Email 2\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"28\" _title=\"Email 3\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"29\" _title=\"Web Site\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"30\" _title=\"Department\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"31\" _title=\"Office\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"32\" _title=\"Title\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"33\" _title=\"Profession\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"34\" _title=\"Manager\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"35\" _title=\"Assistant\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"36\" _title=\"Nickname\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"37\" _title=\"Spouse\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"38\" _title=\"Note\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableColumn model_col=\"39\" _title=\"Free-busy URL\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \ - <ETableState> \ - <column source=\"0\"/> \ - <column source=\"1\"/> \ - <column source=\"5\"/> \ - <column source=\"3\"/> \ - <column source=\"4\"/> \ - <grouping> \ - <leaf column=\"0\" ascending=\"true\"/> \ - </grouping> \ - </ETableState> \ -</ETableSpecification>" - -static void -create_table_view (EAddressbookView *view) -{ - ETableModel *adapter; - ECardSimple *simple; - GtkWidget *table; - - simple = e_card_simple_new(NULL); - - adapter = e_addressbook_table_adapter_new(view->model); - - /* Here we create the table. We give it the three pieces of - the table we've created, the header, the model, and the - initial layout. It does the rest. */ - table = e_table_scrolled_new (adapter, NULL, SPEC, NULL); - - view->object = GTK_OBJECT(adapter); - view->widget = table; - - gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(table))), "double_click", - GTK_SIGNAL_FUNC(table_double_click), view); - gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(table))), "right_click", - GTK_SIGNAL_FUNC(table_right_click), view); - gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(table))), "selection_change", - GTK_SIGNAL_FUNC(table_selection_change), view); - - /* drag & drop signals */ - e_table_drag_source_set (E_TABLE(E_TABLE_SCROLLED(table)->table), GDK_BUTTON1_MASK, - drag_types, num_drag_types, GDK_ACTION_MOVE); - - gtk_signal_connect (GTK_OBJECT (E_TABLE_SCROLLED(table)->table), - "table_drag_data_get", - GTK_SIGNAL_FUNC (table_drag_data_get), - view); - - gtk_table_attach(GTK_TABLE(view), table, - 0, 1, - 0, 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, - 0, 0); - - gtk_widget_show( GTK_WIDGET(table) ); - - gtk_object_unref(GTK_OBJECT(simple)); -} - - -static void -change_view_type (EAddressbookView *view, EAddressbookViewType view_type) -{ - if (view_type == view->view_type) - return; - - if (view->widget) { - gtk_widget_destroy (view->widget); - view->widget = NULL; - } - view->object = NULL; - - switch (view_type) { - case E_ADDRESSBOOK_VIEW_MINICARD: - create_minicard_view (view); - break; - case E_ADDRESSBOOK_VIEW_TABLE: - create_table_view (view); - break; - default: - g_warning ("view_type must be either TABLE or MINICARD\n"); - return; - } - - view->view_type = view_type; - - command_state_change (view); -} - -static void -e_contact_print_destroy(GnomeDialog *dialog, gpointer data) -{ - ETableScrolled *table = gtk_object_get_data(GTK_OBJECT(dialog), "table"); - EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable"); - gtk_object_unref(GTK_OBJECT(printable)); - gtk_object_unref(GTK_OBJECT(table)); -} - -static void -e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) -{ - GnomePrintMaster *master; - GnomePrintContext *pc; - EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable"); - GtkWidget *preview; - switch( button ) { - case GNOME_PRINT_PRINT: - master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) ); - pc = gnome_print_master_get_context( master ); - e_printable_reset(printable); - while (e_printable_data_left(printable)) { - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, 72, 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 6.5 * 72, - 5 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_master_close(master); - gnome_print_master_print(master); - gtk_object_unref(GTK_OBJECT(master)); - gnome_dialog_close(dialog); - break; - case GNOME_PRINT_PREVIEW: - master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) ); - pc = gnome_print_master_get_context( master ); - e_printable_reset(printable); - while (e_printable_data_left(printable)) { - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, 72, 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 6.5 * 72, - 9 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_master_close(master); - preview = GTK_WIDGET(gnome_print_master_preview_new(master, "Print Preview")); - gtk_widget_show_all(preview); - gtk_object_unref(GTK_OBJECT(master)); - break; - case GNOME_PRINT_CANCEL: - gnome_dialog_close(dialog); - break; - } -} - -static void -display_view(GalViewCollection *collection, - GalView *view, - gpointer data) -{ - EAddressbookView *address_view = data; - if (GAL_IS_VIEW_ETABLE(view)) { - change_view_type (address_view, E_ADDRESSBOOK_VIEW_TABLE); - e_table_set_state_object(e_table_scrolled_get_table(E_TABLE_SCROLLED(address_view->widget)), GAL_VIEW_ETABLE(view)->state); - } else if (GAL_IS_VIEW_MINICARD(view)) { - change_view_type (address_view, E_ADDRESSBOOK_VIEW_MINICARD); - } -} - -void -e_addressbook_view_setup_menus (EAddressbookView *view, - BonoboUIComponent *uic) -{ - GalViewFactory *factory; - ETableSpecification *spec; - char *galview; - - g_return_if_fail (view != NULL); - g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view)); - g_return_if_fail (uic != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic)); - g_return_if_fail (view->view_collection == NULL); - - g_assert (view->view_collection == NULL); - g_assert (view->view_menus == NULL); - - view->view_collection = gal_view_collection_new(); - - galview = gnome_util_prepend_user_home("/evolution/views/addressbook/"); - gal_view_collection_set_storage_directories(view->view_collection, - EVOLUTION_DATADIR "/evolution/views/addressbook/", - galview); - g_free(galview); - - spec = e_table_specification_new(); - e_table_specification_load_from_string(spec, SPEC); - - factory = gal_view_factory_etable_new (spec); - gtk_object_unref (GTK_OBJECT (spec)); - gal_view_collection_add_factory (view->view_collection, factory); - gtk_object_unref (GTK_OBJECT (factory)); - - factory = gal_view_factory_minicard_new (); - gal_view_collection_add_factory (view->view_collection, factory); - gtk_object_unref (GTK_OBJECT (factory)); - - gal_view_collection_load(view->view_collection); - - view->view_menus = gal_view_menus_new(view->view_collection); - gal_view_menus_apply(view->view_menus, uic, NULL); - gtk_signal_connect(GTK_OBJECT(view->view_collection), "display_view", - display_view, view); -} - -/** - * e_addressbook_view_discard_menus: - * @view: An addressbook view. - * - * Makes an addressbook view discard its GAL view menus and its views collection - * objects. This should be called when the corresponding Bonobo component is - * deactivated. - **/ -void -e_addressbook_view_discard_menus (EAddressbookView *view) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view)); - g_return_if_fail (view->view_collection); - - g_assert (view->view_collection != NULL); - g_assert (view->view_menus != NULL); - - gtk_object_unref (GTK_OBJECT (view->view_collection)); - view->view_collection = NULL; - - gtk_object_unref (GTK_OBJECT (view->view_menus)); - view->view_menus = NULL; -} - -static ESelectionModel* -get_selection_model (EAddressbookView *view) -{ - if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) - return e_minicard_view_widget_get_selection_model (E_MINICARD_VIEW_WIDGET(view->object)); - else - return E_SELECTION_MODEL(E_TABLE_SCROLLED(view->widget)->table->selection); -} - - -void -e_addressbook_view_print(EAddressbookView *view) -{ - if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) { - char *query; - EBook *book; - GtkWidget *print; - - gtk_object_get (GTK_OBJECT(view->model), - "query", &query, - "book", &book, - NULL); - print = e_contact_print_dialog_new(book, query); - g_free(query); - gtk_widget_show_all(print); - } else if (view->view_type == E_ADDRESSBOOK_VIEW_TABLE) { - GtkWidget *dialog; - EPrintable *printable; - ETable *etable; - - dialog = gnome_print_dialog_new("Print cards", GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); - gnome_print_dialog_construct_range_any(GNOME_PRINT_DIALOG(dialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_SELECTION, - NULL, NULL, NULL); - - gtk_object_get(GTK_OBJECT(view->widget), "table", &etable, NULL); - printable = e_table_get_printable(etable); - - gtk_object_ref(GTK_OBJECT(view->widget)); - - gtk_object_set_data(GTK_OBJECT(dialog), "table", view->widget); - gtk_object_set_data(GTK_OBJECT(dialog), "printable", printable); - - gtk_signal_connect(GTK_OBJECT(dialog), - "clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL); - gtk_signal_connect(GTK_OBJECT(dialog), - "destroy", GTK_SIGNAL_FUNC(e_contact_print_destroy), NULL); - gtk_widget_show(dialog); - } -} - -static void -card_deleted_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - EAddressbookView *view = user_data; - - emit_status_message (view, _("Done.")); - - if (status != E_BOOK_STATUS_SUCCESS) { - e_addressbook_error_dialog (_("Error removing card"), status); - } -} - -static void -do_remove (int i, gpointer user_data) -{ - EBook *book; - ECard *card; - EAddressbookView *view = user_data; - - gtk_object_get (GTK_OBJECT(view->model), - "book", &book, - NULL); - - card = e_addressbook_model_get_card (view->model, i); - - e_book_remove_card(book, card, card_deleted_cb, view); - - gtk_object_unref (GTK_OBJECT (card)); -} - -void -e_addressbook_view_delete_selection(EAddressbookView *view) -{ - ESelectionModel *model = get_selection_model (view); - - g_return_if_fail (model); - - emit_status_message (view, _("Removing cards...")); - - e_selection_model_foreach (model, - do_remove, - view); -} - -static void -invisible_destroyed (GtkWidget *invisible, EAddressbookView *view) -{ - view->invisible = NULL; -} - -static void -selection_get (GtkWidget *invisible, - GtkSelectionData *selection_data, - guint info, - guint time_stamp, - EAddressbookView *view) -{ - char *value; - - value = e_card_list_get_vcard(view->clipboard_cards); - - gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING, - 8, value, strlen (value)); - -} - -static void -selection_clear_event (GtkWidget *invisible, - GdkEventSelection *event, - EAddressbookView *view) -{ - if (view->clipboard_cards) { - g_list_foreach (view->clipboard_cards, (GFunc)gtk_object_unref, NULL); - g_list_free (view->clipboard_cards); - view->clipboard_cards = NULL; - } -} - -static void -selection_received (GtkWidget *invisible, - GtkSelectionData *selection_data, - guint time, - EAddressbookView *view) -{ - if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) { - return; - } - else { - /* XXX make sure selection_data->data = \0 terminated */ - GList *card_list = e_card_load_cards_from_string (selection_data->data); - GList *l; - - if (!card_list /* it wasn't a vcard list */) - return; - - for (l = card_list; l; l = l->next) { - ECard *card = l->data; - - e_card_merging_book_add_card (view->book, card, NULL /* XXX */, NULL); - } - - g_list_foreach (card_list, (GFunc)gtk_object_unref, NULL); - g_list_free (card_list); - } -} - -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_selected_cards (EAddressbookView *view) -{ - GList *list; - GList *iterator; - ESelectionModel *selection = get_selection_model (view); - - list = NULL; - e_selection_model_foreach (selection, add_to_list, &list); - - for (iterator = list; iterator; iterator = iterator->next) { - iterator->data = e_addressbook_model_card_at (view->model, GPOINTER_TO_INT (iterator->data)); - } - list = g_list_reverse (list); - return list; -} - -void -e_addressbook_view_cut (EAddressbookView *view) -{ - e_addressbook_view_copy (view); - e_addressbook_view_delete_selection (view); -} - -void -e_addressbook_view_copy (EAddressbookView *view) -{ - view->clipboard_cards = get_selected_cards (view); - - gtk_selection_owner_set (view->invisible, clipboard_atom, GDK_CURRENT_TIME); -} - -void -e_addressbook_view_paste (EAddressbookView *view) -{ - gtk_selection_convert (view->invisible, clipboard_atom, - GDK_SELECTION_TYPE_STRING, - GDK_CURRENT_TIME); -} - -void -e_addressbook_view_select_all (EAddressbookView *view) -{ - ESelectionModel *model = get_selection_model (view); - - g_return_if_fail (model); - - e_selection_model_select_all (model); -} - -void -e_addressbook_view_show_all(EAddressbookView *view) -{ - gtk_object_set(GTK_OBJECT(view), - "query", NULL, - NULL); -} - -void -e_addressbook_view_stop(EAddressbookView *view) -{ - e_addressbook_model_stop (view->model); -} - -gboolean -e_addressbook_view_can_create (EAddressbookView *view) -{ - return e_addressbook_model_editable (view->model); -} - -gboolean -e_addressbook_view_can_print (EAddressbookView *view) -{ - ESelectionModel *selection_model; - - if (!e_addressbook_model_editable (view->model)) - return FALSE; - - selection_model = get_selection_model (view); - if (selection_model == NULL) - return FALSE; - - return e_selection_model_selected_count (selection_model) != 0; -} - -gboolean -e_addressbook_view_can_delete (EAddressbookView *view) -{ - ESelectionModel *selection_model; - - if (!e_addressbook_model_editable (view->model)) - return FALSE; - - selection_model = get_selection_model (view); - if (selection_model == NULL) - return FALSE; - - return e_selection_model_selected_count (selection_model) != 0; -} - -gboolean -e_addressbook_view_can_cut (EAddressbookView *view) -{ - return (e_addressbook_view_can_copy (view) && e_addressbook_model_editable (view->model)); -} - -gboolean -e_addressbook_view_can_copy (EAddressbookView *view) -{ - ESelectionModel *selection_model; - - if (!e_addressbook_model_editable (view->model)) - return FALSE; - - selection_model = get_selection_model (view); - if (selection_model == NULL) - return FALSE; - - return e_selection_model_selected_count (selection_model) != 0; -} - -gboolean -e_addressbook_view_can_paste (EAddressbookView *view) -{ - return TRUE; -} - -gboolean -e_addressbook_view_can_select_all (EAddressbookView *view) -{ - return e_addressbook_model_card_count (view->model) != 0; -} - -gboolean -e_addressbook_view_can_stop (EAddressbookView *view) -{ - return e_addressbook_model_can_stop (view->model); -} - diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h deleted file mode 100644 index 0a594842d8..0000000000 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-addressbook-view.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_ADDRESSBOOK_VIEW_H__ -#define __E_ADDRESSBOOK_VIEW_H__ - -#include <gtk/gtktable.h> -#include <bonobo/bonobo-ui-component.h> -#include <gal/menus/gal-view-collection.h> -#include "e-addressbook-model.h" -#include "widgets/menus/gal-view-menus.h" -#include "addressbook/backend/ebook/e-book.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EAddressbookView - A card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define E_ADDRESSBOOK_VIEW_TYPE (e_addressbook_view_get_type ()) -#define E_ADDRESSBOOK_VIEW(obj) (GTK_CHECK_CAST ((obj), E_ADDRESSBOOK_VIEW_TYPE, EAddressbookView)) -#define E_ADDRESSBOOK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_ADDRESSBOOK_VIEW_TYPE, EAddressbookViewClass)) -#define E_IS_ADDRESSBOOK_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_ADDRESSBOOK_VIEW_TYPE)) -#define E_IS_ADDRESSBOOK_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_ADDRESSBOOK_VIEW_TYPE)) - -typedef enum { - E_ADDRESSBOOK_VIEW_NONE, /* initialized to this */ - E_ADDRESSBOOK_VIEW_TABLE, - E_ADDRESSBOOK_VIEW_MINICARD -} EAddressbookViewType; - - -typedef struct _EAddressbookView EAddressbookView; -typedef struct _EAddressbookViewClass EAddressbookViewClass; - -struct _EAddressbookView -{ - GtkTable parent; - - /* item specific fields */ - EAddressbookViewType view_type; - - EAddressbookModel *model; - - GtkWidget *invisible; - GList *clipboard_cards; - - EBook *book; - char *query; - guint editable : 1; - - GtkObject *object; - GtkWidget *widget; - - GtkWidget *vbox; - - /* Menus handler and the view collection */ - GalViewCollection *view_collection; - GalViewMenus *view_menus; -}; - -struct _EAddressbookViewClass -{ - GtkTableClass parent_class; - - /* - * Signals - */ - void (*status_message) (EAddressbookView *view, const gchar *message); - void (*command_state_change) (EAddressbookView *view); -}; - -GtkWidget *e_addressbook_view_new (void); -GtkType e_addressbook_view_get_type (void); - -void e_addressbook_view_setup_menus (EAddressbookView *view, - BonoboUIComponent *uic); -void e_addressbook_view_discard_menus (EAddressbookView *view); - -void e_addressbook_view_print (EAddressbookView *view); -void e_addressbook_view_delete_selection (EAddressbookView *view); -void e_addressbook_view_cut (EAddressbookView *view); -void e_addressbook_view_copy (EAddressbookView *view); -void e_addressbook_view_paste (EAddressbookView *view); -void e_addressbook_view_select_all (EAddressbookView *view); -void e_addressbook_view_show_all (EAddressbookView *view); -void e_addressbook_view_stop (EAddressbookView *view); - -gboolean e_addressbook_view_can_create (EAddressbookView *view); -gboolean e_addressbook_view_can_print (EAddressbookView *view); -gboolean e_addressbook_view_can_delete (EAddressbookView *view); -gboolean e_addressbook_view_can_cut (EAddressbookView *view); -gboolean e_addressbook_view_can_copy (EAddressbookView *view); -gboolean e_addressbook_view_can_paste (EAddressbookView *view); -gboolean e_addressbook_view_can_select_all (EAddressbookView *view); -gboolean e_addressbook_view_can_stop (EAddressbookView *view); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_ADDRESSBOOK_VIEW_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-control.c b/addressbook/gui/widgets/e-minicard-control.c deleted file mode 100644 index 94f762560f..0000000000 --- a/addressbook/gui/widgets/e-minicard-control.c +++ /dev/null @@ -1,336 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-control.c - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright 1999, 2000, Ximian, Inc. - */ - -#include <config.h> - -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-persist.h> -#include <bonobo/bonobo-persist-stream.h> -#include <bonobo/bonobo-stream-client.h> -#include <addressbook/backend/ebook/e-book.h> -#include <addressbook/backend/ebook/e-card.h> - -#include "e-minicard-control.h" -#include "e-minicard-widget.h" -#include "e-card-merging.h" - -#if 0 -enum { - PROP_RUNNING -} MyArgs; - -#define RUNNING_KEY "Clock::Running" - -static void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - GtkObject *clock = user_data; - - switch (arg_id) { - - case PROP_RUNNING: - { - gboolean b = GPOINTER_TO_UINT (gtk_object_get_data (clock, RUNNING_KEY)); - BONOBO_ARG_SET_BOOLEAN (arg, b); - break; - } - - default: - g_warning ("Unhandled arg %d", arg_id); - break; - } -} - -static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - GtkClock *clock = user_data; - - switch (arg_id) { - - case PROP_RUNNING: - { - guint i; - - i = BONOBO_ARG_GET_BOOLEAN (arg); - - if (i) - gtk_clock_start (clock); - else - gtk_clock_stop (clock); - - gtk_object_set_data (GTK_OBJECT (clock), RUNNING_KEY, - GUINT_TO_POINTER (i)); - break; - } - - default: - g_warning ("Unhandled arg %d", arg_id); - break; - } -} -#endif - -/* - * Bonobo::PersistStream - * - * These two functions implement the Bonobo::PersistStream load and - * save methods which allow data to be loaded into and out of the - * BonoboObject. - */ -static char * -stream_read (Bonobo_Stream stream) -{ - Bonobo_Stream_iobuf *buffer; - CORBA_Environment ev; - char *data = NULL; - gint length = 0; - - CORBA_exception_init (&ev); - do { -#define READ_CHUNK_SIZE 65536 - Bonobo_Stream_read (stream, READ_CHUNK_SIZE, - &buffer, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - CORBA_exception_free (&ev); - return NULL; - } - - if (buffer->_length <= 0) - break; - - data = g_realloc (data, length + buffer->_length + 1); - - memcpy (data + length, buffer->_buffer, buffer->_length); - - length += buffer->_length; - - CORBA_free (buffer); - } while (1); - - CORBA_free (buffer); - CORBA_exception_free (&ev); - - if (data) - data[length] = '\0'; - else - data = g_strdup(""); - - return data; -} /* stream_read */ - -/* - * This function implements the Bonobo::PersistStream:load method. - */ -static void -pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, - Bonobo_Persist_ContentType type, void *data, - CORBA_Environment *ev) -{ - ECard *card; - char *vcard; - GtkWidget *minicard = data; - - if (type && g_strcasecmp (type, "text/vCard") != 0 && - g_strcasecmp (type, "text/x-vCard") != 0) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Bonobo_Persist_WrongDataType, NULL); - return; - } - - if ((vcard = stream_read (stream)) == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Bonobo_Persist_FileNotFound, NULL); - return; - } - - card = e_card_new(vcard); - g_free(vcard); - gtk_object_set(GTK_OBJECT(minicard), - "card", card, - NULL); - gtk_object_unref(GTK_OBJECT(card)); -} /* pstream_load */ - -/* - * This function implements the Bonobo::PersistStream:save method. - */ -static void -pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream, - Bonobo_Persist_ContentType type, void *data, - CORBA_Environment *ev) -{ - char *vcard; - ECard *card; - EMinicardWidget *minicard = data; - int length; - - if (type && g_strcasecmp (type, "text/vCard") != 0 && - g_strcasecmp (type, "text/x-vCard") != 0) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Bonobo_Persist_WrongDataType, NULL); - return; - } - - gtk_object_get (GTK_OBJECT (minicard), - "card", &card, - NULL); - vcard = e_card_get_vcard(card); - length = strlen (vcard); - bonobo_stream_client_write (stream, vcard, length, ev); - g_free (vcard); -} /* pstream_save */ - -static CORBA_long -pstream_get_max_size (BonoboPersistStream *ps, void *data, - CORBA_Environment *ev) -{ - GtkWidget *minicard = data; - ECard *card; - char *vcard; - gint length; - - gtk_object_get (GTK_OBJECT (minicard), - "card", &card, NULL); - vcard = e_card_get_vcard(card); - length = strlen (vcard); - g_free (vcard); - - return length; -} - -static Bonobo_Persist_ContentTypeList * -pstream_get_content_types (BonoboPersistStream *ps, void *closure, - CORBA_Environment *ev) -{ - return bonobo_persist_generate_content_types (2, "text/vCard", "text/x-vCard"); -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - ECard *card = closure; - e_card_merging_book_add_card(book, card, NULL, NULL); - gtk_object_unref(GTK_OBJECT(card)); -} - -static void -save_in_addressbook(GtkWidget *button, EMinicardWidget *minicard) -{ - EBook *book; - gchar *path, *uri; - ECard *card; - - book = e_book_new (); - - if (!book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - __FUNCTION__); - return; - } - - - path = g_concat_dir_and_file (g_get_home_dir (), - "evolution/local/Contacts/addressbook.db"); - uri = g_strdup_printf ("file://%s", path); - g_free (path); - - gtk_object_get(GTK_OBJECT(minicard), - "card", &card, - NULL); - gtk_object_ref(GTK_OBJECT(card)); - - if (! e_book_load_uri (book, uri, book_open_cb, card)) { - printf ("error calling load_uri!\n"); - } - g_free(uri); -} - -static BonoboObject * -e_minicard_control_factory (BonoboGenericFactory *Factory, void *closure) -{ -#if 0 - BonoboPropertyBag *pb; -#endif - BonoboControl *control; - BonoboPersistStream *stream; - GtkWidget *minicard; - GtkWidget *button; - GtkWidget *vbox; - - /* Create the control. */ - - minicard = e_minicard_widget_new (); - gtk_widget_show (minicard); - - button = gtk_button_new_with_label(_("Save in addressbook")); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(save_in_addressbook), minicard); - gtk_widget_show (button); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), minicard, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); - gtk_widget_show (vbox); - - control = bonobo_control_new (vbox); - - stream = bonobo_persist_stream_new (pstream_load, pstream_save, - pstream_get_max_size, - pstream_get_content_types, - minicard); - -#if 0 - /* Create the properties. */ - pb = bonobo_property_bag_new (get_prop, set_prop, clock); - bonobo_control_set_properties (control, pb); - - bonobo_property_bag_add (pb, "running", PROP_RUNNING, - BONOBO_ARG_BOOLEAN, NULL, - "Whether or not the clock is running", 0); -#endif - - if (stream == NULL) { - bonobo_object_unref (BONOBO_OBJECT (control)); - return NULL; - } - - bonobo_object_add_interface (BONOBO_OBJECT (control), - BONOBO_OBJECT (stream)); - - return BONOBO_OBJECT (control); -} - -void -e_minicard_control_factory_init (void) -{ - static BonoboGenericFactory *factory = NULL; - - if (factory != NULL) - return; - - factory = - bonobo_generic_factory_new ( - "OAFIID:GNOME_Evolution_Addressbook_MiniCard_ControlFactory", - e_minicard_control_factory, NULL); - - if (factory == NULL) - g_error ("I could not register a EMinicard control factory."); -} diff --git a/addressbook/gui/widgets/e-minicard-control.h b/addressbook/gui/widgets/e-minicard-control.h deleted file mode 100644 index 4a0da88435..0000000000 --- a/addressbook/gui/widgets/e-minicard-control.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __E_MINICARD_CONTROL_H__ -#define __E_MINICARD_CONTROL_H__ - -#include <bonobo/bonobo-control.h> - -void e_minicard_control_factory_init (void); - -#endif /* __E_MINICARD_CONTROL_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c deleted file mode 100644 index cdb16ef68d..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.c +++ /dev/null @@ -1,457 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-label.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gtk/gtksignal.h> -#include <libgnomeui/gnome-canvas-rect-ellipse.h> -#include <gal/util/e-util.h> -#include <gal/e-text/e-text.h> -#include <gal/widgets/e-canvas.h> -#include <gal/widgets/e-canvas-utils.h> -#include "e-minicard-label.h" - -static void e_minicard_label_init (EMinicardLabel *card); -static void e_minicard_label_class_init (EMinicardLabelClass *klass); -static void e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_minicard_label_realize (GnomeCanvasItem *item); -static void e_minicard_label_unrealize (GnomeCanvasItem *item); -static void e_minicard_label_reflow(GnomeCanvasItem *item, int flags); - -static void e_minicard_label_resize_children( EMinicardLabel *e_minicard_label ); - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WIDTH, - ARG_HEIGHT, - ARG_HAS_FOCUS, - ARG_FIELD, - ARG_FIELDNAME, - ARG_TEXT_MODEL, - ARG_MAX_FIELD_NAME_WIDTH, - ARG_EDITABLE -}; - -GtkType -e_minicard_label_get_type (void) -{ - static GtkType minicard_label_type = 0; - - if (!minicard_label_type) - { - static const GtkTypeInfo minicard_label_info = - { - "EMinicardLabel", - sizeof (EMinicardLabel), - sizeof (EMinicardLabelClass), - (GtkClassInitFunc) e_minicard_label_class_init, - (GtkObjectInitFunc) e_minicard_label_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - minicard_label_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_label_info); - } - - return minicard_label_type; -} - -static void -e_minicard_label_class_init (EMinicardLabelClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("EMinicardLabel::width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("EMinicardLabel::height", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_HEIGHT); - gtk_object_add_arg_type ("EMinicardLabel::has_focus", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_HAS_FOCUS); - gtk_object_add_arg_type ("EMinicardLabel::field", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_FIELD); - gtk_object_add_arg_type ("EMinicardLabel::fieldname", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_FIELDNAME); - gtk_object_add_arg_type ("EMinicardLabel::text_model", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_TEXT_MODEL); - gtk_object_add_arg_type ("EMinicardLabel::max_field_name_length", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_MAX_FIELD_NAME_WIDTH); - gtk_object_add_arg_type ("EMinicardLabel::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - - object_class->set_arg = e_minicard_label_set_arg; - object_class->get_arg = e_minicard_label_get_arg; - /* object_class->destroy = e_minicard_label_destroy; */ - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_label_realize; - item_class->unrealize = e_minicard_label_unrealize; - item_class->event = e_minicard_label_event; -} - -static void -e_minicard_label_init (EMinicardLabel *minicard_label) -{ - minicard_label->width = 10; - minicard_label->height = 10; - minicard_label->rect = NULL; - minicard_label->fieldname = NULL; - minicard_label->field = NULL; - - minicard_label->max_field_name_length = -1; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow); -} - -static void -e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicardLabel *e_minicard_label; - - item = GNOME_CANVAS_ITEM (o); - e_minicard_label = E_MINICARD_LABEL (o); - - switch (arg_id){ - case ARG_WIDTH: - e_minicard_label->width = GTK_VALUE_DOUBLE (*arg); - e_minicard_label_resize_children(e_minicard_label); - e_canvas_item_request_reflow (item); - break; - case ARG_HAS_FOCUS: - if (e_minicard_label->field && (GTK_VALUE_ENUM(*arg) != E_FOCUS_NONE)) - e_canvas_item_grab_focus(e_minicard_label->field, FALSE); - break; - case ARG_FIELD: - gnome_canvas_item_set( e_minicard_label->field, "text", GTK_VALUE_STRING (*arg), NULL ); - break; - case ARG_FIELDNAME: - gnome_canvas_item_set( e_minicard_label->fieldname, "text", GTK_VALUE_STRING (*arg), NULL ); - break; - case ARG_TEXT_MODEL: - gnome_canvas_item_set( e_minicard_label->field, "model", GTK_VALUE_OBJECT (*arg), NULL); - break; - case ARG_MAX_FIELD_NAME_WIDTH: - e_minicard_label->max_field_name_length = GTK_VALUE_DOUBLE (*arg); - break; - case ARG_EDITABLE: - e_minicard_label->editable = GTK_VALUE_BOOL (*arg); - gtk_object_set (GTK_OBJECT (e_minicard_label->field), "editable", e_minicard_label->editable, NULL); - break; - } -} - -static void -e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardLabel *e_minicard_label; - char *temp; - ETextModel *tempmodel; - - e_minicard_label = E_MINICARD_LABEL (object); - - switch (arg_id) { - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->height; - break; - case ARG_HAS_FOCUS: - GTK_VALUE_ENUM (*arg) = e_minicard_label->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE; - break; - case ARG_FIELD: - gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL ); - GTK_VALUE_STRING (*arg) = temp; - break; - case ARG_FIELDNAME: - gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL ); - GTK_VALUE_STRING (*arg) = temp; - break; - case ARG_TEXT_MODEL: - gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "model", &tempmodel, NULL ); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(tempmodel); - break; - case ARG_MAX_FIELD_NAME_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->max_field_name_length; - break; - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = e_minicard_label->editable; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_label_realize (GnomeCanvasItem *item) -{ - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) - (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item); - - e_canvas_item_request_reflow(item); - - if (!item->canvas->aa) - { - } -} - -void -e_minicard_label_construct (GnomeCanvasItem *item) -{ - EMinicardLabel *e_minicard_label; - GnomeCanvasGroup *group; - GdkFont *font; - - font = ((GtkWidget *) item->canvas)->style->font; - - e_minicard_label = E_MINICARD_LABEL (item); - group = GNOME_CANVAS_GROUP( item ); - - e_minicard_label->rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) e_minicard_label->width - 1, - "y2", (double) e_minicard_label->height - 1, - "outline_color", NULL, - NULL ); - e_minicard_label->fieldname = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "font_gdk", font, - "fill_color", "black", - "draw_background", FALSE, - NULL ); - e_canvas_item_move_absolute(e_minicard_label->fieldname, 2, 1); - - e_minicard_label->field = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "font_gdk", font, - "fill_color", "black", - "editable", e_minicard_label->editable, - "draw_background", FALSE, - NULL ); - e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1); - - e_canvas_item_request_reflow(item); -} - -static void -e_minicard_label_unrealize (GnomeCanvasItem *item) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (item); - - if (!item->canvas->aa) - { - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) - (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item); -} - -static gboolean -e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (item); - - switch( event->type ) - { - case GDK_FOCUS_CHANGE: - { - GdkEventFocus *focus_event = (GdkEventFocus *) event; - if ( focus_event->in ) - { - gnome_canvas_item_set( e_minicard_label->rect, - "outline_color", "grey50", - "fill_color", "grey90", - NULL ); - e_minicard_label->has_focus = TRUE; - } - else - { - gnome_canvas_item_set( e_minicard_label->rect, - "outline_color", NULL, - "fill_color", NULL, - NULL ); - e_minicard_label->has_focus = FALSE; - } - } - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_MOTION_NOTIFY: - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: { - gboolean return_val; -#if 0 - GnomeCanvasItem *field; - ArtPoint p; - double inv[6], affine[6]; - - field = e_minicard_label->field; - art_affine_identity (affine); - - if (field->xform != NULL) { - if (field->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { - art_affine_multiply (affine, affine, field->xform); - } else { - affine[4] += field->xform[0]; - affine[5] += field->xform[1]; - } - } - - art_affine_invert (inv, affine); - switch(event->type) { - case GDK_MOTION_NOTIFY: - p.x = event->motion.x; - p.y = event->motion.y; - art_affine_point (&p, &p, inv); - event->motion.x = p.x; - event->motion.y = p.y; - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - p.x = event->button.x; - p.y = event->button.y; - art_affine_point (&p, &p, inv); - event->button.x = p.x; - event->button.y = p.y; - break; - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: - p.x = event->crossing.x; - p.y = event->crossing.y; - art_affine_point (&p, &p, inv); - event->crossing.x = p.x; - event->crossing.y = p.y; - break; - default: - break; - } -#endif - gtk_signal_emit_by_name(GTK_OBJECT(e_minicard_label->field), "event", event, &return_val); - return return_val; - break; - } - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_minicard_label_resize_children(EMinicardLabel *e_minicard_label) -{ - double left_width; - if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length)) - left_width = e_minicard_label->max_field_name_length; - else - left_width = e_minicard_label->width / 2 - 4; - - gnome_canvas_item_set( e_minicard_label->fieldname, - "clip_width", (double) ( left_width ), - NULL ); - gnome_canvas_item_set( e_minicard_label->field, - "clip_width", (double) ( e_minicard_label->width - 8 - left_width ), - NULL ); -} - -static void -e_minicard_label_reflow(GnomeCanvasItem *item, int flags) -{ - EMinicardLabel *e_minicard_label = E_MINICARD_LABEL(item); - - gint old_height; - gdouble text_height; - gdouble left_width; - - old_height = e_minicard_label->height; - - gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname), - "text_height", &text_height, - NULL); - - e_minicard_label->height = text_height; - - - gtk_object_get(GTK_OBJECT(e_minicard_label->field), - "text_height", &text_height, - NULL); - - if (e_minicard_label->height < text_height) - e_minicard_label->height = text_height; - e_minicard_label->height += 3; - - gnome_canvas_item_set( e_minicard_label->rect, - "x2", (double) e_minicard_label->width - 1, - "y2", (double) e_minicard_label->height - 1, - NULL ); - - if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length)) - left_width = e_minicard_label->max_field_name_length; - else - left_width = e_minicard_label->width / 2 - 4; - - e_canvas_item_move_absolute(e_minicard_label->field, left_width + 6, 1); - - if (old_height != e_minicard_label->height) - e_canvas_item_request_parent_reflow(item); -} - -GnomeCanvasItem * -e_minicard_label_new(GnomeCanvasGroup *parent) -{ - GnomeCanvasItem *item = gnome_canvas_item_new(parent, e_minicard_label_get_type(), NULL); - e_minicard_label_construct(item); - return item; -} - diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h deleted file mode 100644 index eed6e1da21..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-label.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_LABEL_H__ -#define __E_MINICARD_LABEL_H__ - -#include <glib.h> -#include <libgnomeui/gnome-canvas.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicardLabel - A label doing focus with non-marching ants. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the label - * height double R height of the label - * field string RW text in the field label - * fieldname string RW text in the fieldname label - */ - -#define E_MINICARD_LABEL_TYPE (e_minicard_label_get_type ()) -#define E_MINICARD_LABEL(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_LABEL_TYPE, EMinicardLabel)) -#define E_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_LABEL_TYPE, EMiniCardLabelClass)) -#define E_IS_MINICARD_LABEL(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_LABEL_TYPE)) -#define E_IS_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_LABEL_TYPE)) - - -typedef struct _EMinicardLabel EMinicardLabel; -typedef struct _EMinicardLabelClass EMinicardLabelClass; - -struct _EMinicardLabel -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - double width; - double height; - double max_field_name_length; - guint editable : 1; - GnomeCanvasItem *fieldname; - GnomeCanvasItem *field; - GnomeCanvasItem *rect; - - gboolean has_focus; -}; - -struct _EMinicardLabelClass -{ - GnomeCanvasGroupClass parent_class; -}; - - -GtkType e_minicard_label_get_type (void); -GnomeCanvasItem *e_minicard_label_new(GnomeCanvasGroup *parent); -void e_minicard_label_construct (GnomeCanvasItem *item); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_LABEL_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c deleted file mode 100644 index e01ec2cbb0..0000000000 --- a/addressbook/gui/widgets/e-minicard-view-widget.c +++ /dev/null @@ -1,343 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-view-widget.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <gtk/gtksignal.h> -#include <libgnomeui/gnome-canvas-rect-ellipse.h> -#include <gal/widgets/e-canvas.h> - -#include "e-minicard-view-widget.h" - -static void e_minicard_view_widget_init (EMinicardViewWidget *widget); -static void e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass); -static void e_minicard_view_widget_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_view_widget_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_minicard_view_widget_destroy (GtkObject *object); -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 ECanvasClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY, - ARG_EDITABLE -}; - -enum { - SELECTION_CHANGE, - LAST_SIGNAL -}; - -static guint e_minicard_view_widget_signals [LAST_SIGNAL] = {0, }; - -GtkType -e_minicard_view_widget_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GtkTypeInfo info = - { - "EMinicardViewWidget", - sizeof (EMinicardViewWidget), - sizeof (EMinicardViewWidgetClass), - (GtkClassInitFunc) e_minicard_view_widget_class_init, - (GtkObjectInitFunc) e_minicard_view_widget_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (e_canvas_get_type (), &info); - } - - return type; -} - -static void -e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - ECanvasClass *canvas_class; - - object_class = (GtkObjectClass*) klass; - widget_class = GTK_WIDGET_CLASS (klass); - canvas_class = E_CANVAS_CLASS (klass); - - parent_class = gtk_type_class (e_canvas_get_type ()); - - gtk_object_add_arg_type ("EMinicardViewWidget::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EMinicardViewWidget::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - gtk_object_add_arg_type ("EMinicardViewWidget::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - - e_minicard_view_widget_signals [SELECTION_CHANGE] = - gtk_signal_new ("selection_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EMinicardViewWidgetClass, selection_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_minicard_view_widget_signals, LAST_SIGNAL); - - object_class->set_arg = e_minicard_view_widget_set_arg; - object_class->get_arg = e_minicard_view_widget_get_arg; - object_class->destroy = e_minicard_view_widget_destroy; - - widget_class->realize = e_minicard_view_widget_realize; - widget_class->size_allocate = e_minicard_view_widget_size_allocate; - - canvas_class->reflow = e_minicard_view_widget_reflow; -} - -static void -e_minicard_view_widget_init (EMinicardViewWidget *view) -{ - view->emv = NULL; - view->rect = NULL; - - view->book = NULL; - view->query = NULL; - view->editable = FALSE; -} - -GtkWidget * -e_minicard_view_widget_new (EAddressbookReflowAdapter *adapter) -{ - EMinicardViewWidget *widget = E_MINICARD_VIEW_WIDGET (gtk_type_new (e_minicard_view_widget_get_type ())); - - widget->adapter = adapter; - gtk_object_ref (GTK_OBJECT (widget->adapter)); - - return GTK_WIDGET (widget); -} - -static void -e_minicard_view_widget_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EMinicardViewWidget *emvw; - - emvw = E_MINICARD_VIEW_WIDGET (o); - - switch (arg_id){ - case ARG_BOOK: - if (emvw->book) - gtk_object_unref(GTK_OBJECT(emvw->book)); - if (GTK_VALUE_OBJECT (*arg)) { - emvw->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - if (emvw->book) - gtk_object_ref(GTK_OBJECT(emvw->book)); - } else - emvw->book = NULL; - if (emvw->emv) - gtk_object_set(GTK_OBJECT(emvw->emv), - "book", emvw->book, - NULL); - break; - case ARG_QUERY: - emvw->query = g_strdup(GTK_VALUE_STRING (*arg)); - if (emvw->emv) - gtk_object_set(GTK_OBJECT(emvw->emv), - "query", emvw->query, - NULL); - break; - case ARG_EDITABLE: - emvw->editable = GTK_VALUE_BOOL(*arg); - if (emvw->emv) - gtk_object_set (GTK_OBJECT(emvw->emv), - "editable", emvw->editable, - NULL); - break; - } -} - -static void -e_minicard_view_widget_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardViewWidget *emvw; - - emvw = E_MINICARD_VIEW_WIDGET (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(emvw->book); - break; - case ARG_QUERY: - GTK_VALUE_STRING (*arg) = g_strdup(emvw->query); - break; - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = emvw->editable; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_view_widget_destroy (GtkObject *object) -{ - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(object); - - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - g_free(view->query); - - gtk_object_unref (GTK_OBJECT (view->adapter)); - - GTK_OBJECT_CLASS(parent_class)->destroy (object); -} - -static void -e_minicard_view_widget_realize (GtkWidget *widget) -{ - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget); - - view->rect = gnome_canvas_item_new( - gnome_canvas_root( GNOME_CANVAS(view) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - - view->emv = gnome_canvas_item_new( - gnome_canvas_root( GNOME_CANVAS(view) ), - e_minicard_view_get_type(), - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - - gtk_object_set(GTK_OBJECT(view->emv), - "adapter", view->adapter, - NULL); - - gtk_signal_connect (GTK_OBJECT (E_REFLOW(view->emv)->selection), - "selection_changed", - selection_change, view); - - if (GTK_WIDGET_CLASS(parent_class)->realize) - GTK_WIDGET_CLASS(parent_class)->realize (widget); -} - -static void -e_minicard_view_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) -{ - if (GTK_WIDGET_CLASS(parent_class)->size_allocate) - GTK_WIDGET_CLASS(parent_class)->size_allocate (widget, allocation); - - if (GTK_WIDGET_REALIZED(widget)) { - double width; - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget); - - gnome_canvas_item_set( view->emv, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( view->emv, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(view->emv), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region (GNOME_CANVAS (view), 0, 0, width - 1, allocation->height - 1); - gnome_canvas_item_set( view->rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); - } -} - -static void -e_minicard_view_widget_reflow(ECanvas *canvas) -{ - double width; - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(canvas); - - if (E_CANVAS_CLASS(parent_class)->reflow) - E_CANVAS_CLASS(parent_class)->reflow (canvas); - - gtk_object_get(GTK_OBJECT(view->emv), - "width", &width, - NULL); - width = MAX(width, GTK_WIDGET(canvas)->allocation.width); - gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas), 0, 0, width - 1, GTK_WIDGET(canvas)->allocation.height - 1); - gnome_canvas_item_set( view->rect, - "x2", (double) width, - "y2", (double) GTK_WIDGET(canvas)->allocation.height, - NULL ); -} - -static void -selection_change (ESelectionModel *esm, EMinicardViewWidget *widget) -{ - gtk_signal_emit (GTK_OBJECT(widget), - e_minicard_view_widget_signals [SELECTION_CHANGE], widget); -} - -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, - char letter) -{ - if (view->emv) - e_minicard_view_jump_to_letter(E_MINICARD_VIEW(view->emv), letter); -} - -ESelectionModel * -e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view) -{ - if (view->emv) - return E_SELECTION_MODEL (E_REFLOW (view->emv)->selection); - else - return NULL; -} diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h deleted file mode 100644 index 61d5912dd5..0000000000 --- a/addressbook/gui/widgets/e-minicard-view-widget.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view-widget.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_VIEW_WIDGET_H__ -#define __E_MINICARD_VIEW_WIDGET_H__ - -#include <gal/widgets/e-canvas.h> -#include "addressbook/backend/ebook/e-book.h" -#include "e-minicard-view.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_MINICARD_VIEW_WIDGET_TYPE (e_minicard_view_widget_get_type ()) -#define E_MINICARD_VIEW_WIDGET(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_VIEW_WIDGET_TYPE, EMinicardViewWidget)) -#define E_MINICARD_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_VIEW_WIDGET_TYPE, EMinicardViewWidgetClass)) -#define E_IS_MINICARD_VIEW_WIDGET(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_VIEW_WIDGET_TYPE)) -#define E_IS_MINICARD_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_VIEW_WIDGET_TYPE)) - - -typedef struct _EMinicardViewWidget EMinicardViewWidget; -typedef struct _EMinicardViewWidgetClass EMinicardViewWidgetClass; - -struct _EMinicardViewWidget -{ - ECanvas parent; - - GnomeCanvasItem *rect; - GnomeCanvasItem *emv; - - EAddressbookReflowAdapter *adapter; - - EBook *book; - char *query; - guint editable : 1; -}; - -struct _EMinicardViewWidgetClass -{ - ECanvasClass parent_class; - void (*selection_change) (EMinicardViewWidget*); -}; - -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, - char letter); -GtkWidget *e_minicard_view_widget_new (EAddressbookReflowAdapter *adapter); - -ESelectionModel *e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_MINICARD_VIEW_WIDGET_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c deleted file mode 100644 index 4a3925d75b..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.c +++ /dev/null @@ -1,441 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-view.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include "e-minicard-view.h" - -#include "e-addressbook-util.h" - -#include <gtk/gtkselection.h> -#include <gtk/gtkdnd.h> -#include <gal/widgets/e-canvas.h> -#include <gal/widgets/e-unicode.h> -#include <libgnome/gnome-i18n.h> - -static void e_minicard_view_drag_data_get(GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - EMinicardView *view); - -static EReflowClass *parent_class = NULL; -#define PARENT_TYPE (E_REFLOW_TYPE) - -/* The arguments we take */ -enum { - ARG_0, - ARG_ADAPTER, - ARG_BOOK, - ARG_QUERY, - ARG_EDITABLE -}; - -enum DndTargetType { - DND_TARGET_TYPE_VCARD_LIST, -}; -#define VCARD_LIST_TYPE "text/x-vcard" -static GtkTargetEntry drag_types[] = { - { VCARD_LIST_TYPE, 0, DND_TARGET_TYPE_VCARD_LIST } -}; -static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]); - -static void -e_minicard_view_drag_data_get(GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - EMinicardView *view) -{ - if (!E_IS_MINICARD_VIEW(view)) - return; - - switch (info) { - case DND_TARGET_TYPE_VCARD_LIST: { - char *value; - - value = e_card_list_get_vcard(view->drag_list); - - gtk_selection_data_set (selection_data, - selection_data->target, - 8, - value, strlen (value)); - break; - } - } - - g_list_foreach (view->drag_list, (GFunc)gtk_object_unref, NULL); - g_list_free (view->drag_list); - 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) -{ - GdkDragContext *context; - GtkTargetList *target_list; - GdkDragAction actions = GDK_ACTION_MOVE; - - view->drag_list = get_card_list (adapter, E_REFLOW (view)->selection); - - g_print ("dragging %d card(s)\n", g_list_length (view->drag_list)); - - target_list = gtk_target_list_new (drag_types, num_drag_types); - - context = gtk_drag_begin (GTK_WIDGET (GNOME_CANVAS_ITEM (view)->canvas), - target_list, actions, 1/*XXX*/, event); - - if (!view->canvas_drag_data_get_id) - view->canvas_drag_data_get_id = gtk_signal_connect (GTK_OBJECT (GNOME_CANVAS_ITEM (view)->canvas), - "drag_data_get", - GTK_SIGNAL_FUNC (e_minicard_view_drag_data_get), - view); - - gtk_drag_set_icon_default (context); - - return TRUE; -} - -static void -adapter_changed (EMinicardView *view) -{ - char *empty_message; - - empty_message = e_utf8_from_locale_string(_("\n\nThere are no items to show in this view\n\n" - "Double-click here to create a new Contact.")); - gtk_object_set (GTK_OBJECT(view), - "empty_message", empty_message, - NULL); - - gtk_signal_connect (GTK_OBJECT (view->adapter), "drag_begin", - GTK_SIGNAL_FUNC (e_minicard_view_drag_begin), view); - - g_free (empty_message); -} - -static void -e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicardView *view; - - item = GNOME_CANVAS_ITEM (o); - view = E_MINICARD_VIEW (o); - - switch (arg_id){ - case ARG_ADAPTER: - if (view->adapter) - gtk_object_unref (GTK_OBJECT(view->adapter)); - view->adapter = GTK_VALUE_POINTER (*arg); - gtk_object_ref (GTK_OBJECT (view->adapter)); - adapter_changed (view); - gtk_object_set (GTK_OBJECT (view), - "model", view->adapter, - NULL); - break; - case ARG_BOOK: - gtk_object_set (GTK_OBJECT (view->adapter), - "book", GTK_VALUE_OBJECT (*arg), - NULL); - break; - case ARG_QUERY: - gtk_object_set (GTK_OBJECT (view->adapter), - "query", GTK_VALUE_STRING (*arg), - NULL); - break; - case ARG_EDITABLE: - gtk_object_set (GTK_OBJECT (view->adapter), - "editable", GTK_VALUE_BOOL (*arg), - NULL); - break; - } -} - -static void -e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardView *view; - - view = E_MINICARD_VIEW (object); - - switch (arg_id) { - case ARG_ADAPTER: - GTK_VALUE_POINTER (*arg) = view->adapter; - break; - case ARG_BOOK: - gtk_object_get (GTK_OBJECT (view->adapter), - "book", >K_VALUE_OBJECT (*arg), - NULL); - break; - case ARG_QUERY: - gtk_object_get (GTK_OBJECT (view->adapter), - "query", >K_VALUE_STRING (*arg), - NULL); - break; - case ARG_EDITABLE: - gtk_object_get (GTK_OBJECT (view->adapter), - "editable", >K_VALUE_BOOL (*arg), - NULL); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_view_destroy (GtkObject *object) -{ - EMinicardView *view = E_MINICARD_VIEW(object); - - if (view->canvas_drag_data_get_id) { - gtk_signal_disconnect (GTK_OBJECT (GNOME_CANVAS_ITEM (view)->canvas), - view->canvas_drag_data_get_id); - } - gtk_object_unref (GTK_OBJECT (view->adapter)); - - GTK_OBJECT_CLASS(parent_class)->destroy (object); -} - -static gboolean -e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardView *view; - - view = E_MINICARD_VIEW (item); - - switch( event->type ) { - case GDK_2BUTTON_PRESS: - if (((GdkEventButton *)event)->button == 1) - { - EBook *book; - gboolean editable; - - gtk_object_get(GTK_OBJECT(view), "book", &book, NULL); - gtk_object_get(GTK_OBJECT(view->adapter), "editable", &editable, NULL); - - g_assert (E_IS_BOOK (book)); - - e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, editable); - } - return TRUE; - default: - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event) - return GNOME_CANVAS_ITEM_CLASS(parent_class)->event(item, event); - else - return FALSE; - break; - } -} - -static gint -e_minicard_view_selection_event (EReflow *reflow, GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardView *view; - int return_val = FALSE; - - view = E_MINICARD_VIEW (reflow); - if (parent_class->selection_event) { - return_val = parent_class->selection_event (reflow, item, event); - } - - switch (event->type) { - case GDK_BUTTON_PRESS: - if (event->button.button == 3) { - return_val = e_addressbook_reflow_adapter_right_click (view->adapter, event, reflow->selection); - } - break; - default: - break; - } - return return_val; -} - -typedef struct { - EMinicardView *view; - EBookCallback cb; - gpointer closure; -} ViewCbClosure; - -static void -do_remove (int i, gpointer user_data) -{ - EBook *book; - ECard *card; - ViewCbClosure *viewcbclosure = user_data; - EMinicardView *view = viewcbclosure->view; - EBookCallback cb = viewcbclosure->cb; - gpointer closure = viewcbclosure->closure; - - gtk_object_get (GTK_OBJECT(view->adapter), - "book", &book, - NULL); - - card = e_addressbook_reflow_adapter_get_card (view->adapter, i); - - e_book_remove_card(book, card, cb, closure); - - 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_letter(EMinicard *card, char *letter) -{ - g_return_val_if_fail(card != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(card), 0); - - if (*letter == '1') - return 1; - - if (card->card) { - char *file_as; - gtk_object_get(GTK_OBJECT(card->card), - "file_as", &file_as, - NULL); - if (file_as) - return strncasecmp(file_as, letter, 1); - else - return 0; - } else { - return 0; - } -} -#endif - - - -void -e_minicard_view_jump_to_letter (EMinicardView *view, - char letter) -{ -#if 0 - e_reflow_sorted_jump(E_REFLOW_SORTED(view), - (GCompareFunc) compare_to_letter, - &letter); -#endif -} - -static void -e_minicard_view_class_init (EMinicardViewClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - EReflowClass *reflow_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - reflow_class = (EReflowClass *) klass; - - parent_class = gtk_type_class (PARENT_TYPE); - - gtk_object_add_arg_type ("EMinicardView::adapter", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_ADAPTER); - gtk_object_add_arg_type ("EMinicardView::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EMinicardView::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - gtk_object_add_arg_type ("EMinicardView::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - - 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; - - item_class->event = e_minicard_view_event; - - reflow_class->selection_event = e_minicard_view_selection_event; - /* GnomeCanvasItem method overrides */ -} - -static void -e_minicard_view_init (EMinicardView *view) -{ - view->adapter = NULL; - view->canvas_drag_data_get_id = 0; -} - -GtkType -e_minicard_view_get_type (void) -{ - static GtkType reflow_type = 0; - - if (!reflow_type) { - static const GtkTypeInfo reflow_info = { - "EMinicardView", - sizeof (EMinicardView), - sizeof (EMinicardViewClass), - (GtkClassInitFunc) e_minicard_view_class_init, - (GtkObjectInitFunc) e_minicard_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - reflow_type = gtk_type_unique (PARENT_TYPE, &reflow_info); - } - - return reflow_type; -} diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h deleted file mode 100644 index 5c7065fe1d..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_VIEW_H__ -#define __E_MINICARD_VIEW_H__ - -#include "e-minicard.h" - -#include <gal/widgets/e-reflow.h> -#include <gal/widgets/e-selection-model-simple.h> -#include "addressbook/backend/ebook/e-book.h" -#include "e-addressbook-reflow-adapter.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicardView - A canvas item container. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * book EBook RW book to query - * query string RW query string - * - * From EReflowSorted: (you should really know what you're doing if you set these.) - * compare_func GCompareFunc RW compare function - * string_func EReflowStringFunc RW string function - * - * From EReflow: - * minimum_width double RW minimum width of the reflow. width >= minimum_width - * width double R width of the reflow - * height double RW height of the reflow - */ - -#define E_MINICARD_VIEW_TYPE (e_minicard_view_get_type ()) -#define E_MINICARD_VIEW(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_VIEW_TYPE, EMinicardView)) -#define E_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_VIEW_TYPE, EMinicardViewClass)) -#define E_IS_MINICARD_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_VIEW_TYPE)) -#define E_IS_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_VIEW_TYPE)) - - -typedef struct _EMinicardView EMinicardView; -typedef struct _EMinicardViewClass EMinicardViewClass; - -struct _EMinicardView -{ - EReflow parent; - - EAddressbookReflowAdapter *adapter; - - /* item specific fields */ - - ESelectionModelSimple *selection; - - GList *drag_list; - - int canvas_destroy_id; - int canvas_drag_data_get_id; - - int status_message_id; -}; - -struct _EMinicardViewClass -{ - EReflowClass parent_class; -}; - -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, - char letter); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_VIEW_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-widget-test.c b/addressbook/gui/widgets/e-minicard-widget-test.c deleted file mode 100644 index 603f86b556..0000000000 --- a/addressbook/gui/widgets/e-minicard-widget-test.c +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard.c - * - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"ORG:Ximian, Inc. -" \ -"TITLE:Head Geek -" \ -"ROLE:Programmer/Executive -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@ximian.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - -#include "config.h" -#include <gtk/gtkmain.h> -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-init.h> -#include "e-minicard-widget.h" - -/* This is a horrible thing to do, but it is just a test. */ - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey <clahey@umich.edu>", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Widget Test" ), VERSION, - _( "Copyright (C) 2000, Ximian, Inc." ), - authors, - _( "This should test the minicard widget" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *minicard; - ECard *card; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Minicard Widget Test", VERSION, argc, argv); - app = gnome_app_new("Minicard Widget Test", NULL); - - minicard = e_minicard_widget_new(); - card = e_card_new(TEST_VCARD); - gtk_object_set(GTK_OBJECT(minicard), - "card", card, - NULL); - - gnome_app_set_contents( GNOME_APP( app ), minicard ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/widgets/e-minicard-widget.c b/addressbook/gui/widgets/e-minicard-widget.c deleted file mode 100644 index 1a8912e19d..0000000000 --- a/addressbook/gui/widgets/e-minicard-widget.c +++ /dev/null @@ -1,250 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-table-field-chooser.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <libgnomeui/gnome-canvas-rect-ellipse.h> -#include "e-minicard-widget.h" -#include "e-minicard.h" - -static void e_minicard_widget_init (EMinicardWidget *card); -static void e_minicard_widget_class_init (EMinicardWidgetClass *klass); -static void e_minicard_widget_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_widget_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_minicard_widget_destroy (GtkObject *object); -static void e_minicard_widget_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void e_minicard_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void e_minicard_widget_reflow (ECanvas *canvas); - -static ECanvasClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_CARD, -}; - -GtkType -e_minicard_widget_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GtkTypeInfo info = - { - "EMinicardWidget", - sizeof (EMinicardWidget), - sizeof (EMinicardWidgetClass), - (GtkClassInitFunc) e_minicard_widget_class_init, - (GtkObjectInitFunc) e_minicard_widget_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (e_canvas_get_type (), &info); - } - - return type; -} - -static void -e_minicard_widget_class_init (EMinicardWidgetClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - ECanvasClass *ecanvas_class; - - object_class = GTK_OBJECT_CLASS(klass); - widget_class = GTK_WIDGET_CLASS(klass); - ecanvas_class = E_CANVAS_CLASS(klass); - - parent_class = gtk_type_class (e_canvas_get_type ()); - - object_class->set_arg = e_minicard_widget_set_arg; - object_class->get_arg = e_minicard_widget_get_arg; - object_class->destroy = e_minicard_widget_destroy; - - widget_class->size_request = e_minicard_widget_size_request; - widget_class->size_allocate = e_minicard_widget_size_allocate; - - ecanvas_class->reflow = e_minicard_widget_reflow; - - gtk_object_add_arg_type ("EMinicardWidget::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); -} - -static void -e_minicard_widget_size_request(GtkWidget *widget, GtkRequisition *requisition) -{ - double height; - EMinicardWidget *emw = E_MINICARD_WIDGET(widget); - gtk_object_get(GTK_OBJECT(emw->item), - "height", &height, - NULL); - if (height <= 0) - height = 1; - widget->requisition.height = height; - widget->requisition.width = 200; - requisition->height = height; - requisition->width = 200; -} - -static void -e_minicard_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) -{ - double height; - EMinicardWidget *emw = E_MINICARD_WIDGET(widget); - gnome_canvas_item_set( emw->item, - "width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(emw->item), - "height", &height, - NULL); - height = MAX(height, allocation->height); - gnome_canvas_set_scroll_region(GNOME_CANVAS( emw ), 0, 0, allocation->width - 1, height - 1); - gnome_canvas_item_set( emw->rect, - "x2", (double) allocation->width, - "y2", (double) height, - NULL ); - if (GTK_WIDGET_CLASS(parent_class)->size_allocate) - GTK_WIDGET_CLASS(parent_class)->size_allocate(widget, allocation); -} - -static void e_minicard_widget_reflow(ECanvas *canvas) -{ - double height; - EMinicardWidget *emw = E_MINICARD_WIDGET(canvas); - gtk_object_get(GTK_OBJECT(emw->item), - "height", &height, - NULL); - - height = MAX(height, GTK_WIDGET(emw)->allocation.height); - - gnome_canvas_set_scroll_region (GNOME_CANVAS(emw), 0, 0, GTK_WIDGET(emw)->allocation.width - 1, height - 1); - gnome_canvas_item_set( emw->rect, - "x2", (double) GTK_WIDGET(emw)->allocation.width, - "y2", (double) height, - NULL ); - - gtk_widget_queue_resize(GTK_WIDGET(canvas)); -} - -static void -e_minicard_widget_init (EMinicardWidget *emw) -{ - emw->rect = gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(emw)), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - - emw->item = gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(emw)), - e_minicard_get_type(), - "width", (double) 100, - NULL ); - - gnome_canvas_set_scroll_region ( GNOME_CANVAS( emw ), - 0, 0, - 100, 100 ); - - emw->card = NULL; -} - -static void -e_minicard_widget_destroy (GtkObject *object) -{ - EMinicardWidget *emw = E_MINICARD_WIDGET(object); - - if (emw->card) - gtk_object_unref(GTK_OBJECT(emw->card)); - - if (GTK_OBJECT_CLASS(parent_class)->destroy) - GTK_OBJECT_CLASS(parent_class)->destroy(object); -} - -GtkWidget* -e_minicard_widget_new (void) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_minicard_widget_get_type ())); - return widget; -} - -static void -e_minicard_widget_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardWidget *emw = E_MINICARD_WIDGET(object); - gpointer ptr; - - switch (arg_id){ - case ARG_CARD: - ptr = GTK_VALUE_POINTER (*arg); - e_minicard_widget_set_card (emw, ptr ? E_CARD (ptr) : NULL); - break; - default: - break; - } -} - -static void -e_minicard_widget_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardWidget *emw = E_MINICARD_WIDGET(object); - - switch (arg_id) { - case ARG_CARD: - if (emw->card) - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(emw->card); - else - GTK_VALUE_OBJECT (*arg) = NULL; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -void -e_minicard_widget_set_card (EMinicardWidget *emw, ECard *card) -{ - g_return_if_fail (emw && E_IS_MINICARD_WIDGET (emw)); - g_return_if_fail (card == NULL || E_IS_CARD (card)); - - if (card != emw->card) { - - if (emw->card) - gtk_object_unref (GTK_OBJECT (emw->card)); - - emw->card = card; - - if (emw->card) - gtk_object_ref (GTK_OBJECT (emw->card)); - - if (emw->item) - gtk_object_set (GTK_OBJECT (emw->item), - "card", emw->card, - NULL); - } -} diff --git a/addressbook/gui/widgets/e-minicard-widget.h b/addressbook/gui/widgets/e-minicard-widget.h deleted file mode 100644 index 6daf7f6fa3..0000000000 --- a/addressbook/gui/widgets/e-minicard-widget.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-widget.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_WIDGET_H__ -#define __E_MINICARD_WIDGET_H__ - -#include <gal/widgets/e-canvas.h> -#include "addressbook/backend/ebook/e-card.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicardWidget - A card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define E_MINICARD_WIDGET_TYPE (e_minicard_widget_get_type ()) -#define E_MINICARD_WIDGET(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_WIDGET_TYPE, EMinicardWidget)) -#define E_MINICARD_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_WIDGET_TYPE, EMinicardWidgetClass)) -#define E_IS_MINICARD_WIDGET(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_WIDGET_TYPE)) -#define E_IS_MINICARD_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_WIDGET_TYPE)) - - -typedef struct _EMinicardWidget EMinicardWidget; -typedef struct _EMinicardWidgetClass EMinicardWidgetClass; - -struct _EMinicardWidget -{ - ECanvas parent; - - /* item specific fields */ - GnomeCanvasItem *item; - - GnomeCanvasItem *rect; - ECard *card; -}; - -struct _EMinicardWidgetClass -{ - ECanvasClass parent_class; -}; - - -GtkWidget *e_minicard_widget_new(void); -GtkType e_minicard_widget_get_type (void); - -void e_minicard_widget_set_card (EMinicardWidget *, ECard *); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_WIDGET_H__ */ diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c deleted file mode 100644 index 123392df95..0000000000 --- a/addressbook/gui/widgets/e-minicard.c +++ /dev/null @@ -1,926 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <glib.h> -#include <gtk/gtkdnd.h> -#include <gdk/gdkkeysyms.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-canvas-rect-ellipse.h> -#include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include <gal/e-text/e-text.h> -#include <gal/util/e-util.h> -#include <gal/widgets/e-canvas-utils.h> -#include <gal/widgets/e-canvas.h> -#include "addressbook/backend/ebook/e-book.h" -#include "e-addressbook-util.h" -#include "e-minicard.h" -#include "e-minicard-label.h" -#include "e-minicard-view.h" -#include "e-contact-editor.h" -#include "e-card-merging.h" - -static void e_minicard_init (EMinicard *card); -static void e_minicard_class_init (EMinicardClass *klass); -static void e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_minicard_destroy (GtkObject *object); -static void e_minicard_finalize (GtkObject *object); -static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_minicard_realize (GnomeCanvasItem *item); -static void e_minicard_unrealize (GnomeCanvasItem *item); -static void e_minicard_reflow ( GnomeCanvasItem *item, int flags ); - -static void e_minicard_resize_children( EMinicard *e_minicard ); -static void remodel( EMinicard *e_minicard ); - -static gint e_minicard_drag_begin (EMinicard *minicard, GdkEvent *event); - -static GnomeCanvasGroupClass *parent_class = NULL; - -typedef struct _EMinicardField EMinicardField; - -struct _EMinicardField { - ECardSimpleField field; - GnomeCanvasItem *label; -}; - -#define LIST_ICON_FILENAME "contact-is-a-list.png" - -#define E_MINICARD_FIELD(field) ((EMinicardField *)(field)) - -static void -e_minicard_field_destroy(EMinicardField *field) -{ - gtk_object_destroy(GTK_OBJECT(field->label)); - g_free(field); -} - -/* The arguments we take */ -enum { - ARG_0, - ARG_WIDTH, - ARG_HEIGHT, - ARG_HAS_FOCUS, - ARG_SELECTED, - ARG_EDITABLE, - ARG_CARD -}; - -enum { - SELECTED, - DRAG_BEGIN, - LAST_SIGNAL -}; - -static guint e_minicard_signals [LAST_SIGNAL] = {0, }; - -GtkType -e_minicard_get_type (void) -{ - static GtkType minicard_type = 0; - - if (!minicard_type) - { - static const GtkTypeInfo minicard_info = - { - "EMinicard", - sizeof (EMinicard), - sizeof (EMinicardClass), - (GtkClassInitFunc) e_minicard_class_init, - (GtkObjectInitFunc) e_minicard_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - minicard_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_info); - } - - return minicard_type; -} - -static void -e_minicard_class_init (EMinicardClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("EMinicard::width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("EMinicard::height", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_HEIGHT); - gtk_object_add_arg_type ("EMinicard::has_focus", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_HAS_FOCUS); - gtk_object_add_arg_type ("EMinicard::selected", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_SELECTED); - gtk_object_add_arg_type ("EMinicard::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); - - e_minicard_signals [SELECTED] = - gtk_signal_new ("selected", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EMinicardClass, selected), - gtk_marshal_INT__POINTER, - GTK_TYPE_INT, 1, GTK_TYPE_POINTER); - - e_minicard_signals [DRAG_BEGIN] = - gtk_signal_new ("drag_begin", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EMinicardClass, drag_begin), - gtk_marshal_INT__POINTER, - GTK_TYPE_INT, 1, GTK_TYPE_POINTER); - - gtk_object_class_add_signals (object_class, e_minicard_signals, LAST_SIGNAL); - - object_class->set_arg = e_minicard_set_arg; - object_class->get_arg = e_minicard_get_arg; - object_class->destroy = e_minicard_destroy; - object_class->finalize = e_minicard_finalize; - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_realize; - item_class->unrealize = e_minicard_unrealize; - item_class->event = e_minicard_event; - - klass->selected = NULL; -} - -static void -e_minicard_init (EMinicard *minicard) -{ - /* minicard->card = NULL;*/ - minicard->rect = NULL; - minicard->fields = NULL; - minicard->width = 10; - minicard->height = 10; - minicard->has_focus = FALSE; - minicard->selected = FALSE; - minicard->editable = FALSE; - - minicard->card = NULL; - minicard->simple = e_card_simple_new(NULL); - - minicard->list_icon_pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_IMAGESDIR "/" LIST_ICON_FILENAME); - minicard->list_icon_size = gdk_pixbuf_get_height (minicard->list_icon_pixbuf); - - minicard->editor = NULL; - - minicard->changed = FALSE; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow); -} - -static void -set_selected (EMinicard *minicard, gboolean selected) -{ - GtkWidget *canvas = GTK_WIDGET(GNOME_CANVAS_ITEM(minicard)->canvas); - if (selected) { - gnome_canvas_item_set (minicard->rect, - "outline_color_gdk", &canvas->style->bg[GTK_STATE_NORMAL], - NULL); - gnome_canvas_item_set (minicard->header_rect, - "fill_color_gdk", &canvas->style->bg[GTK_STATE_SELECTED], - NULL); - gnome_canvas_item_set (minicard->header_text, - "fill_color_gdk", &canvas->style->text[GTK_STATE_SELECTED], - NULL); - } else { - gnome_canvas_item_set (minicard->rect, - "outline_color", NULL, - NULL); - gnome_canvas_item_set (minicard->header_rect, - "fill_color_gdk", &canvas->style->bg[GTK_STATE_NORMAL], - NULL); - gnome_canvas_item_set (minicard->header_text, - "fill_color_gdk", &canvas->style->fg[GTK_STATE_NORMAL], - NULL); - } - minicard->selected = selected; -} - - -static void -e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicard *e_minicard; - GList *l; - - item = GNOME_CANVAS_ITEM (o); - e_minicard = E_MINICARD (o); - - switch (arg_id){ - case ARG_WIDTH: - if (e_minicard->width != GTK_VALUE_DOUBLE (*arg)) { - e_minicard->width = GTK_VALUE_DOUBLE (*arg); - e_minicard_resize_children(e_minicard); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) - e_canvas_item_request_reflow(item); - } - break; - case ARG_HAS_FOCUS: - if (e_minicard->fields) { - if ( GTK_VALUE_ENUM(*arg) == E_FOCUS_START || - GTK_VALUE_ENUM(*arg) == E_FOCUS_CURRENT) { - gnome_canvas_item_set(E_MINICARD_FIELD(e_minicard->fields->data)->label, - "has_focus", GTK_VALUE_ENUM(*arg), - NULL); - } else if ( GTK_VALUE_ENUM(*arg) == E_FOCUS_END ) { - gnome_canvas_item_set(E_MINICARD_FIELD(g_list_last(e_minicard->fields)->data)->label, - "has_focus", GTK_VALUE_ENUM(*arg), - NULL); - } - } - else - e_canvas_item_grab_focus(item, FALSE); - break; - case ARG_SELECTED: - if (e_minicard->selected != GTK_VALUE_BOOL(*arg)) - set_selected (e_minicard, GTK_VALUE_BOOL(*arg)); - break; - case ARG_EDITABLE: - e_minicard->editable = GTK_VALUE_BOOL(*arg); - for (l = e_minicard->fields; l; l = l->next) - gtk_object_set (GTK_OBJECT (E_MINICARD_FIELD (l->data)->label), - "editable", e_minicard->editable, - NULL); - break; - case ARG_CARD: - if (e_minicard->card) - gtk_object_unref (GTK_OBJECT(e_minicard->card)); - e_minicard->card = E_CARD(GTK_VALUE_OBJECT (*arg)); - if (e_minicard->card) - gtk_object_ref (GTK_OBJECT(e_minicard->card)); - gtk_object_set(GTK_OBJECT(e_minicard->simple), - "card", e_minicard->card, - NULL); - remodel(e_minicard); - e_canvas_item_request_reflow(item); - e_minicard->changed = FALSE; - break; - } -} - -static void -e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (object); - - switch (arg_id) { - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_minicard->height; - break; - case ARG_HAS_FOCUS: - GTK_VALUE_ENUM (*arg) = e_minicard->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE; - break; - case ARG_SELECTED: - GTK_VALUE_BOOL (*arg) = e_minicard->selected; - break; - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = e_minicard->editable; - break; - case ARG_CARD: - e_card_simple_sync_card(e_minicard->simple); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->card); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_destroy (GtkObject *object) -{ - EMinicard *e_minicard; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_MINICARD (object)); - - e_minicard = E_MINICARD (object); - - g_list_foreach(e_minicard->fields, (GFunc) e_minicard_field_destroy, NULL); - g_list_free(e_minicard->fields); - - gdk_pixbuf_unref (e_minicard->list_icon_pixbuf); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -static void -e_minicard_finalize (GtkObject *object) -{ - EMinicard *e_minicard; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_MINICARD (object)); - - e_minicard = E_MINICARD (object); - - if (e_minicard->card) - gtk_object_unref (GTK_OBJECT(e_minicard->card)); - if (e_minicard->simple) - gtk_object_unref (GTK_OBJECT(e_minicard->simple)); - - if (GTK_OBJECT_CLASS (parent_class)->finalize) - (* GTK_OBJECT_CLASS (parent_class)->finalize) (object); -} - -static void -e_minicard_realize (GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - GnomeCanvasGroup *group; - GtkWidget *canvas; - - e_minicard = E_MINICARD (item); - group = GNOME_CANVAS_GROUP( item ); - canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item)->canvas); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item); - - e_minicard->rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) e_minicard->width - 1, - "y2", (double) e_minicard->height - 1, - "outline_color", NULL, - NULL ); - - e_minicard->header_rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 2, - "y1", (double) 2, - "x2", (double) e_minicard->width - 3, - "y2", (double) e_minicard->height - 3, - "fill_color_gdk", &canvas->style->bg[GTK_STATE_NORMAL], - NULL ); - - e_minicard->header_text = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "width", (double) ( e_minicard->width - 12 ), - "clip", TRUE, - "use_ellipsis", TRUE, -#if 0 - "font", "fixed-bold-10", -#endif - "fill_color_gdk", &canvas->style->fg[GTK_STATE_NORMAL], - "text", "", - "draw_background", FALSE, - NULL ); - - e_canvas_item_move_absolute(e_minicard->header_text, 6, 6); - - e_minicard->list_icon = - gnome_canvas_item_new ( group, - gnome_canvas_pixbuf_get_type(), - "pixbuf", e_minicard->list_icon_pixbuf, - NULL); - - remodel(e_minicard); - e_canvas_item_request_reflow(item); - - if (!item->canvas->aa) { - } -} - -static void -e_minicard_unrealize (GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (item); - - if (!item->canvas->aa) - { - } - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item); -} - -static void -card_modified_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__); - if (status != E_BOOK_STATUS_SUCCESS) - e_addressbook_error_dialog (_("Error modifying card"), status); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (GtkObject *editor, gpointer data) -{ - EMinicard *minicard = data; - gtk_object_unref (GTK_OBJECT (editor)); - minicard->editor = NULL; -} - -static gboolean -e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicard *e_minicard; - GtkWidget *canvas; - - e_minicard = E_MINICARD (item); - canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item)->canvas); - - switch( event->type ) { - case GDK_FOCUS_CHANGE: - { - GdkEventFocus *focus_event = (GdkEventFocus *) event; - if (focus_event->in) { - if (!e_minicard->selected) { - e_minicard_selected(e_minicard, event); - } - } else { - EBook *book = NULL; - - if (e_minicard->changed) { - - e_card_simple_sync_card(e_minicard->simple); - - if (E_IS_MINICARD_VIEW(GNOME_CANVAS_ITEM(e_minicard)->parent)) { - - gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(e_minicard)->parent), - "book", &book, - NULL); - - } - - if (book) { - - /* Add the card in the contact editor to our ebook */ - e_card_merging_book_commit_card (book, - e_minicard->card, - card_modified_cb, - NULL); - } else { - remodel(e_minicard); - e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(e_minicard)); - } - e_minicard->changed = FALSE; - } - e_minicard->has_focus = FALSE; - } - } - break; - case GDK_BUTTON_PRESS: - if (event->button.button == 1) { - int ret_val = e_minicard_selected(e_minicard, event); - e_canvas_item_grab_focus(item, TRUE); - e_minicard->button_x = event->button.x; - e_minicard->button_y = event->button.y; - e_minicard->drag_button_down = TRUE; - return ret_val; - } else if (event->button.button == 3) { - return e_minicard_selected(e_minicard, event); - } - break; - case GDK_BUTTON_RELEASE: - e_minicard->drag_button_down = FALSE; - break; - case GDK_MOTION_NOTIFY: - /* shamelessly ripped from e-table.c, complete with - broken stuck-grab behavior */ - if (e_minicard->drag_button_down && event->motion.state & GDK_BUTTON1_MASK) { - if (MAX (abs (e_minicard->button_x - event->motion.x), - abs (e_minicard->button_y - event->motion.y)) > 3) { - gint ret_val = e_minicard_drag_begin(e_minicard, event); - - printf ("signalled drag begin\n"); - - e_minicard->drag_button_down = FALSE; - - return ret_val; - } - } - break; - case GDK_2BUTTON_PRESS: - if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { - if (e_minicard->editor) { - if (e_card_evolution_list (e_minicard->card)) - e_contact_list_editor_raise (E_CONTACT_LIST_EDITOR(e_minicard->editor)); - else - e_contact_editor_raise(E_CONTACT_EDITOR(e_minicard->editor)); - } else { - EBook *book = NULL; - if (E_IS_MINICARD_VIEW(item->parent)) { - gtk_object_get(GTK_OBJECT(item->parent), - "book", &book, - NULL); - } - - if (book != NULL) { - if (e_card_evolution_list (e_minicard->card)) { - EContactListEditor *editor = e_addressbook_show_contact_list_editor (book, e_minicard->card, - FALSE, e_minicard->editable); - e_minicard->editor = GTK_OBJECT (editor); - } - else { - EContactEditor *editor = e_addressbook_show_contact_editor (book, e_minicard->card, - FALSE, e_minicard->editable); - e_minicard->editor = GTK_OBJECT (editor); - } - gtk_object_ref (e_minicard->editor); - - gtk_signal_connect (e_minicard->editor, "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), e_minicard); - - } - } - return TRUE; - } - break; - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Tab || - event->key.keyval == GDK_KP_Tab || - event->key.keyval == GDK_ISO_Left_Tab) { - GList *list; - for (list = e_minicard->fields; list; list = list->next) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - EFocus has_focus; - gtk_object_get(GTK_OBJECT(item), - "has_focus", &has_focus, - NULL); - if (has_focus != E_FOCUS_NONE) { - if (event->key.state & GDK_SHIFT_MASK) - list = list->prev; - else - list = list->next; - if (list) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - gnome_canvas_item_set(item, - "has_focus", (event->key.state & GDK_SHIFT_MASK) ? E_FOCUS_END : E_FOCUS_START, - NULL); - return 1; - } else { - return 0; - } - } - } - } - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_minicard_resize_children( EMinicard *e_minicard ) -{ - GList *list; - - if (e_minicard->header_text) { - gnome_canvas_item_set( e_minicard->header_text, - "width", ((double) e_minicard->width - 12 - - (e_card_evolution_list (e_minicard->card) ? e_minicard->list_icon_size : 0.0)), - NULL ); - } - if (e_minicard->list_icon) { - e_canvas_item_move_absolute(e_minicard->list_icon, - e_minicard->width - e_minicard->list_icon_size - 3, - 3); - } - for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { - gnome_canvas_item_set( E_MINICARD_FIELD( list->data )->label, - "width", (double) e_minicard->width - 4.0, - NULL ); - } -} - -static void -field_changed (EText *text, EMinicard *e_minicard) -{ - ECardSimpleType type; - char *string; - - type = GPOINTER_TO_INT - (gtk_object_get_data(GTK_OBJECT(text), - "EMinicard:field")); - gtk_object_get(GTK_OBJECT(text), - "text", &string, - NULL); - e_card_simple_set(e_minicard->simple, - type, - string); - g_free(string); - e_minicard->changed = TRUE; -} - -static void -add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width) -{ - GnomeCanvasItem *new_item; - GnomeCanvasGroup *group; - ECardSimpleType type; - EMinicardField *minicard_field; - char *name; - char *string; - - group = GNOME_CANVAS_GROUP( e_minicard ); - - type = e_card_simple_type(e_minicard->simple, field); - name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field)); - string = e_card_simple_get(e_minicard->simple, field); - - /* Magically convert embedded XML into an address. */ - if (!strncmp (string, "<?xml", 4)) { - EDestination *dest = e_destination_import (string); - if (dest != NULL) { - gchar *new_string = g_strdup (e_destination_get_address (dest)); - g_free (string); - string = new_string; - gtk_object_unref (GTK_OBJECT (dest)); - } - } - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4.0, - "fieldname", name, - "field", string, - "max_field_name_length", left_width, - "editable", e_minicard->editable, - NULL ); - gtk_signal_connect(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field), - "changed", GTK_SIGNAL_FUNC(field_changed), e_minicard); - gtk_object_set_data(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field), - "EMinicard:field", - GINT_TO_POINTER(field)); - - minicard_field = g_new(EMinicardField, 1); - minicard_field->field = field; - minicard_field->label = new_item; - - e_minicard->fields = g_list_append( e_minicard->fields, minicard_field); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); - g_free(name); - g_free(string); -} - -static gdouble -get_left_width(EMinicard *e_minicard) -{ - gchar *name; - ECardSimpleField field; - gdouble width = -1; - GdkFont *font; - - font = ((GtkWidget *) ((GnomeCanvasItem *) e_minicard)->canvas)->style->font; - - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) { - gdouble this_width; - name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field)); - this_width = gdk_text_width(font, name, strlen(name)); - if (width < this_width) - width = this_width; - g_free(name); - } - return width; -} - -static void -remodel( EMinicard *e_minicard ) -{ - int count = 0; - if ( !(GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED) ) - return; - if (e_minicard->simple) { - ECardSimpleField field; - GList *list; - char *file_as; - gdouble left_width = -1; - - if (e_minicard->header_text) { - file_as = e_card_simple_get(e_minicard->simple, E_CARD_SIMPLE_FIELD_FILE_AS); - gnome_canvas_item_set( e_minicard->header_text, - "text", file_as ? file_as : "", - NULL ); - g_free(file_as); - } - - if ( e_card_evolution_list (e_minicard->card) ) { - gnome_canvas_item_show (e_minicard->list_icon); - } - else { - gnome_canvas_item_hide (e_minicard->list_icon); - } - - list = e_minicard->fields; - e_minicard->fields = NULL; - - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST - 2 && count < 5; field++) { - EMinicardField *minicard_field = NULL; - - if (field == E_CARD_SIMPLE_FIELD_FAMILY_NAME) - continue; - - if (list) - minicard_field = list->data; - if (minicard_field && minicard_field->field == field) { - GList *this_list = list; - char *string; - - string = e_card_simple_get(e_minicard->simple, field); - if (string && *string) { - e_minicard->fields = g_list_append(e_minicard->fields, minicard_field); - gtk_object_set(GTK_OBJECT(minicard_field->label), - "field", string, - NULL); - count ++; - } else { - e_minicard_field_destroy(minicard_field); - } - list = g_list_remove_link(list, this_list); - g_list_free_1(this_list); - g_free(string); - } else { - char *string; - if (left_width == -1) { - left_width = get_left_width(e_minicard); - } - - string = e_card_simple_get(e_minicard->simple, field); - if (string && *string) { - add_field(e_minicard, field, left_width); - count++; - } - g_free(string); - } - } - - g_list_foreach(list, (GFunc) e_minicard_field_destroy, NULL); - g_list_free(list); - } -} - -static void -e_minicard_reflow( GnomeCanvasItem *item, int flags ) -{ - EMinicard *e_minicard = E_MINICARD(item); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - gdouble text_height; - gint old_height; - - old_height = e_minicard->height; - - gtk_object_get( GTK_OBJECT( e_minicard->header_text ), - "text_height", &text_height, - NULL ); - - e_minicard->height = text_height + 10.0; - - gnome_canvas_item_set( e_minicard->header_rect, - "y2", text_height + 9.0, - NULL ); - - for(list = e_minicard->fields; list; list = g_list_next(list)) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - gtk_object_get (GTK_OBJECT(item), - "height", &text_height, - NULL); - e_canvas_item_move_absolute(item, 2, e_minicard->height); - e_minicard->height += text_height; - } - e_minicard->height += 2; - - gnome_canvas_item_set( e_minicard->rect, - "y2", (double) e_minicard->height - 1, - NULL ); - - gnome_canvas_item_set( e_minicard->rect, - "x2", (double) e_minicard->width - 1.0, - "y2", (double) e_minicard->height - 1.0, - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "x2", (double) e_minicard->width - 3.0, - NULL ); - - if (old_height != e_minicard->height) - e_canvas_item_request_parent_reflow(item); - } -} - -const char * -e_minicard_get_card_id (EMinicard *minicard) -{ - g_return_val_if_fail(minicard != NULL, NULL); - g_return_val_if_fail(E_IS_MINICARD(minicard), NULL); - - if (minicard->card) { - return e_card_get_id(minicard->card); - } else { - return ""; - } -} - -int -e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2) -{ - g_return_val_if_fail(minicard1 != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(minicard1), 0); - g_return_val_if_fail(minicard2 != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(minicard2), 0); - - if (minicard1->card && minicard2->card) { - char *file_as1, *file_as2; - gtk_object_get(GTK_OBJECT(minicard1->card), - "file_as", &file_as1, - NULL); - gtk_object_get(GTK_OBJECT(minicard2->card), - "file_as", &file_as2, - NULL); - if (file_as1 && file_as2) - return strcasecmp(file_as1, file_as2); - if (file_as1) - return -1; - if (file_as2) - return 1; - return strcmp(e_minicard_get_card_id(minicard1), e_minicard_get_card_id(minicard2)); - } else { - return 0; - } -} - -int -e_minicard_selected (EMinicard *minicard, GdkEvent *event) -{ - gint ret_val = 0; - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (minicard); - if (item->parent) { - guint signal_id = gtk_signal_lookup ("selection_event", GTK_OBJECT_TYPE (item->parent)); - /* We should probably check the signature here, but I - * don't think it's worth the time required to code - * it. - */ - if (signal_id != 0) { - gtk_signal_emit(GTK_OBJECT(item->parent), - signal_id, - item, event, &ret_val); - } - } - return ret_val; -} - -static gint -e_minicard_drag_begin (EMinicard *minicard, GdkEvent *event) -{ - gint ret_val = 0; - gtk_signal_emit (GTK_OBJECT(minicard), - e_minicard_signals[DRAG_BEGIN], - event, &ret_val); - return ret_val; -} diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h deleted file mode 100644 index 5a0f590c23..0000000000 --- a/addressbook/gui/widgets/e-minicard.h +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_H__ -#define __E_MINICARD_H__ - -#include <libgnomeui/gnome-canvas.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include "addressbook/gui/contact-editor/e-contact-editor.h" -#include "addressbook/backend/ebook/e-card.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicard - A small card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the card - * height double R height of the card - * card ECard* RW Pointer to the ECard - */ - -#define E_MINICARD_TYPE (e_minicard_get_type ()) -#define E_MINICARD(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_TYPE, EMinicard)) -#define E_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_TYPE, EMinicardClass)) -#define E_IS_MINICARD(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_TYPE)) -#define E_IS_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_TYPE)) - - -typedef struct _EMinicard EMinicard; -typedef struct _EMinicardClass EMinicardClass; -typedef enum _EMinicardFocusType EMinicardFocusType; - -enum _EMinicardFocusType { - E_MINICARD_FOCUS_TYPE_START, - E_MINICARD_FOCUS_TYPE_END -}; - -struct _EMinicard -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - ECard *card; - ECardSimple *simple; - - GnomeCanvasItem *rect; - GnomeCanvasItem *header_rect; - GnomeCanvasItem *header_text; - GnomeCanvasItem *list_icon; - - GdkPixbuf *list_icon_pixbuf; - double list_icon_size; - - GtkObject *editor; - - GList *fields; /* Of type EMinicardField */ - guint needs_remodeling : 1; - - guint changed : 1; - - guint selected : 1; - - guint has_focus : 1; - - guint editable : 1; - - guint drag_button_down : 1; - - gint button_x; - gint button_y; - - double width; - double height; -}; - -struct _EMinicardClass -{ - GnomeCanvasGroupClass parent_class; - - gint (* selected) (EMinicard *minicard, GdkEvent *event); - gint (* drag_begin) (EMinicard *minicard, GdkEvent *event); -}; - - -GtkType e_minicard_get_type (void); -const char *e_minicard_get_card_id (EMinicard *minicard); -int e_minicard_compare (EMinicard *minicard1, - EMinicard *minicard2); - -int e_minicard_selected (EMinicard *minicard, - GdkEvent *event); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_H__ */ diff --git a/addressbook/gui/widgets/gal-view-factory-minicard.c b/addressbook/gui/widgets/gal-view-factory-minicard.c deleted file mode 100644 index 10e13d9bdf..0000000000 --- a/addressbook/gui/widgets/gal-view-factory-minicard.c +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory-minicard.c: A View Factory - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#include <config.h> -#include <glib.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-i18n.h> -#include "gal-view-factory-minicard.h" -#include "gal-view-minicard.h" - -#define GVFE_CLASS(e) ((GalViewFactoryMinicardClass *)((GtkObject *)e)->klass) - -#define PARENT_TYPE gal_view_factory_get_type () - -static GalViewFactoryClass *gal_view_factory_minicard_parent_class; - -static const char * -gal_view_factory_minicard_get_title (GalViewFactory *factory) -{ - return _("Card View"); -} - -static GalView * -gal_view_factory_minicard_new_view (GalViewFactory *factory, - const char *name) -{ - return gal_view_minicard_new(name); -} - -static const char * -gal_view_factory_minicard_get_type_code (GalViewFactory *factory) -{ - return "minicard"; -} - -static void -gal_view_factory_minicard_destroy (GtkObject *object) -{ -#if 0 - GalViewFactoryMinicard *factory = GAL_VIEW_FACTORY_MINICARD(object); -#endif -} - -static void -gal_view_factory_minicard_class_init (GtkObjectClass *object_class) -{ - GalViewFactoryClass *view_factory_class = GAL_VIEW_FACTORY_CLASS(object_class); - gal_view_factory_minicard_parent_class = gtk_type_class (PARENT_TYPE); - - view_factory_class->get_title = gal_view_factory_minicard_get_title; - view_factory_class->new_view = gal_view_factory_minicard_new_view; - view_factory_class->get_type_code = gal_view_factory_minicard_get_type_code; - - object_class->destroy = gal_view_factory_minicard_destroy; -} - -static void -gal_view_factory_minicard_init (GalViewFactoryMinicard *factory) -{ -} - -/** - * gal_view_minicard_new - * - * A new GalViewFactory for creating Minicard views. Create one of - * these and pass it to GalViewCollection for use. - * - * Returns: The new GalViewFactoryMinicard. - */ -GalViewFactory * -gal_view_factory_minicard_new (void) -{ - return gal_view_factory_minicard_construct (gtk_type_new (gal_view_factory_minicard_get_type ())); -} - -/** - * gal_view_minicard_construct - * @factory: The factory to construct - * - * constructs the GalViewFactoryMinicard. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewFactoryMinicard. - */ -GalViewFactory * -gal_view_factory_minicard_construct (GalViewFactoryMinicard *factory) -{ - return GAL_VIEW_FACTORY(factory); -} - -GtkType -gal_view_factory_minicard_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "GalViewFactoryMinicard", - sizeof (GalViewFactoryMinicard), - sizeof (GalViewFactoryMinicardClass), - (GtkClassInitFunc) gal_view_factory_minicard_class_init, - (GtkObjectInitFunc) gal_view_factory_minicard_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} diff --git a/addressbook/gui/widgets/gal-view-factory-minicard.h b/addressbook/gui/widgets/gal-view-factory-minicard.h deleted file mode 100644 index 3816fdba46..0000000000 --- a/addressbook/gui/widgets/gal-view-factory-minicard.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory-minicard.c: A View Factory - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#ifndef _GAL_VIEW_FACTORY_MINICARD_H_ -#define _GAL_VIEW_FACTORY_MINICARD_H_ - -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view-factory.h> - -#define GAL_VIEW_FACTORY_MINICARD_TYPE (gal_view_factory_minicard_get_type ()) -#define GAL_VIEW_FACTORY_MINICARD(o) (GTK_CHECK_CAST ((o), GAL_VIEW_FACTORY_MINICARD_TYPE, GalViewFactoryMinicard)) -#define GAL_VIEW_FACTORY_MINICARD_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_FACTORY_MINICARD_TYPE, GalViewFactoryMinicardClass)) -#define GAL_IS_VIEW_FACTORY_MINICARD(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_FACTORY_MINICARD_TYPE)) -#define GAL_IS_VIEW_FACTORY_MINICARD_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_FACTORY_MINICARD_TYPE)) - -typedef struct { - GalViewFactory base; -} GalViewFactoryMinicard; - -typedef struct { - GalViewFactoryClass parent_class; -} GalViewFactoryMinicardClass; - -/* Standard functions */ -GtkType gal_view_factory_minicard_get_type (void); -GalViewFactory *gal_view_factory_minicard_new (void); -GalViewFactory *gal_view_factory_minicard_construct (GalViewFactoryMinicard *factory); - -#endif /* _GAL_VIEW_FACTORY_MINICARD_H_ */ diff --git a/addressbook/gui/widgets/gal-view-minicard.c b/addressbook/gui/widgets/gal-view-minicard.c deleted file mode 100644 index 4cfa71f470..0000000000 --- a/addressbook/gui/widgets/gal-view-minicard.c +++ /dev/null @@ -1,154 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-minicard.c: An Minicard View - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#include <config.h> -#include "gal-view-minicard.h" - -#define PARENT_TYPE gal_view_get_type () - -static GalViewClass *gal_view_minicard_parent_class; - -static void -gal_view_minicard_edit (GalView *view) -{ - /* GalViewMinicard *minicard_view = GAL_VIEW_MINICARD(view); */ -} - -static void -gal_view_minicard_load (GalView *view, - const char *filename) -{ -} - -static void -gal_view_minicard_save (GalView *view, - const char *filename) -{ -} - -static const char * -gal_view_minicard_get_title (GalView *view) -{ - return GAL_VIEW_MINICARD(view)->title; -} - -static void -gal_view_minicard_set_title (GalView *view, - const char *title) -{ - g_free(GAL_VIEW_MINICARD(view)->title); - GAL_VIEW_MINICARD(view)->title = g_strdup(title); -} - -static const char * -gal_view_minicard_get_type_code (GalView *view) -{ - return "minicard"; -} - -static GalView * -gal_view_minicard_clone (GalView *view) -{ - GalViewMinicard *gve, *new; - - gve = GAL_VIEW_MINICARD(view); - - new = gtk_type_new (gal_view_minicard_get_type ()); - new->title = g_strdup (gve->title); - - return GAL_VIEW(new); -} - -static void -gal_view_minicard_destroy (GtkObject *object) -{ - GalViewMinicard *view = GAL_VIEW_MINICARD(object); - g_free(view->title); -} - -static void -gal_view_minicard_class_init (GtkObjectClass *object_class) -{ - GalViewClass *gal_view_class = GAL_VIEW_CLASS(object_class); - gal_view_minicard_parent_class = gtk_type_class (PARENT_TYPE); - - gal_view_class->edit = gal_view_minicard_edit ; - gal_view_class->load = gal_view_minicard_load ; - gal_view_class->save = gal_view_minicard_save ; - gal_view_class->get_title = gal_view_minicard_get_title ; - gal_view_class->set_title = gal_view_minicard_set_title ; - gal_view_class->get_type_code = gal_view_minicard_get_type_code; - gal_view_class->clone = gal_view_minicard_clone ; - - object_class->destroy = gal_view_minicard_destroy ; -} - -static void -gal_view_minicard_init (GalViewMinicard *gve) -{ - gve->title = NULL; -} - -/** - * gal_view_minicard_new - * @title: The name of the new view. - * - * Returns a new GalViewMinicard. This is primarily for use by - * GalViewFactoryMinicard. - * - * Returns: The new GalViewMinicard. - */ -GalView * -gal_view_minicard_new (const gchar *title) -{ - return gal_view_minicard_construct (gtk_type_new (gal_view_minicard_get_type ()), title); -} - -/** - * gal_view_minicard_construct - * @view: The view to construct. - * @title: The name of the new view. - * - * constructs the GalViewMinicard. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewMinicard. - */ -GalView * -gal_view_minicard_construct (GalViewMinicard *view, - const gchar *title) -{ - view->title = g_strdup(title); - return GAL_VIEW(view); -} - -GtkType -gal_view_minicard_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "GalViewMinicard", - sizeof (GalViewMinicard), - sizeof (GalViewMinicardClass), - (GtkClassInitFunc) gal_view_minicard_class_init, - (GtkObjectInitFunc) gal_view_minicard_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} diff --git a/addressbook/gui/widgets/gal-view-minicard.h b/addressbook/gui/widgets/gal-view-minicard.h deleted file mode 100644 index fef98141f3..0000000000 --- a/addressbook/gui/widgets/gal-view-minicard.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-minicard.h: An Minicard View - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#ifndef _GAL_VIEW_MINICARD_H_ -#define _GAL_VIEW_MINICARD_H_ - -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view.h> - -#define GAL_VIEW_MINICARD_TYPE (gal_view_minicard_get_type ()) -#define GAL_VIEW_MINICARD(o) (GTK_CHECK_CAST ((o), GAL_VIEW_MINICARD_TYPE, GalViewMinicard)) -#define GAL_VIEW_MINICARD_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_MINICARD_TYPE, GalViewMinicardClass)) -#define GAL_IS_VIEW_MINICARD(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_MINICARD_TYPE)) -#define GAL_IS_VIEW_MINICARD_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_MINICARD_TYPE)) - -typedef struct { - GalView base; - - char *title; -} GalViewMinicard; - -typedef struct { - GalViewClass parent_class; -} GalViewMinicardClass; - -/* Standard functions */ -GtkType gal_view_minicard_get_type (void); -GalView *gal_view_minicard_new (const gchar *title); -GalView *gal_view_minicard_construct (GalViewMinicard *view, - const gchar *title); - -#endif /* _GAL_VIEW_MINICARD_H_ */ diff --git a/addressbook/gui/widgets/test-minicard-label.c b/addressbook/gui/widgets/test-minicard-label.c deleted file mode 100644 index 90a6ed5f34..0000000000 --- a/addressbook/gui/widgets/test-minicard-label.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard-label.c - * - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - - -#include "config.h" - -#include <gtk/gtkmain.h> -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-canvas-rect-ellipse.h> -#include <libgnomeui/gnome-init.h> -#include <gal/widgets/e-canvas.h> -#include "e-minicard-label.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *label; -GnomeCanvasItem *rect; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height ); - gnome_canvas_item_set( label, - "width", (double) allocation->width, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( rect, - "x2", (double) allocation->width, - "y2", (double) allocation->height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey <clahey@umich.edu>", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Label Test" ), VERSION, - _( "Copyright (C) 2000, Ximian, Inc." ), - authors, - _( "This should test the minicard label canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -static void button_press_callback( GtkWidget *widget, gpointer data ) -{ - gnome_canvas_item_grab_focus( label ); -} - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Minicard Label Test", VERSION, argc, argv); - app = gnome_app_new("Minicard Label Test", NULL); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - label = e_minicard_label_new(gnome_canvas_root( GNOME_CANVAS( canvas ) )); - gnome_canvas_item_set( label, - "width", (double) 100, - "height", (double) 100, - "fieldname", "Full Name:", - "field", "Christopher James Lahey", - NULL ); - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gnome_app_set_contents( GNOME_APP( app ), canvas ); - - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "button_press_event", - GTK_SIGNAL_FUNC( button_press_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/widgets/test-minicard-view.c b/addressbook/gui/widgets/test-minicard-view.c deleted file mode 100644 index e327190987..0000000000 --- a/addressbook/gui/widgets/test-minicard-view.c +++ /dev/null @@ -1,204 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "config.h" - -#include <libgnorba/gnorba.h> -#include <e-util/e-canvas.h> -#include "e-minicard-view.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *reflow; -GnomeCanvasItem *rect; -GtkAllocation last_alloc; - -CORBA_Environment ev; -CORBA_ORB orb; - -static void -init_bonobo (int argc, char **argv) -{ - - gnome_CORBA_init_with_popt_table ( - "Reflow Test", VERSION, - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo")); - -} - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - last_alloc = *allocation; - gnome_canvas_item_set( reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(GnomeCanvas *canvas, gpointer data) -{ - double width; - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, last_alloc.width); - gnome_canvas_set_scroll_region(canvas , 0, 0, width, last_alloc.height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) last_alloc.height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey <clahey@umich.edu>", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Ximian, Inc." ), - authors, - _( "This should test the reflow canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - if (status == E_BOOK_STATUS_SUCCESS) - gnome_canvas_item_set(reflow, - "book", book, - NULL); -} - -static guint -ebook_create (void) -{ - EBook *book; - - book = e_book_new (); - - if (!book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - __FUNCTION__); - return FALSE; - } - - - if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) { - printf ("error calling load_uri!\n"); - } - - - return FALSE; -} - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - GtkWidget *vbox; - GtkWidget *scrollbar; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - CORBA_exception_init (&ev); - init_bonobo (argc, argv); - - app = gnome_app_new("Reflow Test", NULL); - - vbox = gtk_vbox_new(FALSE, 0); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_minicard_view_get_type(), - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - gtk_signal_connect( GTK_OBJECT( canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - ( gpointer ) app); - - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0); - - scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas))); - - gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0); - - gnome_app_set_contents( GNOME_APP( app ), vbox ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE); - - gtk_idle_add ((GtkFunction) ebook_create, NULL); - - bonobo_main (); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/widgets/test-minicard.c b/addressbook/gui/widgets/test-minicard.c deleted file mode 100644 index 362c3fddef..0000000000 --- a/addressbook/gui/widgets/test-minicard.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard.c - * - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - - -#include "config.h" - -#include <gtk/gtkmain.h> -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-init.h> -#include <libgnomeui/gnome-canvas-rect-ellipse.h> - -#include "e-minicard.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *card; -GnomeCanvasItem *rect; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height ); - gnome_canvas_item_set( card, - "width", (double) allocation->width, - NULL ); - gnome_canvas_item_set( rect, - "x2", (double) allocation->width, - "y2", (double) allocation->height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey <clahey@umich.edu>", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Test" ), VERSION, - _( "Copyright (C) 2000, Ximian, Inc." ), - authors, - _( "This should test the minicard canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - int i; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Minicard Test", VERSION, argc, argv); - app = gnome_app_new("Minicard Test", NULL); - - canvas = gnome_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - for ( i = 0; i < 1; i++ ) - { - card = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_minicard_get_type(), - "width", (double) 100, - NULL ); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gnome_app_set_contents( GNOME_APP( app ), canvas ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/widgets/test-reflow.c b/addressbook/gui/widgets/test-reflow.c deleted file mode 100644 index 0a3f34235d..0000000000 --- a/addressbook/gui/widgets/test-reflow.c +++ /dev/null @@ -1,198 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"TITLE:Head Geek -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@ximian.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - - -#include "config.h" - -#include <gtk/gtkmain.h> -#include <gtk/gtkvbox.h> -#include <libgnomeui/gnome-canvas-rect-ellipse.h> -#include <libgnomeui/gnome-init.h> -#include <gal/widgets/e-canvas.h> -#include <gal/widgets/e-reflow.h> -#include <gal/widgets/e-scroll-frame.h> - -#include "e-minicard.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *reflow; -GnomeCanvasItem *rect; -GtkAllocation last_alloc; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - last_alloc = *allocation; - gnome_canvas_item_set( reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width - 1, allocation->height - 1); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(GnomeCanvas *canvas, gpointer data) -{ - double width; - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, last_alloc.width); - gnome_canvas_set_scroll_region(canvas , 0, 0, width - 1, last_alloc.height - 1); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) last_alloc.height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey <clahey@umich.edu>", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Ximian, Inc." ), - authors, - _( "This should test the reflow canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - GtkWidget *vbox; - GtkWidget *scrollframe; - int i; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Reflow Test", VERSION, argc, argv); - app = gnome_app_new("Reflow Test", NULL); - - vbox = gtk_vbox_new(FALSE, 0); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_reflow_get_type(), - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - gtk_signal_connect( GTK_OBJECT( canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - ( gpointer ) app); - for ( i = 0; i < 200; i++ ) - { - GnomeCanvasItem *item; - ECard *card = e_card_new (TEST_VCARD); - item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow), - e_minicard_get_type(), - "card", card, - NULL); - e_reflow_add_item(E_REFLOW(reflow), item, NULL); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - scrollframe = e_scroll_frame_new (gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)), - gtk_layout_get_vadjustment(GTK_LAYOUT(canvas))); - e_scroll_frame_set_policy (E_SCROLL_FRAME (scrollframe), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_NEVER); - - gtk_container_add (GTK_CONTAINER (scrollframe), canvas); - - gnome_app_set_contents( GNOME_APP( app ), scrollframe ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE); - - gtk_main(); - - /* Not reached. */ - return 0; -} |