diff options
author | Christopher James Lahey <clahey@ximian.com> | 2002-02-13 07:49:39 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2002-02-13 07:49:39 +0800 |
commit | 2788f38ed6cd4e82a8eda5183242457e145019d1 (patch) | |
tree | 7c3dd73c6250660ce083c98a6c1e42bdbab0e61f /addressbook/gui | |
parent | f4d3822695cea3f07e8fb2a40231451884796da3 (diff) | |
download | gsoc2013-evolution-2788f38ed6cd4e82a8eda5183242457e145019d1.tar gsoc2013-evolution-2788f38ed6cd4e82a8eda5183242457e145019d1.tar.gz gsoc2013-evolution-2788f38ed6cd4e82a8eda5183242457e145019d1.tar.bz2 gsoc2013-evolution-2788f38ed6cd4e82a8eda5183242457e145019d1.tar.lz gsoc2013-evolution-2788f38ed6cd4e82a8eda5183242457e145019d1.tar.xz gsoc2013-evolution-2788f38ed6cd4e82a8eda5183242457e145019d1.tar.zst gsoc2013-evolution-2788f38ed6cd4e82a8eda5183242457e145019d1.zip |
Added an argument to get the model.
2002-02-12 Christopher James Lahey <clahey@ximian.com>
* gui/widgets/e-addressbook-reflow-adapter.c
(addressbook_get_arg): Added an argument to get the model.
* gui/widgets/e-addressbook-view.c (writable_status): Don't bother
connecting to the writable_status callback on the book, simply
rely on the writable_status callback on the addressbook model.
* gui/widgets/e-minicard-view.c, gui/widgets/e-minicard-view.h
(set_empty_message): Handle the case of a read only view here.
svn path=/trunk/; revision=15698
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-reflow-adapter.c | 18 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 16 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view.c | 81 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view.h | 5 |
4 files changed, 93 insertions, 27 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c index 06be8543c7..51bf381802 100644 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c @@ -36,6 +36,7 @@ enum { ARG_BOOK, ARG_QUERY, ARG_EDITABLE, + ARG_MODEL, }; enum { @@ -263,8 +264,8 @@ open_card (GtkWidget *widget, ModelAndSelection *mns) list = get_card_list (mns); e_addressbook_show_multiple_cards (book, list, e_addressbook_model_editable (priv->model)); - e_free_object_list (list); + model_and_selection_free (mns); } @@ -286,7 +287,7 @@ e_addressbook_reflow_adapter_right_click (EAddressbookReflowAdapter *adapter, Gd {N_("Copy"), NULL, GTK_SIGNAL_FUNC (copy), NULL, 0}, {N_("Paste"), NULL, GTK_SIGNAL_FUNC (paste), NULL, POPUP_READONLY_MASK}, {N_("Delete"), NULL, GTK_SIGNAL_FUNC(delete), NULL, POPUP_READONLY_MASK}, - {NULL, NULL, NULL, 0}}; + E_POPUP_TERMINATOR}; mns->adapter = adapter; mns->selection = selection; @@ -514,7 +515,10 @@ addressbook_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) gtk_object_get (GTK_OBJECT (priv->model), "book", &book, NULL); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(book); + if (book) + GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(book); + else + GTK_VALUE_OBJECT (*arg) = NULL; break; } case ARG_QUERY: { @@ -533,6 +537,12 @@ addressbook_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) GTK_VALUE_BOOL (*arg) = editable; break; } + case ARG_MODEL: + if (priv->model) + GTK_VALUE_OBJECT (*arg) = GTK_OBJECT (priv->model); + else + GTK_VALUE_OBJECT (*arg) = NULL; + break; default: arg->type = GTK_TYPE_INVALID; break; @@ -556,6 +566,8 @@ e_addressbook_reflow_adapter_class_init (GtkObjectClass *object_class) GTK_ARG_READWRITE, ARG_QUERY); gtk_object_add_arg_type ("EAddressbookReflowAdapter::editable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE); + gtk_object_add_arg_type ("EAddressbookReflowAdapter::model", E_ADDRESSBOOK_MODEL_TYPE, + GTK_ARG_READABLE, ARG_MODEL); e_addressbook_reflow_adapter_signals [DRAG_BEGIN] = gtk_signal_new ("drag_begin", diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index e89aa98691..a7e81d7c5b 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -320,13 +320,10 @@ e_addressbook_view_new (void) } static void -book_writable_cb (EBook *book, gboolean writable, EAddressbookView *eav) +writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav) { eav->editable = writable; - gtk_object_set (GTK_OBJECT (eav->model), - "editable", eav->editable, - NULL); - writable_status (GTK_OBJECT(book), writable, eav); + command_state_change (eav); } #ifdef JUST_FOR_TRANSLATORS @@ -507,9 +504,6 @@ e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) if (GTK_VALUE_OBJECT(*arg)) { eav->book = E_BOOK(GTK_VALUE_OBJECT(*arg)); gtk_object_ref(GTK_OBJECT(eav->book)); - gtk_signal_connect (GTK_OBJECT (eav->book), - "writable_status", - book_writable_cb, eav); } else eav->book = NULL; @@ -1117,12 +1111,6 @@ stop_state_changed (GtkObject *object, EAddressbookView *eav) } static void -writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav) -{ - command_state_change (eav); -} - -static void command_state_change (EAddressbookView *eav) { /* Reffing during emission is unnecessary. Gtk automatically refs during an emission. */ diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c index 342e037337..92ac189bca 100644 --- a/addressbook/gui/widgets/e-minicard-view.c +++ b/addressbook/gui/widgets/e-minicard-view.c @@ -143,20 +143,43 @@ e_minicard_view_drag_begin (EAddressbookReflowAdapter *adapter, GdkEvent *event, } static void -adapter_changed (EMinicardView *view) +set_empty_message (EMinicardView *view) { char *empty_message; + gboolean editable = FALSE; + + if (view->adapter) { + gtk_object_get (GTK_OBJECT (view->adapter), + "editable", &editable, + NULL); + } + + if (editable) + empty_message = e_utf8_from_locale_string(_("\n\nThere are no items to show in this view.\n\n" + "Double-click here to create a new Contact.")); + else + empty_message = e_utf8_from_locale_string(_("\n\nThere are no items to show in this view.")); - empty_message = e_utf8_from_locale_string(_("\n\nThere are no items to show in this view\n\n" - "Double-click here to create a new Contact.")); gtk_object_set (GTK_OBJECT(view), "empty_message", empty_message, NULL); + g_free (empty_message); +} + +static void +writable_status_change (EAddressbookModel *model, gboolean writable, EMinicardView *view) +{ + set_empty_message (view); +} + +static void +adapter_changed (EMinicardView *view) +{ + set_empty_message (view); + gtk_signal_connect (GTK_OBJECT (view->adapter), "drag_begin", GTK_SIGNAL_FUNC (e_minicard_view_drag_begin), view); - - g_free (empty_message); } static void @@ -170,19 +193,44 @@ e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) switch (arg_id){ case ARG_ADAPTER: - if (view->adapter) + if (view->adapter) { + if (view->writable_status_id) { + EAddressbookModel *model; + gtk_object_get (GTK_OBJECT (view->adapter), + "model", &model, + NULL); + if (model) { + gtk_signal_disconnect (GTK_OBJECT (model), view->writable_status_id); + } + } + gtk_object_unref (GTK_OBJECT(view->adapter)); + } + view->writable_status_id = 0; view->adapter = GTK_VALUE_POINTER (*arg); gtk_object_ref (GTK_OBJECT (view->adapter)); adapter_changed (view); gtk_object_set (GTK_OBJECT (view), "model", view->adapter, NULL); + if (view->adapter) { + EAddressbookModel *model; + gtk_object_get (GTK_OBJECT (view->adapter), + "model", &model, + NULL); + if (model) { + view->writable_status_id = + gtk_signal_connect (GTK_OBJECT (model), "writable_status", + GTK_SIGNAL_FUNC (writable_status_change), view); + } + + } break; case ARG_BOOK: gtk_object_set (GTK_OBJECT (view->adapter), "book", GTK_VALUE_OBJECT (*arg), NULL); + set_empty_message (view); break; case ARG_QUERY: gtk_object_set (GTK_OBJECT (view->adapter), @@ -193,6 +241,7 @@ e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) gtk_object_set (GTK_OBJECT (view->adapter), "editable", GTK_VALUE_BOOL (*arg), NULL); + set_empty_message (view); break; } } @@ -238,7 +287,22 @@ e_minicard_view_destroy (GtkObject *object) gtk_signal_disconnect (GTK_OBJECT (GNOME_CANVAS_ITEM (view)->canvas), view->canvas_drag_data_get_id); } - gtk_object_unref (GTK_OBJECT (view->adapter)); + + if (view->adapter) { + if (view->writable_status_id) { + EAddressbookModel *model; + gtk_object_get (GTK_OBJECT (view->adapter), + "model", &model, + NULL); + if (model) { + gtk_signal_disconnect (GTK_OBJECT (model), view->writable_status_id); + } + } + + gtk_object_unref (GTK_OBJECT(view->adapter)); + } + view->writable_status_id = 0; + view->adapter = NULL; GTK_OBJECT_CLASS(parent_class)->destroy (object); } @@ -431,6 +495,9 @@ e_minicard_view_init (EMinicardView *view) { view->adapter = NULL; view->canvas_drag_data_get_id = 0; + view->writable_status_id = 0; + + set_empty_message (view); } GtkType diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h index 1140965106..e13dd08c05 100644 --- a/addressbook/gui/widgets/e-minicard-view.h +++ b/addressbook/gui/widgets/e-minicard-view.h @@ -74,10 +74,9 @@ struct _EMinicardView GList *drag_list; - int canvas_destroy_id; - int canvas_drag_data_get_id; + guint canvas_drag_data_get_id; - int status_message_id; + guint writable_status_id; }; struct _EMinicardViewClass |