From 609b4b21f61f1bc26cb8a53d9b739f03399ee3c2 Mon Sep 17 00:00:00 2001 From: monsta Date: Thu, 4 Jan 2018 19:20:07 +0300 Subject: rework the process of cancelling the background change operation don't mess with additional references to a GCancellable, instead keep just a const pointer to the internal operation data and use it as a key when it's needed to cancel the operation. fixes https://github.com/mate-desktop/mate-panel/issues/214 fixes https://github.com/mate-desktop/mate-panel/issues/431 (squashed 180ba4ae21e8f5bc7d67f4902d0cda6ff053f4b2 + 7f711b89d0db04c12db2286b5d18892be45f26a5 for 1.18 branch) --- .../panel-applet-frame-dbus.c | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c') diff --git a/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c b/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c index 9a3464ce..47be5dcc 100644 --- a/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c +++ b/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c @@ -42,7 +42,7 @@ G_DEFINE_TYPE (MatePanelAppletFrameDBus, struct _MatePanelAppletFrameDBusPrivate { MatePanelAppletContainer *container; - GCancellable *bg_cancellable; + gconstpointer bg_operation; }; /* Keep in sync with mate-panel-applet.h. Uggh. */ @@ -235,10 +235,7 @@ container_child_background_set (GObject *source_object, mate_panel_applet_container_child_set_finish (container, res, NULL); - if (frame->priv->bg_cancellable) - g_object_unref (frame->priv->bg_cancellable); - - frame->priv->bg_cancellable = NULL; + frame->priv->bg_operation = NULL; } static void @@ -246,22 +243,23 @@ mate_panel_applet_frame_dbus_change_background (MatePanelAppletFrame *frame, PanelBackgroundType type) { MatePanelAppletFrameDBus *dbus_frame = MATE_PANEL_APPLET_FRAME_DBUS (frame); + MatePanelAppletFrameDBusPrivate *priv = dbus_frame->priv; char *bg_str; bg_str = _mate_panel_applet_frame_get_background_string ( frame, PANEL_WIDGET (gtk_widget_get_parent (GTK_WIDGET (frame))), type); if (bg_str != NULL) { - if (dbus_frame->priv->bg_cancellable) - g_cancellable_cancel (dbus_frame->priv->bg_cancellable); - dbus_frame->priv->bg_cancellable = g_cancellable_new (); + if (priv->bg_operation) + mate_panel_applet_container_cancel_operation (priv->container, priv->bg_operation); - mate_panel_applet_container_child_set (dbus_frame->priv->container, + priv->bg_operation = mate_panel_applet_container_child_set (priv->container, "background", g_variant_new_string (bg_str), - dbus_frame->priv->bg_cancellable, + NULL, container_child_background_set, dbus_frame); + g_free (bg_str); } } @@ -328,9 +326,7 @@ mate_panel_applet_frame_dbus_finalize (GObject *object) { MatePanelAppletFrameDBus *frame = MATE_PANEL_APPLET_FRAME_DBUS (object); - if (frame->priv->bg_cancellable) - g_object_unref (frame->priv->bg_cancellable); - frame->priv->bg_cancellable = NULL; + frame->priv->bg_operation = NULL; G_OBJECT_CLASS (mate_panel_applet_frame_dbus_parent_class)->finalize (object); } @@ -348,7 +344,7 @@ mate_panel_applet_frame_dbus_init (MatePanelAppletFrameDBus *frame) gtk_widget_show (container); gtk_container_add (GTK_CONTAINER (frame), container); frame->priv->container = MATE_PANEL_APPLET_CONTAINER (container); - frame->priv->bg_cancellable = NULL; + frame->priv->bg_operation = NULL; g_signal_connect (container, "child-property-changed::flags", G_CALLBACK (mate_panel_applet_frame_dbus_flags_changed), -- cgit v1.2.1