eog r4850 - in trunk: . doc/reference src
- From: csaavedra svn gnome org
- To: svn-commits-list gnome org
- Subject: eog r4850 - in trunk: . doc/reference src
- Date: Sun, 26 Oct 2008 17:24:37 +0000 (UTC)
Author: csaavedra
Date: Sun Oct 26 17:24:37 2008
New Revision: 4850
URL: http://svn.gnome.org/viewvc/eog?rev=4850&view=rev
Log:
2008-09-29 Claudio Saavedra <csaavedra igalia com>
* src/eog-job-queue.c: (handle_job), (no_jobs_available_unlocked),
(search_for_jobs_unlocked), (eog_job_queue_init), (find_queue),
(eog_job_queue_remove_job): Add EogJobCopy to the queue operations.
* src/eog-jobs.c: (+eog_job_copy_init), (+eog_job_copy_dispose),
(+eog_job_copy_class_init), (+eog_job_copy_new),
(+eog_job_copy_progress_callback), (+eog_job_copy_run): New EogJobCopy
job, for file copying operations.
* src/eog-jobs.h: Add EogJobCopy definitions.
* doc/reference/eog-sections.txt: Add methods in EogJobCopy.
* doc/reference/eog.types: Add eog_job_copy_get_type().
Modified:
trunk/ChangeLog
trunk/doc/reference/eog-sections.txt
trunk/doc/reference/eog.types
trunk/src/eog-job-queue.c
trunk/src/eog-jobs.c
trunk/src/eog-jobs.h
Modified: trunk/doc/reference/eog-sections.txt
==============================================================================
--- trunk/doc/reference/eog-sections.txt (original)
+++ trunk/doc/reference/eog-sections.txt Sun Oct 26 17:24:37 2008
@@ -256,6 +256,8 @@
EOG_JOB_SAVE_AS
EOG_JOB_SAVE_AS_CLASS
EOG_IS_JOB_SAVE_AS
+EOG_JOB_COPY
+EOG_JOB_COPY_CLASS
<TITLE>EogJob</TITLE>
EogJob
<TITLE>EogJobThumbnail</TITLE>
@@ -271,6 +273,8 @@
EogJobSave
<TITLE>EogJobSaveAs</TITLE>
EogJobSaveAs
+<TITLE>EogJobCopy</TITLE>
+EogJobCopy
eog_job_finished
eog_job_set_progress
eog_job_thumbnail_get_type
@@ -290,6 +294,9 @@
eog_job_save_run
eog_job_save_as_get_type
eog_job_save_as_new
+eog_job_copy_get_type
+eog_job_copy_new
+eog_job_copy_run
<SUBSECTION Standard>
EOG_JOB
EOG_IS_JOB
Modified: trunk/doc/reference/eog.types
==============================================================================
--- trunk/doc/reference/eog.types (original)
+++ trunk/doc/reference/eog.types Sun Oct 26 17:24:37 2008
@@ -13,6 +13,7 @@
eog_job_transform_get_type
eog_job_save_get_type
eog_job_save_as_get_type
+eog_job_copy_get_type
eog_thumb_nav_get_type
eog_metadata_reader_png_get_type
eog_uri_converter_get_type
Modified: trunk/src/eog-job-queue.c
==============================================================================
--- trunk/src/eog-job-queue.c (original)
+++ trunk/src/eog-job-queue.c Sun Oct 26 17:24:37 2008
@@ -33,6 +33,7 @@
static GQueue *model_queue = NULL;
static GQueue *transform_queue = NULL;
static GQueue *save_queue = NULL;
+static GQueue *copy_queue = NULL;
static gboolean
remove_job_from_queue (GQueue *queue, EogJob *job)
@@ -82,6 +83,8 @@
eog_job_transform_run (EOG_JOB_TRANSFORM (job));
else if (EOG_IS_JOB_SAVE (job))
eog_job_save_run (EOG_JOB_SAVE (job));
+ else if (EOG_IS_JOB_COPY (job))
+ eog_job_copy_run (EOG_JOB_COPY (job));
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
(GSourceFunc) notify_finished,
@@ -96,7 +99,8 @@
g_queue_is_empty (transform_queue) &&
g_queue_is_empty (thumbnail_queue) &&
g_queue_is_empty (model_queue) &&
- g_queue_is_empty (save_queue);
+ g_queue_is_empty (save_queue) &&
+ g_queue_is_empty (copy_queue);
}
static EogJob *
@@ -119,11 +123,15 @@
job = (EogJob *) g_queue_pop_head (model_queue);
if (job)
return job;
-
+
job = (EogJob *) g_queue_pop_head (save_queue);
if (job)
return job;
+ job = (EogJob *) g_queue_pop_head (copy_queue);
+ if (job)
+ return job;
+
return NULL;
}
@@ -166,6 +174,7 @@
model_queue = g_queue_new ();
transform_queue = g_queue_new ();
save_queue = g_queue_new ();
+ copy_queue = g_queue_new ();
g_thread_create (eog_render_thread, NULL, FALSE, NULL);
}
@@ -183,6 +192,8 @@
return transform_queue;
} else if (EOG_IS_JOB_SAVE (job)) {
return save_queue;
+ } else if (EOG_IS_JOB_COPY (job)) {
+ return copy_queue;
}
g_assert_not_reached ();
@@ -225,6 +236,8 @@
retval = remove_job_from_queue (transform_queue, job);
} else if (EOG_IS_JOB_SAVE (job)) {
retval = remove_job_from_queue (save_queue, job);
+ } else if (EOG_IS_JOB_COPY (job)) {
+ retval = remove_job_from_queue (copy_queue, job);
} else {
g_assert_not_reached ();
}
Modified: trunk/src/eog-jobs.c
==============================================================================
--- trunk/src/eog-jobs.c (original)
+++ trunk/src/eog-jobs.c Sun Oct 26 17:24:37 2008
@@ -43,6 +43,7 @@
G_DEFINE_TYPE (EogJobTransform, eog_job_transform, EOG_TYPE_JOB);
G_DEFINE_TYPE (EogJobSave, eog_job_save, EOG_TYPE_JOB);
G_DEFINE_TYPE (EogJobSaveAs, eog_job_save_as, EOG_TYPE_JOB_SAVE);
+G_DEFINE_TYPE (EogJobCopy, eog_job_copy, EOG_TYPE_JOB);
enum
{
@@ -722,3 +723,85 @@
EOG_JOB (job)->finished = TRUE;
}
+
+static void eog_job_copy_init (EogJobCopy *job) { /* do nothing */};
+
+static void
+eog_job_copy_dispose (GObject *object)
+{
+ EogJobCopy *job = EOG_JOB_COPY (object);
+
+ if (job->dest) {
+ g_free (job->dest);
+ job->dest = NULL;
+ }
+
+ (* G_OBJECT_CLASS (eog_job_copy_parent_class)->dispose) (object);
+}
+
+static void
+eog_job_copy_class_init (EogJobCopyClass *class)
+{
+ G_OBJECT_CLASS (class)->dispose = eog_job_copy_dispose;
+}
+
+EogJob *
+eog_job_copy_new (GList *images, const gchar *dest)
+{
+ EogJobCopy *job;
+
+ g_assert (images != NULL && dest != NULL);
+
+ job = g_object_new (EOG_TYPE_JOB_COPY, NULL);
+
+ job->images = images;
+ job->dest = g_strdup (dest);
+
+ return EOG_JOB (job);
+}
+
+static void
+eog_job_copy_progress_callback (goffset current_num_bytes,
+ goffset total_num_bytes,
+ gpointer user_data)
+{
+ gfloat job_progress;
+ guint n_images;
+ EogJobCopy *job;
+
+ job = EOG_JOB_COPY (user_data);
+ n_images = g_list_length (job->images);
+
+ job_progress = ((current_num_bytes / (gfloat) total_num_bytes) + job->current_pos)/n_images;
+
+ eog_job_set_progress (EOG_JOB (job), job_progress);
+}
+
+void
+eog_job_copy_run (EogJobCopy *job)
+{
+ GList *it;
+ guint n_images;
+ GFile *src, *dest;
+ gchar *filename, *dest_filename;
+
+ n_images = g_list_length (job->images);
+
+ job->current_pos = 0;
+
+ for (it = job->images; it != NULL; it = g_list_next (it), job->current_pos++) {
+ src = (GFile *) it->data;
+ filename = g_file_get_basename (src);
+ dest_filename = g_build_filename (job->dest, filename, NULL);
+ dest = g_file_new_for_path (dest_filename);
+
+ g_file_copy (src, dest,
+ G_FILE_COPY_OVERWRITE, NULL,
+ eog_job_copy_progress_callback, job,
+ &EOG_JOB (job)->error);
+ g_free (filename);
+ g_free (dest_filename);
+ }
+
+ EOG_JOB (job)->finished = TRUE;
+}
Modified: trunk/src/eog-jobs.h
==============================================================================
--- trunk/src/eog-jobs.h (original)
+++ trunk/src/eog-jobs.h Sun Oct 26 17:24:37 2008
@@ -69,6 +69,9 @@
typedef struct _EogJobSaveAs EogJobSaveAs;
typedef struct _EogJobSaveAsClass EogJobSaveAsClass;
+typedef struct _EogJobCopy EogJobCopy;
+typedef struct _EogJobCopyClass EogJobCopyClass;
+
#define EOG_TYPE_JOB (eog_job_get_type())
#define EOG_JOB(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), EOG_TYPE_JOB, EogJob))
#define EOG_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EOG_TYPE_JOB, EogJobClass))
@@ -105,6 +108,12 @@
#define EOG_JOB_SAVE_AS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EOG_TYPE_JOB_SAVE_AS, EogJobSaveAsClass))
#define EOG_IS_JOB_SAVE_AS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), EOG_TYPE_JOB_SAVE_AS))
+#define EOG_TYPE_JOB_COPY (eog_job_copy_get_type())
+#define EOG_JOB_COPY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), EOG_TYPE_JOB_COPY, EogJobCopy))
+#define EOG_JOB_COPY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EOG_TYPE_JOB_COPY, EogJobCopyClass))
+#define EOG_IS_JOB_COPY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), EOG_TYPE_JOB_COPY))
+
+
struct _EogJob
{
GObject parent;
@@ -207,7 +216,20 @@
EogJobSaveClass parent;
};
-/* Base job class */
+struct _EogJobCopy
+{
+ EogJob parent;
+ GList *images;
+ guint current_pos;
+ gchar *dest;
+};
+
+struct _EogJobCopyClass
+{
+ EogJobClass parent_class;
+};
+
+/* base job class */
GType eog_job_get_type (void) G_GNUC_CONST;
void eog_job_finished (EogJob *job);
void eog_job_set_progress (EogJob *job,
@@ -245,6 +267,12 @@
EogURIConverter *converter,
GFile *file);
+/*EogJobCopy */
+GType eog_job_copy_get_type (void) G_GNUC_CONST;
+EogJob *eog_job_copy_new (GList *images,
+ const gchar *dest);
+void eog_job_copy_run (EogJobCopy *job);
+
G_END_DECLS
#endif /* __EOG_JOBS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]