diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-07-08 13:21:06 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-07-08 13:21:06 +0800 |
commit | 04c9a5189dac46e93a3b35134dbc499df3e28c21 (patch) | |
tree | 80eb111e562f39c0b2b75b5e9a974689c1a50427 /addressbook/gui | |
parent | d1550ea22f88670875c2cb77d2bb46d8a97d6de0 (diff) | |
download | gsoc2013-evolution-04c9a5189dac46e93a3b35134dbc499df3e28c21.tar gsoc2013-evolution-04c9a5189dac46e93a3b35134dbc499df3e28c21.tar.gz gsoc2013-evolution-04c9a5189dac46e93a3b35134dbc499df3e28c21.tar.bz2 gsoc2013-evolution-04c9a5189dac46e93a3b35134dbc499df3e28c21.tar.lz gsoc2013-evolution-04c9a5189dac46e93a3b35134dbc499df3e28c21.tar.xz gsoc2013-evolution-04c9a5189dac46e93a3b35134dbc499df3e28c21.tar.zst gsoc2013-evolution-04c9a5189dac46e93a3b35134dbc499df3e28c21.zip |
Added an "editable" argument.
2000-07-08 Christopher James Lahey <clahey@helixcode.com>
* gui/component/e-addressbook-model.c,
gui/component/e-addressbook-model.h: Added an "editable" argument.
* gui/component/select-names/e-select-names.c: Set our
EAddressModel to not be editable.
svn path=/trunk/; revision=3969
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/component/e-addressbook-model.c | 36 | ||||
-rw-r--r-- | addressbook/gui/component/e-addressbook-model.h | 2 | ||||
-rw-r--r-- | addressbook/gui/component/select-names/e-select-names.c | 3 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.c | 36 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.h | 2 |
5 files changed, 55 insertions, 24 deletions
diff --git a/addressbook/gui/component/e-addressbook-model.c b/addressbook/gui/component/e-addressbook-model.c index 7deda52c98..2401677807 100644 --- a/addressbook/gui/component/e-addressbook-model.c +++ b/addressbook/gui/component/e-addressbook-model.c @@ -29,6 +29,7 @@ enum { ARG_0, ARG_BOOK, ARG_QUERY, + ARG_EDITABLE, }; static void @@ -93,24 +94,26 @@ addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) { EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); ECard *card; - 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); + 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 TRUE; + return E_ADDRESSBOOK_MODEL(etc)->editable; } static gint @@ -219,6 +222,8 @@ e_addressbook_model_class_init (GtkObjectClass *object_class) 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; @@ -246,6 +251,7 @@ e_addressbook_model_init (GtkObject *object) model->modify_card_id = 0; model->data = NULL; model->data_count = 0; + model->editable = TRUE; } static void @@ -339,6 +345,9 @@ e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) 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; } } @@ -356,6 +365,9 @@ e_addressbook_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) 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; diff --git a/addressbook/gui/component/e-addressbook-model.h b/addressbook/gui/component/e-addressbook-model.h index bff9a21d00..8f5f6485cf 100644 --- a/addressbook/gui/component/e-addressbook-model.h +++ b/addressbook/gui/component/e-addressbook-model.h @@ -34,6 +34,8 @@ typedef struct { int data_count; int create_card_id, remove_card_id, modify_card_id; + + guint editable : 1; } EAddressbookModel; diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c index 93214ca923..a588b10770 100644 --- a/addressbook/gui/component/select-names/e-select-names.c +++ b/addressbook/gui/component/select-names/e-select-names.c @@ -135,6 +135,9 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n char *uri; model = e_addressbook_model_new(); + gtk_object_set(GTK_OBJECT(model), + "editable", FALSE, + NULL); cell_left_just = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); header = e_table_header_new (); diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index 7deda52c98..2401677807 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -29,6 +29,7 @@ enum { ARG_0, ARG_BOOK, ARG_QUERY, + ARG_EDITABLE, }; static void @@ -93,24 +94,26 @@ addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) { EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); ECard *card; - 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); + 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 TRUE; + return E_ADDRESSBOOK_MODEL(etc)->editable; } static gint @@ -219,6 +222,8 @@ e_addressbook_model_class_init (GtkObjectClass *object_class) 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; @@ -246,6 +251,7 @@ e_addressbook_model_init (GtkObject *object) model->modify_card_id = 0; model->data = NULL; model->data_count = 0; + model->editable = TRUE; } static void @@ -339,6 +345,9 @@ e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) 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; } } @@ -356,6 +365,9 @@ e_addressbook_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) 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; diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h index bff9a21d00..8f5f6485cf 100644 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ b/addressbook/gui/widgets/e-addressbook-model.h @@ -34,6 +34,8 @@ typedef struct { int data_count; int create_card_id, remove_card_id, modify_card_id; + + guint editable : 1; } EAddressbookModel; |