[gnome-panel] libgnome-panel: don't queue resize from size_allocate
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] libgnome-panel: don't queue resize from size_allocate
- Date: Fri, 30 Apr 2021 22:54:20 +0000 (UTC)
commit b745fe59cc9a08f66a247660c01a4c6a57697a43
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Apr 30 19:57:43 2021 +0300
libgnome-panel: don't queue resize from size_allocate
libgnome-panel/gp-applet.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/libgnome-panel/gp-applet.c b/libgnome-panel/gp-applet.c
index eb036e9d2..baaccfd55 100644
--- a/libgnome-panel/gp-applet.c
+++ b/libgnome-panel/gp-applet.c
@@ -86,6 +86,8 @@ typedef struct
guint panel_icon_size;
guint menu_icon_size;
+ guint icon_resize_id;
+
GtkWidget *about_dialog;
} GpAppletPrivate;
@@ -235,6 +237,21 @@ general_settings_changed_cb (GSettings *settings,
update_panel_icon_size (applet);
}
+static gboolean
+icon_resize_cb (gpointer user_data)
+{
+ GpApplet *self;
+ GpAppletPrivate *priv;
+
+ self = GP_APPLET (user_data);
+ priv = gp_applet_get_instance_private (self);
+
+ update_panel_icon_size (self);
+ priv->icon_resize_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
static gboolean
emit_size_hints_changed_cb (gpointer user_data)
{
@@ -351,6 +368,12 @@ gp_applet_dispose (GObject *object)
priv->size_hints_idle = 0;
}
+ if (priv->icon_resize_id != 0)
+ {
+ g_source_remove (priv->icon_resize_id);
+ priv->icon_resize_id = 0;
+ }
+
g_clear_pointer (&priv->initial_settings, g_variant_unref);
g_clear_object (&priv->general_settings);
@@ -598,13 +621,29 @@ static void
gp_applet_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GpApplet *applet;
+ GpApplet *self;
+ GpAppletPrivate *priv;
+ GtkAllocation old_allocation;
- applet = GP_APPLET (widget);
+ self = GP_APPLET (widget);
+ priv = gp_applet_get_instance_private (self);
+
+ gtk_widget_get_allocation (widget, &old_allocation);
GTK_WIDGET_CLASS (gp_applet_parent_class)->size_allocate (widget, allocation);
- update_panel_icon_size (applet);
+ if ((priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
+ old_allocation.height != allocation->height) ||
+ (priv->orientation == GTK_ORIENTATION_VERTICAL &&
+ old_allocation.width != allocation->width))
+ {
+ if (priv->icon_resize_id == 0)
+ {
+ priv->icon_resize_id = g_idle_add (icon_resize_cb, self);
+ g_source_set_name_by_id (priv->icon_resize_id,
+ "[libgnome-panel] icon_resize_cb");
+ }
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]