[libhandy] view-switcher-title: Remove has-subtitle property



commit 96a0eaed6e79376993af6d2846662b1c3a6d65c4
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Jun 1 18:26:49 2020 +0500

    view-switcher-title: Remove has-subtitle property
    
    This property doesn't really do anything considering the widget also has an
    embedded view switcher which is taller than title+subtitle combined.

 src/hdy-view-switcher-title.c  | 169 -----------------------------------------
 src/hdy-view-switcher-title.h  |   4 -
 src/hdy-view-switcher-title.ui |  31 --------
 3 files changed, 204 deletions(-)
---
diff --git a/src/hdy-view-switcher-title.c b/src/hdy-view-switcher-title.c
index 8d35a6fc..ab0a03ee 100644
--- a/src/hdy-view-switcher-title.c
+++ b/src/hdy-view-switcher-title.c
@@ -74,7 +74,6 @@ enum {
   PROP_STACK,
   PROP_TITLE,
   PROP_SUBTITLE,
-  PROP_HAS_SUBTITLE,
   PROP_VIEW_SWITCHER_ENABLED,
   PROP_TITLE_VISIBLE,
   LAST_PROP,
@@ -83,13 +82,10 @@ enum {
 typedef struct {
   HdySqueezer *squeezer;
   GtkLabel *subtitle_label;
-  GtkLabel *subtitle_sizing_label;
   GtkBox *title_box;
   GtkLabel *title_label;
-  GtkBox *title_sizing_box;
   HdyViewSwitcher *view_switcher;
 
-  gboolean has_subtitle;
   gboolean view_switcher_enabled;
 } HdyViewSwitcherTitlePrivate;
 
@@ -105,7 +101,6 @@ update_subtitle_label (HdyViewSwitcherTitle *self)
   const gchar *subtitle = gtk_label_get_label (priv->subtitle_label);
 
   gtk_widget_set_visible (GTK_WIDGET (priv->subtitle_label), subtitle && subtitle[0]);
-  gtk_widget_set_visible (GTK_WIDGET (priv->subtitle_sizing_label), priv->has_subtitle || (subtitle && 
subtitle[0]));
 
   gtk_widget_queue_resize (GTK_WIDGET (self));
 }
@@ -160,9 +155,6 @@ hdy_view_switcher_title_get_property (GObject    *object,
   case PROP_SUBTITLE:
     g_value_set_string (value, hdy_view_switcher_title_get_subtitle (self));
     break;
-  case PROP_HAS_SUBTITLE:
-    g_value_set_boolean (value, hdy_view_switcher_title_get_has_subtitle (self));
-    break;
   case PROP_VIEW_SWITCHER_ENABLED:
     g_value_set_boolean (value, hdy_view_switcher_title_get_view_switcher_enabled (self));
     break;
@@ -199,9 +191,6 @@ hdy_view_switcher_title_set_property (GObject      *object,
   case PROP_SUBTITLE:
     hdy_view_switcher_title_set_subtitle (self, g_value_get_string (value));
     break;
-  case PROP_HAS_SUBTITLE:
-    hdy_view_switcher_title_set_has_subtitle (self, g_value_get_boolean (value));
-    break;
   case PROP_VIEW_SWITCHER_ENABLED:
     hdy_view_switcher_title_set_view_switcher_enabled (self, g_value_get_boolean (value));
     break;
@@ -211,84 +200,6 @@ hdy_view_switcher_title_set_property (GObject      *object,
   }
 }
 
-static void
-hdy_view_switcher_title_get_preferred_width (GtkWidget *widget,
-                                             gint      *minimum,
-                                             gint      *natural)
-{
-  HdyViewSwitcherTitle *self = HDY_VIEW_SWITCHER_TITLE (widget);
-  HdyViewSwitcherTitlePrivate *priv = hdy_view_switcher_title_get_instance_private (self);
-  gint title_minimum, title_natural;
-
-  GTK_WIDGET_CLASS (hdy_view_switcher_title_parent_class)->get_preferred_width (widget, minimum, natural);
-  gtk_widget_get_preferred_width (GTK_WIDGET (priv->title_sizing_box),
-                                  &title_minimum, &title_natural);
-
-  if (minimum)
-    *minimum = MAX (*minimum, title_minimum);
-  if (natural)
-    *natural = MAX (*natural, title_natural);
-}
-
-static void
-hdy_view_switcher_title_get_preferred_height (GtkWidget *widget,
-                                              gint      *minimum,
-                                              gint      *natural)
-{
-  HdyViewSwitcherTitle *self = HDY_VIEW_SWITCHER_TITLE (widget);
-  HdyViewSwitcherTitlePrivate *priv = hdy_view_switcher_title_get_instance_private (self);
-  gint title_minimum, title_natural;
-
-  GTK_WIDGET_CLASS (hdy_view_switcher_title_parent_class)->get_preferred_height (widget, minimum, natural);
-  gtk_widget_get_preferred_height (GTK_WIDGET (priv->title_sizing_box),
-                                   &title_minimum, &title_natural);
-
-  if (minimum)
-    *minimum = MAX (*minimum, title_minimum);
-  if (natural)
-    *natural = MAX (*natural, title_natural);
-}
-
-static void
-hdy_view_switcher_title_get_preferred_width_for_height (GtkWidget *widget,
-                                                        gint       height,
-                                                        gint      *minimum,
-                                                        gint      *natural)
-{
-  HdyViewSwitcherTitle *self = HDY_VIEW_SWITCHER_TITLE (widget);
-  HdyViewSwitcherTitlePrivate *priv = hdy_view_switcher_title_get_instance_private (self);
-  gint title_minimum, title_natural;
-
-  GTK_WIDGET_CLASS (hdy_view_switcher_title_parent_class)->get_preferred_width_for_height (widget, height, 
minimum, natural);
-  gtk_widget_get_preferred_width_for_height (GTK_WIDGET (priv->title_sizing_box),
-                                             height, &title_minimum, &title_natural);
-
-  if (minimum)
-    *minimum = MAX (*minimum, title_minimum);
-  if (natural)
-    *natural = MAX (*natural, title_natural);
-}
-
-static void
-hdy_view_switcher_title_get_preferred_height_for_width (GtkWidget *widget,
-                                                        gint       width,
-                                                        gint      *minimum,
-                                                        gint      *natural)
-{
-  HdyViewSwitcherTitle *self = HDY_VIEW_SWITCHER_TITLE (widget);
-  HdyViewSwitcherTitlePrivate *priv = hdy_view_switcher_title_get_instance_private (self);
-  gint title_minimum, title_natural;
-
-  GTK_WIDGET_CLASS (hdy_view_switcher_title_parent_class)->get_preferred_height_for_width (widget, width, 
minimum, natural);
-  gtk_widget_get_preferred_height_for_width (GTK_WIDGET (priv->title_sizing_box),
-                                             width, &title_minimum, &title_natural);
-
-  if (minimum)
-    *minimum = MAX (*minimum, title_minimum);
-  if (natural)
-    *natural = MAX (*natural, title_natural);
-}
-
 static void
 hdy_view_switcher_title_dispose (GObject *object) {
   HdyViewSwitcherTitle *self = (HdyViewSwitcherTitle *)object;
@@ -314,11 +225,6 @@ hdy_view_switcher_title_class_init (HdyViewSwitcherTitleClass *klass)
   object_class->get_property = hdy_view_switcher_title_get_property;
   object_class->set_property = hdy_view_switcher_title_set_property;
 
-  widget_class->get_preferred_width = hdy_view_switcher_title_get_preferred_width;
-  widget_class->get_preferred_height = hdy_view_switcher_title_get_preferred_height;
-  widget_class->get_preferred_width_for_height = hdy_view_switcher_title_get_preferred_width_for_height;
-  widget_class->get_preferred_height_for_width = hdy_view_switcher_title_get_preferred_height_for_width;
-
   /**
    * HdyViewSwitcherTitle:policy:
    *
@@ -391,20 +297,6 @@ hdy_view_switcher_title_class_init (HdyViewSwitcherTitleClass *klass)
                          NULL,
                          G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
-  /**
-   * HdyViewSwitcherTitle:has-subtitle:
-   *
-   * If %TRUE, reserve space for a subtitle, even if none is currently set.
-   *
-   * Since: 1.0
-   */
-  props[PROP_HAS_SUBTITLE] =
-    g_param_spec_boolean ("has-subtitle",
-                          _("Has Subtitle"),
-                          _("Whether to reserve space for a subtitle"),
-                          TRUE,
-                          G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
   /**
    * HdyViewSwitcherTitle:view-switcher-enabled:
    *
@@ -441,10 +333,8 @@ hdy_view_switcher_title_class_init (HdyViewSwitcherTitleClass *klass)
                                                "/sm/puri/handy/ui/hdy-view-switcher-title.ui");
   gtk_widget_class_bind_template_child_private (widget_class, HdyViewSwitcherTitle, squeezer);
   gtk_widget_class_bind_template_child_private (widget_class, HdyViewSwitcherTitle, subtitle_label);
-  gtk_widget_class_bind_template_child_private (widget_class, HdyViewSwitcherTitle, subtitle_sizing_label);
   gtk_widget_class_bind_template_child_private (widget_class, HdyViewSwitcherTitle, title_box);
   gtk_widget_class_bind_template_child_private (widget_class, HdyViewSwitcherTitle, title_label);
-  gtk_widget_class_bind_template_child_private (widget_class, HdyViewSwitcherTitle, title_sizing_box);
   gtk_widget_class_bind_template_child_private (widget_class, HdyViewSwitcherTitle, view_switcher);
   gtk_widget_class_bind_template_callback (widget_class, notify_squeezer_visible_child_cb);
 }
@@ -459,7 +349,6 @@ hdy_view_switcher_title_init (HdyViewSwitcherTitle *self)
   /* This must be initialized before the template so the embedded view switcher
    * can pick up the correct default value.
    */
-  priv->has_subtitle = TRUE;
   priv->view_switcher_enabled = TRUE;
 
   gtk_widget_init_template (GTK_WIDGET (self));
@@ -726,10 +615,6 @@ hdy_view_switcher_title_get_subtitle (HdyViewSwitcherTitle *self)
  * Sets the subtitle of @self. The subtitle should give a user additional
  * details.
  *
- * Note that #HdyViewSwitcherTitle by default reserves room for the subtitle,
- * even if none is currently set. If this is not desired, set the
- * #HdyViewSwitcherTitle:has-subtitle property to %FALSE.
- *
  * Since: 1.0
  */
 void
@@ -751,60 +636,6 @@ hdy_view_switcher_title_set_subtitle (HdyViewSwitcherTitle *self,
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SUBTITLE]);
 }
 
-/**
- * hdy_view_switcher_title_get_has_subtitle:
- * @self: a #HdyViewSwitcherTitle
- *
- * gets whether the view switcher reserves space for a subtitle, regardless if
- * one is currently set or not.
- *
- * Returns: %TRUE if the view switcher reserves space for a subtitle
- *
- * Since: 1.0
- */
-gboolean
-hdy_view_switcher_title_get_has_subtitle (HdyViewSwitcherTitle *self)
-{
-  HdyViewSwitcherTitlePrivate *priv;
-
-  g_return_val_if_fail (HDY_IS_VIEW_SWITCHER_TITLE (self), FALSE);
-
-  priv = hdy_view_switcher_title_get_instance_private (self);
-
-  return priv->has_subtitle;
-}
-
-/**
- * hdy_view_switcher_title_set_has_subtitle:
- * @self: a #HdyViewSwitcherTitle
- * @has_subtitle: %TRUE to reserve space for a subtitle
- *
- * Sets whether the view switcher should reserve space for a subtitle, even if
- * none is currently set.
- *
- * Since: 1.0
- */
-void
-hdy_view_switcher_title_set_has_subtitle (HdyViewSwitcherTitle *self,
-                                          gboolean              has_subtitle)
-{
-  HdyViewSwitcherTitlePrivate *priv;
-
-  g_return_if_fail (HDY_IS_VIEW_SWITCHER_TITLE (self));
-
-  priv = hdy_view_switcher_title_get_instance_private (self);
-
-  has_subtitle = !!has_subtitle;
-
-  if (priv->has_subtitle == has_subtitle)
-    return;
-
-  priv->has_subtitle = has_subtitle;
-  update_subtitle_label (self);
-
-  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_HAS_SUBTITLE]);
-}
-
 /**
  * hdy_view_switcher_title_get_view_switcher_enabled:
  * @self: a #HdyViewSwitcherTitle
diff --git a/src/hdy-view-switcher-title.h b/src/hdy-view-switcher-title.h
index 46fb1b1f..83b95c20 100644
--- a/src/hdy-view-switcher-title.h
+++ b/src/hdy-view-switcher-title.h
@@ -47,10 +47,6 @@ const gchar *hdy_view_switcher_title_get_subtitle (HdyViewSwitcherTitle *self);
 void         hdy_view_switcher_title_set_subtitle (HdyViewSwitcherTitle *self,
                                                    const gchar          *subtitle);
 
-gboolean hdy_view_switcher_title_get_has_subtitle (HdyViewSwitcherTitle *self);
-void     hdy_view_switcher_title_set_has_subtitle (HdyViewSwitcherTitle *self,
-                                                   gboolean              has_subtitle);
-
 gboolean hdy_view_switcher_title_get_view_switcher_enabled (HdyViewSwitcherTitle *self);
 void     hdy_view_switcher_title_set_view_switcher_enabled (HdyViewSwitcherTitle *self,
                                                             gboolean              enabled);
diff --git a/src/hdy-view-switcher-title.ui b/src/hdy-view-switcher-title.ui
index b8425446..1221462f 100644
--- a/src/hdy-view-switcher-title.ui
+++ b/src/hdy-view-switcher-title.ui
@@ -1,37 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.0"/>
-  <object class="GtkBox" id="title_sizing_box">
-    <property name="orientation">vertical</property>
-    <property name="halign">center</property>
-    <property name="valign">center</property>
-    <property name="visible">True</property>
-    <child>
-      <object class="GtkLabel" id="title_sizing_label">
-        <property name="ellipsize">end</property>
-        <property name="halign">center</property>
-        <property name="wrap">False</property>
-        <property name="single-line-mode">True</property>
-        <property name="visible">True</property>
-        <property name="width-chars">5</property>
-        <style>
-          <class name="title"/>
-        </style>
-      </object>
-    </child>
-    <child>
-      <object class="GtkLabel" id="subtitle_sizing_label">
-        <property name="ellipsize">end</property>
-        <property name="halign">center</property>
-        <property name="wrap">False</property>
-        <property name="single-line-mode">True</property>
-        <property name="visible">True</property>
-        <style>
-          <class name="subtitle"/>
-        </style>
-      </object>
-    </child>
-  </object>
   <template class="HdyViewSwitcherTitle" parent="GtkBin">
     <child>
       <object class="HdySqueezer" id="squeezer">


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