[gnome-builder/wip/gtk4-port] libide/gui: add grid column helpers



commit da592ac8f3db86a4a8073f744eb0fb90826aee4b
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 13 21:56:47 2022 -0700

    libide/gui: add grid column helpers

 src/libide/editor/ide-editor-workspace.c |  8 ++++++++
 src/libide/gui/ide-frame.c               | 10 ----------
 src/libide/gui/ide-primary-workspace.c   |  8 ++++++++
 src/libide/gui/ide-workspace.c           | 16 ++++++++++++++--
 src/libide/gui/ide-workspace.h           |  5 +++++
 5 files changed, 35 insertions(+), 12 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-workspace.c b/src/libide/editor/ide-editor-workspace.c
index d12edb5a8..d39dcda0f 100644
--- a/src/libide/editor/ide-editor-workspace.c
+++ b/src/libide/editor/ide-editor-workspace.c
@@ -139,6 +139,13 @@ ide_editor_workspace_add_pane (IdeWorkspace     *workspace,
                              self->grid);
 }
 
+static void
+ide_editor_workspace_add_grid_column (IdeWorkspace *workspace,
+                                      guint         position)
+{
+  panel_grid_insert_column (PANEL_GRID (IDE_EDITOR_WORKSPACE (workspace)->grid), position);
+}
+
 static IdeFrame *
 ide_editor_workspace_get_most_recent_frame (IdeWorkspace *workspace)
 {
@@ -204,6 +211,7 @@ ide_editor_workspace_class_init (IdeEditorWorkspaceClass *klass)
 
   workspace_class->add_page = ide_editor_workspace_add_page;
   workspace_class->add_pane = ide_editor_workspace_add_pane;
+  workspace_class->add_grid_column = ide_editor_workspace_add_grid_column;
   workspace_class->can_search = ide_editor_workspace_can_search;
   workspace_class->context_set = ide_editor_workspace_context_set;
   workspace_class->get_frame_at_position = ide_editor_workspace_get_frame_at_position;
diff --git a/src/libide/gui/ide-frame.c b/src/libide/gui/ide-frame.c
index 48ea1950d..9ac1f93e4 100644
--- a/src/libide/gui/ide-frame.c
+++ b/src/libide/gui/ide-frame.c
@@ -88,16 +88,6 @@ ide_frame_notify_visible_child (IdeFrame   *self,
 
   g_assert (IDE_IS_FRAME (self));
 
-#if 0
-  /* FIXME: We can probably this differently in GTK 4
-   *
-   * Mux/Proxy actions to our level so that they also be activated
-   * from the header bar without any weirdness by the View.
-   */
-  dzl_gtk_widget_mux_action_groups (GTK_WIDGET (self), visible_child,
-                                    "IDE_FRAME_MUXED_ACTION");
-#endif
-
   visible_child = panel_frame_get_visible_child (PANEL_FRAME (self));
 
   if (self->addins != NULL)
diff --git a/src/libide/gui/ide-primary-workspace.c b/src/libide/gui/ide-primary-workspace.c
index 48fc5e071..ab4f63d17 100644
--- a/src/libide/gui/ide-primary-workspace.c
+++ b/src/libide/gui/ide-primary-workspace.c
@@ -124,6 +124,13 @@ ide_primary_workspace_add_pane (IdeWorkspace     *workspace,
                              self->grid);
 }
 
+static void
+ide_primary_workspace_add_grid_column (IdeWorkspace *workspace,
+                                       guint         position)
+{
+  panel_grid_insert_column (PANEL_GRID (IDE_PRIMARY_WORKSPACE (workspace)->grid), position);
+}
+
 static void
 ide_primary_workspace_add_overlay (IdeWorkspace *workspace,
                                    GtkWidget    *overlay)
@@ -212,6 +219,7 @@ ide_primary_workspace_class_init (IdePrimaryWorkspaceClass *klass)
   workspace_class->add_page = ide_primary_workspace_add_page;
   workspace_class->add_pane = ide_primary_workspace_add_pane;
   workspace_class->add_overlay = ide_primary_workspace_add_overlay;
+  workspace_class->add_grid_column = ide_primary_workspace_add_grid_column;
   workspace_class->remove_overlay = ide_primary_workspace_remove_overlay;
   workspace_class->can_search = ide_primary_workspace_can_search;
   workspace_class->context_set = ide_primary_workspace_context_set;
diff --git a/src/libide/gui/ide-workspace.c b/src/libide/gui/ide-workspace.c
index 28f739091..14fa2ecea 100644
--- a/src/libide/gui/ide-workspace.c
+++ b/src/libide/gui/ide-workspace.c
@@ -1208,12 +1208,14 @@ _ide_workspace_find_frame (IdeWorkspace     *self,
 
   if (edge == PANEL_DOCK_POSITION_CENTER)
     {
+      gboolean has_column = ide_panel_position_get_column (position, &column);
+      gboolean has_row = ide_panel_position_get_row (position, &row);
+
       /* If we are adding a page, and no row or column is set, then the next
        * best thing to do is to try to find an open frame. If we can't do that
        * then we'll try to find the most recent frame.
        */
-      if (!ide_panel_position_get_column (position, &column) &&
-          !ide_panel_position_get_row (position, &row))
+      if (!has_column && !has_row)
         {
           if (!find_open_frame (grid, &column, &row))
             find_most_recent_frame (self, grid, &column, &row);
@@ -1382,3 +1384,13 @@ _ide_workspace_set_shortcut_model (IdeWorkspace *self,
 
   ide_workspace_attach_shortcuts (self, GTK_WIDGET (self));
 }
+
+void
+ide_workspace_add_grid_column (IdeWorkspace *self,
+                               guint         position)
+{
+  g_return_if_fail (IDE_IS_WORKSPACE (self));
+  g_return_if_fail (IDE_WORKSPACE_GET_CLASS (self)->add_grid_column);
+
+  IDE_WORKSPACE_GET_CLASS (self)->add_grid_column (self, position);
+}
diff --git a/src/libide/gui/ide-workspace.h b/src/libide/gui/ide-workspace.h
index 07631e72f..8c27a2d4a 100644
--- a/src/libide/gui/ide-workspace.h
+++ b/src/libide/gui/ide-workspace.h
@@ -75,6 +75,8 @@ struct _IdeWorkspaceClass
   void          (*add_page)              (IdeWorkspace         *self,
                                           IdePage              *page,
                                           IdePanelPosition     *position);
+  void          (*add_grid_column)       (IdeWorkspace         *self,
+                                          guint                 column);
   void          (*add_overlay)           (IdeWorkspace         *self,
                                           GtkWidget            *overlay);
   void          (*remove_overlay)        (IdeWorkspace         *self,
@@ -119,6 +121,9 @@ void            ide_workspace_add_page                 (IdeWorkspace      *self,
                                                         IdePage           *page,
                                                         IdePanelPosition  *position);
 IDE_AVAILABLE_IN_ALL
+void            ide_workspace_add_grid_column          (IdeWorkspace      *self,
+                                                        guint              position);
+IDE_AVAILABLE_IN_ALL
 PanelStatusbar *ide_workspace_get_statusbar            (IdeWorkspace      *self);
 IDE_AVAILABLE_IN_ALL
 void            ide_workspace_add_overlay              (IdeWorkspace      *self,


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