static void
impl_set_property (GObject *object,
		   guint prop_id,
		   const GValue *value,
		   GParamSpec *pspec)
{
	RhythmDBImportJob *job = RHYTHMDB_IMPORT_JOB (object);

	switch (prop_id) {
	case PROP_DB:
		job->priv->db = RHYTHMDB (g_value_dup_object (value));
		g_signal_connect_object (job->priv->db,
					 "entry-added",
					 G_CALLBACK (entry_added_cb),
					 job, 0);
		break;
	case PROP_ENTRY_TYPE:
		job->priv->entry_type = g_value_get_object (value);
		break;
	case PROP_IGNORE_TYPE:
		job->priv->ignore_type = g_value_get_object (value);
		break;
	case PROP_ERROR_TYPE:
		job->priv->error_type = g_value_get_object (value);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
static void
impl_get_property (GObject *object,
		   guint prop_id,
		   GValue *value,
		   GParamSpec *pspec)
{
	RhythmDBImportJob *job = RHYTHMDB_IMPORT_JOB (object);

	switch (prop_id) {
	case PROP_DB:
		g_value_set_object (value, job->priv->db);
		break;
	case PROP_ENTRY_TYPE:
		g_value_set_object (value, job->priv->entry_type);
		break;
	case PROP_IGNORE_TYPE:
		g_value_set_object (value, job->priv->ignore_type);
		break;
	case PROP_ERROR_TYPE:
		g_value_set_object (value, job->priv->error_type);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
static void
impl_finalize (GObject *object)
{
	RhythmDBImportJob *job = RHYTHMDB_IMPORT_JOB (object);
	
	g_hash_table_destroy (job->priv->outstanding);

	rb_slist_deep_free (job->priv->uri_list);

	G_OBJECT_CLASS (rhythmdb_import_job_parent_class)->finalize (object);
}
Esempio n. 4
0
static void
impl_finalize (GObject *object)
{
	RhythmDBImportJob *job = RHYTHMDB_IMPORT_JOB (object);

	g_queue_free_full (job->priv->outstanding, g_free);
	g_queue_free_full (job->priv->processing, g_free);

	rb_slist_deep_free (job->priv->uri_list);

	g_free (job->priv->task_label);

	G_OBJECT_CLASS (rhythmdb_import_job_parent_class)->finalize (object);
}
Esempio n. 5
0
static void
impl_set_property (GObject *object,
		   guint prop_id,
		   const GValue *value,
		   GParamSpec *pspec)
{
	RhythmDBImportJob *job = RHYTHMDB_IMPORT_JOB (object);

	switch (prop_id) {
	case PROP_DB:
		job->priv->db = RHYTHMDB (g_value_dup_object (value));
		g_signal_connect_object (job->priv->db,
					 "entry-added",
					 G_CALLBACK (entry_added_cb),
					 job, 0);
		break;
	case PROP_ENTRY_TYPE:
		job->priv->entry_type = g_value_get_object (value);
		break;
	case PROP_IGNORE_TYPE:
		job->priv->ignore_type = g_value_get_object (value);
		break;
	case PROP_ERROR_TYPE:
		job->priv->error_type = g_value_get_object (value);
		break;
	case PROP_TASK_LABEL:
		job->priv->task_label = g_value_dup_string (value);
		break;
	case PROP_TASK_DETAIL:
		/* ignore */
		break;
	case PROP_TASK_PROGRESS:
		/* ignore */
		break;
	case PROP_TASK_OUTCOME:
		/* ignore */
		break;
	case PROP_TASK_NOTIFY:
		job->priv->task_notify = g_value_get_boolean (value);
		break;
	case PROP_TASK_CANCELLABLE:
		/* ignore */
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
/**
 * rhythmdb_import_job_new:
 * @db: the #RhythmDB object
 * @entry_type: the #RhythmDBEntryType to use for normal entries
 * @ignore_type: the #RhythmDBEntryType to use for ignored files
 *   (or NULL to not create ignore entries)
 * @error_type: the #RhythmDBEntryType to use for import error
 *   entries (or NULL for none)
 *
 * Creates a new import job with the specified entry types.
 * Before starting the job, the caller must add one or more
 * paths to import.
 *
 * Return value: new #RhythmDBImportJob object.
 */
RhythmDBImportJob *
rhythmdb_import_job_new (RhythmDB *db,
			 RhythmDBEntryType *entry_type,
			 RhythmDBEntryType *ignore_type,
			 RhythmDBEntryType *error_type)
{
	GObject *obj;

	obj = g_object_new (RHYTHMDB_TYPE_IMPORT_JOB,
			    "db", db,
			    "entry-type", entry_type,
			    "ignore-type", ignore_type,
			    "error-type", error_type,
			    NULL);
	return RHYTHMDB_IMPORT_JOB (obj);
}
static void
impl_dispose (GObject *object)
{
	RhythmDBImportJob *job = RHYTHMDB_IMPORT_JOB (object);

	if (job->priv->db != NULL) {
		g_object_unref (job->priv->db);
		job->priv->db = NULL;
	}

	if (job->priv->cancel != NULL) {
		g_object_unref (job->priv->cancel);
		job->priv->cancel = NULL;
	}
	
	G_OBJECT_CLASS (rhythmdb_import_job_parent_class)->dispose (object);
}
Esempio n. 8
0
static void
impl_get_property (GObject *object,
		   guint prop_id,
		   GValue *value,
		   GParamSpec *pspec)
{
	RhythmDBImportJob *job = RHYTHMDB_IMPORT_JOB (object);

	switch (prop_id) {
	case PROP_DB:
		g_value_set_object (value, job->priv->db);
		break;
	case PROP_ENTRY_TYPE:
		g_value_set_object (value, job->priv->entry_type);
		break;
	case PROP_IGNORE_TYPE:
		g_value_set_object (value, job->priv->ignore_type);
		break;
	case PROP_ERROR_TYPE:
		g_value_set_object (value, job->priv->error_type);
		break;
	case PROP_TASK_LABEL:
		g_value_set_string (value, job->priv->task_label);
		break;
	case PROP_TASK_DETAIL:
		if (job->priv->scan_complete == FALSE) {
			g_value_set_string (value, _("Scanning"));
		} else {
			g_value_take_string (value,
					     g_strdup_printf (_("%d of %d"),
							      job->priv->processed,
							      job->priv->total));
		}
		break;
	case PROP_TASK_PROGRESS:
		if (job->priv->scan_complete == FALSE) {
			g_value_set_double (value, -1.0);
		} else if (job->priv->total == 0) {
			g_value_set_double (value, 0.0);
		} else {
			g_value_set_double (value, ((float)job->priv->processed / (float)job->priv->total));
		}
		break;
	case PROP_TASK_OUTCOME:
		if (job->priv->complete) {
			g_value_set_enum (value, RB_TASK_OUTCOME_COMPLETE);
		} else if (g_cancellable_is_cancelled (job->priv->cancel)) {
			g_value_set_enum (value, RB_TASK_OUTCOME_CANCELLED);
		} else {
			g_value_set_enum (value, RB_TASK_OUTCOME_NONE);
		}
		break;
	case PROP_TASK_NOTIFY:
		g_value_set_boolean (value, job->priv->task_notify);
		break;
	case PROP_TASK_CANCELLABLE:
		g_value_set_boolean (value, TRUE);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
Esempio n. 9
0
static void
task_progress_cancel (RBTaskProgress *progress)
{
	rhythmdb_import_job_cancel (RHYTHMDB_IMPORT_JOB (progress));
}