aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-list-editor/e-contact-list-editor.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2001-06-26 05:51:17 +0800
committerChris Toshok <toshok@src.gnome.org>2001-06-26 05:51:17 +0800
commit9a1c55ede5e6aad25d0053b097dab47a66b479d1 (patch)
tree019f1b0c0b08dd5c8ae5240fe77559fdd47040c7 /addressbook/gui/contact-list-editor/e-contact-list-editor.c
parent0296d70c6e207fa4c6acc14f6a0541b14028b64e (diff)
downloadgsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.gz
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.bz2
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.lz
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.xz
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.zst
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.zip
change layout slightly, the icon no longer pushes everything to the left,
2001-06-25 Chris Toshok <toshok@ximian.com> * gui/contact-list-editor/contact-list-editor.glade: change layout slightly, the icon no longer pushes everything to the left, and make the buttons on the right smaller and more in line with the other widgets. * gui/contact-list-editor/e-contact-list-model.c (contact_list_value_at): return the SimpleAndString->string instead of querying the ecardsimple. (e_contact_list_model_init): initially allocate 10 of each type (email and simple). (e_contact_list_model_add_email): realloc if need be. (e_contact_list_model_add_card): same, and initialize the string displayed to be "[Name] [<email>]". (e_contact_list_model_remove_row): change for SimpleAndString. (contact_list_model_destroy): free our 2 arrays. * gui/contact-list-editor/e-contact-list-model.h: add alloc counts and the SimpleAndString struct. * gui/contact-list-editor/e-contact-list-editor.c: Helix Code => Ximian. (e_contact_list_editor_init): hook up d&d destination signals, and un-#if 0 the delete_event signal. (table_drag_motion_cb): new function. (table_drag_drop_cb): new function. (table_drag_data_received_cb): new function. (file_close_cb): new function. (verbs) uncomment the close verb. (close_dialog): new function. (app_delete_event_cb): new function. * gui/contact-list-editor/e-contact-list-editor.h: Helix Code => Ximian. svn path=/trunk/; revision=10494
Diffstat (limited to 'addressbook/gui/contact-list-editor/e-contact-list-editor.c')
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c144
1 files changed, 135 insertions, 9 deletions
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index f95cb936af..06a3473baa 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* e-contact-list-editor.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Toshok <toshok@helixcode.com>
+ * Copyright (C) 2001 Ximian, Inc.
+ * Author: Chris Toshok <toshok@ximian.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -45,15 +45,35 @@ static void e_contact_list_editor_destroy (GtkObject *object);
static void create_ui (EContactListEditor *ce);
static void set_editable (EContactListEditor *editor);
static void command_state_changed (EContactListEditor *editor);
+static void close_dialog (EContactListEditor *cle);
static void add_email_cb (GtkWidget *w, EContactListEditor *editor);
static void remove_entry_cb (GtkWidget *w, EContactListEditor *editor);
static void list_name_changed_cb (GtkWidget *w, EContactListEditor *editor);
+static gint app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data);
+static gboolean table_drag_drop_cb (ETable *table, int row, int col, GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor);
+static gboolean table_drag_motion_cb (ETable *table, int row, int col, GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor);
+static void table_drag_data_received_cb (ETable *table, int row, int col,
+ GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data, guint info, guint time,
+ EContactListEditor *editor);
static GtkObjectClass *parent_class = NULL;
static guint contact_list_editor_signals[LAST_SIGNAL];
+enum DndTargetType {
+ DND_TARGET_TYPE_VCARD,
+};
+#define VCARD_TYPE "text/x-vcard"
+static GtkTargetEntry drag_types[] = {
+ { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD },
+};
+static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
+
/* The arguments we take */
enum {
ARG_0,
@@ -236,14 +256,22 @@ e_contact_list_editor_init (EContactListEditor *editor)
gtk_signal_connect (GTK_OBJECT(editor->list_name_entry),
"changed", GTK_SIGNAL_FUNC(list_name_changed_cb), editor);
+ e_table_drag_dest_set (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
+ 0, drag_types, num_drag_types, GDK_ACTION_LINK);
+
+ gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))),
+ "table_drag_motion", GTK_SIGNAL_FUNC(table_drag_motion_cb), editor);
+ gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))),
+ "table_drag_drop", GTK_SIGNAL_FUNC(table_drag_drop_cb), editor);
+ gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))),
+ "table_drag_data_received", GTK_SIGNAL_FUNC(table_drag_data_received_cb), editor);
+
command_state_changed (editor);
/* Connect to the deletion of the dialog */
-#if 0
gtk_signal_connect (GTK_OBJECT (editor->app), "delete_event",
GTK_SIGNAL_FUNC (app_delete_event_cb), editor);
-#endif
}
static void
@@ -251,6 +279,16 @@ e_contact_list_editor_destroy (GtkObject *object)
{
}
+/* File/Close callback */
+static void
+file_close_cb (GtkWidget *widget, gpointer data)
+{
+ EContactListEditor *cle;
+
+ cle = E_CONTACT_LIST_EDITOR (data);
+ close_dialog (cle);
+}
+
static
BonoboUIVerb verbs [] = {
#if 0
@@ -260,11 +298,8 @@ BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("ContactEditorSendAs", file_send_as_cb),
BONOBO_UI_UNSAFE_VERB ("ContactEditorSendTo", file_send_to_cb),
BONOBO_UI_UNSAFE_VERB ("ContactEditorDelete", delete_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactEditorPrint", print_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactEditorPrintEnvelope", print_envelope_cb),
- /* BONOBO_UI_UNSAFE_VERB ("ContactEditorPageSetup", file_page_setup_menu), */
- BONOBO_UI_UNSAFE_VERB ("ContactEditorClose", file_close_cb),
-#endif
+#endif
+ BONOBO_UI_UNSAFE_VERB ("ContactListEditorClose", file_close_cb),
BONOBO_UI_VERB_END
};
@@ -479,6 +514,97 @@ set_editable (EContactListEditor *editor)
gtk_widget_set_sensitive (editor->table, editor->editable);
}
+/* Closes the dialog box and emits the appropriate signals */
+static void
+close_dialog (EContactListEditor *cle)
+{
+ g_assert (cle->app != NULL);
+
+ gtk_widget_destroy (cle->app);
+ cle->app = NULL;
+
+ gtk_signal_emit (GTK_OBJECT (cle), contact_list_editor_signals[EDITOR_CLOSED]);
+}
+
+/* Callback used when the editor is destroyed */
+static gint
+app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ EContactListEditor *ce;
+
+ ce = E_CONTACT_LIST_EDITOR (data);
+
+ close_dialog (ce);
+ return TRUE;
+}
+
+static gboolean
+table_drag_motion_cb (ETable *table, int row, int col,
+ GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor)
+{
+ GList *p;
+
+ for (p = context->targets; p != NULL; p = p->next) {
+ char *possible_type;
+
+ possible_type = gdk_atom_name ((GdkAtom) p->data);
+ if (!strcmp (possible_type, VCARD_TYPE)) {
+ g_free (possible_type);
+ gdk_drag_status (context, GDK_ACTION_LINK, time);
+ return TRUE;
+ }
+
+ g_free (possible_type);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+table_drag_drop_cb (ETable *table, int row, int col,
+ GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor)
+{
+ if (context->targets != NULL) {
+ gtk_drag_get_data (GTK_WIDGET (table), context,
+ GPOINTER_TO_INT (context->targets->data),
+ time);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+table_drag_data_received_cb (ETable *table, int row, int col,
+ GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data,
+ guint info, guint time, EContactListEditor *editor)
+{
+ char *target_type;
+
+ target_type = gdk_atom_name (selection_data->target);
+
+ if (!strcmp (target_type, VCARD_TYPE)) {
+ GList *card_list = e_card_load_cards_from_string (selection_data->data);
+ GList *c;
+
+ for (c = card_list; c; c = c->next) {
+ ECard *ecard = c->data;
+ ECardSimple *simple = e_card_simple_new (ecard);
+
+ e_contact_list_model_add_card (E_CONTACT_LIST_MODEL (editor->model),
+ simple);
+
+ gtk_object_unref (GTK_OBJECT (simple));
+ }
+ g_list_foreach (card_list, (GFunc)gtk_object_unref, NULL);
+ g_list_free (card_list);
+ }
+}
+
static void
command_state_changed (EContactListEditor *editor)
{