[gtk/tabular-menus: 6/9] combobox: Drop support for grids



commit a5ba0d46c2cc9e35e3f713198a50fe3f67ea55f7
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jan 23 22:52:36 2019 -0500

    combobox: Drop support for grids
    
    This is pretty much unued, and we want to get rid of it.
    
    This removes support for wrap-width, row-span-column
    and column-span-column properties.

 gtk/gtkcombobox.c | 279 ++++--------------------------------------------------
 1 file changed, 20 insertions(+), 259 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index b47ffe50f6..ae71aa48a8 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -116,11 +116,6 @@ typedef struct
 
   GtkCellArea *area;
 
-  gint col_column;
-  gint row_column;
-
-  gint wrap_width;
-
   gint active; /* Only temporary */
   GtkTreeRowReference *active_row;
 
@@ -188,9 +183,6 @@ enum {
 enum {
   PROP_0,
   PROP_MODEL,
-  PROP_WRAP_WIDTH,
-  PROP_ROW_SPAN_COLUMN,
-  PROP_COLUMN_SPAN_COLUMN,
   PROP_ACTIVE,
   PROP_HAS_FRAME,
   PROP_POPUP_SHOWN,
@@ -379,20 +371,17 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
     {
       gint menu_width;
 
-      if (priv->wrap_width == 0)
-        {
-          gtk_widget_set_size_request (priv->popup_widget, -1, -1);
+      gtk_widget_set_size_request (priv->popup_widget, -1, -1);
 
-          if (priv->popup_fixed_width)
-            gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
-                                &menu_width, NULL, NULL, NULL);
-          else
-            gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
-                                NULL, &menu_width, NULL, NULL);
+      if (priv->popup_fixed_width)
+        gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
+                            &menu_width, NULL, NULL, NULL);
+      else
+        gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
+                            NULL, &menu_width, NULL, NULL);
 
-          gtk_widget_set_size_request (priv->popup_widget,
-                                       MAX (width, menu_width), -1);
-        }
+      gtk_widget_set_size_request (priv->popup_widget,
+                                   MAX (width, menu_width), -1);
 
       /* reposition the menu after giving it a new width */
       gtk_menu_reposition (GTK_MENU (priv->popup_widget));
@@ -649,61 +638,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
                                                         GTK_TYPE_TREE_MODEL,
                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
 
-  /**
-   * GtkComboBox:wrap-width:
-   *
-   * If wrap-width is set to a positive value, items in the popup will be laid
-   * out along multiple columns, starting a new row on reaching the wrap width.
-   */
-  g_object_class_install_property (object_class,
-                                   PROP_WRAP_WIDTH,
-                                   g_param_spec_int ("wrap-width",
-                                                     P_("Wrap width"),
-                                                     P_("Wrap width for laying out the items in a grid"),
-                                                     0,
-                                                     G_MAXINT,
-                                                     0,
-                                                     GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
-
-  /**
-   * GtkComboBox:row-span-column:
-   *
-   * If this is set to a non-negative value, it must be the index of a column
-   * of type %G_TYPE_INT in the model. The value in that column for each item
-   * will determine how many rows that item will span in the popup. Therefore,
-   * values in this column must be greater than zero.
-   */
-  g_object_class_install_property (object_class,
-                                   PROP_ROW_SPAN_COLUMN,
-                                   g_param_spec_int ("row-span-column",
-                                                     P_("Row span column"),
-                                                     P_("TreeModel column containing the row span values"),
-                                                     -1,
-                                                     G_MAXINT,
-                                                     -1,
-                                                     GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
-
-  /**
-   * GtkComboBox:column-span-column:
-   *
-   * If this is set to a non-negative value, it must be the index of a column
-   * of type %G_TYPE_INT in the model. The value in that column for each item
-   * will determine how many columns that item will span in the popup.
-   * Therefore, values in this column must be greater than zero, and the sum of
-   * an item’s column position + span should not exceed #GtkComboBox:wrap-width.
-   */
-  g_object_class_install_property (object_class,
-                                   PROP_COLUMN_SPAN_COLUMN,
-                                   g_param_spec_int ("column-span-column",
-                                                     P_("Column span column"),
-                                                     P_("TreeModel column containing the column span 
values"),
-                                                     -1,
-                                                     G_MAXINT,
-                                                     -1,
-                                                     GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
 
   /**
    * GtkComboBox:active:
@@ -902,12 +836,8 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   GtkTreeMenu *menu;
   GtkEventController *controller;
 
-  priv->wrap_width = 0;
-
   priv->active = -1;
   priv->active_row = NULL;
-  priv->col_column = -1;
-  priv->row_column = -1;
 
   priv->popup_shown = FALSE;
   priv->has_frame = TRUE;
@@ -931,9 +861,6 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   gtk_style_context_add_class (context, "combo");
 
   menu = GTK_TREE_MENU (priv->popup_widget);
-  _gtk_tree_menu_set_wrap_width (menu, priv->wrap_width);
-  _gtk_tree_menu_set_row_span_column (menu, priv->row_column);
-  _gtk_tree_menu_set_column_span_column (menu, priv->col_column);
   _gtk_tree_menu_set_row_separator_func (menu,
                                          (GtkTreeViewRowSeparatorFunc)gtk_combo_box_row_separator_func,
                                          combo_box, NULL);
@@ -964,18 +891,6 @@ gtk_combo_box_set_property (GObject      *object,
       gtk_combo_box_set_model (combo_box, g_value_get_object (value));
       break;
 
-    case PROP_WRAP_WIDTH:
-      gtk_combo_box_set_wrap_width (combo_box, g_value_get_int (value));
-      break;
-
-    case PROP_ROW_SPAN_COLUMN:
-      gtk_combo_box_set_row_span_column (combo_box, g_value_get_int (value));
-      break;
-
-    case PROP_COLUMN_SPAN_COLUMN:
-      gtk_combo_box_set_column_span_column (combo_box, g_value_get_int (value));
-      break;
-
     case PROP_ACTIVE:
       gtk_combo_box_set_active (combo_box, g_value_get_int (value));
       break;
@@ -1053,18 +968,6 @@ gtk_combo_box_get_property (GObject    *object,
         g_value_set_object (value, priv->model);
         break;
 
-      case PROP_WRAP_WIDTH:
-        g_value_set_int (value, priv->wrap_width);
-        break;
-
-      case PROP_ROW_SPAN_COLUMN:
-        g_value_set_int (value, priv->row_column);
-        break;
-
-      case PROP_COLUMN_SPAN_COLUMN:
-        g_value_set_int (value, priv->col_column);
-        break;
-
       case PROP_ACTIVE:
         g_value_set_int (value, gtk_combo_box_get_active (combo_box));
         break;
@@ -1357,6 +1260,7 @@ gtk_combo_box_menu_popup (GtkComboBox    *combo_box)
   GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
   gint active_item;
   GtkWidget *active;
+  int width, min_width, nat_width;
 
   update_menu_sensitivity (combo_box, priv->popup_widget);
 
@@ -1373,22 +1277,17 @@ gtk_combo_box_menu_popup (GtkComboBox    *combo_box)
   /* FIXME handle nested menus better */
   gtk_menu_set_active (GTK_MENU (priv->popup_widget), active_item);
 
-  if (priv->wrap_width == 0)
-    {
-      int width, min_width, nat_width;
-
-      width = gtk_widget_get_width (GTK_WIDGET (combo_box));
-      gtk_widget_set_size_request (priv->popup_widget, -1, -1);
-      gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
-                          &min_width, &nat_width, NULL, NULL);
+  width = gtk_widget_get_width (GTK_WIDGET (combo_box));
+  gtk_widget_set_size_request (priv->popup_widget, -1, -1);
+  gtk_widget_measure (priv->popup_widget, GTK_ORIENTATION_HORIZONTAL, -1,
+                      &min_width, &nat_width, NULL, NULL);
 
-      if (priv->popup_fixed_width)
-        width = MAX (width, min_width);
-      else
-        width = MAX (width, nat_width);
+  if (priv->popup_fixed_width)
+    width = MAX (width, min_width);
+  else
+    width = MAX (width, nat_width);
 
-      gtk_widget_set_size_request (priv->popup_widget, width, -1);
-    }
+  gtk_widget_set_size_request (priv->popup_widget, width, -1);
 
   g_signal_handlers_disconnect_by_func (priv->popup_widget,
                                         gtk_menu_update_scroll_offset,
@@ -1396,7 +1295,7 @@ gtk_combo_box_menu_popup (GtkComboBox    *combo_box)
 
   g_object_set (priv->popup_widget, "menu-type-hint", GDK_SURFACE_TYPE_HINT_COMBO, NULL);
 
-  if (priv->wrap_width > 0 || priv->cell_view == NULL)
+  if (priv->cell_view == NULL)
     {
       g_object_set (priv->popup_widget,
                     "anchor-hints", (GDK_ANCHOR_FLIP_Y |
@@ -2042,144 +1941,6 @@ gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model)
                        NULL);
 }
 
-/**
- * gtk_combo_box_get_wrap_width:
- * @combo_box: A #GtkComboBox
- *
- * Returns the wrap width which is used to determine the number of columns
- * for the popup menu. If the wrap width is larger than 1, the combo box
- * is in table mode.
- *
- * Returns: the wrap width.
- */
-gint
-gtk_combo_box_get_wrap_width (GtkComboBox *combo_box)
-{
-  GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
-
-  return priv->wrap_width;
-}
-
-/**
- * gtk_combo_box_set_wrap_width:
- * @combo_box: A #GtkComboBox
- * @width: Preferred number of columns
- *
- * Sets the wrap width of @combo_box to be @width. The wrap width is basically
- * the preferred number of columns when you want the popup to be layed out
- * in a table.
- */
-void
-gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
-                              gint         width)
-{
-  GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (width >= 0);
-
-  if (width != priv->wrap_width)
-    {
-      priv->wrap_width = width;
-      _gtk_tree_menu_set_wrap_width (GTK_TREE_MENU (priv->popup_widget), priv->wrap_width);
-      g_object_notify (G_OBJECT (combo_box), "wrap-width");
-    }
-}
-
-/**
- * gtk_combo_box_get_row_span_column:
- * @combo_box: A #GtkComboBox
- *
- * Returns the column with row span information for @combo_box.
- *
- * Returns: the row span column.
- */
-gint
-gtk_combo_box_get_row_span_column (GtkComboBox *combo_box)
-{
-  GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
-
-  return priv->row_column;
-}
-
-/**
- * gtk_combo_box_set_row_span_column:
- * @combo_box: A #GtkComboBox.
- * @row_span: A column in the model passed during construction.
- *
- * Sets the column with row span information for @combo_box to be @row_span.
- * The row span column contains integers which indicate how many rows
- * an item should span.
- */
-void
-gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
-                                   gint         row_span)
-{
-  GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
-  gint col;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-
-  col = gtk_tree_model_get_n_columns (priv->model);
-  g_return_if_fail (row_span >= -1 && row_span < col);
-
-  if (row_span != priv->row_column)
-    {
-      priv->row_column = row_span;
-      _gtk_tree_menu_set_row_span_column (GTK_TREE_MENU (priv->popup_widget), priv->row_column);
-      g_object_notify (G_OBJECT (combo_box), "row-span-column");
-    }
-}
-
-/**
- * gtk_combo_box_get_column_span_column:
- * @combo_box: A #GtkComboBox
- *
- * Returns the column with column span information for @combo_box.
- *
- * Returns: the column span column.
- */
-gint
-gtk_combo_box_get_column_span_column (GtkComboBox *combo_box)
-{
-  GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
-
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), -1);
-
-  return priv->col_column;
-}
-
-/**
- * gtk_combo_box_set_column_span_column:
- * @combo_box: A #GtkComboBox
- * @column_span: A column in the model passed during construction
- *
- * Sets the column with column span information for @combo_box to be
- * @column_span. The column span column contains integers which indicate
- * how many columns an item should span.
- */
-void
-gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
-                                      gint         column_span)
-{
-  GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
-  gint col;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-
-  col = gtk_tree_model_get_n_columns (priv->model);
-  g_return_if_fail (column_span >= -1 && column_span < col);
-
-  if (column_span != priv->col_column)
-    {
-      priv->col_column = column_span;
-      _gtk_tree_menu_set_column_span_column (GTK_TREE_MENU (priv->popup_widget), priv->col_column);
-      g_object_notify (G_OBJECT (combo_box), "column-span-column");
-    }
-}
-
 /**
  * gtk_combo_box_get_active:
  * @combo_box: A #GtkComboBox


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