[gnome-builder/wip/gtk4-port: 284/343] plugins/todo: port todo plugin to GTK 4
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 284/343] plugins/todo: port todo plugin to GTK 4
- Date: Mon, 4 Apr 2022 20:02:17 +0000 (UTC)
commit 60e9edcbfaf84a94e927ea7aaf6977ceabd57d80
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 1 02:20:41 2022 -0700
plugins/todo: port todo plugin to GTK 4
Also requires new presented signal from libpanel.
src/plugins/todo/gbp-todo-model.c | 11 ++++----
src/plugins/todo/gbp-todo-panel.c | 41 ++++++++++-------------------
src/plugins/todo/gbp-todo-panel.h | 4 +--
src/plugins/todo/gbp-todo-workspace-addin.c | 31 +++++++---------------
src/plugins/todo/todo.plugin | 1 -
5 files changed, 32 insertions(+), 56 deletions(-)
---
diff --git a/src/plugins/todo/gbp-todo-model.c b/src/plugins/todo/gbp-todo-model.c
index e6ca73572..14ff04f97 100644
--- a/src/plugins/todo/gbp-todo-model.c
+++ b/src/plugins/todo/gbp-todo-model.c
@@ -20,9 +20,10 @@
#define G_LOG_DOMAIN "gbp-todo-model"
+#include <string.h>
+
#include <libide-code.h>
#include <libide-gui.h>
-#include <string.h>
#include "gbp-todo-model.h"
#include "gbp-todo-item.h"
@@ -502,7 +503,7 @@ gbp_todo_model_mine_worker (IdeTask *task,
continue;
}
- if (dzl_str_empty0 (line) || len > 256)
+ if (ide_str_empty0 (line) || len > 256)
{
/* cancel anything if the line is too long so that we don't get into
* pathological cases.
@@ -607,9 +608,9 @@ gbp_todo_model_mine_worker (IdeTask *task,
info->self = g_object_ref (source_object);
info->items = g_steal_pointer (&items);
- gdk_threads_add_idle_full (G_PRIORITY_LOW + 100,
- gbp_todo_model_merge_results,
- info, result_info_free);
+ g_idle_add_full (G_PRIORITY_LOW + 100,
+ gbp_todo_model_merge_results,
+ info, result_info_free);
ide_task_return_boolean (task, TRUE);
}
diff --git a/src/plugins/todo/gbp-todo-panel.c b/src/plugins/todo/gbp-todo-panel.c
index 1e33966b5..10ef01689 100644
--- a/src/plugins/todo/gbp-todo-panel.c
+++ b/src/plugins/todo/gbp-todo-panel.c
@@ -21,6 +21,7 @@
#define G_LOG_DOMAIN "gbp-todo-panel"
#include <glib/gi18n.h>
+
#include <libide-code.h>
#include <libide-gui.h>
@@ -29,7 +30,7 @@
struct _GbpTodoPanel
{
- DzlDockWidget parent_instance;
+ IdePane parent_instance;
GbpTodoModel *model;
@@ -37,7 +38,7 @@ struct _GbpTodoPanel
GtkStack *stack;
};
-G_DEFINE_FINAL_TYPE (GbpTodoPanel, gbp_todo_panel, DZL_TYPE_DOCK_WIDGET)
+G_DEFINE_FINAL_TYPE (GbpTodoPanel, gbp_todo_panel, IDE_TYPE_PANE)
enum {
PROP_0,
@@ -207,9 +208,9 @@ gbp_todo_panel_query_tooltip (GbpTodoPanel *self,
}
static void
-gbp_todo_panel_destroy (GtkWidget *widget)
+gbp_todo_panel_dispose (GObject *object)
{
- GbpTodoPanel *self = (GbpTodoPanel *)widget;
+ GbpTodoPanel *self = (GbpTodoPanel *)object;
g_assert (GBP_IS_TODO_PANEL (self));
@@ -218,7 +219,7 @@ gbp_todo_panel_destroy (GtkWidget *widget)
g_clear_object (&self->model);
- GTK_WIDGET_CLASS (gbp_todo_panel_parent_class)->destroy (widget);
+ G_OBJECT_CLASS (gbp_todo_panel_parent_class)->dispose (object);
}
static void
@@ -263,13 +264,11 @@ static void
gbp_todo_panel_class_init (GbpTodoPanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->dispose = gbp_todo_panel_dispose;
object_class->get_property = gbp_todo_panel_get_property;
object_class->set_property = gbp_todo_panel_set_property;
- widget_class->destroy = gbp_todo_panel_destroy;
-
properties [PROP_MODEL] =
g_param_spec_object ("model",
"Model",
@@ -290,36 +289,24 @@ gbp_todo_panel_init (GbpTodoPanel *self)
self->stack = g_object_new (GTK_TYPE_STACK,
"transition-duration", 333,
"transition-type", GTK_STACK_TRANSITION_TYPE_CROSSFADE,
- "homogeneous", FALSE,
- "visible", TRUE,
NULL);
- gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->stack));
+ panel_widget_set_child (PANEL_WIDGET (self), GTK_WIDGET (self->stack));
- empty = g_object_new (DZL_TYPE_EMPTY_STATE,
+ empty = g_object_new (ADW_TYPE_STATUS_PAGE,
"title", _("Loading TODOs…"),
- "subtitle", _("Please wait while we scan your project"),
+ "description", _("Please wait while we scan your project"),
"icon-name", "builder-todo-symbolic",
- "valign", GTK_ALIGN_START,
- "visible", TRUE,
NULL);
- gtk_container_add (GTK_CONTAINER (self->stack), empty);
+ gtk_stack_add_named (self->stack, empty, "empty");
scroller = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
- "visible", TRUE,
"vexpand", TRUE,
NULL);
- gtk_container_add_with_properties (GTK_CONTAINER (self->stack), scroller,
- "name", "todos",
- NULL);
+ gtk_stack_add_named (self->stack, scroller, "todos");
self->tree_view = g_object_new (IDE_TYPE_FANCY_TREE_VIEW,
"has-tooltip", TRUE,
- "visible", TRUE,
NULL);
- g_signal_connect (self->tree_view,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &self->tree_view);
g_signal_connect_swapped (self->tree_view,
"row-activated",
G_CALLBACK (gbp_todo_panel_row_activated),
@@ -328,8 +315,8 @@ gbp_todo_panel_init (GbpTodoPanel *self)
"query-tooltip",
G_CALLBACK (gbp_todo_panel_query_tooltip),
self);
- dzl_gtk_widget_add_style_class (GTK_WIDGET (self->tree_view), "i-wanna-be-listbox");
- gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET (self->tree_view));
+ gtk_widget_add_css_class (GTK_WIDGET (self->tree_view), "i-wanna-be-listbox");
+ gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroller), GTK_WIDGET (self->tree_view));
selection = gtk_tree_view_get_selection (self->tree_view);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
diff --git a/src/plugins/todo/gbp-todo-panel.h b/src/plugins/todo/gbp-todo-panel.h
index 5da1addce..b670cc2b1 100644
--- a/src/plugins/todo/gbp-todo-panel.h
+++ b/src/plugins/todo/gbp-todo-panel.h
@@ -20,7 +20,7 @@
#pragma once
-#include <dazzle.h>
+#include <libide-gui.h>
#include "gbp-todo-model.h"
@@ -28,7 +28,7 @@ G_BEGIN_DECLS
#define GBP_TYPE_TODO_PANEL (gbp_todo_panel_get_type())
-G_DECLARE_FINAL_TYPE (GbpTodoPanel, gbp_todo_panel, GBP, TODO_PANEL, DzlDockWidget)
+G_DECLARE_FINAL_TYPE (GbpTodoPanel, gbp_todo_panel, GBP, TODO_PANEL, IdePane)
GbpTodoModel *gbp_todo_panel_get_model (GbpTodoPanel *self);
void gbp_todo_panel_set_model (GbpTodoPanel *self,
diff --git a/src/plugins/todo/gbp-todo-workspace-addin.c b/src/plugins/todo/gbp-todo-workspace-addin.c
index 9837476fe..a0e019fd9 100644
--- a/src/plugins/todo/gbp-todo-workspace-addin.c
+++ b/src/plugins/todo/gbp-todo-workspace-addin.c
@@ -20,7 +20,6 @@
#define G_LOG_DOMAIN "gbp-todo-workspace-addin"
-#include <libide-editor.h>
#include <glib/gi18n.h>
#include "gbp-todo-workspace-addin.h"
@@ -110,9 +109,8 @@ gbp_todo_workspace_addin_load (IdeWorkspaceAddin *addin,
IdeWorkspace *workspace)
{
GbpTodoWorkspaceAddin *self = (GbpTodoWorkspaceAddin *)addin;
- IdeEditorSidebar *sidebar;
+ g_autoptr(IdePanelPosition) position = NULL;
IdeBufferManager *bufmgr;
- IdeSurface *editor;
IdeContext *context;
IdeVcs *vcs;
GFile *workdir;
@@ -126,8 +124,6 @@ gbp_todo_workspace_addin_load (IdeWorkspaceAddin *addin,
vcs = ide_vcs_from_context (context);
workdir = ide_vcs_get_workdir (vcs);
bufmgr = ide_buffer_manager_from_context (context);
- editor = ide_workspace_get_surface_by_name (workspace, "editor");
- sidebar = ide_editor_surface_get_sidebar (IDE_EDITOR_SURFACE (editor));
self->workdir = g_object_ref (workdir);
@@ -140,25 +136,21 @@ gbp_todo_workspace_addin_load (IdeWorkspaceAddin *addin,
self->model = gbp_todo_model_new (vcs);
self->panel = g_object_new (GBP_TYPE_TODO_PANEL,
+ "title", _("TODO/FIXMEs"),
+ "icon-name", "builder-todo-symbolic",
"model", self->model,
- "visible", TRUE,
NULL);
g_signal_connect_object (self->panel,
"presented",
G_CALLBACK (gbp_todo_workspace_addin_presented_cb),
self,
G_CONNECT_SWAPPED);
- g_signal_connect (self->panel,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &self->panel);
- ide_editor_sidebar_add_section (sidebar,
- "todo",
- _("TODO/FIXMEs"),
- "builder-todo-symbolic",
- NULL, NULL,
- GTK_WIDGET (self->panel),
- 200);
+
+ position = ide_panel_position_new ();
+ ide_panel_position_set_edge (position, PANEL_DOCK_POSITION_START);
+ ide_panel_position_set_depth (position, 2);
+
+ ide_workspace_add_pane (workspace, IDE_PANE (self->panel), position);
}
static void
@@ -182,10 +174,7 @@ gbp_todo_workspace_addin_unload (IdeWorkspaceAddin *addin,
G_CALLBACK (gbp_todo_workspace_addin_buffer_saved),
self);
- if (self->panel != NULL)
- gtk_widget_destroy (GTK_WIDGET (self->panel));
-
- g_assert (self->panel == NULL);
+ panel_widget_close (PANEL_WIDGET (self->panel));
g_clear_object (&self->model);
g_clear_object (&self->workdir);
diff --git a/src/plugins/todo/todo.plugin b/src/plugins/todo/todo.plugin
index a249e9b6f..73af9097b 100644
--- a/src/plugins/todo/todo.plugin
+++ b/src/plugins/todo/todo.plugin
@@ -2,7 +2,6 @@
Authors=Christian Hergert <christian hergert me>
Builtin=true
Copyright=Copyright © 2015-2018 Christian Hergert
-Depends=editor;
Description=Find and present To-Do items from source code
Embedded=_gbp_todo_register_types
Module=todo
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]