static void import_items(ICalImporterData *icidata) { ESource *source; g_return_if_fail (icidata != NULL); source = e_source_selector_peek_primary_selection ((ESourceSelector *)icidata->selector); g_return_if_fail ( source != NULL); icidata->client = auth_new_cal_from_source (source, icidata->source_type); e_cal_open (icidata->client, FALSE, NULL); switch (icidata->source_type) { case E_CAL_SOURCE_TYPE_EVENT: prepare_events (icidata->icalcomp, NULL); if (!update_objects (icidata->client, icidata->icalcomp)) /* FIXME: e_error ... */; break; case E_CAL_SOURCE_TYPE_TODO: prepare_tasks (icidata->icalcomp, NULL); if (!update_objects (icidata->client, icidata->icalcomp)) /* FIXME: e_error ... */; break; default: g_assert_not_reached (); } ical_import_done (icidata); }
static gboolean ivcal_import_items (gpointer d) { ICalImporter *ici = d; switch (ici->source_type) { case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: prepare_events (ici->icalcomp, NULL); update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici); break; case E_CAL_CLIENT_SOURCE_TYPE_TASKS: prepare_tasks (ici->icalcomp, NULL); update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici); break; default: g_warn_if_reached (); ici->idle_id = 0; ivcal_import_done (ici); return FALSE; } ici->idle_id = 0; return FALSE; }
static void gnome_calendar_import (EImport *ei, EImportTarget *target, EImportImporter *im) { icalcomponent *icalcomp = NULL; gchar *filename; gint do_calendar, do_tasks; ICalIntelligentImporter *ici; /* This is pretty shitty, everything runs in the gui thread and can block * for quite some time */ do_calendar = GPOINTER_TO_INT (g_datalist_get_data (&target->data, "gnomecal-do-cal")); do_tasks = GPOINTER_TO_INT (g_datalist_get_data (&target->data, "gnomecal-do-tasks")); /* If neither is selected, just return. */ if (!do_calendar && !do_tasks) return; /* Load the Gnome Calendar file and convert to iCalendar. */ filename = g_build_filename (g_get_home_dir (), "user-cal.vcf", NULL); icalcomp = load_vcalendar_file (filename); g_free (filename); /* If we couldn't load the file, just return. FIXME: Error message? */ if (icalcomp) { ici = g_malloc0 (sizeof (*ici)); ici->ei = ei; ici->target = target; ici->cancellable = g_cancellable_new (); ici->icalcomp = icalcomp; g_datalist_set_data_full (&target->data, "gnomecal-data", ici, free_ici); prepare_events (ici->icalcomp, &ici->tasks); if (do_calendar) { open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, gc_import_events); return; } prepare_tasks (ici->icalcomp, ici->tasks); if (do_tasks) { open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS, gc_import_tasks); return; } } e_import_complete (ei, target); }
int main(void) { buffer_t buf = buf_new(1); screen_t fake, real; int rows, cols; read_dimensions(&rows, &cols); fake_screen_init(&fake, rows, cols); real_screen_init(&buf, &real, rows, cols); prepare_events(); int x = 0, y = 0; char text[cols*rows]; bool marks[cols*rows]; memset(text, ' ', sizeof text); memset(marks, 0, sizeof marks); await: { event_t e = await_event(); switch (e.type) { case E_SIG: goto quit; break; case E_KEY: switch (e.key) { case '\b': if (x > 0) x -= 1; break; case '\n': x = 0; y += 1; break; case '~': marks[x + y*cols] = !marks[x + y*cols]; x++; break; default: text[x + y*cols] = e.key; x++; break; } break; case E_UP: y -= 1; break; case E_DOWN: y += 1; break; case E_LEFT: x -= 1; break; case E_RIGHT: x += 1; break; default: break; } int cx, cy; for (cx = 0; cx < cols; cx++) { for (cy = 0; cy < rows; cy++) { fake.cells[cx + cy*cols].codes[0] = text[cx + cy*cols]; } } int j; for (j = 0; j < cols*rows; j++) { if (marks[j]) { fake.cells[j].style.back.rgb = 0xff0000; } } fake.cursor.x = x; fake.cursor.y = y; fake.cursor.visible = true; screen_flush(&buf, &fake, &real); write(STDOUT_FILENO, buf.data, buf.used); buf.used = 0; fake_screen_reset(&fake, 25, 80); goto await; } quit: cleanup_events(); real_screen_cleanup(&buf, &real); write(STDOUT_FILENO, buf.data, buf.used); screen_free(&fake); screen_free(&real); buf_free(&buf); return 0; }