[Xfce4-commits] [apps/xfdashboard] 02/03: Add signal 'style-revalidated' to interface XfdashboardStylable
noreply at xfce.org
noreply at xfce.org
Fri May 18 11:17:14 CEST 2018
This is an automated email from the git hooks/post-receive script.
n o m a d p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfdashboard.
commit 92f8511ef80a32455245d3d20fc9cd95fda7023b
Author: Stephan Haller <nomad at froevel.de>
Date: Fri May 18 11:06:36 2018 +0200
Add signal 'style-revalidated' to interface XfdashboardStylable
This signal is emitted when the style information for a XfdashboardStylable derived object was invalidated and the new style information was calculated and applied. This signal is mostly useful for stylable (inheriting XfdashboardStylable interface) non-actor (no sub-class of #XfdashboardActor) objects to also invalidate their style information and to get them recalculated and applied if they depend on the stylable object which emitted the signal. Connected XfdashboardDynamicTableLayo [...]
This commit fixes issue GH #168
---
libxfdashboard/dynamic-table-layout.c | 37 ++++++++++++++++++++++++++++++++-
libxfdashboard/stylable.c | 39 +++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/libxfdashboard/dynamic-table-layout.c b/libxfdashboard/dynamic-table-layout.c
index 84abd8f..7a3fdb2 100644
--- a/libxfdashboard/dynamic-table-layout.c
+++ b/libxfdashboard/dynamic-table-layout.c
@@ -67,6 +67,7 @@ struct _XfdashboardDynamicTableLayoutPrivate
GArray *rowCoords;
gpointer container;
+ guint styleRevalidationSignalID;
};
/* Properties */
@@ -468,6 +469,16 @@ static void _xfdashboard_dynamic_table_layout_update_layout_data(XfdashboardDyna
}
}
+/* A style revalidation happened at container this layout manager is attached to */
+static void _xfdashboard_dynamic_table_layout_on_style_revalidated(XfdashboardDynamicTableLayout *self,
+ gpointer inUserData)
+{
+ g_return_if_fail(XFDASHBOARD_IS_DYNAMIC_TABLE_LAYOUT(self));
+
+ /* Invalidate style to get new possible styles applied */
+ xfdashboard_stylable_invalidate(XFDASHBOARD_STYLABLE(self));
+}
+
/* IMPLEMENTATION: ClutterLayoutManager */
@@ -608,6 +619,14 @@ static void _xfdashboard_dynamic_table_layout_set_container(ClutterLayoutManager
/* Remove weak reference at old container */
if(priv->container)
{
+ /* Disconnect signal handler to get notified about style revalidations */
+ if(priv->styleRevalidationSignalID)
+ {
+ g_signal_handler_disconnect(priv->container, priv->styleRevalidationSignalID);
+ priv->styleRevalidationSignalID=0;
+ }
+
+ /* Remove weak reference from container */
g_object_remove_weak_pointer(G_OBJECT(priv->container), &priv->container);
priv->container=NULL;
}
@@ -615,8 +634,15 @@ static void _xfdashboard_dynamic_table_layout_set_container(ClutterLayoutManager
/* Add weak reference at new container */
if(inContainer)
{
+ /* Remember new container set and add weak reference */
priv->container=inContainer;
g_object_add_weak_pointer(G_OBJECT(priv->container), &priv->container);
+
+ /* Connect signal handler to get notified about style revalidations */
+ priv->styleRevalidationSignalID=g_signal_connect_swapped(priv->container,
+ "style-revalidated",
+ G_CALLBACK(_xfdashboard_dynamic_table_layout_on_style_revalidated),
+ self);
}
/* Invalidate style to get new possible styles applied */
@@ -718,6 +744,14 @@ static void _xfdashboard_dynamic_table_layout_dispose(GObject *inObject)
if(priv->container)
{
+ /* Disconnect signal handler to get notified about style revalidations */
+ if(priv->styleRevalidationSignalID)
+ {
+ g_signal_handler_disconnect(priv->container, priv->styleRevalidationSignalID);
+ priv->styleRevalidationSignalID=0;
+ }
+
+ /* Remove weak reference from container */
g_object_remove_weak_pointer(G_OBJECT(priv->container), &priv->container);
priv->container=NULL;
}
@@ -908,8 +942,9 @@ static void xfdashboard_dynamic_table_layout_init(XfdashboardDynamicTableLayout
priv->columnCoords=NULL;
priv->rowCoords=NULL;
priv->container=NULL;
+ priv->styleRevalidationSignalID=0;
- /* Style content */
+ /* Style layout manager */
xfdashboard_stylable_invalidate(XFDASHBOARD_STYLABLE(self));
}
diff --git a/libxfdashboard/stylable.c b/libxfdashboard/stylable.c
index 2c4673a..6f1c7b0 100644
--- a/libxfdashboard/stylable.c
+++ b/libxfdashboard/stylable.c
@@ -39,6 +39,17 @@ G_DEFINE_INTERFACE(XfdashboardStylable,
xfdashboard_stylable,
G_TYPE_OBJECT)
+/* Signals */
+enum
+{
+ /* Signals */
+ SIGNAL_STYLE_REVALIDATED,
+
+ SIGNAL_LAST
+};
+
+static guint XfdashboardStylableSignals[SIGNAL_LAST]={ 0, };
+
/* IMPLEMENTATION: Private variables and methods */
#define XFDASHBOARD_STYLABLE_WARN_NOT_IMPLEMENTED(self, vfunc) \
g_warning(_("Object of type %s does not implement required virtual function XfdashboardStylable::%s"), \
@@ -239,6 +250,9 @@ static void _xfdashboard_stylable_real_invalidate(XfdashboardStylable *self)
/* Release allocated resources */
g_hash_table_destroy(themeStyleSet);
g_hash_table_destroy(stylableProperties);
+
+ /* Emit 'style-revalidated' signal to notify other objects about it's done */
+ g_signal_emit(self, XfdashboardStylableSignals[SIGNAL_STYLE_REVALIDATED], 0);
}
/* IMPLEMENTATION: GObject */
@@ -283,6 +297,31 @@ void xfdashboard_stylable_default_init(XfdashboardStylableInterface *iface)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_interface_install_property(iface, property);
+ /* Define signals */
+ /**
+ * XfdashboardStylable::style-revalidated:
+ * @self: A #XfdashboardStylable
+ *
+ * The ::style-revalidated signal is emitted when the style information
+ * for @self were invalidated and the new style information were calculated
+ * and applied.
+ *
+ * Connecting to this signal is mostly useful for stylable non-actor object,
+ * i.e. objects which are no sub-class of #XfdashboardActor (neither directly
+ * not indirectly) but inherit the #XfdashboardStylable interface, to invalidate
+ * their style information and to get them recalculated and applied.
+ */
+ XfdashboardStylableSignals[SIGNAL_STYLE_REVALIDATED]=
+ g_signal_new("style-revalidated",
+ G_TYPE_FROM_INTERFACE(iface),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
/* Set flag that base initialization was done for this interface */
initialized=TRUE;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list