[Xfce4-commits] r29875 - in thunar/branches/migration-to-gio: . thunar
Jannis Pohlmann
jannis at xfce.org
Tue Apr 21 13:22:26 CEST 2009
Author: jannis
Date: 2009-04-21 11:22:26 +0000 (Tue, 21 Apr 2009)
New Revision: 29875
Modified:
thunar/branches/migration-to-gio/ChangeLog
thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.c
thunar/branches/migration-to-gio/thunar/thunar-job.c
thunar/branches/migration-to-gio/thunar/thunar-job.h
thunar/branches/migration-to-gio/thunar/thunar-progress-dialog.c
thunar/branches/migration-to-gio/thunar/thunar-progress-dialog.h
Log:
* thunar/thunar-enum-types.c: Remove vfs_ from
thunar_vfs_job_response_get_type().
* thunar/thunar-gio-extensions.c: Include exo.h for the I_() macro.
* thunar/thunar-job.{c,h}: Add functions thunar_job_ask_overwrite(),
thunar_job_info_message(), thunar_job_percent(),
thunar_job_set_total_files() and thunar_job_processing_file(). Add
signals "ask", "info-message" and "percent".
* thunar/thunar-progress-dialog.{c,h}: Make ThunarProgressDialog work
with both, ThunarVfsJob and ThunarJob by using a G_TYPE_OBJECT
property and gpointer parameters.
Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog 2009-04-21 10:08:08 UTC (rev 29874)
+++ thunar/branches/migration-to-gio/ChangeLog 2009-04-21 11:22:26 UTC (rev 29875)
@@ -1,5 +1,18 @@
2009-04-21 Jannis Pohlmann <jannis at xfce.org>
+ * thunar/thunar-enum-types.c: Remove vfs_ from
+ thunar_vfs_job_response_get_type().
+ * thunar/thunar-gio-extensions.c: Include exo.h for the I_() macro.
+ * thunar/thunar-job.{c,h}: Add functions thunar_job_ask_overwrite(),
+ thunar_job_info_message(), thunar_job_percent(),
+ thunar_job_set_total_files() and thunar_job_processing_file(). Add
+ signals "ask", "info-message" and "percent".
+ * thunar/thunar-progress-dialog.{c,h}: Make ThunarProgressDialog work
+ with both, ThunarVfsJob and ThunarJob by using a G_TYPE_OBJECT
+ property and gpointer parameters.
+
+2009-04-21 Jannis Pohlmann <jannis at xfce.org>
+
* thunar/thunar-deep-count-job.c: Improve the error handling code in
thunar_deep_count_job_execute().
* thunar/thunar-gio-extensions.{c,h}: Add G_TYPE_FILE_LIST macro and
Modified: thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.c 2009-04-21 10:08:08 UTC (rev 29874)
+++ thunar/branches/migration-to-gio/thunar/thunar-gio-extensions.c 2009-04-21 11:22:26 UTC (rev 29875)
@@ -23,6 +23,7 @@
#include <gio/gio.h>
+#include <exo/exo.h>
#include <libxfce4util/libxfce4util.h>
#include <thunar/thunar-gio-extensions.h>
@@ -250,7 +251,7 @@
if (G_UNLIKELY (type == G_TYPE_INVALID))
{
- type = g_boxed_type_register_static ("GFileList",
+ type = g_boxed_type_register_static (I_("GFileList"),
(GBoxedCopyFunc) g_file_list_copy,
(GBoxedFreeFunc) g_file_list_free);
}
Modified: thunar/branches/migration-to-gio/thunar/thunar-job.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-job.c 2009-04-21 10:08:08 UTC (rev 29874)
+++ thunar/branches/migration-to-gio/thunar/thunar-job.c 2009-04-21 11:22:26 UTC (rev 29875)
@@ -80,9 +80,11 @@
struct _ThunarJobPrivate
{
- GIOSchedulerJob *scheduler_job;
- GCancellable *cancellable;
- guint running : 1;
+ ThunarJobResponse earlier_ask_overwrite_response;
+ GIOSchedulerJob *scheduler_job;
+ GCancellable *cancellable;
+ GList *total_files;
+ guint running : 1;
};
struct _ThunarJobSyncSignalData
@@ -121,6 +123,18 @@
+static gboolean
+_thunar_job_ask_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer data)
+{
+ g_value_copy (handler_return, return_accu);
+ return FALSE;
+}
+
+
+
static void
thunar_job_class_init (ThunarJobClass *klass)
{
@@ -138,6 +152,27 @@
klass->execute = NULL;
/**
+ * ThunarJob::ask:
+ * @job : a #ThunarJob.
+ * @message : question to display to the user.
+ * @choices : a combination of #ThunarJobResponse<!---->s.
+ *
+ * The @message is garantied to contain valid UTF-8.
+ *
+ * Return value: the selected choice.
+ **/
+ job_signals[ASK] =
+ g_signal_new (I_("ask"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_NO_HOOKS | G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ThunarJobClass, ask),
+ _thunar_job_ask_accumulator, NULL,
+ _thunar_marshal_FLAGS__STRING_FLAGS,
+ THUNAR_TYPE_JOB_RESPONSE,
+ 2, G_TYPE_STRING,
+ THUNAR_TYPE_JOB_RESPONSE);
+
+ /**
* ThunarJob::error:
* @job : a #ThunarJob.
* @error : a #GError describing the cause.
@@ -166,6 +201,44 @@
G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * ThunarJob::info-message:
+ * @job : a #ThunarJob.
+ * @message : information to be displayed about @job.
+ *
+ * This signal is emitted to display information about the
+ * @job. Examples of messages are "Preparing..." or
+ * "Cleaning up...".
+ *
+ * The @message is garantied to contain valid UTF-8, so
+ * it can be displayed by #GtkWidget<!---->s out of the
+ * box.
+ **/
+ job_signals[INFO_MESSAGE] =
+ g_signal_new (I_("info-message"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ /**
+ * ThunarJob::percent:
+ * @job : a #ThunarJob.
+ * @percent : the percentage of completeness.
+ *
+ * This signal is emitted to present the state
+ * of the overall progress.
+ *
+ * The @percent value is garantied to be in the
+ * range 0.0 to 100.0.
+ **/
+ job_signals[PERCENT] =
+ g_signal_new (I_("percent"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__DOUBLE,
+ G_TYPE_NONE, 1, G_TYPE_DOUBLE);
}
@@ -245,10 +318,8 @@
success = (*THUNAR_JOB_GET_CLASS (job)->execute) (job, &error);
/* TODO why was this necessary again? */
- g_io_scheduler_job_send_to_mainloop (scheduler_job,
- (GSourceFunc) gtk_false,
- NULL,
- NULL);
+ g_io_scheduler_job_send_to_mainloop (scheduler_job, (GSourceFunc) gtk_false,
+ NULL, NULL);
if (!success)
{
@@ -356,7 +427,6 @@
GError **error)
{
_thunar_return_val_if_fail (THUNAR_IS_JOB (job), FALSE);
- _thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return g_cancellable_set_error_if_cancelled (job->priv->cancellable, error);
}
@@ -412,6 +482,8 @@
{
va_list var_args;
+ _thunar_return_if_fail (THUNAR_IS_JOB (job));
+
va_start (var_args, signal_detail);
thunar_job_emit_valist (job, signal_id, signal_detail, var_args);
va_end (var_args);
@@ -419,6 +491,121 @@
+static ThunarJobResponse
+_thunar_job_ask_valist (ThunarJob *job,
+ const gchar *format,
+ va_list var_args,
+ const gchar *question,
+ ThunarJobResponse choices)
+{
+ ThunarJobResponse response;
+ gchar *text;
+ gchar *message;
+
+ _thunar_return_val_if_fail (THUNAR_IS_JOB (job), THUNAR_JOB_RESPONSE_CANCEL);
+ _thunar_return_val_if_fail (g_utf8_validate (format, -1, NULL), THUNAR_JOB_RESPONSE_CANCEL);
+
+ /* generate the dialog message */
+ text = g_strdup_vprintf (format, var_args);
+ message = (question != NULL)
+ ? g_strconcat (text, ".\n\n", question, NULL)
+ : g_strconcat (text, ".", NULL);
+ g_free (text);
+
+ /* send the question and wait for the answer */
+ thunar_job_emit (job, job_signals[ASK], 0, message, choices, &response);
+ g_free (message);
+
+ /* cancel the job as per users request */
+ if (G_UNLIKELY (response == THUNAR_JOB_RESPONSE_CANCEL))
+ thunar_job_cancel (job);
+
+ return response;
+}
+
+
+
+ThunarJobResponse
+thunar_job_ask_overwrite (ThunarJob *job,
+ const gchar *format,
+ ...)
+{
+ ThunarJobResponse response;
+ va_list var_args;
+
+ _thunar_return_val_if_fail (THUNAR_IS_JOB (job), THUNAR_JOB_RESPONSE_CANCEL);
+ _thunar_return_val_if_fail (format != NULL, THUNAR_JOB_RESPONSE_CANCEL);
+
+ /* check if the user already cancelled the job */
+ if (G_UNLIKELY (thunar_job_is_cancelled (job)))
+ return THUNAR_JOB_RESPONSE_CANCEL;
+
+ /* check if the user said "Overwrite All" earlier */
+ if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_YES_ALL))
+ return THUNAR_JOB_RESPONSE_YES;
+
+ /* check if the user said "Overwrite None" earlier */
+ if (G_UNLIKELY (job->priv->earlier_ask_overwrite_response == THUNAR_JOB_RESPONSE_NO_ALL))
+ return THUNAR_JOB_RESPONSE_NO;
+
+ /* ask the user what he wants to do */
+ va_start (var_args, format);
+ response = _thunar_job_ask_valist (job, format, var_args,
+ _("Do you want to overwrite it?"),
+ THUNAR_JOB_RESPONSE_YES
+ | THUNAR_JOB_RESPONSE_YES_ALL
+ | THUNAR_JOB_RESPONSE_NO
+ | THUNAR_JOB_RESPONSE_NO_ALL
+ | THUNAR_JOB_RESPONSE_CANCEL);
+ va_end (var_args);
+
+ /* remember response for later */
+ job->priv->earlier_ask_overwrite_response = response;
+
+ /* translate response */
+ switch (response)
+ {
+ case THUNAR_JOB_RESPONSE_YES_ALL:
+ response = THUNAR_JOB_RESPONSE_YES;
+ break;
+
+ case THUNAR_JOB_RESPONSE_NO_ALL:
+ response = THUNAR_JOB_RESPONSE_NO;
+ break;
+
+ default:
+ break;
+ }
+
+ return response;
+}
+
+
+
+void
+thunar_job_info_message (ThunarJob *job,
+ const gchar *message)
+{
+ _thunar_return_if_fail (THUNAR_IS_JOB (job));
+ _thunar_return_if_fail (message != NULL);
+
+ thunar_job_emit (job, job_signals[INFO_MESSAGE], 0, message);
+}
+
+
+
+void
+thunar_job_percent (ThunarJob *job,
+ gdouble percent)
+{
+ _thunar_return_if_fail (THUNAR_IS_JOB (job));
+
+ percent = MIN (0.0, MAX (100.0, percent));
+ thunar_job_emit (job, job_signals[PERCENT], 0, percent);
+}
+
+
+
static void
_thunar_job_error (ThunarJob *job,
GError *error)
@@ -438,3 +625,57 @@
_thunar_return_if_fail (THUNAR_IS_JOB (job));
g_signal_emit (job, job_signals[FINISHED], 0);
}
+
+
+
+void
+thunar_job_set_total_files (ThunarJob *job,
+ GList *total_files)
+{
+ _thunar_return_if_fail (THUNAR_IS_JOB (job));
+ _thunar_return_if_fail (job->priv->total_files == NULL);
+ _thunar_return_if_fail (total_files != NULL);
+
+ job->priv->total_files = total_files;
+}
+
+
+
+void
+thunar_job_processing_file (ThunarJob *job,
+ GList *current_file)
+{
+ GList *lp;
+ gchar *basename;
+ gchar *display_name;
+ guint n_processed;
+ guint n_total;
+
+ _thunar_return_if_fail (THUNAR_IS_JOB (job));
+ _thunar_return_if_fail (current_file != NULL);
+
+ basename = g_file_get_basename (current_file->data);
+ display_name = g_filename_display_name (basename);
+ g_free (basename);
+
+ thunar_job_info_message (job, display_name);
+ g_free (display_name);
+
+ /* verify that we have total files set */
+ if (G_LIKELY (job->priv->total_files != NULL))
+ {
+ /* determine the number of files processed so far */
+ for (lp = job->priv->total_files, n_processed = 0;
+ lp != current_file;
+ lp = lp->next);
+
+ /* emit only if n_processed is a multiple of 8 */
+ if ((n_processed % 8) == 0)
+ {
+ /* determine the total_number of files */
+ n_total = g_list_length (job->priv->total_files);
+
+ thunar_job_percent (job, (n_processed * 100.0) / n_total);
+ }
+ }
+}
Modified: thunar/branches/migration-to-gio/thunar/thunar-job.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-job.h 2009-04-21 10:08:08 UTC (rev 29874)
+++ thunar/branches/migration-to-gio/thunar/thunar-job.h 2009-04-21 11:22:26 UTC (rev 29875)
@@ -48,8 +48,13 @@
/*< public >*/
/* virtual methods */
- gboolean (*execute) (ThunarJob *job,
- GError **error);
+ gboolean (*execute) (ThunarJob *job,
+ GError **error);
+
+ /* signals */
+ ThunarJobResponse (*ask) (ThunarJob *job,
+ const gchar *message,
+ ThunarJobResponse choices);
};
struct _ThunarJob
@@ -59,20 +64,32 @@
ThunarJobPrivate *priv;
};
-GType thunar_job_get_type (void) G_GNUC_CONST;
-ThunarJob *thunar_job_launch (ThunarJob *job);
-void thunar_job_cancel (ThunarJob *job);
-gboolean thunar_job_is_cancelled (const ThunarJob *job);
+GType thunar_job_get_type (void) G_GNUC_CONST;
+ThunarJob *thunar_job_launch (ThunarJob *job);
+void thunar_job_cancel (ThunarJob *job);
+gboolean thunar_job_is_cancelled (const ThunarJob *job);
-GCancellable *thunar_job_get_cancellable (const ThunarJob *job);
-gboolean thunar_job_set_error_if_cancelled (ThunarJob *job,
- GError **error);
+GCancellable *thunar_job_get_cancellable (const ThunarJob *job);
+gboolean thunar_job_set_error_if_cancelled (ThunarJob *job,
+ GError **error);
-void thunar_job_emit (ThunarJob *job,
- guint signal_id,
- GQuark signal_detail,
- ...);
+void thunar_job_set_total_files (ThunarJob *job,
+ GList *total_files);
+void thunar_job_processing_file (ThunarJob *job,
+ GList *current_file);
+void thunar_job_emit (ThunarJob *job,
+ guint signal_id,
+ GQuark signal_detail,
+ ...);
+ThunarJobResponse thunar_job_ask_overwrite (ThunarJob *job,
+ const gchar *format,
+ ...);
+void thunar_job_info_message (ThunarJob *job,
+ const gchar *message);
+void thunar_job_percent (ThunarJob *job,
+ gdouble percent);
+
G_END_DECLS
#endif /* !__THUNAR_JOB_H__ */
Modified: thunar/branches/migration-to-gio/thunar/thunar-progress-dialog.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-progress-dialog.c 2009-04-21 10:08:08 UTC (rev 29874)
+++ thunar/branches/migration-to-gio/thunar/thunar-progress-dialog.c 2009-04-21 11:22:26 UTC (rev 29875)
@@ -1,6 +1,7 @@
/* $Id$ */
/*-
* Copyright (c) 2005-2007 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -23,6 +24,7 @@
#include <thunar/thunar-dialogs.h>
#include <thunar/thunar-gobject-extensions.h>
+#include <thunar/thunar-job.h>
#include <thunar/thunar-pango-extensions.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-progress-dialog.h>
@@ -50,25 +52,25 @@
GParamSpec *pspec);
static void thunar_progress_dialog_response (GtkDialog *dialog,
gint response);
-static ThunarVfsJobResponse thunar_progress_dialog_ask (ThunarProgressDialog *dialog,
+static ThunarJobResponse thunar_progress_dialog_ask (ThunarProgressDialog *dialog,
const gchar *message,
- ThunarVfsJobResponse choices,
- ThunarVfsJob *job);
+ ThunarJobResponse choices,
+ gpointer *job);
static ThunarVfsJobResponse thunar_progress_dialog_ask_replace (ThunarProgressDialog *dialog,
ThunarVfsInfo *src_info,
ThunarVfsInfo *dst_info,
ThunarVfsJob *job);
static void thunar_progress_dialog_error (ThunarProgressDialog *dialog,
GError *error,
- ThunarVfsJob *job);
+ gpointer *job);
static void thunar_progress_dialog_finished (ThunarProgressDialog *dialog,
- ThunarVfsJob *job);
+ gpointer *job);
static void thunar_progress_dialog_info_message (ThunarProgressDialog *dialog,
const gchar *message,
- ThunarVfsJob *job);
+ gpointer *job);
static void thunar_progress_dialog_percent (ThunarProgressDialog *dialog,
gdouble percent,
- ThunarVfsJob *job);
+ gpointer *job);
@@ -79,15 +81,15 @@
struct _ThunarProgressDialog
{
- GtkDialog __parent__;
+ GtkDialog __parent__;
- ThunarVfsJob *job;
+ gpointer job;
- GTimeVal start_time;
- GTimeVal last_update_time;
+ GTimeVal start_time;
+ GTimeVal last_update_time;
- GtkWidget *progress_bar;
- GtkWidget *progress_label;
+ GtkWidget *progress_bar;
+ GtkWidget *progress_label;
};
@@ -145,13 +147,13 @@
/**
* ThunarProgressDialog:job:
*
- * The #ThunarVfsJob, whose progress is displayed by
+ * The #ThunarVfsJob or #ThunarJob, whose progress is displayed by
* this dialog, or %NULL if no job is set.
**/
g_object_class_install_property (gobject_class,
PROP_JOB,
g_param_spec_object ("job", "job", "job",
- THUNAR_VFS_TYPE_JOB,
+ G_TYPE_OBJECT,
EXO_PARAM_READWRITE));
}
@@ -267,16 +269,16 @@
-static ThunarVfsJobResponse
+static ThunarJobResponse
thunar_progress_dialog_ask (ThunarProgressDialog *dialog,
const gchar *message,
- ThunarVfsJobResponse choices,
- ThunarVfsJob *job)
+ ThunarJobResponse choices,
+ gpointer *job)
{
- _thunar_return_val_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog), THUNAR_VFS_JOB_RESPONSE_CANCEL);
- _thunar_return_val_if_fail (g_utf8_validate (message, -1, NULL), THUNAR_VFS_JOB_RESPONSE_CANCEL);
- _thunar_return_val_if_fail (THUNAR_VFS_IS_JOB (job), THUNAR_VFS_JOB_RESPONSE_CANCEL);
- _thunar_return_val_if_fail (dialog->job == job, THUNAR_VFS_JOB_RESPONSE_CANCEL);
+ _thunar_return_val_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog), THUNAR_JOB_RESPONSE_CANCEL);
+ _thunar_return_val_if_fail (g_utf8_validate (message, -1, NULL), THUNAR_JOB_RESPONSE_CANCEL);
+ _thunar_return_val_if_fail (THUNAR_VFS_IS_JOB (job) || THUNAR_IS_JOB (job), THUNAR_JOB_RESPONSE_CANCEL);
+ _thunar_return_val_if_fail (dialog->job == job, THUNAR_JOB_RESPONSE_CANCEL);
/* be sure to display the progress dialog prior to opening the question dialog */
gtk_widget_show_now (GTK_WIDGET (dialog));
@@ -309,11 +311,11 @@
static void
thunar_progress_dialog_error (ThunarProgressDialog *dialog,
GError *error,
- ThunarVfsJob *job)
+ gpointer *job)
{
_thunar_return_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog));
_thunar_return_if_fail (error != NULL && error->message != NULL);
- _thunar_return_if_fail (THUNAR_VFS_IS_JOB (job));
+ _thunar_return_if_fail (THUNAR_VFS_IS_JOB (job) || THUNAR_IS_JOB (job));
_thunar_return_if_fail (dialog->job == job);
/* be sure to display the progress dialog prior to opening the error dialog */
@@ -327,10 +329,10 @@
static void
thunar_progress_dialog_finished (ThunarProgressDialog *dialog,
- ThunarVfsJob *job)
+ gpointer *job)
{
_thunar_return_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog));
- _thunar_return_if_fail (THUNAR_VFS_IS_JOB (job));
+ _thunar_return_if_fail (THUNAR_VFS_IS_JOB (job) || THUNAR_IS_JOB (job));
_thunar_return_if_fail (dialog->job == job);
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
@@ -341,11 +343,11 @@
static void
thunar_progress_dialog_info_message (ThunarProgressDialog *dialog,
const gchar *message,
- ThunarVfsJob *job)
+ gpointer *job)
{
_thunar_return_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog));
_thunar_return_if_fail (g_utf8_validate (message, -1, NULL));
- _thunar_return_if_fail (THUNAR_VFS_IS_JOB (job));
+ _thunar_return_if_fail (THUNAR_VFS_IS_JOB (job) || THUNAR_IS_JOB (job));
_thunar_return_if_fail (dialog->job == job);
gtk_label_set_text (GTK_LABEL (dialog->progress_label), message);
@@ -366,7 +368,7 @@
static void
thunar_progress_dialog_percent (ThunarProgressDialog *dialog,
gdouble percent,
- ThunarVfsJob *job)
+ gpointer *job)
{
GTimeVal current_time;
gulong remaining_time;
@@ -375,7 +377,7 @@
_thunar_return_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog));
_thunar_return_if_fail (percent >= 0.0 && percent <= 100.0);
- _thunar_return_if_fail (THUNAR_VFS_IS_JOB (job));
+ _thunar_return_if_fail (THUNAR_VFS_IS_JOB (job) || THUNAR_IS_JOB (job));
_thunar_return_if_fail (dialog->job == job);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (dialog->progress_bar), percent / 100.0);
@@ -438,7 +440,12 @@
case GTK_RESPONSE_CLOSE:
case GTK_RESPONSE_NO:
if (G_LIKELY (THUNAR_PROGRESS_DIALOG (dialog)->job != NULL))
- thunar_vfs_job_cancel (THUNAR_PROGRESS_DIALOG (dialog)->job);
+ {
+ if (THUNAR_VFS_IS_JOB (THUNAR_PROGRESS_DIALOG (dialog)->job))
+ thunar_vfs_job_cancel (THUNAR_PROGRESS_DIALOG (dialog)->job);
+ else
+ thunar_job_cancel (THUNAR_PROGRESS_DIALOG (dialog)->job);
+ }
break;
}
@@ -465,7 +472,7 @@
/**
* thunar_progress_dialog_new_with_job:
- * @job : a #ThunarVfsJob or %NULL.
+ * @job : a #ThunarVfsJob, #ThunarJob or %NULL.
*
* Allocates a new #ThunarProgressDialog and associates it with
* the @job.
@@ -473,9 +480,9 @@
* Return value: the newly allocated #ThunarProgressDialog.
**/
GtkWidget*
-thunar_progress_dialog_new_with_job (ThunarVfsJob *job)
+thunar_progress_dialog_new_with_job (gpointer job)
{
- _thunar_return_val_if_fail (job == NULL || THUNAR_VFS_IS_JOB (job), NULL);
+ _thunar_return_val_if_fail (job == NULL || THUNAR_VFS_IS_JOB (job) || THUNAR_IS_JOB (job), NULL);
return g_object_new (THUNAR_TYPE_PROGRESS_DIALOG, "job", job, NULL);
}
@@ -485,12 +492,12 @@
* thunar_progress_dialog_get_job:
* @dialog : a #ThunarProgressDialog.
*
- * Returns the #ThunarVfsJob associated with @dialog
+ * Returns the #ThunarVfsJob or #ThunarJob associated with @dialog
* or %NULL if no job is currently associated with @dialog.
*
* Return value: the job associated with @dialog or %NULL.
**/
-ThunarVfsJob*
+gpointer
thunar_progress_dialog_get_job (ThunarProgressDialog *dialog)
{
_thunar_return_val_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog), NULL);
@@ -502,16 +509,16 @@
/**
* thunar_progress_dialog_set_job:
* @dialog : a #ThunarProgressDialog.
- * @job : a #ThunarVfsJob or %NULL.
+ * @job : a #ThunarVfsJob, #ThunarJob or %NULL.
*
* Associates @job with @dialog.
**/
void
thunar_progress_dialog_set_job (ThunarProgressDialog *dialog,
- ThunarVfsJob *job)
+ gpointer job)
{
_thunar_return_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog));
- _thunar_return_if_fail (job == NULL || THUNAR_VFS_IS_JOB (job));
+ _thunar_return_if_fail (job == NULL || THUNAR_VFS_IS_JOB (job) || THUNAR_IS_JOB (job));
/* check if we're already on that job */
if (G_UNLIKELY (dialog->job == job))
@@ -530,10 +537,11 @@
/* connect to the new job */
if (G_LIKELY (job != NULL))
{
- g_object_ref (G_OBJECT (job));
+ g_object_ref (job);
g_signal_connect_swapped (job, "ask", G_CALLBACK (thunar_progress_dialog_ask), dialog);
- g_signal_connect_swapped (job, "ask-replace", G_CALLBACK (thunar_progress_dialog_ask_replace), dialog);
+ if (THUNAR_VFS_IS_JOB (job))
+ g_signal_connect_swapped (job, "ask-replace", G_CALLBACK (thunar_progress_dialog_ask_replace), dialog);
g_signal_connect_swapped (job, "error", G_CALLBACK (thunar_progress_dialog_error), dialog);
g_signal_connect_swapped (job, "finished", G_CALLBACK (thunar_progress_dialog_finished), dialog);
g_signal_connect_swapped (job, "info-message", G_CALLBACK (thunar_progress_dialog_info_message), dialog);
Modified: thunar/branches/migration-to-gio/thunar/thunar-progress-dialog.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-progress-dialog.h 2009-04-21 10:08:08 UTC (rev 29874)
+++ thunar/branches/migration-to-gio/thunar/thunar-progress-dialog.h 2009-04-21 11:22:26 UTC (rev 29875)
@@ -1,6 +1,7 @@
/* $Id$ */
/*-
* Copyright (c) 2005 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -37,11 +38,11 @@
GType thunar_progress_dialog_get_type (void) G_GNUC_CONST;
GtkWidget *thunar_progress_dialog_new (void) G_GNUC_MALLOC;
-GtkWidget *thunar_progress_dialog_new_with_job (ThunarVfsJob *job) G_GNUC_MALLOC;
+GtkWidget *thunar_progress_dialog_new_with_job (gpointer job) G_GNUC_MALLOC;
-ThunarVfsJob *thunar_progress_dialog_get_job (ThunarProgressDialog *dialog);
+gpointer thunar_progress_dialog_get_job (ThunarProgressDialog *dialog);
void thunar_progress_dialog_set_job (ThunarProgressDialog *dialog,
- ThunarVfsJob *job);
+ gpointer job);
G_END_DECLS;
More information about the Xfce4-commits
mailing list