[Xfce4-commits] <thunar:master> Remember progress dialog position. No show delay after the first job.
Jannis Pohlmann
jannis at xfce.org
Sun Sep 13 15:52:14 CEST 2009
Updating branch refs/heads/master
to eaf555a874f07efb190d0438ed8882d662e9776d (commit)
from 6e20e6d00dfb704f0a266daa01cb1d46792b3a8e (commit)
commit eaf555a874f07efb190d0438ed8882d662e9776d
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Sun Sep 13 15:39:40 2009 +0200
Remember progress dialog position. No show delay after the first job.
thunar/thunar-application.c | 30 ++++++++++++++++++++++--------
thunar/thunar-progress-dialog.c | 27 ++++++++++++++++++++++++++-
thunar/thunar-progress-dialog.h | 15 ++++++++-------
3 files changed, 56 insertions(+), 16 deletions(-)
diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c
index 9e6b7dd..c6f883a 100644
--- a/thunar/thunar-application.c
+++ b/thunar/thunar-application.c
@@ -411,16 +411,30 @@ thunar_application_launch (ThunarApplication *application,
if (screen != NULL)
gtk_window_set_screen (GTK_WINDOW (dialog), screen);
- thunar_progress_dialog_add_job (THUNAR_PROGRESS_DIALOG (dialog), job, icon_name, title);
+ if (thunar_progress_dialog_has_jobs (THUNAR_PROGRESS_DIALOG (dialog)))
+ {
+ /* add the job to the dialog */
+ thunar_progress_dialog_add_job (THUNAR_PROGRESS_DIALOG (dialog),
+ job, icon_name, title);
- /* Set up a timer to show the dialog, to make sure we don't
- * just popup and destroy a dialog for a very short job.
- */
- if (G_LIKELY (application->show_dialogs_timer_id == 0))
+ /* show the dialog immediately */
+ thunar_application_show_dialogs (application);
+ }
+ else
{
- application->show_dialogs_timer_id =
- g_timeout_add_full (G_PRIORITY_DEFAULT, 750, thunar_application_show_dialogs,
- application, thunar_application_show_dialogs_destroy);
+ /* add the job to the dialog */
+ thunar_progress_dialog_add_job (THUNAR_PROGRESS_DIALOG (dialog),
+ job, icon_name, title);
+
+ /* Set up a timer to show the dialog, to make sure we don't
+ * just popup and destroy a dialog for a very short job.
+ */
+ if (G_LIKELY (application->show_dialogs_timer_id == 0))
+ {
+ application->show_dialogs_timer_id =
+ g_timeout_add_full (G_PRIORITY_DEFAULT, 750, thunar_application_show_dialogs,
+ application, thunar_application_show_dialogs_destroy);
+ }
}
/* drop our reference on the job */
diff --git a/thunar/thunar-progress-dialog.c b/thunar/thunar-progress-dialog.c
index aac2fc1..30ad94b 100644
--- a/thunar/thunar-progress-dialog.c
+++ b/thunar/thunar-progress-dialog.c
@@ -60,6 +60,9 @@ struct _ThunarProgressDialog
GtkWidget *content_box;
GList *views;
+
+ gint x;
+ gint y;
};
@@ -160,6 +163,9 @@ thunar_progress_dialog_closed (ThunarProgressDialog *dialog)
{
_thunar_return_val_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog), FALSE);
+ /* remember the position of the dialog */
+ gtk_window_get_position (GTK_WINDOW (dialog), &dialog->x, &dialog->y);
+
/* hide the progress dialog */
gtk_widget_hide (GTK_WIDGET (dialog));
@@ -181,13 +187,23 @@ thunar_progress_dialog_toggled (ThunarProgressDialog *dialog,
if (GTK_WIDGET_VISIBLE (GTK_WIDGET (dialog))
&& gtk_window_is_active (GTK_WINDOW (dialog)))
{
+ /* remember the position of the dialog */
+ gtk_window_get_position (GTK_WINDOW (dialog), &dialog->x, &dialog->y);
+
/* it is, so hide it now */
gtk_widget_hide (GTK_WIDGET (dialog));
}
else
{
+ /* check if the dialog is invisible */
+ if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (dialog)))
+ {
+ /* restore its previous position before presenting it */
+ gtk_window_move (GTK_WINDOW (dialog), dialog->x, dialog->y);
+ }
+
/* it's not, so we need to raise it above other windows */
- gtk_window_present (GTK_WINDOW (dialog));
+ gtk_window_present_with_time (GTK_WINDOW (dialog), event->time);
}
return TRUE;
@@ -355,3 +371,12 @@ thunar_progress_dialog_add_job (ThunarProgressDialog *dialog,
thunar_progress_dialog_update_status_icon (dialog);
}
+
+
+
+gboolean
+thunar_progress_dialog_has_jobs (ThunarProgressDialog *dialog)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog), FALSE);
+ return dialog->views != NULL;
+}
diff --git a/thunar/thunar-progress-dialog.h b/thunar/thunar-progress-dialog.h
index e4bdbf8..335fa62 100644
--- a/thunar/thunar-progress-dialog.h
+++ b/thunar/thunar-progress-dialog.h
@@ -36,13 +36,14 @@ typedef struct _ThunarProgressDialog ThunarProgressDialog;
#define THUNAR_IS_PROGRESS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_PROGRESS_DIALOG))
#define THUNAR_PROGRESS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_PROGRESS_DIALOG, ThunarProgressDialogClass))
-GType thunar_progress_dialog_get_type (void) G_GNUC_CONST;
-
-GtkWidget *thunar_progress_dialog_new (void);
-void thunar_progress_dialog_add_job (ThunarProgressDialog *dialog,
- ThunarJob *job,
- const gchar *icon_name,
- const gchar *title);
+GType thunar_progress_dialog_get_type (void) G_GNUC_CONST;
+
+GtkWidget *thunar_progress_dialog_new (void);
+void thunar_progress_dialog_add_job (ThunarProgressDialog *dialog,
+ ThunarJob *job,
+ const gchar *icon_name,
+ const gchar *title);
+gboolean thunar_progress_dialog_has_jobs (ThunarProgressDialog *dialog);
G_END_DECLS;
More information about the Xfce4-commits
mailing list