diff options
author | Chris Toshok <toshok@ximian.com> | 2001-06-04 07:45:20 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2001-06-04 07:45:20 +0800 |
commit | 484d91f1f5c40baa74aad0a230fe89f4ed643210 (patch) | |
tree | dd558243dc75877a8c699393683e9bbe0f326934 /addressbook/gui/widgets | |
parent | 9669aebe859441b65258adcc3f2a6819f7903875 (diff) | |
download | gsoc2013-evolution-484d91f1f5c40baa74aad0a230fe89f4ed643210.tar.gz gsoc2013-evolution-484d91f1f5c40baa74aad0a230fe89f4ed643210.tar.zst gsoc2013-evolution-484d91f1f5c40baa74aad0a230fe89f4ed643210.zip |
remove spew, and don't call the ShellView CORBA method if the interface
2001-06-03 Chris Toshok <toshok@ximian.com>
* gui/component/addressbook.c (set_status_message): remove spew,
and don't call the ShellView CORBA method if the interface doesn't
exist (for whatever reason.)
* gui/widgets/e-addressbook-view.c (e_addressbook_view_destroy):
unref the EAddressbookModel.
(create_minicard_view): unref the adapter.
(card_added_cb): call e_book_error_dialog if status != SUCCESS.
(card_modified_cb): same.
(card_removed_cb): new function, and same.
(delete_card_cb): pass card_removed_cb as the callback.
(emit_status_message): new function, just emit status_message.
(status_message): change to call emit_status_message.
(card_deleted_cb): emit_status_message ("Done."), and call
e_book_error_dialog if status != SUCCESS.
(do_remove): pass view in the closure arg.
(e_addressbook_view_delete_selection): emit status "Removing
cards..." before starting the removal.
(e_book_error_dialog): new function - pop up a (possibly) helpful
message about why an operation failed.
* gui/widgets/e-minicard-view-widget.c
(e_minicard_view_widget_new): ref the EAddressbookReflowAdapter.
(e_minicard_view_widget_destroy): unref the adapter.
(e_minicard_view_widget_get_selection_model): if there isn't a
minicard view return NULL.
* gui/widgets/e-addressbook-table-adapter.c
(e_addressbook_table_adapter_construct): ref the
EAddressbookModel.
* gui/widgets/e-addressbook-reflow-adapter.c
(addressbook_finalize): rename this from addressbook_destroy, to
reflect the method change.
(e_addressbook_reflow_adapter_class_init): same.
(e_addressbook_reflow_adapter_construct): ref the
EAddressbookModel.
* gui/widgets/e-addressbook-model.h: add editable_set flag.
* gui/widgets/e-addressbook-model.c (writable_status): only record
the writable state of the addressbook if the user hasn't set it.
(e_addressbook_model_init): init editable_set to FALSE.
(e_addressbook_model_set_arg): set editable_set to TRUE.
svn path=/trunk/; revision=10107
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.c | 12 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.h | 1 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-reflow-adapter.c | 5 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-table-adapter.c | 1 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 65 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view-widget.c | 7 |
6 files changed, 80 insertions, 11 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index 9183ee0831..0d84d70e45 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -197,11 +197,13 @@ writable_status (EBook *book, gboolean writable, EAddressbookModel *model) { - model->editable = writable; + if (!model->editable_set) { + model->editable = writable; - gtk_signal_emit (GTK_OBJECT (model), - e_addressbook_model_signals [WRITABLE_STATUS], - writable); + gtk_signal_emit (GTK_OBJECT (model), + e_addressbook_model_signals [WRITABLE_STATUS], + writable); + } } static void @@ -298,6 +300,7 @@ e_addressbook_model_init (GtkObject *object) model->allocated_count = 0; model->search_in_progress = FALSE; model->editable = FALSE; + model->editable_set = FALSE; model->first_get_view = TRUE; } @@ -416,6 +419,7 @@ e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) break; case ARG_EDITABLE: model->editable = GTK_VALUE_BOOL (*arg); + model->editable_set = TRUE; break; } } diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h index d6d605efe5..a0956d7003 100644 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ b/addressbook/gui/widgets/e-addressbook-model.h @@ -33,6 +33,7 @@ struct _EAddressbookModel { guint search_in_progress : 1; guint editable : 1; + guint editable_set : 1; guint first_get_view : 1; }; diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c index dc767c142d..04f17fd074 100644 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c @@ -244,7 +244,7 @@ e_addressbook_reflow_adapter_right_click (EAddressbookReflowAdapter *adapter, Gd } static void -addressbook_destroy(GtkObject *object) +addressbook_finalize(GtkObject *object) { EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object); @@ -495,7 +495,7 @@ e_addressbook_reflow_adapter_class_init (GtkObjectClass *object_class) object_class->set_arg = addressbook_set_arg; object_class->get_arg = addressbook_get_arg; - object_class->destroy = addressbook_destroy; + object_class->finalize = addressbook_finalize; gtk_object_add_arg_type ("EAddressbookReflowAdapter::book", GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_BOOK); @@ -567,6 +567,7 @@ e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter, EAddressbookReflowAdapterPrivate *priv = adapter->priv; priv->model = model; + gtk_object_ref (GTK_OBJECT (priv->model)); priv->create_card_id = gtk_signal_connect(GTK_OBJECT(priv->model), "card_added", diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index 4881615811..47a664df59 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -319,6 +319,7 @@ e_addressbook_table_adapter_construct (EAddressbookTableAdapter *adapter, EAddressbookTableAdapterPrivate *priv = adapter->priv; priv->model = model; + gtk_object_ref (GTK_OBJECT (priv->model)); priv->create_card_id = gtk_signal_connect(GTK_OBJECT(priv->model), "card_added", diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 6b12c95e73..6b73e0c92e 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -33,6 +33,7 @@ #include <gal/widgets/e-popup-menu.h> #include <gal/menus/gal-view-factory-etable.h> #include <gal/menus/gal-view-etable.h> +#include <libgnomeui/gnome-dialog-util.h> #include <libgnomeprint/gnome-print.h> #include <libgnomeprint/gnome-print-dialog.h> @@ -74,6 +75,8 @@ static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_dat guint info, guint time_stamp, EAddressbookView *view); static void invisible_destroyed (GtkWidget *invisible, EAddressbookView *view); +static void e_book_error_dialog (const gchar *msg, EBookStatus status); + static GtkTableClass *parent_class = NULL; /* The arguments we take */ @@ -227,6 +230,9 @@ e_addressbook_view_destroy (GtkObject *object) { EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object); + if (eav->model) + gtk_object_unref(GTK_OBJECT(eav->model)); + if (eav->book) gtk_object_unref(GTK_OBJECT(eav->book)); g_free(eav->query); @@ -457,6 +463,8 @@ create_minicard_view (EAddressbookView *view) gtk_widget_pop_colormap (); e_reflow_model_changed (E_REFLOW_MODEL (adapter)); + + gtk_object_unref (GTK_OBJECT (adapter)); } @@ -465,6 +473,8 @@ card_added_cb (EBook* book, EBookStatus status, const char *id, gpointer user_data) { g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__); + if (status != E_BOOK_STATUS_SUCCESS) + e_book_error_dialog (_("Error adding card"), status); } static void @@ -472,6 +482,17 @@ card_modified_cb (EBook* book, EBookStatus status, gpointer user_data) { g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__); + if (status != E_BOOK_STATUS_SUCCESS) + e_book_error_dialog (_("Error modifying card"), status); +} + +static void +card_removed_cb (EBook* book, EBookStatus status, + gpointer user_data) +{ + g_print ("%s: %s(): a card was removed\n", __FILE__, __FUNCTION__); + if (status != E_BOOK_STATUS_SUCCESS) + e_book_error_dialog (_("Error removing card"), status); } /* Callback for the add_card signal from the contact editor */ @@ -501,7 +522,7 @@ 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); + e_book_remove_card (book, card, card_removed_cb, NULL); } /* Callback used when the contact editor is closed */ @@ -734,7 +755,7 @@ table_drag_data_get (ETable *table, } static void -status_message (GtkObject *object, const gchar *status, EAddressbookView *eav) +emit_status_message (EAddressbookView *eav, const gchar *status) { gtk_signal_emit (GTK_OBJECT (eav), e_addressbook_view_signals [STATUS_MESSAGE], @@ -742,6 +763,12 @@ status_message (GtkObject *object, const gchar *status, EAddressbookView *eav) } static void +status_message (GtkObject *object, const gchar *status, EAddressbookView *eav) +{ + emit_status_message (eav, status); +} + +static void stop_state_changed (GtkObject *object, EAddressbookView *eav) { command_state_change (eav); @@ -1142,7 +1169,13 @@ e_addressbook_view_print(EAddressbookView *view) static void card_deleted_cb (EBook* book, EBookStatus status, gpointer user_data) { - g_print ("%s: %s(): a card was deleted\n", __FILE__, __FUNCTION__); + EAddressbookView *view = user_data; + + emit_status_message (view, _("Done.")); + + if (status != E_BOOK_STATUS_SUCCESS) { + e_book_error_dialog (_("Error removing card"), status); + } } static void @@ -1158,7 +1191,7 @@ do_remove (int i, gpointer user_data) card = e_addressbook_model_get_card (view->model, i); - e_book_remove_card(book, card, card_deleted_cb, NULL); + e_book_remove_card(book, card, card_deleted_cb, view); gtk_object_unref (GTK_OBJECT (card)); } @@ -1170,6 +1203,8 @@ e_addressbook_view_delete_selection(EAddressbookView *view) g_return_if_fail (model); + emit_status_message (view, _("Removing cards...")); + e_selection_model_foreach (model, do_remove, view); @@ -1182,6 +1217,28 @@ invisible_destroyed (GtkWidget *invisible, EAddressbookView *view) } static void +e_book_error_dialog (const gchar *msg, EBookStatus status) +{ + static char *status_to_string[] = { + N_("Success"), + N_("Unknown error"), + N_("Repository offline"), + N_("Permission denied"), + N_("Card not found"), + N_("Protocol not supported"), + N_("Canceled"), + N_("Other error") + }; + char *error_msg; + + error_msg = g_strdup_printf ("%s: %s", msg, status_to_string [status]); + + gtk_widget_show (gnome_error_dialog (error_msg)); + + g_free (error_msg); +} + +static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_data, guint info, diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c index 8e9f3c2761..25dbf8d272 100644 --- a/addressbook/gui/widgets/e-minicard-view-widget.c +++ b/addressbook/gui/widgets/e-minicard-view-widget.c @@ -138,6 +138,7 @@ e_minicard_view_widget_new (EAddressbookReflowAdapter *adapter) EMinicardViewWidget *widget = E_MINICARD_VIEW_WIDGET (gtk_type_new (e_minicard_view_widget_get_type ())); widget->adapter = adapter; + gtk_object_ref (GTK_OBJECT (widget->adapter)); return GTK_WIDGET (widget); } @@ -212,7 +213,9 @@ e_minicard_view_widget_destroy (GtkObject *object) if (view->book) gtk_object_unref(GTK_OBJECT(view->book)); g_free(view->query); - + + gtk_object_unref (GTK_OBJECT (view->adapter)); + GTK_OBJECT_CLASS(parent_class)->destroy (object); } @@ -335,4 +338,6 @@ e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view) { if (view->emv) return E_SELECTION_MODEL (E_REFLOW (view->emv)->selection); + else + return NULL; } |