[gnome-panel] widget: remove size hints



commit 5af99e6d953bbcec1615e62edd450238afd18465
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed May 26 14:27:54 2021 +0300

    widget: remove size hints

 gnome-panel/panel-applet-frame.c |  45 ----------------
 gnome-panel/panel-widget.c       | 109 ++-------------------------------------
 gnome-panel/panel-widget.h       |   8 ---
 3 files changed, 5 insertions(+), 157 deletions(-)
---
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index 16f5ebf4d..d4bcac92f 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -655,43 +655,10 @@ update_flags (PanelAppletFrame *self)
                                       minor);
 }
 
-static void
-update_size_hints (PanelAppletFrame *self)
-{
-  guint n_elements;
-  gint *size_hints;
-
-  size_hints = gp_applet_get_size_hints (self->priv->applet, &n_elements);
-
-  if (self->priv->handle != NULL)
-    {
-      GtkAllocation allocation;
-      gint extra_size;
-      guint i;
-
-      gtk_widget_get_allocation (self->priv->handle, &allocation);
-
-      if (self->priv->orientation & PANEL_HORIZONTAL_MASK)
-        extra_size = allocation.width + 1;
-      else
-        extra_size = allocation.height + 1;
-
-      for (i = 0; i < n_elements; i++)
-        size_hints[i] += extra_size;
-    }
-
-  /* It takes the ownership of size-hints array */
-  panel_widget_set_applet_size_hints (self->priv->panel,
-                                      GTK_WIDGET (self),
-                                      size_hints,
-                                      n_elements);
-}
-
 static void
 panel_applet_frame_init_properties (PanelAppletFrame *self)
 {
   update_flags (self);
-  update_size_hints (self);
 }
 
 static void
@@ -772,13 +739,6 @@ flags_changed_cb (GpApplet         *applet,
   update_flags (self);
 }
 
-static void
-size_hints_changed_cb (GpApplet         *applet,
-                       PanelAppletFrame *self)
-{
-  update_size_hints (self);
-}
-
 void
 _panel_applet_frame_set_applet (PanelAppletFrame *self,
                                 GpApplet         *applet)
@@ -790,11 +750,6 @@ _panel_applet_frame_set_applet (PanelAppletFrame *self,
                     G_CALLBACK (flags_changed_cb),
                     self);
 
-  g_signal_connect (applet,
-                    "size-hints-changed",
-                    G_CALLBACK (size_hints_changed_cb),
-                    self);
-
   gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (applet));
   gtk_widget_show (GTK_WIDGET (applet));
 }
diff --git a/gnome-panel/panel-widget.c b/gnome-panel/panel-widget.c
index 4c6d5eebf..c90f97c45 100644
--- a/gnome-panel/panel-widget.c
+++ b/gnome-panel/panel-widget.c
@@ -251,28 +251,6 @@ remove_all_move_bindings (PanelWidget *panel)
        gtk_binding_entry_remove (binding_set, GDK_KEY_space, 0);
 }
 
-static void
-get_preferred_size_from_hints (AppletData *ad,
-                               int        *minimum_size,
-                               int        *natural_size)
-{
-  int max_size;
-  int min_size;
-  int i;
-
-  max_size = 0;
-  min_size = INT_MAX;
-
-  for (i = 0; i < ad->size_hints_len; i += 2)
-    {
-      max_size = MAX (max_size, ad->size_hints[i]);
-      min_size = MIN (min_size, ad->size_hints[i + 1]);
-    }
-
-  *minimum_size = min_size;
-  *natural_size = max_size;
-}
-
 static GtkSizeRequestMode
 panel_widget_get_request_mode (GtkWidget *widget)
 {
@@ -323,13 +301,6 @@ panel_widget_get_preferred_height (GtkWidget *widget,
 
           if (ad->expand_major)
             {
-              if (ad->size_hints != NULL)
-                {
-                  get_preferred_size_from_hints (ad,
-                                                 &child_min_height,
-                                                 &child_nat_height);
-                }
-
               min_height += child_min_height;
               nat_height += child_nat_height;
             }
@@ -388,13 +359,6 @@ panel_widget_get_preferred_width_for_height (GtkWidget *widget,
 
           if (ad->expand_major)
             {
-              if (ad->size_hints != NULL)
-                {
-                  get_preferred_size_from_hints (ad,
-                                                 &child_min_width,
-                                                 &child_nat_width);
-                }
-
               min_width += child_min_width;
               nat_width += child_nat_width;
             }
@@ -451,13 +415,6 @@ panel_widget_get_preferred_width (GtkWidget *widget,
 
           if (ad->expand_major)
             {
-              if (ad->size_hints != NULL)
-                {
-                  get_preferred_size_from_hints (ad,
-                                                 &child_min_width,
-                                                 &child_nat_width);
-                }
-
               min_width += child_min_width;
               nat_width += child_nat_width;
             }
@@ -516,13 +473,6 @@ panel_widget_get_preferred_height_for_width (GtkWidget *widget,
 
           if (ad->expand_major)
             {
-              if (ad->size_hints != NULL)
-                {
-                  get_preferred_size_from_hints (ad,
-                                                 &child_min_height,
-                                                 &child_nat_height);
-                }
-
               min_height += child_min_height;
               nat_height += child_nat_height;
             }
@@ -1460,19 +1410,8 @@ get_preferred_size (PanelWidget    *self,
                                                  &minimum_size->width,
                                                  &natural_size->width);
 
-      if (ad->expand_major)
-        {
-          if (ad->size_hints != NULL)
-            {
-              get_preferred_size_from_hints (ad,
-                                             &minimum_size->width,
-                                             &natural_size->width);
-            }
-        }
-      else
-        {
-          natural_size->width = minimum_size->width;
-        }
+      if (!ad->expand_major)
+        natural_size->width = minimum_size->width;
     }
   else if (self->orient == GTK_ORIENTATION_VERTICAL)
     {
@@ -1493,19 +1432,8 @@ get_preferred_size (PanelWidget    *self,
                                                  &minimum_size->height,
                                                  &natural_size->height);
 
-      if (ad->expand_major)
-        {
-          if (ad->size_hints != NULL)
-            {
-              get_preferred_size_from_hints (ad,
-                                             &minimum_size->height,
-                                             &natural_size->height);
-            }
-        }
-      else
-        {
-          natural_size->height = minimum_size->height;
-        }
+      if (!ad->expand_major)
+        natural_size->height = minimum_size->height;
     }
   else
     {
@@ -2284,8 +2212,6 @@ panel_widget_applet_destroy (GtkWidget *applet, gpointer data)
                panel->applet_list = g_list_remove (panel->applet_list,ad);
        }
 
-       g_free (ad->size_hints);
-
        g_free (ad);
 }
 
@@ -2414,7 +2340,7 @@ panel_widget_add (PanelWidget         *panel,
                ad->position = 0;
                ad->expand_major = FALSE;
                ad->expand_minor = FALSE;
-               ad->size_hints = NULL;
+
                g_object_set_data (G_OBJECT (applet),
                                   PANEL_APPLET_DATA, ad);
                
@@ -2710,31 +2636,6 @@ panel_widget_set_applet_expandable (PanelWidget *panel,
        gtk_widget_queue_resize (GTK_WIDGET (panel));
 }
 
-void
-panel_widget_set_applet_size_hints (PanelWidget *panel,
-                                   GtkWidget   *applet,
-                                   int         *size_hints,
-                                   int          size_hints_len)
-{
-       AppletData *ad;
-
-       ad = g_object_get_data (G_OBJECT (applet), PANEL_APPLET_DATA);
-       if (!ad)
-               return;
-
-       g_free (ad->size_hints);
-
-       if (size_hints_len > 0 && (size_hints_len % 2 == 0)) {
-               ad->size_hints     = size_hints;
-               ad->size_hints_len = size_hints_len;
-       } else {
-               g_free (size_hints);
-               ad->size_hints = NULL;
-       }
-
-       gtk_widget_queue_resize (GTK_WIDGET (panel));
-}
-
 gboolean
 panel_applet_is_in_drag (void)
 {
diff --git a/gnome-panel/panel-widget.h b/gnome-panel/panel-widget.h
index fe296f61f..81070e9b5 100644
--- a/gnome-panel/panel-widget.h
+++ b/gnome-panel/panel-widget.h
@@ -43,10 +43,6 @@ struct _AppletData
        int             position;
        int             size;
 
-       /* Valid size ranges for expanded applets */
-       int *           size_hints; 
-       int             size_hints_len;
-
        guint           expand_major : 1;
        guint           expand_minor : 1;
 };
@@ -152,10 +148,6 @@ void     panel_widget_set_applet_expandable       (PanelWidget *panel,
                                                   GtkWidget   *applet,
                                                   gboolean     major,
                                                   gboolean     minor);
-void     panel_widget_set_applet_size_hints       (PanelWidget *panel,
-                                                  GtkWidget   *applet,
-                                                  int         *size_hints,
-                                                  int          size_hints_len);
 
 void     panel_widget_register_open_dialog        (PanelWidget *panel,
                                                   GtkWidget   *dialog);  


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]