Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions libxapp/xapp-status-icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (XAppStatusIcon, xapp_status_icon, G_TYPE_OBJECT)
static void refresh_icon (XAppStatusIcon *self);
static void use_gtk_status_icon (XAppStatusIcon *self);
static void remove_icon_path_from_bus (XAppStatusIcon *self);
static void hide_and_defer_unref_status_icon (XAppStatusIcon *self, GtkStatusIcon *status_icon);

static void
cancellable_reset (XAppStatusIcon *self)
Expand Down Expand Up @@ -805,6 +806,30 @@ on_name_lost (GDBusConnection *connection,
g_list_free_full (instances, g_object_unref);
}

static gboolean
return_false_cb (gpointer user_data)
{
Comment thread
leigh123linux marked this conversation as resolved.
(void) user_data;

return G_SOURCE_REMOVE;
}

static void
hide_and_defer_unref_status_icon (XAppStatusIcon *self, GtkStatusIcon *status_icon)
{
if (status_icon == NULL)
return;

g_signal_handlers_disconnect_by_data (status_icon, self);

gtk_status_icon_set_visible (status_icon, FALSE);

g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
return_false_cb,
status_icon,
g_object_unref);
}
Comment thread
leigh123linux marked this conversation as resolved.
Comment thread
leigh123linux marked this conversation as resolved.

static void
sync_skeleton (XAppStatusIcon *self)
{
Expand All @@ -813,7 +838,8 @@ sync_skeleton (XAppStatusIcon *self)

priv->fail_counter = 0;

g_clear_object (&self->priv->gtk_status_icon);
hide_and_defer_unref_status_icon (self, self->priv->gtk_status_icon);
self->priv->gtk_status_icon = NULL;
Comment thread
leigh123linux marked this conversation as resolved.

g_object_set (G_OBJECT (priv->interface_skeleton),
"name", priv->name,
Expand Down Expand Up @@ -1047,7 +1073,8 @@ use_gtk_status_icon (XAppStatusIcon *self)
remove_icon_path_from_bus (self);

// Make sure there wasn't already one
g_clear_object (&self->priv->gtk_status_icon);
hide_and_defer_unref_status_icon (self, self->priv->gtk_status_icon);
self->priv->gtk_status_icon = NULL;

self->priv->gtk_status_icon = gtk_status_icon_new ();

Expand Down Expand Up @@ -1362,9 +1389,7 @@ xapp_status_icon_dispose (GObject *object)

if (self->priv->gtk_status_icon != NULL)
{
g_signal_handlers_disconnect_by_func (self->priv->gtk_status_icon, on_gtk_status_icon_button_press, self);
g_signal_handlers_disconnect_by_func (self->priv->gtk_status_icon, on_gtk_status_icon_button_release, self);
g_object_unref (self->priv->gtk_status_icon);
hide_and_defer_unref_status_icon (self, self->priv->gtk_status_icon);
self->priv->gtk_status_icon = NULL;
}

Expand Down
Loading