[gnome-builder/wip/gtk4-port: 747/1774] plugins/buildui: Port GbpBuilduiWorkspaceAddin to GTK4
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 747/1774] plugins/buildui: Port GbpBuilduiWorkspaceAddin to GTK4
- Date: Mon, 11 Jul 2022 22:31:22 +0000 (UTC)
commit 85b353ab3e0c9a7f0b5056d6e31ad8517f4587b7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Apr 26 19:34:15 2022 -0300
plugins/buildui: Port GbpBuilduiWorkspaceAddin to GTK4
This introduces some changes in how the buildui workspace addin
works. The build and cancel buttons were removed in favour of
PanelOmniBar's 'icon-name' and 'action-name' properties. The
omnibar itself is fetched directly from IdePrimaryWorkspace,
using the getter introduced by the previous commit.
src/plugins/buildui/buildui-plugin.c | 4 +-
src/plugins/buildui/gbp-buildui-workspace-addin.c | 138 ++++++++--------------
src/plugins/buildui/meson.build | 2 +-
3 files changed, 52 insertions(+), 92 deletions(-)
---
diff --git a/src/plugins/buildui/buildui-plugin.c b/src/plugins/buildui/buildui-plugin.c
index 8ab3f9a9e..9451ee228 100644
--- a/src/plugins/buildui/buildui-plugin.c
+++ b/src/plugins/buildui/buildui-plugin.c
@@ -29,7 +29,7 @@
//#include "gbp-buildui-config-view-addin.h"
//#include "gbp-buildui-editor-page-addin.h"
-//#include "gbp-buildui-workspace-addin.h"
+#include "gbp-buildui-workspace-addin.h"
//#include "gbp-buildui-tree-addin.h"
_IDE_EXTERN void
@@ -42,9 +42,11 @@ _gbp_buildui_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_EDITOR_PAGE_ADDIN,
GBP_TYPE_BUILDUI_EDITOR_PAGE_ADDIN);
+#endif
peas_object_module_register_extension_type (module,
IDE_TYPE_WORKSPACE_ADDIN,
GBP_TYPE_BUILDUI_WORKSPACE_ADDIN);
+#if 0
peas_object_module_register_extension_type (module,
IDE_TYPE_TREE_ADDIN,
GBP_TYPE_BUILDUI_TREE_ADDIN);
diff --git a/src/plugins/buildui/gbp-buildui-workspace-addin.c
b/src/plugins/buildui/gbp-buildui-workspace-addin.c
index de83125e1..c792bc924 100644
--- a/src/plugins/buildui/gbp-buildui-workspace-addin.c
+++ b/src/plugins/buildui/gbp-buildui-workspace-addin.c
@@ -22,7 +22,6 @@
#include "config.h"
-#include <dazzle.h>
#include <glib/gi18n.h>
#include <libide-editor.h>
#include <libide-foundry.h>
@@ -53,11 +52,9 @@ struct _GbpBuilduiWorkspaceAddin
GtkLabel *error_label;
GtkImage *warning_image;
GtkLabel *warning_label;
- GtkButton *build_button;
- GtkButton *cancel_button;
/* Owned references */
- DzlSignalGroup *build_manager_signals;
+ IdeSignalGroup *build_manager_signals;
};
static void
@@ -86,7 +83,7 @@ gbp_buildui_workspace_addin_notify_error_count (GbpBuilduiWorkspaceAddin *self,
gtk_widget_set_visible (GTK_WIDGET (self->error_image), TRUE);
if (count > 0)
- dzl_dock_item_needs_attention (DZL_DOCK_ITEM (self->pane));
+ panel_widget_set_needs_attention (PANEL_WIDGET (self->pane), TRUE);
}
static void
@@ -115,7 +112,7 @@ gbp_buildui_workspace_addin_notify_warning_count (GbpBuilduiWorkspaceAddin *self
gtk_widget_set_visible (GTK_WIDGET (self->warning_image), TRUE);
if (count > 0)
- dzl_dock_item_needs_attention (DZL_DOCK_ITEM (self->pane));
+ panel_widget_set_needs_attention (PANEL_WIDGET (self->pane), TRUE);
}
static void
@@ -139,27 +136,32 @@ gbp_buildui_workspace_addin_notify_busy (GbpBuilduiWorkspaceAddin *self,
GParamSpec *pspec,
IdeBuildManager *build_manager)
{
+ IdeOmniBar *omni_bar;
gboolean busy;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_BUILDUI_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_BUILD_MANAGER (build_manager));
+ g_assert (IDE_IS_PRIMARY_WORKSPACE (self->workspace));
+ omni_bar = ide_primary_workspace_get_omni_bar (IDE_PRIMARY_WORKSPACE (self->workspace));
busy = ide_build_manager_get_busy (build_manager);
- gtk_widget_set_visible (GTK_WIDGET (self->build_button), !busy);
- gtk_widget_set_visible (GTK_WIDGET (self->cancel_button), busy);
+ g_object_set (omni_bar,
+ "icon-name", busy ? "builder-build-stop-symbolic" : "builder-build-symbolic",
+ "action-name", busy ? "build-manager.cancel" : "build-manager.build",
+ NULL);
}
static void
gbp_buildui_workspace_addin_bind_build_manager (GbpBuilduiWorkspaceAddin *self,
IdeBuildManager *build_manager,
- DzlSignalGroup *signals)
+ IdeSignalGroup *signals)
{
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_BUILDUI_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_BUILD_MANAGER (build_manager));
- g_assert (DZL_IS_SIGNAL_GROUP (signals));
+ g_assert (IDE_IS_SIGNAL_GROUP (signals));
gbp_buildui_workspace_addin_notify_busy (self, NULL, build_manager);
gbp_buildui_workspace_addin_notify_pipeline (self, NULL, build_manager);
@@ -178,7 +180,8 @@ on_view_output_cb (GSimpleAction *action,
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (GBP_IS_BUILDUI_WORKSPACE_ADDIN (self));
- ide_widget_reveal_and_grab (GTK_WIDGET (self->log_pane));
+ panel_widget_raise (PANEL_WIDGET (self->log_pane));
+ gtk_widget_grab_focus (GTK_WIDGET (self->log_pane));
}
#if 0 /* TODO: port GbpBuilduiConfigSurface */
@@ -240,7 +243,7 @@ gbp_buildui_workspace_addin_build_started (GbpBuilduiWorkspaceAddin *self,
gbp_buildui_log_pane_clear (self->log_pane);
if (phase > IDE_PIPELINE_PHASE_CONFIGURE)
- dzl_dock_item_present (DZL_DOCK_ITEM (self->log_pane));
+ panel_widget_raise (PANEL_WIDGET (self->log_pane));
IDE_EXIT;
}
@@ -253,16 +256,13 @@ gbp_buildui_workspace_addin_load (IdeWorkspaceAddin *addin,
#if 0 /* TODO: port GbpBuilduiConfigSurface */
IdeConfigManager *config_manager;
#endif
+ g_autoptr(IdePanelPosition) pane_position = NULL;
+ g_autoptr(IdePanelPosition) log_position = NULL;
PangoAttrList *small_attrs = NULL;
- DzlShortcutController *shortcuts;
- IdeEditorSidebar *sidebar;
IdeBuildManager *build_manager;
IdeWorkbench *workbench;
- IdeHeaderBar *headerbar;
- IdeSurface *surface;
IdeOmniBar *omnibar;
IdeContext *context;
- GtkWidget *utilities;
g_assert (GBP_IS_BUILDUI_WORKSPACE_ADDIN (self));
g_assert (IDE_IS_PRIMARY_WORKSPACE (workspace));
@@ -274,20 +274,7 @@ gbp_buildui_workspace_addin_load (IdeWorkspaceAddin *addin,
G_N_ELEMENTS (actions),
self);
- shortcuts = dzl_shortcut_controller_find (GTK_WIDGET (workspace));
- dzl_shortcut_controller_add_command_action (shortcuts,
- "org.gnome.builder.buildui.build",
- "<Control>F7",
- DZL_SHORTCUT_PHASE_GLOBAL | DZL_SHORTCUT_PHASE_CAPTURE,
- "build-manager.build");
- dzl_shortcut_controller_add_command_action (shortcuts,
- "org.gnome.builder.buildui.rebuild",
- "<Control><Shift>F7",
- DZL_SHORTCUT_PHASE_GLOBAL | DZL_SHORTCUT_PHASE_CAPTURE,
- "build-manager.rebuild");
-
- headerbar = ide_workspace_get_header_bar (workspace);
- omnibar = IDE_OMNI_BAR (hdy_header_bar_get_custom_title (HDY_HEADER_BAR (headerbar)));
+ omnibar = ide_primary_workspace_get_omni_bar (IDE_PRIMARY_WORKSPACE (workspace));
workbench = ide_widget_get_workbench (GTK_WIDGET (workspace));
context = ide_workbench_get_context (workbench);
build_manager = ide_build_manager_from_context (context);
@@ -300,7 +287,6 @@ gbp_buildui_workspace_addin_load (IdeWorkspaceAddin *addin,
self->diag_box = g_object_new (GTK_TYPE_BOX,
"orientation", GTK_ORIENTATION_HORIZONTAL,
- "visible", TRUE,
NULL);
g_signal_connect (self->diag_box,
"destroy",
@@ -314,16 +300,18 @@ gbp_buildui_workspace_addin_load (IdeWorkspaceAddin *addin,
"margin-start", 4,
"pixel-size", 12,
"valign", GTK_ALIGN_BASELINE,
+ "visible", FALSE,
NULL);
- gtk_container_add (GTK_CONTAINER (self->diag_box), GTK_WIDGET (self->error_image));
+ gtk_box_append (self->diag_box, GTK_WIDGET (self->error_image));
self->error_label = g_object_new (GTK_TYPE_LABEL,
"attributes", small_attrs,
"margin-end", 2,
"margin-start", 2,
"valign", GTK_ALIGN_BASELINE,
+ "visible", FALSE,
NULL);
- gtk_container_add (GTK_CONTAINER (self->diag_box), GTK_WIDGET (self->error_label));
+ gtk_box_append (self->diag_box, GTK_WIDGET (self->error_label));
self->warning_image = g_object_new (GTK_TYPE_IMAGE,
"icon-name", "dialog-warning-symbolic",
@@ -331,22 +319,22 @@ gbp_buildui_workspace_addin_load (IdeWorkspaceAddin *addin,
"margin-start", 4,
"pixel-size", 12,
"valign", GTK_ALIGN_BASELINE,
+ "visible", FALSE,
NULL);
- gtk_container_add (GTK_CONTAINER (self->diag_box), GTK_WIDGET (self->warning_image));
+ gtk_box_append (self->diag_box, GTK_WIDGET (self->warning_image));
self->warning_label = g_object_new (GTK_TYPE_LABEL,
"attributes", small_attrs,
"margin-end", 2,
"margin-start", 2,
"valign", GTK_ALIGN_BASELINE,
+ "visible", FALSE,
NULL);
- gtk_container_add (GTK_CONTAINER (self->diag_box), GTK_WIDGET (self->warning_label));
+ gtk_box_append (self->diag_box, GTK_WIDGET (self->warning_label));
g_clear_pointer (&small_attrs, pango_attr_list_unref);
- self->omni_bar_section = g_object_new (GBP_TYPE_BUILDUI_OMNI_BAR_SECTION,
- "visible", TRUE,
- NULL);
+ self->omni_bar_section = g_object_new (GBP_TYPE_BUILDUI_OMNI_BAR_SECTION, NULL);
g_signal_connect (self->omni_bar_section,
"destroy",
G_CALLBACK (ide_gtk_widget_destroyed),
@@ -354,49 +342,19 @@ gbp_buildui_workspace_addin_load (IdeWorkspaceAddin *addin,
ide_omni_bar_add_popover_section (omnibar, GTK_WIDGET (self->omni_bar_section), 0);
gbp_buildui_omni_bar_section_set_context (self->omni_bar_section, context);
- self->build_button = g_object_new (GTK_TYPE_BUTTON,
- "action-name", "build-manager.build",
- "child", g_object_new (GTK_TYPE_IMAGE,
- "icon-name", "builder-build-symbolic",
- "visible", TRUE,
- NULL),
- "focus-on-click", FALSE,
- "has-tooltip", TRUE,
- "visible", TRUE,
- NULL);
- ide_omni_bar_add_button (omnibar, GTK_WIDGET (self->build_button), GTK_PACK_END, 0);
-
- self->cancel_button = g_object_new (GTK_TYPE_BUTTON,
- "action-name", "build-manager.cancel",
- "child", g_object_new (GTK_TYPE_IMAGE,
- "icon-name", "builder-build-stop-symbolic",
- "visible", TRUE,
- NULL),
- "focus-on-click", FALSE,
- "has-tooltip", TRUE,
- "visible", TRUE,
- NULL);
- ide_omni_bar_add_button (omnibar, GTK_WIDGET (self->cancel_button), GTK_PACK_END, 0);
+ log_position = ide_panel_position_new ();
+ ide_panel_position_set_edge (log_position, PANEL_DOCK_POSITION_BOTTOM);
+ ide_panel_position_set_depth (log_position, 2);
- surface = ide_workspace_get_surface_by_name (workspace, "editor");
- utilities = ide_editor_surface_get_utilities (IDE_EDITOR_SURFACE (surface));
- sidebar = ide_editor_surface_get_sidebar (IDE_EDITOR_SURFACE (surface));
+ self->log_pane = g_object_new (GBP_TYPE_BUILDUI_LOG_PANE, NULL);
+ ide_workspace_add_pane (workspace, IDE_PANE (self->log_pane), log_position);
- self->log_pane = g_object_new (GBP_TYPE_BUILDUI_LOG_PANE,
- "visible", TRUE,
- NULL);
- gtk_container_add (GTK_CONTAINER (utilities), GTK_WIDGET (self->log_pane));
-
- self->pane = g_object_new (GBP_TYPE_BUILDUI_PANE,
- "visible", TRUE,
- NULL);
- ide_editor_sidebar_add_section (sidebar,
- "build-issues",
- _("Build Issues"),
- "builder-build-issues-symbolic",
- NULL, NULL,
- GTK_WIDGET (self->pane),
- 100);
+ pane_position = ide_panel_position_new ();
+ ide_panel_position_set_edge (pane_position, PANEL_DOCK_POSITION_START);
+ ide_panel_position_set_depth (pane_position, 2);
+
+ self->pane = g_object_new (GBP_TYPE_BUILDUI_PANE, NULL);
+ ide_workspace_add_pane (workspace, IDE_PANE (self->pane), pane_position);
#if 0 /* TODO: port GbpBuilduiConfigSurface */
self->surface = g_object_new (GBP_TYPE_BUILDUI_CONFIG_SURFACE,
@@ -413,38 +371,38 @@ gbp_buildui_workspace_addin_load (IdeWorkspaceAddin *addin,
ide_workspace_add_surface (workspace, IDE_SURFACE (self->surface));
#endif
- self->build_manager_signals = dzl_signal_group_new (IDE_TYPE_BUILD_MANAGER);
+ self->build_manager_signals = ide_signal_group_new (IDE_TYPE_BUILD_MANAGER);
g_signal_connect_object (self->build_manager_signals,
"bind",
G_CALLBACK (gbp_buildui_workspace_addin_bind_build_manager),
self,
G_CONNECT_SWAPPED);
- dzl_signal_group_connect_object (self->build_manager_signals,
+ ide_signal_group_connect_object (self->build_manager_signals,
"notify::error-count",
G_CALLBACK (gbp_buildui_workspace_addin_notify_error_count),
self,
G_CONNECT_SWAPPED);
- dzl_signal_group_connect_object (self->build_manager_signals,
+ ide_signal_group_connect_object (self->build_manager_signals,
"notify::warning-count",
G_CALLBACK (gbp_buildui_workspace_addin_notify_warning_count),
self,
G_CONNECT_SWAPPED);
- dzl_signal_group_connect_object (self->build_manager_signals,
+ ide_signal_group_connect_object (self->build_manager_signals,
"notify::pipeline",
G_CALLBACK (gbp_buildui_workspace_addin_notify_pipeline),
self,
G_CONNECT_SWAPPED);
- dzl_signal_group_connect_object (self->build_manager_signals,
+ ide_signal_group_connect_object (self->build_manager_signals,
"notify::busy",
G_CALLBACK (gbp_buildui_workspace_addin_notify_busy),
self,
G_CONNECT_SWAPPED);
- dzl_signal_group_connect_object (self->build_manager_signals,
+ ide_signal_group_connect_object (self->build_manager_signals,
"build-started",
G_CALLBACK (gbp_buildui_workspace_addin_build_started),
self,
G_CONNECT_SWAPPED);
- dzl_signal_group_set_target (self->build_manager_signals, build_manager);
+ ide_signal_group_set_target (self->build_manager_signals, build_manager);
}
static void
@@ -460,17 +418,17 @@ gbp_buildui_workspace_addin_unload (IdeWorkspaceAddin *addin,
g_action_map_remove_action (G_ACTION_MAP (workspace), actions[i].name);
if (self->omni_bar_section)
- gtk_widget_destroy (GTK_WIDGET (self->omni_bar_section));
+ gtk_widget_unparent (GTK_WIDGET (self->omni_bar_section));
if (self->diag_box)
- gtk_widget_destroy (GTK_WIDGET (self->diag_box));
+ gtk_widget_unparent (GTK_WIDGET (self->diag_box));
#if 0 /* TODO: port GbpBuilduiConfigSurface */
if (self->surface)
gtk_widget_destroy (GTK_WIDGET (self->surface));
#endif
- dzl_signal_group_set_target (self->build_manager_signals, NULL);
+ ide_signal_group_set_target (self->build_manager_signals, NULL);
g_clear_object (&self->build_manager_signals);
self->workspace = NULL;
diff --git a/src/plugins/buildui/meson.build b/src/plugins/buildui/meson.build
index 97cdae194..d3491335a 100644
--- a/src/plugins/buildui/meson.build
+++ b/src/plugins/buildui/meson.build
@@ -10,7 +10,7 @@ plugins_sources += files([
#'gbp-buildui-runtime-row.c',
'gbp-buildui-stage-row.c',
#'gbp-buildui-tree-addin.c',
- #'gbp-buildui-workspace-addin.c',
+ 'gbp-buildui-workspace-addin.c',
])
plugin_buildui_resources = gnome.compile_resources(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]