listbase: Privatize 2 functions
authorBenjamin Otte <otte@redhat.com>
Sat, 11 Mar 2023 16:22:36 +0000 (17:22 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 23 Mar 2023 03:45:03 +0000 (04:45 +0100)
They're not used outside of GtkListBase, so no use to have them in the
header.

Requires moving one function up in the source now that the forward
declaration is missing.

gtk/gtklistbase.c
gtk/gtklistbaseprivate.h

index 8bc7271c26e0ec6cbfa5a16dd5966a7ec304dfaf..f786e197613d7389b9b0019f6880361513fa9d98 100644 (file)
@@ -363,7 +363,7 @@ gtk_list_base_get_allocation (GtkListBase  *self,
  * selections, both when clicking rows with the mouse or when using
  * the keyboard.
  **/
-void
+static void
 gtk_list_base_select_item (GtkListBase *self,
                            guint        pos,
                            gboolean     modify,
@@ -441,6 +441,68 @@ gtk_list_base_select_item (GtkListBase *self,
                                       0, 0);
 }
 
+/*
+ * gtk_list_base_grab_focus_on_item:
+ * @self: a `GtkListBase`
+ * @pos: position of the item to focus
+ * @select: %TRUE to select the item
+ * @modify: if selecting, %TRUE to modify the selected
+ *   state, %FALSE to always select
+ * @extend: if selecting, %TRUE to extend the selection,
+ *   %FALSE to only operate on this item
+ *
+ * Tries to grab focus on the given item. If there is no item
+ * at this position or grabbing focus failed, %FALSE will be
+ * returned.
+ *
+ * Returns: %TRUE if focusing the item succeeded
+ **/
+static gboolean
+gtk_list_base_grab_focus_on_item (GtkListBase *self,
+                                  guint        pos,
+                                  gboolean     select,
+                                  gboolean     modify,
+                                  gboolean     extend)
+{
+  GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
+  GtkListTile *tile;
+  gboolean success;
+
+  tile = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
+  if (tile == NULL)
+    return FALSE;
+
+  if (!tile->widget)
+    {
+      GtkListItemTracker *tracker = gtk_list_item_tracker_new (priv->item_manager);
+
+      /* We need a tracker here to create the widget.
+       * That needs to have happened or we can't grab it.
+       * And we can't use a different tracker, because they manage important rows,
+       * so we create a temporary one. */
+      gtk_list_item_tracker_set_position (priv->item_manager, tracker, pos, 0, 0);
+
+      tile = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
+      g_assert (tile->widget);
+
+      success = gtk_widget_grab_focus (tile->widget);
+
+      gtk_list_item_tracker_free (priv->item_manager, tracker);
+    }
+  else
+    {
+      success = gtk_widget_grab_focus (tile->widget);
+    }
+
+  if (!success)
+    return FALSE;
+
+  if (select)
+    gtk_list_base_select_item (self, pos, modify, extend);
+
+  return TRUE;
+}
+
 guint
 gtk_list_base_get_n_items (GtkListBase *self)
 {
@@ -2149,68 +2211,6 @@ gtk_list_base_set_anchor_max_widgets (GtkListBase *self,
                             priv->anchor_side_along);
 }
 
-/*
- * gtk_list_base_grab_focus_on_item:
- * @self: a `GtkListBase`
- * @pos: position of the item to focus
- * @select: %TRUE to select the item
- * @modify: if selecting, %TRUE to modify the selected
- *   state, %FALSE to always select
- * @extend: if selecting, %TRUE to extend the selection,
- *   %FALSE to only operate on this item
- *
- * Tries to grab focus on the given item. If there is no item
- * at this position or grabbing focus failed, %FALSE will be
- * returned.
- *
- * Returns: %TRUE if focusing the item succeeded
- **/
-gboolean
-gtk_list_base_grab_focus_on_item (GtkListBase *self,
-                                  guint        pos,
-                                  gboolean     select,
-                                  gboolean     modify,
-                                  gboolean     extend)
-{
-  GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
-  GtkListTile *tile;
-  gboolean success;
-
-  tile = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
-  if (tile == NULL)
-    return FALSE;
-
-  if (!tile->widget)
-    {
-      GtkListItemTracker *tracker = gtk_list_item_tracker_new (priv->item_manager);
-
-      /* We need a tracker here to create the widget.
-       * That needs to have happened or we can't grab it.
-       * And we can't use a different tracker, because they manage important rows,
-       * so we create a temporary one. */
-      gtk_list_item_tracker_set_position (priv->item_manager, tracker, pos, 0, 0);
-
-      tile = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
-      g_assert (tile->widget);
-
-      success = gtk_widget_grab_focus (tile->widget);
-
-      gtk_list_item_tracker_free (priv->item_manager, tracker);
-    }
-  else
-    {
-      success = gtk_widget_grab_focus (tile->widget);
-    }
-
-  if (!success)
-    return FALSE;
-
-  if (select)
-    gtk_list_base_select_item (self, pos, modify, extend);
-
-  return TRUE;
-}
-
 GtkSelectionModel *
 gtk_list_base_get_model (GtkListBase *self)
 {
index e8ab5b5db791006bd24c53875ca68b40fa8a2e36..c4d436308dbea73b66a1a574a6cc4a945424f267 100644 (file)
@@ -83,15 +83,6 @@ void                   gtk_list_base_set_anchor                 (GtkListBase
 void                   gtk_list_base_set_anchor_max_widgets     (GtkListBase            *self,
                                                                  guint                   n_center,
                                                                  guint                   n_above_below);
-void                   gtk_list_base_select_item                (GtkListBase            *self,
-                                                                 guint                   pos,
-                                                                 gboolean                modify,
-                                                                 gboolean                extend);
-gboolean               gtk_list_base_grab_focus_on_item         (GtkListBase            *self,
-                                                                 guint                   pos,
-                                                                 gboolean                select,
-                                                                 gboolean                modify,
-                                                                 gboolean                extend);
 
 void                   gtk_list_base_set_enable_rubberband      (GtkListBase            *self,
                                                                  gboolean                enable);