diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-06-16 05:40:12 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-06-16 05:40:12 +0800 |
commit | 7395fd6ba14d1267ec54719687d461ac7707f8fb (patch) | |
tree | aee5d69a1aec941182074bc5627776f4abc1f101 /mail | |
parent | f0d0478ea1e4f44df4743554808ff04d887b3038 (diff) | |
download | gsoc2013-evolution-7395fd6ba14d1267ec54719687d461ac7707f8fb.tar.gz gsoc2013-evolution-7395fd6ba14d1267ec54719687d461ac7707f8fb.tar.zst gsoc2013-evolution-7395fd6ba14d1267ec54719687d461ac7707f8fb.zip |
Implemented.
2001-06-15 Jeffrey Stedfast <fejj@ximian.com>
* component-factory.c (destination_folder_handle_drop): Implemented.
* message-list.c (message_list_construct): Don't connect to the
DnD signals here.
(message_list_drag_data_get): Removed.
(add_uid): Removed.
* folder-browser.c (my_folder_browser_init): Connect to DnD signals.
(message_list_drag_data_get): Implemented.
svn path=/trunk/; revision=10257
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 12 | ||||
-rw-r--r-- | mail/component-factory.c | 21 | ||||
-rw-r--r-- | mail/folder-browser.c | 237 | ||||
-rw-r--r-- | mail/message-list.c | 128 |
4 files changed, 235 insertions, 163 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index ceabc5f8a5..17d70172d4 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,17 @@ 2001-06-15 Jeffrey Stedfast <fejj@ximian.com> + * component-factory.c (destination_folder_handle_drop): Implemented. + + * message-list.c (message_list_construct): Don't connect to the + DnD signals here. + (message_list_drag_data_get): Removed. + (add_uid): Removed. + + * folder-browser.c (my_folder_browser_init): Connect to DnD signals. + (message_list_drag_data_get): Implemented. + +2001-06-15 Jeffrey Stedfast <fejj@ximian.com> + * mail-ops.c (mail_send_message): Fixed misuse of an uninitialized variable. diff --git a/mail/component-factory.c b/mail/component-factory.c index a4b95c30aa..de73ff269a 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -68,7 +68,7 @@ static GHashTable *storages_hash; static char *accepted_dnd_types[] = { "message/rfc822", /* if we drag from nautilus or something... */ - "x-evolution-folder-dnd", /* if we drag from an evolution folder... */ + "x-evolution-dnd", /* if we drag from an evolution folder... */ NULL }; @@ -345,19 +345,28 @@ destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *fol camel_object_unref (CAMEL_OBJECT (stream)); } else { /* x-evolution-dnd */ - char *uri, *in, *inptr, *inend; + char *url, *name, *in, *inptr, *inend; CamelFolder *source; GPtrArray *uids; - /* format is "uri uid1\0uid2\0uid3\0...\0uidn" */ + /* format: "url folder_name uid1\0uid2\0uid3\0...\0uidn" */ in = data->bytes._buffer; inend = in + data->bytes._length; inptr = strchr (in, ' '); - uri = g_strndup (data->bytes._buffer, inptr - in); - source = mail_tool_uri_to_folder (uri, NULL); - g_free (uri); + url = g_strndup (in, inptr - in); + + name = inptr + 1; + inptr = strchr (name, ' '); + name = g_strndup (name, inptr - name); + + source = mail_tool_get_folder_from_urlname (url, name, 0, NULL); + g_free (name); + g_free (url); + + if (!source) + return FALSE; /* split the uids */ inptr++; diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 663dd40f6c..25c8a6c289 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -51,6 +51,25 @@ #define PARENT_TYPE (gtk_table_get_type ()) + +enum DndTargetType { + DND_TARGET_TYPE_X_EVOLUTION_DND, + DND_TARGET_TYPE_MESSAGE_RFC822, + DND_TARGET_TYPE_URI_LIST, +}; + +#define X_EVOLUTION_DND_TYPE "x-evolution-dnd" +#define MESSAGE_RFC822_TYPE "message/rfc822" +#define URI_LIST_TYPE "text/uri-list" + +static GtkTargetEntry drag_types[] = { + { X_EVOLUTION_DND_TYPE, 0, DND_TARGET_TYPE_X_EVOLUTION_DND }, + { MESSAGE_RFC822_TYPE, 0, DND_TARGET_TYPE_MESSAGE_RFC822 }, + { URI_LIST_TYPE, 0, DND_TARGET_TYPE_URI_LIST }, +}; + +static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); + static void fb_resize_cb (GtkWidget *w, GtkAllocation *a); static void update_unread_count (CamelObject *, gpointer, gpointer); @@ -168,7 +187,7 @@ update_unread_count_main(CamelObject *object, gpointer event_data, gpointer user } static void -update_unread_count(CamelObject *object, gpointer event_data, gpointer user_data) +update_unread_count (CamelObject *object, gpointer event_data, gpointer user_data) { CamelFolder *folder = (CamelFolder *)object; FolderBrowser *fb = user_data; @@ -182,47 +201,153 @@ update_unread_count(CamelObject *object, gpointer event_data, gpointer user_data } static void +add_uid (MessageList *ml, const char *uid, gpointer data) +{ + g_ptr_array_add ((GPtrArray *) data, g_strdup (uid)); +} + +static void +message_list_drag_data_get (ETree *tree, + int row, + ETreePath path, + int col, + GdkDragContext *context, + GtkSelectionData *selection_data, + guint info, + guint time, + gpointer user_data) +{ + FolderBrowser *fb = FOLDER_BROWSER (user_data); + GPtrArray *uids = NULL; + + switch (info) { + case DND_TARGET_TYPE_URI_LIST: + { + char *tmpl, *tmpdir, *filename, *subject; + CamelMessageInfo *minfo; + + /* drag & drop into nautilus */ + tmpl = g_strdup ("/tmp/evolution.XXXXXX"); +#ifdef HAVE_MKDTEMP + tmpdir = mkdtemp (tmpl); +#else + tmpdir = mktemp (tmpl); + if (tmpdir) { + if (mkdir (tmpdir, S_IRWXU) == -1) + tmpdir = NULL; + } +#endif + if (!tmpdir) { + g_free (tmpl); + return; + } + g_free (tmpl); + + uids = g_ptr_array_new (); + message_list_foreach (fb->message_list, add_uid, uids); + + minfo = camel_folder_get_message_info (fb->folder, uids->pdata[0]); + + subject = g_strdup (camel_message_info_subject (minfo)); + e_filename_make_safe (subject); + filename = g_strdup_printf ("%s/%s.eml", tmpdir, subject); + g_free (subject); + + mail_msg_wait (mail_save_messages (fb->folder, uids, filename, NULL, NULL)); + + gtk_selection_data_set (selection_data, selection_data->target, 8, + (guchar *) filename, strlen (filename)); + } + break; + case DND_TARGET_TYPE_MESSAGE_RFC822: + break; + case DND_TARGET_TYPE_X_EVOLUTION_DND: + { + GByteArray *array; + char *uri; + int i; + + /* format: "url folder_name uid1\0uid2\0uid3\0...\0uidn" */ + + uids = g_ptr_array_new (); + message_list_foreach (fb->message_list, add_uid, uids); + + uri = camel_url_to_string (CAMEL_SERVICE (camel_folder_get_parent_store (fb->folder))->url, 0); + + /* write the url portion */ + array = g_byte_array_new (); + g_byte_array_append (array, uri, strlen (uri)); + g_byte_array_append (array, " ", 1); + g_free (uri); + + /* write the folder_name portion */ + g_byte_array_append (array, fb->folder->name, strlen (fb->folder->name)); + g_byte_array_append (array, " ", 1); + + /* write the uids */ + for (i = 0; i < uids->len; i++) { + g_byte_array_append (array, uids->pdata[i], strlen (uids->pdata[i])); + g_free (uids->pdata[i]); + + if (i + 1 < uids->len) + g_byte_array_append (array, "", 1); + } + + g_ptr_array_free (uids, TRUE); + + gtk_selection_data_set (selection_data, selection_data->target, 8, + array->data, array->len); + + g_byte_array_free (array, FALSE); + } + break; + default: + break; + } +} + +static void got_folder(char *uri, CamelFolder *folder, void *data) { FolderBrowser *fb = data; EvolutionStorage *storage; - - printf("got folder '%s' = %p\n", uri, folder); - + + d(printf ("got folder '%s' = %p\n", uri, folder)); + if (fb->folder == folder) goto done; - + if (fb->folder) - camel_object_unref((CamelObject *)fb->folder); - g_free(fb->uri); - fb->uri = g_strdup(uri); + camel_object_unref (CAMEL_OBJECT (fb->folder)); + g_free (fb->uri); + fb->uri = g_strdup (uri); fb->folder = folder; - + if (folder == NULL) goto done; - - camel_object_ref((CamelObject *)folder); - + + camel_object_ref (CAMEL_OBJECT (folder)); + if ((storage = mail_lookup_storage (folder->parent_store))) { gtk_object_unref (GTK_OBJECT (storage)); fb->unread_count = camel_folder_get_unread_message_count (folder); - update_unread_count_main ((CamelObject *)folder, NULL, fb); - camel_object_hook_event ((CamelObject *)folder, "message_changed", + update_unread_count_main (CAMEL_OBJECT (folder), NULL, fb); + camel_object_hook_event (CAMEL_OBJECT (folder), "message_changed", update_unread_count, fb); - camel_object_hook_event ((CamelObject *)folder, "folder_changed", + camel_object_hook_event (CAMEL_OBJECT (folder), "folder_changed", update_unread_count, fb); } - - gtk_widget_set_sensitive(GTK_WIDGET(fb->search), camel_folder_has_search_capability(folder)); + + gtk_widget_set_sensitive (GTK_WIDGET (fb->search), camel_folder_has_search_capability (folder)); message_list_set_threaded (fb->message_list, mail_config_get_thread_list (fb->uri)); - message_list_set_folder(fb->message_list, folder, - folder_browser_is_drafts (fb) || - folder_browser_is_sent (fb) || - folder_browser_is_outbox (fb)); - vfolder_register_source(folder); -done: - gtk_object_unref((GtkObject *)fb); - + message_list_set_folder (fb->message_list, folder, + folder_browser_is_drafts (fb) || + folder_browser_is_sent (fb) || + folder_browser_is_outbox (fb)); + vfolder_register_source (folder); + done: + gtk_object_unref (GTK_OBJECT (fb)); + /* Sigh, i dont like this (it can be set in reconfigure folder), but its just easier right now to do it this way */ fb->reconfigure = FALSE; @@ -241,7 +366,7 @@ folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri) but its just easier right now to do it this way */ folder_browser->reconfigure = FALSE; } - + return TRUE; } @@ -260,12 +385,12 @@ folder_browser_is_drafts (FolderBrowser *fb) { const GSList *accounts; MailConfigAccount *account; - + g_return_val_if_fail (IS_FOLDER_BROWSER (fb) && fb->uri, FALSE); - + if (fb->folder == drafts_folder) return TRUE; - + accounts = mail_config_get_accounts (); while (accounts) { account = accounts->data; @@ -274,6 +399,7 @@ folder_browser_is_drafts (FolderBrowser *fb) return TRUE; accounts = accounts->next; } + return FALSE; } @@ -289,12 +415,12 @@ folder_browser_is_sent (FolderBrowser *fb) { const GSList *accounts; MailConfigAccount *account; - + g_return_val_if_fail (IS_FOLDER_BROWSER (fb) && fb->uri, FALSE); - + if (fb->folder == sent_folder) return TRUE; - + accounts = mail_config_get_accounts (); while (accounts) { account = accounts->data; @@ -303,6 +429,7 @@ folder_browser_is_sent (FolderBrowser *fb) return TRUE; accounts = accounts->next; } + return FALSE; } @@ -325,7 +452,7 @@ folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show { if (folder_browser->preview_shown == show_message_preview) return; - + g_warning ("FIXME: implement me"); } @@ -345,15 +472,15 @@ static void folder_browser_search_menu_activated (ESearchBar *esb, int id, FolderBrowser *fb) { EFilterBar *efb = (EFilterBar *)esb; - - printf("menyu activated\n"); - + + d(printf("menu activated\n")); + switch (id) { case ESB_SAVE: - printf("Save vfolder\n"); + d(printf("Save vfolder\n")); if (efb->current_query) { FilterRule *rule = vfolder_clone_rule(efb->current_query); - + filter_rule_set_source(rule, FILTER_SOURCE_INCOMING); vfolder_rule_add_source((VfolderRule *)rule, fb->uri); vfolder_gui_add_rule((VfolderRule *)rule); @@ -362,7 +489,8 @@ folder_browser_search_menu_activated (ESearchBar *esb, int id, FolderBrowser *fb } } -static void folder_browser_config_search(EFilterBar *efb, FilterRule *rule, int id, const char *query, void *data) +static void +folder_browser_config_search (EFilterBar *efb, FilterRule *rule, int id, const char *query, void *data) { FolderBrowser *fb = FOLDER_BROWSER (data); ESearchingTokenizer *st; @@ -394,8 +522,9 @@ static void folder_browser_config_search(EFilterBar *efb, FilterRule *rule, int partl = partl->next; } - printf("configuring search for search string '%s', rule is '%s'\n", query, rule->name); - + + d(printf("configuring search for search string '%s', rule is '%s'\n", query, rule->name)); + mail_display_redisplay (fb->mail_display, FALSE); } @@ -403,16 +532,16 @@ static void folder_browser_search_query_changed (ESearchBar *esb, FolderBrowser *fb) { char *search_word; - - printf("query changed\n"); - + + d(printf("query changed\n")); + gtk_object_get (GTK_OBJECT (esb), "query", &search_word, NULL); message_list_set_search (fb->message_list, search_word); - - printf("query is %s\n", search_word); + + d(printf("query is %s\n", search_word)); g_free(search_word); return; } @@ -1000,8 +1129,7 @@ folder_browser_gui_init (FolderBrowser *fb) fb->vpaned = e_vpaned_new (); gtk_widget_show (fb->vpaned); - gtk_table_attach ( - GTK_TABLE (fb), fb->vpaned, + gtk_table_attach (GTK_TABLE (fb), fb->vpaned, 0, 1, 1, 3, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, @@ -1194,10 +1322,17 @@ my_folder_browser_init (GtkObject *object) gtk_signal_connect (GTK_OBJECT (fb->message_list->tree), "double_click", GTK_SIGNAL_FUNC (on_double_click), fb); - - gtk_signal_connect (GTK_OBJECT(fb->message_list), "message_selected", + + gtk_signal_connect (GTK_OBJECT (fb->message_list), "message_selected", on_message_selected, fb); - + + /* drag & drop */ + e_tree_drag_source_set (fb->message_list->tree, GDK_BUTTON1_MASK, + drag_types, num_drag_types, GDK_ACTION_MOVE); + + gtk_signal_connect (GTK_OBJECT (fb->message_list->tree), "tree_drag_data_get", + GTK_SIGNAL_FUNC (message_list_drag_data_get), fb); + folder_browser_gui_init (fb); } diff --git a/mail/message-list.c b/mail/message-list.c index 3ae49c8e35..64729048f1 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -153,15 +153,6 @@ static struct { { NULL, NULL } }; -enum DndTargetTyhpe { - DND_TARGET_LIST_TYPE_URI, -}; -#define URI_LIST_TYPE "text/uri-list" -static GtkTargetEntry drag_types[] = { - { URI_LIST_TYPE, 0, DND_TARGET_LIST_TYPE_URI }, -}; -static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); - #ifdef SMART_ADDRESS_COMPARE static EMailAddress * e_mail_address_new (const char *address) @@ -218,12 +209,12 @@ e_mail_address_compare (gconstpointer address1, gconstpointer address2) return g_strcasecmp (addr1->address, addr2->address); } - + if (!addr1->wname) return -1; if (!addr2->wname) return 1; - + if (!addr1->wname->last && !addr2->wname->last) { /* neither has a last name - default to address? */ /* FIXME: what do we compare next? */ @@ -232,30 +223,30 @@ e_mail_address_compare (gconstpointer address1, gconstpointer address2) return g_strcasecmp (addr1->address, addr2->address); } - + if (!addr1->wname->last) return -1; if (!addr2->wname->last) return 1; - + retval = g_strcasecmp (addr1->wname->last, addr2->wname->last); if (retval) return retval; - + /* last names are identical - compare first names */ - + if (!addr1->wname->first && !addr2->wname->first) return g_strcasecmp (addr1->address, addr2->address); - + if (!addr1->wname->first) return -1; if (!addr2->wname->first) return 1; - + retval = g_strcasecmp (addr1->wname->first, addr2->wname->first); if (retval) return retval; - + return g_strcasecmp (addr1->address, addr2->address); } #endif /* SMART_ADDRESS_COMPARE */ @@ -381,7 +372,7 @@ message_list_select (MessageList *message_list, int base_row, CamelMessageInfo *info; int vrow, last; ETree *et = message_list->tree; - + if (!GTK_WIDGET_HAS_FOCUS (message_list)) gtk_widget_grab_focus (GTK_WIDGET (message_list)); @@ -454,73 +445,6 @@ message_list_select_uid (MessageList *message_list, const char *uid) } } -static void -add_uid (MessageList *ml, const char *uid, gpointer data) -{ - g_ptr_array_add ((GPtrArray *) data, g_strdup (uid)); -} - -static void -message_list_drag_data_get (ETree *tree, - int row, - ETreePath path, - int col, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - gpointer user_data) -{ - MessageList *mlist = (MessageList *) user_data; - CamelMessageInfo *minfo; - GPtrArray *uids = NULL; - char *tmpl, *tmpdir, *filename, *subject; - - switch (info) { - case DND_TARGET_LIST_TYPE_URI: - /* drag & drop into nautilus */ - tmpl = g_strdup ("/tmp/evolution.XXXXXX"); -#ifdef HAVE_MKDTEMP - tmpdir = mkdtemp (tmpl); -#else - tmpdir = mktemp (tmpl); - if (tmpdir) { - if (mkdir (tmpdir, S_IRWXU) == -1) - tmpdir = NULL; - } -#endif - if (!tmpdir) { - g_free (tmpl); - return; - } - - minfo = get_message_info (mlist, path); - if (minfo == NULL) { - g_warning("Row %d is invalid", row); - g_free(tmpl); - return; - } - subject = g_strdup (camel_message_info_subject (minfo)); - e_filename_make_safe (subject); - filename = g_strdup_printf ("%s/%s.eml", tmpdir, subject); - g_free (subject); - - uids = g_ptr_array_new (); - message_list_foreach (mlist, add_uid, uids); - - mail_msg_wait(mail_save_messages(mlist->folder, uids, filename, NULL, NULL)); - - gtk_selection_data_set (selection_data, selection_data->target, 8, - (guchar *) filename, strlen (filename)); - - g_free (tmpl); - g_free (filename); - break; - default: - break; - } -} - /* * SimpleTableModel::col_count */ @@ -1223,32 +1147,32 @@ static void message_list_construct (MessageList *message_list) { ETableExtras *extras; - + message_list->model = e_tree_memory_callbacks_new (ml_tree_icon_at, - + ml_column_count, - + ml_has_save_id, ml_get_save_id, - + ml_has_get_node_by_id, ml_get_node_by_id, - + ml_tree_value_at, ml_tree_set_value_at, ml_tree_is_cell_editable, - + ml_duplicate_value, ml_free_value, ml_initialize_value, ml_value_is_empty, ml_value_to_string, - + message_list); gtk_object_ref (GTK_OBJECT (message_list->model)); gtk_object_sink (GTK_OBJECT (message_list->model)); - + e_tree_memory_set_expanded_default(E_TREE_MEMORY(message_list->model), TRUE); /* @@ -1260,26 +1184,18 @@ message_list_construct (MessageList *message_list) extras, EVOLUTION_ETSPECDIR "/message-list.etspec", NULL); - + message_list->tree = e_tree_scrolled_get_tree(E_TREE_SCROLLED (message_list)); e_tree_root_node_set_visible (message_list->tree, FALSE); - + gtk_object_sink (GTK_OBJECT (extras)); - + gtk_signal_connect (GTK_OBJECT (message_list->tree), "cursor_activated", GTK_SIGNAL_FUNC (on_cursor_activated_cmd), message_list); - + gtk_signal_connect (GTK_OBJECT (message_list->tree), "click", GTK_SIGNAL_FUNC (on_click), message_list); - - /* drag & drop */ - e_tree_drag_source_set (message_list->tree, GDK_BUTTON1_MASK, - drag_types, num_drag_types, GDK_ACTION_MOVE); - - gtk_signal_connect (GTK_OBJECT (message_list->tree), "drag_data_get", - GTK_SIGNAL_FUNC (message_list_drag_data_get), - message_list); } GtkWidget * |