[Xfce4-commits] <thunar:master> Create status icon when we're actually going to display it.
Nick Schermer
noreply at xfce.org
Wed Feb 24 16:28:02 CET 2010
Updating branch refs/heads/master
to eb89a0fdc3b7823ac7e0e630d2db98b2230f6954 (commit)
from ee62db374dd3ff5e8896e7188640378f991615fc (commit)
commit eb89a0fdc3b7823ac7e0e630d2db98b2230f6954
Author: Nick Schermer <nick at xfce.org>
Date: Wed Feb 24 16:20:21 2010 +0100
Create status icon when we're actually going to display it.
The show/hide in status icons emits a critical warning (in the
plug window) because of the quick hide we do after creating in
status icon. This crashes the status icon in the panel.
Although this is a problem in Gtk, it is also better to delay
creating the status icon until we actually show it.
thunar/thunar-progress-dialog.c | 30 +++++++++++++++++-------------
1 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/thunar/thunar-progress-dialog.c b/thunar/thunar-progress-dialog.c
index 30ad94b..ab8155c 100644
--- a/thunar/thunar-progress-dialog.c
+++ b/thunar/thunar-progress-dialog.c
@@ -112,13 +112,6 @@ thunar_progress_dialog_init (ThunarProgressDialog *dialog)
gtk_container_set_border_width (GTK_CONTAINER (dialog->content_box), 8);
gtk_container_add (GTK_CONTAINER (dialog->vbox), dialog->content_box);
gtk_widget_show (dialog->content_box);
-
- dialog->status_icon = gtk_status_icon_new_from_icon_name ("stock_folder-copy");
- gtk_status_icon_set_visible (dialog->status_icon, FALSE);
-
- g_signal_connect_swapped (dialog->status_icon, "button-press-event",
- G_CALLBACK (thunar_progress_dialog_toggled),
- GTK_WIDGET (dialog));
}
@@ -137,7 +130,8 @@ thunar_progress_dialog_finalize (GObject *object)
ThunarProgressDialog *dialog = THUNAR_PROGRESS_DIALOG (object);
/* destroy the status icon */
- g_object_unref (dialog->status_icon);
+ if (dialog->status_icon != NULL)
+ g_object_unref (dialog->status_icon);
/* free the view list */
g_list_free (dialog->views);
@@ -153,7 +147,14 @@ thunar_progress_dialog_shown (ThunarProgressDialog *dialog)
_thunar_return_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog));
/* show the status icon */
- gtk_status_icon_set_visible (dialog->status_icon, TRUE);
+ if (dialog->status_icon == NULL)
+ {
+ dialog->status_icon = gtk_status_icon_new_from_icon_name ("stock_folder-copy");
+ thunar_progress_dialog_update_status_icon (dialog);
+ g_signal_connect_swapped (dialog->status_icon, "button-press-event",
+ G_CALLBACK (thunar_progress_dialog_toggled),
+ GTK_WIDGET (dialog));
+ }
}
@@ -267,7 +268,8 @@ thunar_progress_dialog_job_finished (ThunarProgressDialog *dialog,
if (dialog->views != NULL)
{
/* update the status icon */
- thunar_progress_dialog_update_status_icon (dialog);
+ if (dialog->status_icon != NULL)
+ thunar_progress_dialog_update_status_icon (dialog);
}
else
{
@@ -285,7 +287,8 @@ thunar_progress_dialog_update_status_icon (ThunarProgressDialog *dialog)
guint n_views;
_thunar_return_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog));
-
+ _thunar_return_if_fail (GTK_IS_STATUS_ICON (dialog->status_icon));
+
/* determine the number of views now being active */
n_views = g_list_length (dialog->views);
@@ -293,7 +296,7 @@ thunar_progress_dialog_update_status_icon (ThunarProgressDialog *dialog)
tooltip_text = g_strdup_printf (ngettext ("%d file operation running",
"%d file operations running",
n_views),
- n_views);
+ n_views);
/* update the tooltip */
#if GTK_CHECK_VERSION (2, 16, 0)
@@ -369,7 +372,8 @@ thunar_progress_dialog_add_job (ThunarProgressDialog *dialog,
g_signal_connect_swapped (view, "finished",
G_CALLBACK (thunar_progress_dialog_job_finished), dialog);
- thunar_progress_dialog_update_status_icon (dialog);
+ if (dialog->status_icon != NULL)
+ thunar_progress_dialog_update_status_icon (dialog);
}
More information about the Xfce4-commits
mailing list