static gint mail_importer_pine_import (EImport *ei, EImportTarget *target) { GCancellable *cancellable; struct _pine_import_msg *m; gint id; cancellable = camel_operation_new (); m = mail_msg_new_with_cancellable (&pine_import_info, cancellable); g_datalist_set_data (&target->data, "pine-msg", m); m->import = ei; g_object_ref (m->import); m->target = target; m->status_timeout_id = e_named_timeout_add ( 100, pine_status_timeout, m); g_mutex_init (&m->status_lock); m->cancellable = cancellable; g_signal_connect ( m->cancellable, "status", G_CALLBACK (pine_status), m); id = m->base.seq; mail_msg_fast_ordered_push (m); return id; }
/* Start the main import operation */ void org_gnome_evolution_readdbx_import (EImport *ei, EImportTarget *target, EImportImporter *im) { DbxImporter *m; m = mail_msg_new (&dbx_import_info); g_datalist_set_data (&target->data, "dbx-msg", m); m->import = ei; g_object_ref (m->import); m->target = target; m->parent_uri = NULL; m->folder_name = NULL; m->folder_uri = NULL; m->status_timeout_id = e_named_timeout_add (100, dbx_status_timeout, m); g_mutex_init (&m->status_lock); m->cancellable = camel_operation_new (); g_signal_connect ( m->cancellable, "status", G_CALLBACK (dbx_status), m); mail_msg_unordered_push (m); }
static void mbox_import (EImport *ei, EImportTarget *target, EImportImporter *im) { EShell *shell; EShellBackend *shell_backend; EMailSession *session; MboxImporter *importer; gchar *filename; /* XXX Dig up the EMailSession from the default EShell. * Since the EImport framework doesn't allow for user * data, I don't see how else to get to it. */ shell = e_shell_get_default (); shell_backend = e_shell_get_backend_by_name (shell, "mail"); session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend)); /* TODO: do we validate target? */ importer = g_malloc0 (sizeof (*importer)); g_datalist_set_data (&target->data, "mbox-data", importer); importer->import = ei; importer->target = target; g_mutex_init (&importer->status_lock); importer->status_timeout_id = e_named_timeout_add (100, mbox_status_timeout, importer); importer->cancellable = camel_operation_new (); g_signal_connect ( importer->cancellable, "status", G_CALLBACK (mbox_status), importer); filename = g_filename_from_uri ( ((EImportTargetURI *) target)->uri_src, NULL, NULL); mail_importer_import_mbox ( session, filename, ((EImportTargetURI *) target)->uri_dest, importer->cancellable, mbox_import_done, importer); g_free (filename); }
/* * ECell::event method */ static gint ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col, gint row, ECellFlags flags, ECellActions *actions) { GtkLayout *layout; GdkWindow *window; ECellTreeView *tree_view = (ECellTreeView *) ecell_view; ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row); ETreeTableAdapter *etta = e_cell_tree_get_tree_table_adapter (ecell_view->e_table_model, row); ETreePath node = e_cell_tree_get_node (ecell_view->e_table_model, row); gint offset = offset_of_node (ecell_view->e_table_model, row); gint result; layout = GTK_LAYOUT (tree_view->canvas); window = gtk_layout_get_bin_window (layout); switch (event->type) { case GDK_BUTTON_PRESS: if (event_in_expander (event, offset, 0)) { if (e_tree_model_node_is_expandable (tree_model, node)) { gboolean expanded = e_tree_table_adapter_node_is_expanded (etta, node); gint tmp_row = row; GdkRectangle area; animate_closure_t *closure = g_new0 (animate_closure_t, 1); cairo_t *cr; gint hgt; e_table_item_get_cell_geometry ( tree_view->cell_view.e_table_item_view, &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height); area.width = offset - 2; hgt = e_cell_height (ecell_view, model_col, view_col, row); if (hgt != area.height) /* Composite cells */ area.height += hgt; cr = gdk_cairo_create (window); draw_expander ( tree_view, cr, expanded ? GTK_EXPANDER_SEMI_EXPANDED : GTK_EXPANDER_SEMI_COLLAPSED, GTK_STATE_NORMAL, &area); cairo_destroy (cr); closure->ectv = tree_view; closure->etta = etta; closure->node = node; closure->expanded = expanded; closure->area = area; tree_view->animate_timeout = e_named_timeout_add ( 50, animate_expander, closure); return TRUE; } } else if (event->button.x < (offset - INDENT_AMOUNT)) return FALSE; break; case GDK_MOTION_NOTIFY: if (e_tree_model_node_is_expandable (tree_model, node)) { gint height = ect_height (ecell_view, model_col, view_col, row); GdkRectangle area; gboolean in_expander = event_in_expander (event, offset, height); if (tree_view->prelit ^ in_expander) { gint tmp_row = row; cairo_t *cr; e_table_item_get_cell_geometry ( tree_view->cell_view.e_table_item_view, &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height); area.width = offset - 2; cr = gdk_cairo_create (window); draw_expander ( tree_view, cr, e_tree_table_adapter_node_is_expanded (etta, node) ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, in_expander ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, &area); cairo_destroy (cr); tree_view->prelit = in_expander; return TRUE; } } break; case GDK_LEAVE_NOTIFY: if (tree_view->prelit) { gint tmp_row = row; GdkRectangle area; cairo_t *cr; e_table_item_get_cell_geometry ( tree_view->cell_view.e_table_item_view, &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height); area.width = offset - 2; cr = gdk_cairo_create (window); draw_expander ( tree_view, cr, e_tree_table_adapter_node_is_expanded (etta, node) ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, GTK_STATE_NORMAL, &area); cairo_destroy (cr); tree_view->prelit = FALSE; } return TRUE; default: break; } adjust_event_position (event, -offset); result = e_cell_event (tree_view->subcell_view, event, model_col, view_col, row, flags, actions); adjust_event_position (event, offset); return result; }