Commit 3cac9d32 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

crash when deleting duplicate

gth_file_source_vfs_remove: use a progress dialog if the parent
window is not a GthBrowser

[bug #759631]
parent 272b2b2b
......@@ -5512,6 +5512,7 @@ gth_browser_exec_task (GthBrowser *browser,
GthTask *task,
GthTaskFlags flags)
{
g_return_if_fail (GTH_IS_BROWSER (browser));
g_return_if_fail (task != NULL);
if ((flags & GTH_TASK_FLAGS_FOREGROUND) == 0) {
......
......@@ -31,6 +31,7 @@
#include "gth-file-source-vfs.h"
#include "gth-main.h"
#include "gth-preferences.h"
#include "gth-progress-dialog.h"
#include "gth-trash-task.h"
#include "gtk-utils.h"
......@@ -661,7 +662,16 @@ delete_file_permanently (GtkWindow *window,
files = gth_file_data_list_to_file_list (file_list);
task = gth_delete_task_new (files);
gth_browser_exec_task (GTH_BROWSER (window), task, GTH_TASK_FLAGS_DEFAULT);
if (GTH_IS_BROWSER (window)) {
gth_browser_exec_task (GTH_BROWSER (window), task, GTH_TASK_FLAGS_DEFAULT);
}
else {
GtkWidget *dialog;
dialog = gth_progress_dialog_new (window);
gth_progress_dialog_destroy_with_tasks (GTH_PROGRESS_DIALOG (dialog), TRUE);
gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (dialog), task, GTH_TASK_FLAGS_DEFAULT);
}
g_object_unref (task);
_g_object_list_unref (files);
......
......@@ -250,6 +250,7 @@ struct _GthProgressDialogPrivate {
GtkWidget *task_box;
gulong show_event;
gboolean custom_dialog_opened;
gboolean destroy_with_tasks;
};
......@@ -294,6 +295,7 @@ gth_progress_dialog_init (GthProgressDialog *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_PROGRESS_DIALOG, GthProgressDialogPrivate);
self->priv->custom_dialog_opened = FALSE;
self->priv->destroy_with_tasks = FALSE;
gtk_widget_set_size_request (GTK_WIDGET (self), DIALOG_WIDTH, -1);
gtk_window_set_title (GTK_WINDOW (self), "");
......@@ -325,6 +327,15 @@ gth_progress_dialog_new (GtkWindow *parent)
}
void
gth_progress_dialog_destroy_with_tasks (GthProgressDialog *self,
gboolean value)
{
g_return_if_fail (GTH_IS_PROGRESS_DIALOG (self));
self->priv->destroy_with_tasks = value;
}
static gboolean
_show_dialog_cb (gpointer data)
{
......@@ -454,6 +465,9 @@ gth_progress_dialog_child_removed (GthProgressDialog *self)
g_source_remove (self->priv->show_event);
self->priv->show_event = 0;
}
gtk_widget_hide (GTK_WIDGET (self));
if (self->priv->destroy_with_tasks)
gtk_widget_destroy (self);
else
gtk_widget_hide (GTK_WIDGET (self));
}
}
......@@ -47,13 +47,15 @@ struct _GthProgressDialogClass {
GtkDialogClass parent_class;
};
GType gth_progress_dialog_get_type (void);
GtkWidget * gth_progress_dialog_new (GtkWindow *parent);
void gth_progress_dialog_add_task (GthProgressDialog *dialog,
GthTask *task,
GthTaskFlags flags);
GtkWidget * gth_task_progress_new (GthTask *task);
GType gth_progress_dialog_get_type (void);
GtkWidget * gth_progress_dialog_new (GtkWindow *parent);
void gth_progress_dialog_destroy_with_tasks (GthProgressDialog *dialog,
gboolean value);
void gth_progress_dialog_add_task (GthProgressDialog *dialog,
GthTask *task,
GthTaskFlags flags);
GtkWidget * gth_task_progress_new (GthTask *task);
G_END_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment