From 4882b9f898a1e44b7462f0eb1cdc0c8d11897c6a Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 6 Nov 2000 21:40:14 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'BONOBO_0_31'. svn path=/tags/BONOBO_0_31/; revision=6435 --- addressbook/gui/widgets/.cvsignore | 12 - addressbook/gui/widgets/Makefile.am | 126 ---- addressbook/gui/widgets/alphabet.glade | 357 ---------- addressbook/gui/widgets/alphabet.glade.h | 34 - addressbook/gui/widgets/e-addressbook-model.c | 444 ------------ addressbook/gui/widgets/e-addressbook-model.h | 56 -- addressbook/gui/widgets/e-addressbook-search.c | 333 --------- addressbook/gui/widgets/e-addressbook-search.h | 83 --- addressbook/gui/widgets/e-addressbook-view.c | 731 -------------------- addressbook/gui/widgets/e-addressbook-view.h | 90 --- addressbook/gui/widgets/e-minicard-control.c | 331 --------- addressbook/gui/widgets/e-minicard-control.h | 8 - addressbook/gui/widgets/e-minicard-label.c | 444 ------------ addressbook/gui/widgets/e-minicard-label.h | 83 --- addressbook/gui/widgets/e-minicard-view-widget.c | 276 -------- addressbook/gui/widgets/e-minicard-view-widget.h | 74 -- addressbook/gui/widgets/e-minicard-view.c | 453 ------------- addressbook/gui/widgets/e-minicard-view.h | 98 --- addressbook/gui/widgets/e-minicard-widget-test.c | 113 ---- addressbook/gui/widgets/e-minicard-widget.c | 236 ------- addressbook/gui/widgets/e-minicard-widget.h | 76 --- addressbook/gui/widgets/e-minicard.c | 816 ----------------------- addressbook/gui/widgets/e-minicard.h | 100 --- addressbook/gui/widgets/test-minicard-label.c | 126 ---- addressbook/gui/widgets/test-minicard-view.c | 206 ------ addressbook/gui/widgets/test-minicard.c | 115 ---- addressbook/gui/widgets/test-reflow.c | 194 ------ 27 files changed, 6015 deletions(-) delete mode 100644 addressbook/gui/widgets/.cvsignore delete mode 100644 addressbook/gui/widgets/Makefile.am delete mode 100644 addressbook/gui/widgets/alphabet.glade delete mode 100644 addressbook/gui/widgets/alphabet.glade.h delete mode 100644 addressbook/gui/widgets/e-addressbook-model.c delete mode 100644 addressbook/gui/widgets/e-addressbook-model.h delete mode 100644 addressbook/gui/widgets/e-addressbook-search.c delete mode 100644 addressbook/gui/widgets/e-addressbook-search.h delete mode 100644 addressbook/gui/widgets/e-addressbook-view.c delete mode 100644 addressbook/gui/widgets/e-addressbook-view.h delete mode 100644 addressbook/gui/widgets/e-minicard-control.c delete mode 100644 addressbook/gui/widgets/e-minicard-control.h delete mode 100644 addressbook/gui/widgets/e-minicard-label.c delete mode 100644 addressbook/gui/widgets/e-minicard-label.h delete mode 100644 addressbook/gui/widgets/e-minicard-view-widget.c delete mode 100644 addressbook/gui/widgets/e-minicard-view-widget.h delete mode 100644 addressbook/gui/widgets/e-minicard-view.c delete mode 100644 addressbook/gui/widgets/e-minicard-view.h delete mode 100644 addressbook/gui/widgets/e-minicard-widget-test.c delete mode 100644 addressbook/gui/widgets/e-minicard-widget.c delete mode 100644 addressbook/gui/widgets/e-minicard-widget.h delete mode 100644 addressbook/gui/widgets/e-minicard.c delete mode 100644 addressbook/gui/widgets/e-minicard.h delete mode 100644 addressbook/gui/widgets/test-minicard-label.c delete mode 100644 addressbook/gui/widgets/test-minicard-view.c delete mode 100644 addressbook/gui/widgets/test-minicard.c delete mode 100644 addressbook/gui/widgets/test-reflow.c (limited to 'addressbook/gui/widgets') 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 91e361bee1..0000000000 --- a/addressbook/gui/widgets/Makefile.am +++ /dev/null @@ -1,126 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"e-minicard\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend/ebook \ - -I$(top_srcdir)/addressbook/contact-editor \ - -I$(top_srcdir)/widgets/e-text \ - -I$(top_srcdir)/widgets/e-table \ - -I$(top_srcdir)/widgets/e-reflow \ - -I$(top_srcdir)/widgets/e-table \ - -I$(top_srcdir)/widgets/misc \ - $(BONOBO_GNOME_CFLAGS) \ - $(EXTRA_GNOME_CFLAGS) - -noinst_LIBRARIES = \ - libeminicard.a - -libeminicard_a_SOURCES = \ - e-addressbook-model.c \ - e-addressbook-model.h \ - e-addressbook-search.c \ - e-addressbook-search.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 - -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 = \ - $(EXTRA_GNOME_LIBS) \ - libeminicard.a \ - $(BONOBO_GNOME_LIBS) \ - $(top_builddir)/e-util/libeutil.la - -minicard_test_SOURCES = \ - test-minicard.c - -minicard_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - libeminicard.a \ - $(BONOBO_GNOME_LIBS) \ - $(GNOME_PRINT_LIBS) \ - $(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 - -reflow_test_SOURCES = \ - test-reflow.c - -reflow_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - $(GNOME_PRINT_LIBS) \ - 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 - -#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 = \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - $(GNOME_PRINT_LIBS) \ - 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 - -gladedir = $(datadir)/evolution/glade -glade_DATA = alphabet.glade - -EXTRA_DIST = \ - $(glade_DATA) \ - alphabet.glade.h diff --git a/addressbook/gui/widgets/alphabet.glade b/addressbook/gui/widgets/alphabet.glade deleted file mode 100644 index bc6e5f3798..0000000000 --- a/addressbook/gui/widgets/alphabet.glade +++ /dev/null @@ -1,357 +0,0 @@ - - - - - alphabet - alphabet - - src - pixmaps - C - True - True - True - False - False - False - True - True - alphabet.glade.h - - - - GtkWindow - window2 - False - window2 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkScrolledWindow - scrolledwindow-top - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - - GtkViewport - viewport1 - 4 - GTK_SHADOW_NONE - - - GtkVBox - vbox2 - 27 - False - 4 - - - GtkButton - button-1 - - - 0 - False - False - - - - - GtkButton - button-a - - - 0 - False - False - - - - - GtkButton - button-b - - - 0 - False - False - - - - - GtkButton - button-c - - - 0 - False - False - - - - - GtkButton - button-d - - - 0 - False - False - - - - - GtkButton - button-e - - - 0 - False - False - - - - - GtkButton - button-f - - - 0 - False - False - - - - - GtkButton - button-g - - - 0 - False - False - - - - - GtkButton - button-h - - - 0 - False - False - - - - - GtkButton - button-i - - - 0 - False - False - - - - - GtkButton - button-j - - - 0 - False - False - - - - - GtkButton - button-k - - - 0 - False - False - - - - - GtkButton - button-l - - - 0 - False - False - - - - - GtkButton - button-m - - - 0 - False - False - - - - - GtkButton - button-n - - - 0 - False - False - - - - - GtkButton - button-o - - - 0 - False - False - - - - - GtkButton - button-p - - - 0 - False - False - - - - - GtkButton - button-q - - - 0 - False - False - - - - - GtkButton - button-r - - - 0 - False - False - - - - - GtkButton - button-s - - - 0 - False - False - - - - - GtkButton - button-t - - - 0 - False - False - - - - - GtkButton - button-u - - - 0 - False - False - - - - - GtkButton - button-v - - - 0 - False - False - - - - - GtkButton - button-w - True - - - 0 - False - False - - - - - GtkButton - button-x - - - 0 - False - False - - - - - GtkButton - button-y - - - 0 - False - False - - - - - GtkButton - button-z - - - 0 - False - False - - - - - - - - diff --git a/addressbook/gui/widgets/alphabet.glade.h b/addressbook/gui/widgets/alphabet.glade.h deleted file mode 100644 index 2448eeb4fc..0000000000 --- a/addressbook/gui/widgets/alphabet.glade.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("window2"); -gchar *s = N_("123"); -gchar *s = N_("a"); -gchar *s = N_("b"); -gchar *s = N_("c"); -gchar *s = N_("d"); -gchar *s = N_("e"); -gchar *s = N_("f"); -gchar *s = N_("g"); -gchar *s = N_("h"); -gchar *s = N_("i"); -gchar *s = N_("j"); -gchar *s = N_("k"); -gchar *s = N_("l"); -gchar *s = N_("m"); -gchar *s = N_("n"); -gchar *s = N_("o"); -gchar *s = N_("p"); -gchar *s = N_("q"); -gchar *s = N_("r"); -gchar *s = N_("s"); -gchar *s = N_("t"); -gchar *s = N_("u"); -gchar *s = N_("v"); -gchar *s = N_("w"); -gchar *s = N_("x"); -gchar *s = N_("y"); -gchar *s = N_("z"); diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c deleted file mode 100644 index 830b70879c..0000000000 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ /dev/null @@ -1,444 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Christopher James Lahey - * - * (C) 1999 Helix Code, Inc. - */ - -#include -#include "e-addressbook-model.h" -#include -#include -#include -#include - -#define PARENT_TYPE e_table_model_get_type() -ETableModelClass *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, -}; - -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); - - model->create_card_id = 0; - model->remove_card_id = 0; - model->modify_card_id = 0; - - 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) - 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); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -addressbook_col_count (ETableModel *etc) -{ - return E_CARD_SIMPLE_FIELD_LAST; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -addressbook_row_count (ETableModel *etc) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - return addressbook->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -addressbook_value_at (ETableModel *etc, int col, int row) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - const char *value; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1 || row >= addressbook->data_count ) - return NULL; - - value = e_card_simple_get_const(addressbook->data[row], - col + 1); - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - ECard *card; - if (addressbook->editable) { - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= addressbook->data_count ) - return; - e_card_simple_set(addressbook->data[row], - col + 1, - val); - gtk_object_get(GTK_OBJECT(addressbook->data[row]), - "card", &card, - NULL); - e_book_commit_card(addressbook->book, card, NULL, NULL); - - 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) -{ - return E_ADDRESSBOOK_MODEL(etc)->editable; -} - -static void -addressbook_append_row (ETableModel *etm, ETableModel *source, gint row) -{ - ECard *card; - ECardSimple *simple; - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etm); - int col; - - card = e_card_new(""); - simple = e_card_simple_new(card); - - for (col = 0; col < E_CARD_SIMPLE_FIELD_LAST - 1; col++) { - const void *val = e_table_model_value_at(source, col, row); - e_card_simple_set(simple, - col + 1, - val); - } - e_card_simple_sync_card(simple); - e_book_add_card(addressbook->book, 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 -create_card(EBookView *book_view, - const GList *cards, - EAddressbookModel *model) -{ - model->data = g_realloc(model->data, (model->data_count + g_list_length((GList *)cards)) * sizeof(ECard *)); - e_table_model_pre_change(E_TABLE_MODEL(model)); - for ( ; cards; cards = cards->next) { - model->data[model->data_count++] = e_card_simple_new (E_CARD(cards->data)); - e_table_model_row_inserted(E_TABLE_MODEL(model), model->data_count - 1); - } -} - -static void -remove_card(EBookView *book_view, - const char *id, - EAddressbookModel *model) -{ - int i; - e_table_model_pre_change(E_TABLE_MODEL(model)); - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_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 *)); - e_table_model_row_deleted(E_TABLE_MODEL(model), i); - } - } -} - -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_simple_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_simple_new(E_CARD(cards->data)); - gtk_object_ref(GTK_OBJECT(model->data[i])); - e_table_model_row_changed(E_TABLE_MODEL(model), i); - break; - } - } - } -} - -static void -e_addressbook_model_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) 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); - - 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_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->data = NULL; - model->data_count = 0; - model->editable = TRUE; - 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); - - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - - e_table_model_pre_change(E_TABLE_MODEL(model)); - g_free(model->data); - model->data = NULL; - model->data_count = 0; - e_table_model_changed(E_TABLE_MODEL(model)); -} - -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 (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; - gtk_object_get(GTK_OBJECT(model->data[row]), - "card", &card, - NULL); - 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) - 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); - } - 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); - 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; -} - -ETableModel * -e_addressbook_model_new (void) -{ - EAddressbookModel *et; - - et = gtk_type_new (e_addressbook_model_get_type ()); - - return E_TABLE_MODEL(et); -} - -void e_addressbook_model_stop (EAddressbookModel *model) -{ - remove_book_view(model); -} diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h deleted file mode 100644 index 860fb641ac..0000000000 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ /dev/null @@ -1,56 +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 -#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)) - -/* Virtual Column list: - 0 Email - 1 Full Name - 2 Street - 3 Phone -*/ - -typedef struct { - ETableModel parent; - - /* item specific fields */ - EBook *book; - char *query; - EBookView *book_view; - - int get_view_idle; - - ECardSimple **data; - int data_count; - - int create_card_id, remove_card_id, modify_card_id; - - guint editable : 1; - guint first_get_view : 1; -} EAddressbookModel; - - -typedef struct { - ETableModelClass parent_class; -} EAddressbookModelClass; - - -GtkType e_addressbook_model_get_type (void); -ETableModel *e_addressbook_model_new (void); - -/* Returns object with ref count of 1. */ -ECard *e_addressbook_model_get_card(EAddressbookModel *model, - int row); -void e_addressbook_model_stop (EAddressbookModel *model); - -#endif /* _E_ADDRESSBOOK_MODEL_H_ */ diff --git a/addressbook/gui/widgets/e-addressbook-search.c b/addressbook/gui/widgets/e-addressbook-search.c deleted file mode 100644 index e58e72d560..0000000000 --- a/addressbook/gui/widgets/e-addressbook-search.c +++ /dev/null @@ -1,333 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-addressbook-search.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include - -#include "e-addressbook-search.h" -#include - -static void e_addressbook_search_init (EAddressbookSearch *card); -static void e_addressbook_search_class_init (EAddressbookSearchClass *klass); -static void e_addressbook_search_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_addressbook_search_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_addressbook_search_destroy (GtkObject *object); - -enum { - QUERY_CHANGED, - MENU_ACTIVATED, - - LAST_SIGNAL -}; - -static gint eas_signals [LAST_SIGNAL] = { 0, }; - -static GtkHBoxClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_OPTION_CHOICE, - ARG_TEXT, -}; - -GtkType -e_addressbook_search_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GtkTypeInfo info = - { - "EAddressbookSearch", - sizeof (EAddressbookSearch), - sizeof (EAddressbookSearchClass), - (GtkClassInitFunc) e_addressbook_search_class_init, - (GtkObjectInitFunc) e_addressbook_search_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_hbox_get_type (), &info); - } - - return type; -} - -static void -e_addressbook_search_class_init (EAddressbookSearchClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - parent_class = gtk_type_class (gtk_hbox_get_type ()); - - object_class->set_arg = e_addressbook_search_set_arg; - object_class->get_arg = e_addressbook_search_get_arg; - object_class->destroy = e_addressbook_search_destroy; - - gtk_object_add_arg_type ("EAddressbookSearch::option_choice", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_OPTION_CHOICE); - gtk_object_add_arg_type ("EAddressbookSearch::text", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_TEXT); - - eas_signals [QUERY_CHANGED] = - gtk_signal_new ("query_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookSearchClass, query_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - eas_signals [MENU_ACTIVATED] = - gtk_signal_new ("menu_activated", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EAddressbookSearchClass, menu_activated), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, eas_signals, LAST_SIGNAL); -} - -static void -eas_query_changed(EAddressbookSearch *eas) -{ - gtk_signal_emit(GTK_OBJECT (eas), - eas_signals [QUERY_CHANGED]); -} - -static void -eas_menu_activated(EAddressbookSearch *eas, int item) -{ - gtk_signal_emit(GTK_OBJECT (eas), - eas_signals [MENU_ACTIVATED], - item); -} - -static void -eas_menubar_activated(GtkWidget *widget, EAddressbookSearch *eas) -{ - int id = GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT (widget), "EasMenuId")); - - eas_menu_activated(eas, id); -} - -typedef enum { - EAS_CLEAR = 0, -} EasMenuId; - - -typedef struct { - char *text; - char *name; - int id; -} EasMenuItem; - -static EasMenuItem eas_menu_items[] = { - { N_("Show All"), "all", 0 }, - { NULL, "sep", -1 }, - { N_("Advanced"), "advanced", 1}, - { NULL, NULL, 0 } -}; - -static void -eas_pack_menubar(EAddressbookSearch *eas) -{ - GtkWidget *menu, *menuitem; - int i; - - menu = gtk_menu_new (); - for (i = 0; eas_menu_items[i].name; i++) { - GtkWidget *item; - - item = gtk_menu_item_new_with_label (_(eas_menu_items[i].text)); - - gtk_menu_append (GTK_MENU (menu), item); - - gtk_object_set_data (GTK_OBJECT (item), "EasMenuId", GINT_TO_POINTER(eas_menu_items[i].id)); - - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (eas_menubar_activated), - eas); - } - gtk_widget_show_all (menu); - - menuitem = gtk_menu_item_new_with_label(_("Search")); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); - - gtk_widget_show (menuitem); - - gtk_menu_bar_append (GTK_MENU_BAR(eas->menubar), menuitem); - gtk_widget_set_sensitive (eas->menubar, TRUE); -} - -typedef enum { - EAS_ANY = 0, - EAS_FULL_NAME = 1, - EAS_EMAIL = 2, -} EasChoiceId; - - -typedef struct { - char *text; - char *name; - int id; -} EasChoice; - -static EasChoice eas_choices[] = { - { N_("Any field contains"), "x-evolution-any-field", EAS_ANY }, - { N_("Name contains"), "full_name", EAS_FULL_NAME }, - { N_("Email contains"), "email", EAS_EMAIL }, - { NULL, NULL, 0 } -}; - -static void -eas_option_activated(GtkWidget *widget, EAddressbookSearch *eas) -{ - int id = GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT (widget), "EasChoiceId")); - - eas->option_choice = id; - eas_query_changed(eas); -} - -static void -eas_entry_activated(GtkWidget *widget, EAddressbookSearch *eas) -{ - eas_query_changed(eas); -} - -static void -eas_pack_option_menu(EAddressbookSearch *eas) -{ - GtkWidget *menu; - int i; - - menu = gtk_menu_new (); - for (i = 0; eas_choices[i].name; i++) { - GtkWidget *item; - - item = gtk_menu_item_new_with_label (_(eas_choices[i].text)); - - gtk_menu_append (GTK_MENU (menu), item); - - gtk_object_set_data (GTK_OBJECT (item), "EasChoiceId", GINT_TO_POINTER(eas_choices[i].id)); - - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (eas_option_activated), - eas); - } - gtk_widget_show_all (menu); - - gtk_option_menu_set_menu (GTK_OPTION_MENU (eas->option), - menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (eas->option), 0); - gtk_widget_set_sensitive (eas->option, TRUE); -} - -static void -e_addressbook_search_init (EAddressbookSearch *eas) -{ - GtkWidget *spacer; - - gtk_box_set_spacing(GTK_BOX(eas), GNOME_PAD); - - eas->menubar = gtk_menu_bar_new(); - eas_pack_menubar(eas); - gtk_widget_show(eas->menubar); - gtk_box_pack_start(GTK_BOX(eas), eas->menubar, FALSE, FALSE, 0); - - eas->option = gtk_option_menu_new(); - eas_pack_option_menu(eas); - gtk_widget_show(eas->option); - gtk_box_pack_start(GTK_BOX(eas), eas->option, FALSE, FALSE, 0); - - eas->entry = gtk_entry_new(); - gtk_signal_connect (GTK_OBJECT (eas->entry), "activate", - GTK_SIGNAL_FUNC (eas_entry_activated), eas); - gtk_widget_show(eas->entry); - gtk_box_pack_start(GTK_BOX(eas), eas->entry, TRUE, TRUE, 0); - eas->option_choice = 0; - - spacer = gtk_drawing_area_new(); - gtk_widget_show(spacer); - gtk_box_pack_start(GTK_BOX(eas), spacer, FALSE, FALSE, 0); - gtk_widget_set_usize(spacer, 100, 1); -} - -static void -e_addressbook_search_destroy (GtkObject *object) -{ - if (GTK_OBJECT_CLASS(parent_class)->destroy) - GTK_OBJECT_CLASS(parent_class)->destroy(object); -} - -GtkWidget* -e_addressbook_search_new (void) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_addressbook_search_get_type ())); - return widget; -} - -static void -e_addressbook_search_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EAddressbookSearch *eas = E_ADDRESSBOOK_SEARCH(object); - - switch (arg_id) { - case ARG_OPTION_CHOICE: - GTK_VALUE_ENUM (*arg) = eas->option_choice; - break; - - case ARG_TEXT: - GTK_VALUE_STRING (*arg) = e_utf8_gtk_editable_get_text(GTK_EDITABLE(eas->entry)); - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_addressbook_search_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EAddressbookSearch *eas = E_ADDRESSBOOK_SEARCH(object); - - switch (arg_id) { - case ARG_OPTION_CHOICE: - eas->option_choice = GTK_VALUE_ENUM (*arg); - gtk_option_menu_set_history (GTK_OPTION_MENU (eas->option), eas->option_choice); - eas_query_changed(eas); - break; - - case ARG_TEXT: - e_utf8_gtk_editable_set_text(GTK_EDITABLE(eas->entry), GTK_VALUE_STRING (*arg)); - eas_query_changed(eas); - break; - - default: - break; - } -} diff --git a/addressbook/gui/widgets/e-addressbook-search.h b/addressbook/gui/widgets/e-addressbook-search.h deleted file mode 100644 index 5b229ee03e..0000000000 --- a/addressbook/gui/widgets/e-addressbook-search.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-addressbook-search.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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_SEARCH_H__ -#define __E_ADDRESSBOOK_SEARCH_H__ - -#include -#include "addressbook/backend/ebook/e-book.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EAddressbookSearch - A card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define E_ADDRESSBOOK_SEARCH_TYPE (e_addressbook_search_get_type ()) -#define E_ADDRESSBOOK_SEARCH(obj) (GTK_CHECK_CAST ((obj), E_ADDRESSBOOK_SEARCH_TYPE, EAddressbookSearch)) -#define E_ADDRESSBOOK_SEARCH_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_ADDRESSBOOK_SEARCH_TYPE, EAddressbookSearchClass)) -#define E_IS_ADDRESSBOOK_SEARCH(obj) (GTK_CHECK_TYPE ((obj), E_ADDRESSBOOK_SEARCH_TYPE)) -#define E_IS_ADDRESSBOOK_SEARCH_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_ADDRESSBOOK_SEARCH_TYPE)) - -typedef enum { - E_ADDRESSBOOK_SEARCH_NONE, /* initialized to this */ - E_ADDRESSBOOK_SEARCH_TABLE, - E_ADDRESSBOOK_SEARCH_MINICARD -} EAddressbookSearchType; - - -typedef struct _EAddressbookSearch EAddressbookSearch; -typedef struct _EAddressbookSearchClass EAddressbookSearchClass; - -struct _EAddressbookSearch -{ - GtkHBox parent; - - /* item specific fields */ - GtkWidget *menubar; - GtkWidget *option; - GtkWidget *entry; - int option_choice; -}; - -struct _EAddressbookSearchClass -{ - GtkHBoxClass parent_class; - - void (*query_changed) (EAddressbookSearch *search); - void (*menu_activated) (EAddressbookSearch *search, int item); -}; - -GtkWidget *e_addressbook_search_new (void); -GtkType e_addressbook_search_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_ADDRESSBOOK_SEARCH_H__ */ diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c deleted file mode 100644 index 3d081ab14c..0000000000 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ /dev/null @@ -1,731 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-table-field-chooser.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include - -#include "e-addressbook-view.h" - -#include -#include -#include -#include - -#include "e-addressbook-model.h" - -#include "e-minicard-view-widget.h" - -#include "e-contact-editor.h" -#include "e-contact-save-as.h" -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/printing/e-contact-print-envelope.h" -#include "e-card-simple.h" -#include "e-card.h" -#include "e-book.h" - -#include "glade/glade-xml.h" - -#include -#include -#include -#include - -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 GtkTableClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY, - ARG_TYPE, -}; - -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); -} - -static void -e_addressbook_view_init (EAddressbookView *eav) -{ - eav->view_type = E_ADDRESSBOOK_VIEW_NONE; - - eav->book = NULL; - eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")"); - - eav->object = NULL; - eav->widget = NULL; -} - -static void -e_addressbook_view_destroy (GtkObject *object) -{ - EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object); - - if (eav->book) - gtk_object_unref(GTK_OBJECT(eav->book)); - g_free(eav->query); - - 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 -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)); - } - else - eav->book = NULL; - if (eav->object) - gtk_object_set(GTK_OBJECT(eav->object), - "book", eav->book, - 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\" \"\")"); - if (eav->object) - gtk_object_set(GTK_OBJECT(eav->object), - "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 -create_minicard_view (EAddressbookView *view) -{ - GtkWidget *scrollframe; - GtkWidget *alphabet; - GtkWidget *minicard_view; - GtkWidget *minicard_hbox; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - minicard_hbox = gtk_hbox_new(FALSE, 0); - - minicard_view = e_minicard_view_widget_new(); - - 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 (); -} - - -static void -card_added_cb (EBook* book, EBookStatus status, const char *id, - gpointer user_data) -{ - g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__); -} - -static void -card_modified_cb (EBook* book, EBookStatus status, - gpointer user_data) -{ - g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__); -} - -/* Callback for the add_card signal from the contact editor */ -static void -add_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_add_card (book, card, card_added_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_commit_card (book, card, card_modified_cb, NULL); -} - -/* Callback for the delete_card signal from the contact editor */ -static void -delete_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_remove_card (book, card, card_modified_cb, NULL); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ce)); -} - -static void -table_double_click(ETableScrolled *table, gint row, EAddressbookView *view) -{ - if (E_IS_ADDRESSBOOK_MODEL(view->object)) { - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(view->object); - ECard *card = e_addressbook_model_get_card(model, row); - EBook *book; - EContactEditor *ce; - - gtk_object_get(GTK_OBJECT(model), - "book", &book, - NULL); - - g_assert (E_IS_BOOK (book)); - - ce = e_contact_editor_new (card, FALSE); - - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "delete_card", - GTK_SIGNAL_FUNC (delete_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - gtk_object_unref(GTK_OBJECT(card)); - } -} - -typedef struct { - EBook *book; - ECard *card; - GtkWidget *widget; -} 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)); -} - -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 -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)))) { - /* Add the card in the contact editor to our ebook */ - e_book_remove_card (card_and_book->book, - card_and_book->card, - NULL, - NULL); - } - 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_MODEL(view->object)) { - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(view->object); - CardAndBook *card_and_book; - - EPopupMenu menu[] = { - {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, - {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, - {"Print Envelope", NULL, GTK_SIGNAL_FUNC(print_envelope), 0}, - {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0}, - {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); - gtk_object_get(GTK_OBJECT(model), - "book", &(card_and_book->book), - NULL); - - gtk_object_ref(GTK_OBJECT(card_and_book->book)); - - e_popup_menu_run (menu, (GdkEventButton *)event, 0, 0, card_and_book); - return TRUE; - } else - return FALSE; -} -#define SPEC " \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -" - -static void -create_table_view (EAddressbookView *view) -{ - ETableModel *model; - ECardSimple *simple; - GtkWidget *table; - - simple = e_card_simple_new(NULL); - - model = e_addressbook_model_new(); - - /* 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 (model, NULL, SPEC, NULL); - - view->object = GTK_OBJECT(model); - view->widget = table; - - gtk_signal_connect(GTK_OBJECT(table), "double_click", - GTK_SIGNAL_FUNC(table_double_click), view); - gtk_signal_connect(GTK_OBJECT(table), "right_click", - GTK_SIGNAL_FUNC(table_right_click), 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; - - gtk_object_set(view->object, - "query", view->query, - "book", view->book, - NULL); -} - -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; - } -} - -void -e_addressbook_view_print(EAddressbookView *view) -{ - if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) { - char *query; - EBook *book; - GtkWidget *print; - - gtk_object_get (view->object, - "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; - - 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); - - printable = e_table_scrolled_get_printable(E_TABLE_SCROLLED(view->widget)); - - 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) -{ - g_print ("%s: %s(): a card was deleted\n", __FILE__, __FUNCTION__); -} - -void -e_addressbook_view_delete_selection(EAddressbookView *view) -{ - if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) - e_minicard_view_widget_remove_selection (E_MINICARD_VIEW_WIDGET(view->object), card_deleted_cb, NULL); -} - -void -e_addressbook_view_show_all(EAddressbookView *view) -{ - gtk_object_set(GTK_OBJECT(view), - "query", NULL, - NULL); -} - -void -e_addressbook_view_stop(EAddressbookView *view) -{ - switch(view->view_type) { - case E_ADDRESSBOOK_VIEW_MINICARD: - e_minicard_view_widget_stop(E_MINICARD_VIEW_WIDGET (view->object)); - break; - case E_ADDRESSBOOK_VIEW_TABLE: - e_addressbook_model_stop(E_ADDRESSBOOK_MODEL (view->object)); - break; - case E_ADDRESSBOOK_VIEW_NONE: - break; - } -} diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h deleted file mode 100644 index 60da283a75..0000000000 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-addressbook-view.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#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; - - EBook *book; - char *query; - - GtkObject *object; - GtkWidget *widget; - - GtkWidget *vbox; -}; - -struct _EAddressbookViewClass -{ - GtkTableClass parent_class; -}; - -GtkWidget *e_addressbook_view_new (void); -GtkType e_addressbook_view_get_type (void); - -void e_addressbook_view_print (EAddressbookView *view); -void e_addressbook_view_delete_selection (EAddressbookView *view); -void e_addressbook_view_show_all (EAddressbookView *view); -void e_addressbook_view_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 d69f422f63..0000000000 --- a/addressbook/gui/widgets/e-minicard-control.c +++ /dev/null @@ -1,331 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-control.c - * - * Authors: - * Chris Lahey - * - * Copyright 1999, 2000, Helix Code, Inc. - */ - -#include -#include -#include - -#include "addressbook/backend/ebook/e-book.h" - -#include "e-minicard-control.h" -#include "e-minicard-widget.h" -#include "addressbook/backend/ebook/e-card.h" - -#if 0 -enum { - PROP_RUNNING -} MyArgs; - -#define RUNNING_KEY "Clock::Running" - -static void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - 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, - 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); - - memcpy (data + length, - buffer->_buffer, buffer->_length); - - length += buffer->_length; - - CORBA_free (buffer); - } while (1); - - CORBA_free (buffer); - CORBA_exception_free (&ev); - - if (data == NULL) - 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_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:control-factory:e_minicard:16bb7c25-c7d2-46dc-a5f0-a0975d0e0595", - 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 - -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 3bdf1f2c47..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.c +++ /dev/null @@ -1,444 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-label.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include -#include "e-minicard-label.h" -#include -#include -#include -#include - -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, -}; - -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); - - 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); - 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; - } -} - -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; - 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", - 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", TRUE, - 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 08eb51ee53..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-label.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 - -#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; - 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 c6809bf1d0..0000000000 --- a/addressbook/gui/widgets/e-minicard-view-widget.c +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-view-widget.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include -#include -#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 ECanvasClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY -}; - -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); - - 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; -} - -GtkWidget * -e_minicard_view_widget_new (void) -{ - return GTK_WIDGET (gtk_type_new (e_minicard_view_widget_get_type ())); -} - -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; - } -} - -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; - 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_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), - "book", view->book, - "query", view->query, - NULL); - - 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 ); -} - -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); -} - -void -e_minicard_view_widget_stop(EMinicardViewWidget *view) -{ - e_minicard_view_stop(E_MINICARD_VIEW(view->emv)); -} 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 cf20c9a4df..0000000000 --- a/addressbook/gui/widgets/e-minicard-view-widget.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view-widget.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include "e-minicard-view.h" -#include -#include "addressbook/backend/ebook/e-book.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; - - EBook *book; - char *query; -}; - -struct _EMinicardViewWidgetClass -{ - ECanvasClass parent_class; -}; - -GtkType e_minicard_view_widget_get_type (void); -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); -void e_minicard_view_widget_stop (EMinicardViewWidget *view); - -GtkWidget *e_minicard_view_widget_new (void); - -#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 7169e41542..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.c +++ /dev/null @@ -1,453 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-view.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include -#include -#include "e-minicard-view.h" -#include "e-minicard.h" -#include "e-contact-editor.h" -static void e_minicard_view_init (EMinicardView *reflow); -static void e_minicard_view_class_init (EMinicardViewClass *klass); -static void e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_minicard_view_destroy (GtkObject *object); -static gboolean e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event); -static void canvas_destroy (GtkObject *object, EMinicardView *view); -static void disconnect_signals (EMinicardView *view); - -static EReflowSortedClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY -}; - -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 (e_reflow_sorted_get_type (), &reflow_info); - } - - return reflow_type; -} - -static void -e_minicard_view_class_init (EMinicardViewClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (e_reflow_sorted_get_type ()); - - 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); - - 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; - - /* GnomeCanvasItem method overrides */ -} - -static void -e_minicard_view_init (EMinicardView *view) -{ - view->book = NULL; - view->query = g_strdup("(contains \"x-evolution-any-field\" \"\")"); - view->book_view = NULL; - view->get_view_idle = 0; - view->create_card_id = 0; - view->remove_card_id = 0; - view->modify_card_id = 0; - view->canvas_destroy_id = 0; - view->first_get_view = TRUE; - - gtk_object_set(GTK_OBJECT(view), - "empty_message", _("\n\nThere are no items to show in this view\n\n" - "Double-click here to create a new Contact."), - NULL); - - E_REFLOW_SORTED(view)->compare_func = (GCompareFunc) e_minicard_compare; - E_REFLOW_SORTED(view)->string_func = (EReflowStringFunc) e_minicard_get_card_id; -} - -static void -create_card(EBookView *book_view, const GList *cards, EMinicardView *view) -{ - for (; cards; cards = g_list_next(cards)) { - GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view), - e_minicard_get_type(), - "card", cards->data, - NULL); - e_reflow_add_item(E_REFLOW(view), item); - } -} - -static void -modify_card(EBookView *book_view, const GList *cards, EMinicardView *view) -{ - for (; cards; cards = g_list_next(cards)) { - ECard *card = cards->data; - gchar *id = e_card_get_id(card); - GnomeCanvasItem *item = e_reflow_sorted_get_item(E_REFLOW_SORTED(view), id); - if (item && !GTK_OBJECT_DESTROYED(item)) { - gnome_canvas_item_set(item, - "card", card, - NULL); - e_reflow_sorted_reorder_item(E_REFLOW_SORTED(view), id); - } - } -} - -static void -remove_card(EBookView *book_view, const char *id, EMinicardView *view) -{ - e_reflow_sorted_remove_item(E_REFLOW_SORTED(view), id); -} - -static void -book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure) -{ - EMinicardView *view = closure; - disconnect_signals(view); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - - if (!view->canvas_destroy_id) - view->canvas_destroy_id = - gtk_signal_connect(GTK_OBJECT(GNOME_CANVAS_ITEM(view)->canvas), - "destroy", GTK_SIGNAL_FUNC(canvas_destroy), - view); - - view->book_view = book_view; - if (view->book_view) - gtk_object_ref(GTK_OBJECT(view->book_view)); - - - view->create_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_added", - GTK_SIGNAL_FUNC(create_card), - view); - view->remove_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_removed", - GTK_SIGNAL_FUNC(remove_card), - view); - view->modify_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_changed", - GTK_SIGNAL_FUNC(modify_card), - view); - - g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_unref, NULL); - g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_destroy, NULL); - g_list_free(E_REFLOW(view)->items); - E_REFLOW(view)->items = NULL; - e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(view)); -} - -static gboolean -get_view(EMinicardView *view) -{ - if (view->book && view->query) { - if (view->first_get_view) { - char *capabilities; - capabilities = e_book_get_static_capabilities(view->book); - if (strstr(capabilities, "local")) { - e_book_get_book_view(view->book, view->query, book_view_loaded, view); - } - view->first_get_view = FALSE; - } - else - e_book_get_book_view(view->book, view->query, book_view_loaded, view); - } - - view->get_view_idle = 0; - return FALSE; -} - -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_BOOK: - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - if (GTK_VALUE_OBJECT (*arg)) { - view->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - gtk_object_ref(GTK_OBJECT(view->book)); - if (view->get_view_idle == 0) - view->get_view_idle = g_idle_add((GSourceFunc)get_view, view); - } - else - view->book = NULL; - break; - case ARG_QUERY: - g_free(view->query); - view->query = g_strdup(GTK_VALUE_STRING (*arg)); - if (view->get_view_idle == 0) - view->get_view_idle = g_idle_add((GSourceFunc)get_view, view); - break; - } -} - -static void -e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardView *e_minicard_view; - - e_minicard_view = E_MINICARD_VIEW (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard_view->book); - break; - case ARG_QUERY: - GTK_VALUE_STRING (*arg) = g_strdup(e_minicard_view->query); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_view_destroy (GtkObject *object) -{ - EMinicardView *view = E_MINICARD_VIEW(object); - - if (view->get_view_idle) - g_source_remove(view->get_view_idle); - if (view->canvas_destroy_id) - gtk_signal_disconnect(GTK_OBJECT (GNOME_CANVAS_ITEM(view)->canvas), - view->canvas_destroy_id); - disconnect_signals(view); - g_free(view->query); - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - - GTK_OBJECT_CLASS(parent_class)->destroy (object); -} - -static void -card_added_cb (EBook* book, EBookStatus status, const char *id, - gpointer user_data) -{ - g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__); -} - -static void -card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status); -} - -/* Callback for the add_card signal from the contact editor */ -static void -add_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_add_card (book, card, card_added_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_commit_card (book, card, card_changed_cb, NULL); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ce)); -} - -static 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) - { - ECard *card; - EContactEditor *ce; - EBook *book; - - card = e_card_new(""); - - gtk_object_get(GTK_OBJECT(view), "book", &book, NULL); - g_assert (E_IS_BOOK (book)); - - ce = e_contact_editor_new (card, TRUE); - - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - gtk_object_sink(GTK_OBJECT(card)); - } - 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 void -disconnect_signals(EMinicardView *view) -{ - if (view->book_view && view->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->create_card_id); - if (view->book_view && view->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->remove_card_id); - if (view->book_view && view->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->modify_card_id); - - view->create_card_id = 0; - view->remove_card_id = 0; - view->modify_card_id = 0; -} - -static void -canvas_destroy(GtkObject *object, EMinicardView *view) -{ - disconnect_signals(view); -} - -void -e_minicard_view_remove_selection(EMinicardView *view, - EBookCallback cb, - gpointer closure) -{ - if (view->book) { - EReflow *reflow = E_REFLOW(view); - GList *list; - for (list = reflow->items; list; list = g_list_next(list)) { - GnomeCanvasItem *item = list->data; - gboolean has_focus; - gtk_object_get(GTK_OBJECT(item), - "has_focus", &has_focus, - NULL); - if (has_focus) { - ECard *card; - gtk_object_get(GTK_OBJECT(item), - "card", &card, - NULL); - e_book_remove_card(view->book, card, cb, closure); - return; - } - } - } -} - -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; - } -} - -void -e_minicard_view_jump_to_letter (EMinicardView *view, - char letter) -{ - e_reflow_sorted_jump(E_REFLOW_SORTED(view), - (GCompareFunc) compare_to_letter, - &letter); -} - -void -e_minicard_view_stop (EMinicardView *view) -{ - disconnect_signals(view); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - view->book_view = NULL; -} diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h deleted file mode 100644 index e4c1be870a..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include -#include "addressbook/backend/ebook/e-book.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 -{ - EReflowSorted parent; - - /* item specific fields */ - EBook *book; - char *query; - EBookView *book_view; - - int get_view_idle; - - int canvas_destroy_id; - - int create_card_id, remove_card_id, modify_card_id; - - guint first_get_view : 1; -}; - -struct _EMinicardViewClass -{ - EReflowSortedClass 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); -void e_minicard_view_stop (EMinicardView *view); - -#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 f6489f2a6a..0000000000 --- a/addressbook/gui/widgets/e-minicard-widget-test.c +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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:Helix Code, 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@helixcode.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 -#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 ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Widget Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, 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 3f765425e4..0000000000 --- a/addressbook/gui/widgets/e-minicard-widget.c +++ /dev/null @@ -1,236 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-table-field-chooser.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include -#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); - - switch (arg_id){ - case ARG_CARD: - if (emw->card) - gtk_object_unref(GTK_OBJECT(emw->card)); - if (GTK_VALUE_OBJECT(*arg)) { - emw->card = E_CARD(GTK_VALUE_OBJECT(*arg)); - gtk_object_ref(GTK_OBJECT(emw->card)); - } - else - emw->card = NULL; - if (emw->item) - gtk_object_set(GTK_OBJECT(emw->item), - "card", emw->card, - 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; - } -} diff --git a/addressbook/gui/widgets/e-minicard-widget.h b/addressbook/gui/widgets/e-minicard-widget.h deleted file mode 100644 index 95b56cf3de..0000000000 --- a/addressbook/gui/widgets/e-minicard-widget.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-widget.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include "addressbook/backend/ebook/e-card.h" -#include - -#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); - -#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 4dda2cee1d..0000000000 --- a/addressbook/gui/widgets/e-minicard.c +++ /dev/null @@ -1,816 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include -#include "e-minicard.h" -#include "e-minicard-label.h" -#include "addressbook/backend/ebook/e-book.h" -#include -#include -#include -#include -#include -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/printing/e-contact-print-envelope.h" -#include "e-contact-editor.h" -#include "e-contact-save-as.h" -#include "e-minicard-view.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 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 GnomeCanvasGroupClass *parent_class = NULL; - -typedef struct _EMinicardField EMinicardField; - -struct _EMinicardField { - ECardSimpleField field; - GnomeCanvasItem *label; -}; - -#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_CARD -}; - -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::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); - - object_class->set_arg = e_minicard_set_arg; - object_class->get_arg = e_minicard_get_arg; - object_class->destroy = e_minicard_destroy; - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_realize; - item_class->unrealize = e_minicard_unrealize; - item_class->event = e_minicard_event; -} - -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->card = NULL; - minicard->simple = e_card_simple_new(NULL); - - minicard->changed = FALSE; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow); -} - -static void -e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicard *e_minicard; - - 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); - 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_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); - - 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)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (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", "", - NULL ); - e_canvas_item_move_absolute(e_minicard->header_text, 6, 6); - - 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_added_cb (EBook* book, EBookStatus status, const char *id, gpointer user_data) -{ - g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__); -} - -static void -card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status); -} - -static void -save_as (GtkWidget *widget, EMinicard *minicard) -{ - e_card_simple_sync_card(minicard->simple); - e_contact_save_as(_("Save as VCard"), minicard->card); -} - -static void -delete (GtkWidget *widget, EMinicard *minicard) -{ - EBook *book; - - if (e_contact_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(GNOME_CANVAS_ITEM(minicard)->canvas))))) { - e_card_simple_sync_card(minicard->simple); - - gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(minicard)->parent), - "book", &book, - NULL); - - /* Add the card in the contact editor to our ebook */ - e_book_remove_card (book, - minicard->card, - card_changed_cb, - NULL); - } -} - -static void -print (GtkWidget *widget, EMinicard *minicard) -{ - e_card_simple_sync_card(minicard->simple); - - gtk_widget_show(e_contact_print_card_dialog_new(minicard->card)); -} - -static void -print_envelope (GtkWidget *widget, EMinicard *minicard) -{ - e_card_simple_sync_card(minicard->simple); - - gtk_widget_show(e_contact_print_envelope_dialog_new(minicard->card)); -} - -/* Callback for the add_card signal from the contact editor */ -static void -add_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_add_card (book, card, card_added_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_commit_card (book, card, card_changed_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -delete_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_remove_card (book, card, card_changed_cb, NULL); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ce)); -} - -static 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 ) { - gnome_canvas_item_set( e_minicard->rect, - "outline_color_gdk", &canvas->style->bg[GTK_STATE_NORMAL], - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "fill_color_gdk", &canvas->style->bg[GTK_STATE_SELECTED], - NULL ); - gnome_canvas_item_set( e_minicard->header_text, - "fill_color_gdk", &canvas->style->text[GTK_STATE_SELECTED], - NULL ); - e_minicard->has_focus = TRUE; - } 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_book_commit_card (book, - e_minicard->card, - card_changed_cb, - NULL); - } else { - remodel(e_minicard); - e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(e_minicard)); - } - e_minicard->changed = FALSE; - } - - gnome_canvas_item_set( e_minicard->rect, - "outline_color", NULL, - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "fill_color_gdk", - &canvas->style->bg[GTK_STATE_NORMAL], - NULL ); - gnome_canvas_item_set( e_minicard->header_text, - "fill_color_gdk", - &canvas->style->fg[GTK_STATE_NORMAL], - NULL ); - e_minicard->has_focus = FALSE; - } - } - break; - case GDK_BUTTON_PRESS: - if (event->button.button == 1) { - e_canvas_item_grab_focus(item); - } else if (event->button.button == 3) { - if (E_IS_MINICARD_VIEW(item->parent)) { - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, - {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, - {"Print Envelope", NULL, GTK_SIGNAL_FUNC(print_envelope), 0}, - {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0}, - {NULL, NULL, NULL, 0}}; - e_popup_menu_run (menu, (GdkEventButton *)event, 0, 0, e_minicard); - } else { - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, - {"Print Envelope", NULL, GTK_SIGNAL_FUNC(print_envelope), 0}, - {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, - {NULL, NULL, NULL, 0}}; - e_popup_menu_run (menu, (GdkEventButton *)event, 0, 0, e_minicard); - } - } - break; - - case GDK_2BUTTON_PRESS: - if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { - EContactEditor *ce; - EBook *book = NULL; - if (E_IS_MINICARD_VIEW(item->parent)) { - - gtk_object_get(GTK_OBJECT(item->parent), - "book", &book, - NULL); - } - ce = e_contact_editor_new (e_minicard->card, FALSE); - - if (book != NULL) { - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "delete_card", - GTK_SIGNAL_FUNC (delete_card_cb), book); - } - - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - 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, - NULL ); - } - 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); - - 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, - 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 (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); - } - - 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 (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); - } -} - -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; - } -} diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h deleted file mode 100644 index a0272ee58b..0000000000 --- a/addressbook/gui/widgets/e-minicard.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#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; - - GList *fields; /* Of type EMinicardField */ - guint needs_remodeling : 1; - - guint changed : 1; - - gboolean has_focus; - - double width; - double height; -}; - -struct _EMinicardClass -{ - GnomeCanvasGroupClass parent_class; - - void (* resize) (EMinicard *minicard); -}; - - -GtkType e_minicard_get_type (void); -char *e_minicard_get_card_id (EMinicard *minicard); -int e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_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 0566a85760..0000000000 --- a/addressbook/gui/widgets/test-minicard-label.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard-label.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include "e-minicard-label.h" -#include - -/* 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 ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Label Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, 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 c03d11d07e..0000000000 --- a/addressbook/gui/widgets/test-minicard-view.c +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#include -#include -#include -#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 ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, 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 e16ca675b3..0000000000 --- a/addressbook/gui/widgets/test-minicard.c +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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 -#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 ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, 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 2a8e7093fe..0000000000 --- a/addressbook/gui/widgets/test-reflow.c +++ /dev/null @@ -1,194 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * 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@helixcode.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 -#include -#include -#include "e-minicard.h" -#include - -/* 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 ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, 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); - } - 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; -} -- cgit v1.2.3