diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-08-20 01:35:44 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-08-20 01:35:44 +0800 |
commit | 7aa37d45375de7a08821f7108cd90cdc96273be5 (patch) | |
tree | d9849bbdc0ccb0aa28617d984e8d70217b26171e /addressbook/gui/widgets | |
parent | 81657a54af2413a1b2be6a00f2d46b31e035df5a (diff) | |
download | gsoc2013-evolution-7aa37d45375de7a08821f7108cd90cdc96273be5.tar.gz gsoc2013-evolution-7aa37d45375de7a08821f7108cd90cdc96273be5.tar.zst gsoc2013-evolution-7aa37d45375de7a08821f7108cd90cdc96273be5.zip |
Set the folder bar message here.
2001-08-19 Christopher James Lahey <clahey@ximian.com>
* gui/component/addressbook.c (set_folder_bar_label),
gui/widgets/e-addressbook-model.c,
gui/widgets/e-addressbook-model.h (update_folder_bar_message),
gui/widgets/e-addressbook-view.c, gui/widgets/e-addressbook-view.h
(folder_bar_message): Set the folder bar message here.
* gui/component/select-names/e-select-names-model.c (SEPLEN): Use
strlen(SEPARATOR) here so that if the separator changes the length
will work properly.
svn path=/trunk/; revision=12220
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.c | 48 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.h | 1 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 61 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.h | 3 |
4 files changed, 110 insertions, 3 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index a44c066d4f..49086da70b 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -35,6 +35,7 @@ enum { enum { WRITABLE_STATUS, STATUS_MESSAGE, + FOLDER_BAR_MESSAGE, CARD_ADDED, CARD_REMOVED, CARD_CHANGED, @@ -108,6 +109,33 @@ addressbook_destroy(GtkObject *object) } static void +update_folder_bar_message (EAddressbookModel *model) +{ + int count; + char *message; + + count = model->data_count; + + switch (count) { + case 0: + message = g_strdup (_("No cards")); + break; + case 1: + message = g_strdup (_("1 card")); + break; + default: + message = g_strdup_printf (_("%d cards"), count); + break; + } + + gtk_signal_emit (GTK_OBJECT (model), + e_addressbook_model_signals [FOLDER_BAR_MESSAGE], + message); + + g_free (message); +} + +static void create_card(EBookView *book_view, const GList *cards, EAddressbookModel *model) @@ -122,13 +150,23 @@ create_card(EBookView *book_view, } for ( ; cards; cards = cards->next) { + char *file_as; + model->data[model->data_count++] = cards->data; gtk_object_ref (cards->data); + gtk_object_get (GTK_OBJECT (cards->data), + "file_as", &file_as, + NULL); + g_print ("Received card: %s\n", file_as); } + g_print ("Finished\n"); + gtk_signal_emit (GTK_OBJECT (model), e_addressbook_model_signals [CARD_ADDED], old_count, model->data_count - old_count); + + update_folder_bar_message (model); } static void @@ -147,6 +185,7 @@ remove_card(EBookView *book_view, gtk_signal_emit (GTK_OBJECT (model), e_addressbook_model_signals [CARD_REMOVED], i); + update_folder_bar_message (model); break; } } @@ -238,6 +277,14 @@ e_addressbook_model_class_init (GtkObjectClass *object_class) gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + e_addressbook_model_signals [FOLDER_BAR_MESSAGE] = + gtk_signal_new ("folder_bar_message", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EAddressbookModelClass, folder_bar_message), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + e_addressbook_model_signals [CARD_ADDED] = gtk_signal_new ("card_added", GTK_RUN_LAST, @@ -376,7 +423,6 @@ e_addressbook_model_get_card(EAddressbookModel *model, if (model->data && row < model->data_count) { ECard *card; card = e_card_duplicate (model->data[row]); - gtk_object_ref (GTK_OBJECT (card)); return card; } return NULL; diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h index a0956d7003..3bd66ca46f 100644 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ b/addressbook/gui/widgets/e-addressbook-model.h @@ -46,6 +46,7 @@ struct _EAddressbookModelClass { */ void (*writable_status) (EAddressbookModel *model, gboolean writable); void (*status_message) (EAddressbookModel *model, const gchar *message); + void (*folder_bar_message) (EAddressbookModel *model, const gchar *message); void (*card_added) (EAddressbookModel *model, gint index, gint count); void (*card_removed) (EAddressbookModel *model, gint index); void (*card_changed) (EAddressbookModel *model, gint index); diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index d285fa283a..beb399e38a 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -56,6 +56,7 @@ #include "e-card-merging.h" #include "e-contact-editor.h" +#include <gdk/gdkkeysyms.h> #include <ctype.h> static void e_addressbook_view_init (EAddressbookView *card); @@ -63,9 +64,12 @@ 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 gint e_addressbook_view_key_press_event (GtkWidget *widget, + GdkEventKey *event); static void change_view_type (EAddressbookView *view, EAddressbookViewType view_type); -static void status_message (GtkObject *object, const gchar *status, EAddressbookView *eav); +static void status_message (GtkObject *object, const gchar *status, EAddressbookView *eav); +static void folder_bar_message (GtkObject *object, const gchar *status, EAddressbookView *eav); static void stop_state_changed (GtkObject *object, EAddressbookView *eav); static void writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav); static void command_state_change (EAddressbookView *eav); @@ -90,6 +94,7 @@ enum { enum { STATUS_MESSAGE, + FOLDER_BAR_MESSAGE, COMMAND_STATE_CHANGE, LAST_SIGNAL }; @@ -135,8 +140,10 @@ static void e_addressbook_view_class_init (EAddressbookViewClass *klass) { GtkObjectClass *object_class; + GtkWidgetClass *widget_class; object_class = GTK_OBJECT_CLASS(klass); + widget_class = GTK_WIDGET_CLASS(klass); parent_class = gtk_type_class (gtk_table_get_type ()); @@ -144,6 +151,8 @@ e_addressbook_view_class_init (EAddressbookViewClass *klass) object_class->get_arg = e_addressbook_view_get_arg; object_class->destroy = e_addressbook_view_destroy; + widget_class->key_press_event = e_addressbook_view_key_press_event; + 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, @@ -159,6 +168,14 @@ e_addressbook_view_class_init (EAddressbookViewClass *klass) gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + e_addressbook_view_signals [FOLDER_BAR_MESSAGE] = + gtk_signal_new ("folder_bar_message", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EAddressbookViewClass, folder_bar_message), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + e_addressbook_view_signals [COMMAND_STATE_CHANGE] = gtk_signal_new ("command_state_change", GTK_RUN_LAST, @@ -186,6 +203,11 @@ e_addressbook_view_init (EAddressbookView *eav) eav); gtk_signal_connect (GTK_OBJECT(eav->model), + "folder_bar_message", + GTK_SIGNAL_FUNC (folder_bar_message), + eav); + + gtk_signal_connect (GTK_OBJECT(eav->model), "stop_state_changed", GTK_SIGNAL_FUNC (stop_state_changed), eav); @@ -261,6 +283,29 @@ e_addressbook_view_destroy (GtkObject *object) GTK_OBJECT_CLASS(parent_class)->destroy(object); } +static gint +e_addressbook_view_key_press_event (GtkWidget *widget, + GdkEventKey *event) +{ + EAddressbookView *view = E_ADDRESSBOOK_VIEW (widget); + guint return_val = 0; + + if (GTK_WIDGET_CLASS (parent_class)->key_press_event) { + return_val = GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); + if (return_val != 0) + return return_val; + } + + if ((event->keyval == GDK_Delete || + event->keyval == GDK_KP_Delete) && + event->state == 0) { + e_addressbook_view_delete_selection(view); + return_val = TRUE; + } + + return return_val; +} + GtkWidget* e_addressbook_view_new (void) { @@ -745,12 +790,26 @@ emit_status_message (EAddressbookView *eav, const gchar *status) } static void +emit_folder_bar_message (EAddressbookView *eav, const gchar *message) +{ + gtk_signal_emit (GTK_OBJECT (eav), + e_addressbook_view_signals [FOLDER_BAR_MESSAGE], + message); +} + +static void status_message (GtkObject *object, const gchar *status, EAddressbookView *eav) { emit_status_message (eav, status); } static void +folder_bar_message (GtkObject *object, const gchar *status, EAddressbookView *eav) +{ + emit_folder_bar_message (eav, status); +} + +static void stop_state_changed (GtkObject *object, EAddressbookView *eav) { command_state_change (eav); diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h index 8fc807572a..621f26bb2a 100644 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ b/addressbook/gui/widgets/e-addressbook-view.h @@ -90,7 +90,8 @@ struct _EAddressbookViewClass /* * Signals */ - void (*status_message) (EAddressbookView *view, const gchar *message); + void (*status_message) (EAddressbookView *view, const gchar *message); + void (*folder_bar_message) (EAddressbookView *view, const gchar *message); void (*command_state_change) (EAddressbookView *view); }; |