[gnome-builder/wip/gtk4-port: 713/1774] plugins/grep: port to GTK 4




commit a11750cc90194125aa98cd9f0520b7f7fc721f87
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 22 17:52:19 2022 -0700

    plugins/grep: port to GTK 4

 src/plugins/grep/gbp-grep-editor-addin.c           | 133 ---------------------
 src/plugins/grep/gbp-grep-panel.c                  |  81 ++++++-------
 src/plugins/grep/gbp-grep-panel.h                  |   4 +-
 src/plugins/grep/gbp-grep-panel.ui                 |  41 +++----
 src/plugins/grep/gbp-grep-popover.c                |  26 ++--
 src/plugins/grep/gbp-grep-workspace-addin.c        | 116 ++++++++++++++++++
 ...p-editor-addin.h => gbp-grep-workspace-addin.h} |   6 +-
 src/plugins/grep/grep-plugin.c                     |   9 +-
 src/plugins/grep/grep.plugin                       |   1 +
 src/plugins/grep/meson.build                       |   2 +-
 src/plugins/meson.build                            |   2 +-
 11 files changed, 199 insertions(+), 222 deletions(-)
---
diff --git a/src/plugins/grep/gbp-grep-panel.c b/src/plugins/grep/gbp-grep-panel.c
index 477324918..36cb8f1a6 100644
--- a/src/plugins/grep/gbp-grep-panel.c
+++ b/src/plugins/grep/gbp-grep-panel.c
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include <glib/gi18n.h>
+
 #include <libide-code.h>
 #include <libide-editor.h>
 #include <libide-gui.h>
@@ -33,7 +34,7 @@
 
 struct _GbpGrepPanel
 {
-  DzlDockWidget      parent_instance;
+  IdePane            parent_instance;
 
   GCancellable      *cancellable;
 
@@ -66,7 +67,7 @@ enum {
   N_PROPS
 };
 
-G_DEFINE_FINAL_TYPE (GbpGrepPanel, gbp_grep_panel, DZL_TYPE_DOCK_WIDGET)
+G_DEFINE_FINAL_TYPE (GbpGrepPanel, gbp_grep_panel, IDE_TYPE_PANE)
 
 static GParamSpec *properties [N_PROPS];
 
@@ -241,13 +242,12 @@ gbp_grep_panel_row_activated_cb (GbpGrepPanel      *self,
       if G_LIKELY (line != NULL)
         {
           g_autoptr(IdeLocation) location = NULL;
+          g_autoptr(IdePanelPosition) position = NULL;
           g_autoptr(GFile) child = NULL;
           IdeWorkspace *workspace;
-          IdeSurface *editor;
           guint lineno = line->line;
 
           workspace = ide_widget_get_workspace (GTK_WIDGET (self));
-          editor = ide_workspace_get_surface_by_name (workspace, "editor");
 
           if (lineno > 0)
             lineno--;
@@ -255,7 +255,8 @@ gbp_grep_panel_row_activated_cb (GbpGrepPanel      *self,
           child = gbp_grep_model_get_file (GBP_GREP_MODEL (model), line->path);
           location = ide_location_new (child, lineno, -1);
 
-          ide_editor_surface_focus_location (IDE_EDITOR_SURFACE (editor), location);
+          position = ide_panel_position_new ();
+          ide_editor_focus_location (workspace, position, location);
         }
     }
 }
@@ -289,14 +290,14 @@ static void
 gbp_grep_panel_toggle_all_cb (GbpGrepPanel      *self,
                               GtkTreeViewColumn *column)
 {
-  GtkToggleButton *toggle;
+  GtkCheckButton *toggle;
   GtkTreeModel *model;
 
   g_assert (GBP_IS_GREP_PANEL (self));
   g_assert (GTK_IS_TREE_VIEW_COLUMN (column));
 
-  toggle = GTK_TOGGLE_BUTTON (self->check);
-  gtk_toggle_button_set_active (toggle, !gtk_toggle_button_get_active (toggle));
+  toggle = GTK_CHECK_BUTTON (self->check);
+  gtk_check_button_set_active (toggle, !gtk_check_button_get_active (toggle));
 
   model = gtk_tree_view_get_model (self->tree_view);
   gbp_grep_model_toggle_mode (GBP_GREP_MODEL (model));
@@ -339,7 +340,7 @@ gbp_grep_panel_replace_clicked_cb (GbpGrepPanel *self,
   if (edits == NULL || edits->len == 0)
     return;
 
-  text = gtk_entry_get_text (self->replace_entry);
+  text = gtk_editable_get_text (GTK_EDITABLE (self->replace_entry));
 
   for (guint i = 0; i < edits->len; i++)
     {
@@ -374,7 +375,7 @@ gbp_grep_panel_find_entry_text_changed_cb (GbpGrepPanel *self,
   g_assert (GBP_IS_GREP_PANEL (self));
   g_assert (GTK_IS_ENTRY (entry));
 
-  is_query_empty = (g_strcmp0 (gtk_entry_get_text (entry), "") == 0);
+  is_query_empty = (g_strcmp0 (gtk_editable_get_text (GTK_EDITABLE (entry)), "") == 0);
 
   gtk_widget_set_sensitive (GTK_WIDGET (self->find_button), !is_query_empty);
 }
@@ -394,7 +395,7 @@ gbp_grep_panel_close_panel_action (GSimpleAction *action,
   is_project_wide = (model == NULL || gbp_grep_model_get_directory (model) == NULL);
 
   if (!is_project_wide)
-    gtk_widget_destroy (GTK_WIDGET (self));
+    ide_pane_destroy (IDE_PANE (self));
 }
 
 static void
@@ -404,7 +405,7 @@ gbp_grep_panel_close_clicked_cb (GbpGrepPanel *self,
   g_assert (GBP_IS_GREP_PANEL (self));
   g_assert (GTK_IS_BUTTON (button));
 
-  gtk_widget_destroy (GTK_WIDGET (self));
+  ide_pane_destroy (IDE_PANE (self));
 }
 
 static void
@@ -452,9 +453,10 @@ gbp_grep_panel_scan_cb (GObject      *object,
    * box will unselect the items when it should have selected all of them. To avoid this,
    * just set back the "Select all" check box to "selected" when starting a new search.
    */
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->check), TRUE);
+  gtk_check_button_set_active (GTK_CHECK_BUTTON (self->check), TRUE);
 
-  ide_widget_reveal_and_grab (GTK_WIDGET (self->replace_entry));
+  panel_widget_raise (PANEL_WIDGET (self));
+  gtk_widget_grab_focus (GTK_WIDGET (self->replace_entry));
 }
 
 /**
@@ -485,19 +487,20 @@ gbp_grep_panel_launch_search (GbpGrepPanel *self)
   model = gbp_grep_model_new (ide_widget_get_context (GTK_WIDGET (self)));
   gbp_grep_model_set_directory (model, root_dir);
 
-  gbp_grep_model_set_use_regex (model, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(self->regex_button)));
-  gbp_grep_model_set_at_word_boundaries (model, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(self->whole_words_button)));
-  gbp_grep_model_set_case_sensitive (model, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(self->case_button)));
-  gbp_grep_model_set_query (model, gtk_entry_get_text (self->find_entry));
+  gbp_grep_model_set_use_regex (model, gtk_check_button_get_active (GTK_CHECK_BUTTON (self->regex_button)));
+  gbp_grep_model_set_at_word_boundaries (model, gtk_check_button_get_active (GTK_CHECK_BUTTON 
(self->whole_words_button)));
+  gbp_grep_model_set_case_sensitive (model, gtk_check_button_get_active (GTK_CHECK_BUTTON 
(self->case_button)));
+  gbp_grep_model_set_query (model, gtk_editable_get_text (GTK_EDITABLE (self->find_entry)));
 
-  gbp_grep_model_set_recursive (model, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(self->recursive_button)));
+  gbp_grep_model_set_recursive (model, gtk_check_button_get_active (GTK_CHECK_BUTTON 
(self->recursive_button)));
 
   gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->spinner));
   gtk_spinner_start (self->spinner);
   gtk_widget_set_sensitive (GTK_WIDGET (self->replace_button), FALSE);
   gtk_widget_set_sensitive (GTK_WIDGET (self->replace_entry), FALSE);
 
-  ide_widget_reveal_and_grab (GTK_WIDGET (self));
+  panel_widget_raise (PANEL_WIDGET (self));
+  gtk_widget_grab_focus (GTK_WIDGET (self));
 
   /* We allow making a new search even if there's already one running, but cancel the previous
    * one to make sure it doesn't needlessly use resources for the grep process that's still
@@ -540,14 +543,14 @@ on_entry_activate_toggle_action_button_cb (GtkEntry *entry,
     g_signal_emit_by_name (button, "activate", NULL);
 }
 
-static void
+static gboolean
 gbp_grep_panel_grab_focus (GtkWidget *widget)
 {
   GbpGrepPanel *self = (GbpGrepPanel *)widget;
 
   g_assert (GBP_IS_GREP_PANEL (self));
 
-  gtk_widget_grab_focus (GTK_WIDGET (self->find_entry));
+  return gtk_widget_grab_focus (GTK_WIDGET (self->find_entry));
 }
 
 static void
@@ -651,8 +654,6 @@ static void
 gbp_grep_panel_init (GbpGrepPanel *self)
 {
   g_autoptr(GSimpleActionGroup) group = NULL;
-  DzlShortcutController *controller;
-
   GtkTreeViewColumn *column;
   GtkCellRenderer *cell;
 
@@ -663,14 +664,9 @@ gbp_grep_panel_init (GbpGrepPanel *self)
                                    actions,
                                    G_N_ELEMENTS (actions),
                                    self);
-  gtk_widget_insert_action_group (GTK_WIDGET (self), "grep", G_ACTION_GROUP (group));
-
-  controller = dzl_shortcut_controller_find (GTK_WIDGET (self));
-  dzl_shortcut_controller_add_command_action (controller,
-                                              I_("org.gnome.builder.grep"),
-                                              I_("Escape"),
-                                              DZL_SHORTCUT_PHASE_BUBBLE,
-                                              I_("grep.close-panel"));
+  gtk_widget_insert_action_group (GTK_WIDGET (self),
+                                  "grep",
+                                  G_ACTION_GROUP (group));
 
   g_signal_connect (self->find_entry,
                     "activate",
@@ -716,7 +712,6 @@ gbp_grep_panel_init (GbpGrepPanel *self)
                               "margin-end", 6,
                               "margin-start", 6,
                               "margin-top", 3,
-                              "visible", TRUE,
                               "active", TRUE,
                               NULL);
   self->toggle_column = g_object_new (GTK_TYPE_TREE_VIEW_COLUMN,
@@ -824,7 +819,8 @@ gbp_grep_panel_set_model (GbpGrepPanel *self,
       gtk_widget_set_sensitive (GTK_WIDGET (self->replace_button), has_item);
       gtk_widget_set_sensitive (GTK_WIDGET (self->replace_entry), has_item);
 
-      gtk_entry_set_text (self->find_entry, gbp_grep_model_get_query (model));
+      gtk_editable_set_text (GTK_EDITABLE (self->find_entry),
+                             gbp_grep_model_get_query (model));
 
       gtk_widget_set_visible (GTK_WIDGET (self->close_button), !is_initial_panel);
 
@@ -843,14 +839,15 @@ gbp_grep_panel_set_model (GbpGrepPanel *self,
 
           gtk_widget_set_visible (GTK_WIDGET (self->recursive_button), is_dir);
         }
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->regex_button),
-                                    gbp_grep_model_get_use_regex (model));
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->whole_words_button),
-                                    gbp_grep_model_get_at_word_boundaries (model));
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->case_button),
-                                    gbp_grep_model_get_case_sensitive (model));
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->recursive_button),
-                                    gbp_grep_model_get_recursive (model));
+
+      gtk_check_button_set_active (GTK_CHECK_BUTTON (self->regex_button),
+                                   gbp_grep_model_get_use_regex (model));
+      gtk_check_button_set_active (GTK_CHECK_BUTTON (self->whole_words_button),
+                                   gbp_grep_model_get_at_word_boundaries (model));
+      gtk_check_button_set_active (GTK_CHECK_BUTTON (self->case_button),
+                                   gbp_grep_model_get_case_sensitive (model));
+      gtk_check_button_set_active (GTK_CHECK_BUTTON (self->recursive_button),
+                                   gbp_grep_model_get_recursive (model));
     }
 
   gtk_tree_view_set_model (self->tree_view, GTK_TREE_MODEL (model));
diff --git a/src/plugins/grep/gbp-grep-panel.h b/src/plugins/grep/gbp-grep-panel.h
index 4b916b6f3..4e0f19e72 100644
--- a/src/plugins/grep/gbp-grep-panel.h
+++ b/src/plugins/grep/gbp-grep-panel.h
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include <dazzle.h>
+#include <libide-gui.h>
 
 #include "gbp-grep-model.h"
 
@@ -28,7 +28,7 @@ G_BEGIN_DECLS
 
 #define GBP_TYPE_GREP_PANEL (gbp_grep_panel_get_type())
 
-G_DECLARE_FINAL_TYPE (GbpGrepPanel, gbp_grep_panel, GBP, GREP_PANEL, DzlDockWidget)
+G_DECLARE_FINAL_TYPE (GbpGrepPanel, gbp_grep_panel, GBP, GREP_PANEL, IdePane)
 
 GtkWidget    *gbp_grep_panel_new           (void);
 GbpGrepModel *gbp_grep_panel_get_model     (GbpGrepPanel *self);
diff --git a/src/plugins/grep/gbp-grep-panel.ui b/src/plugins/grep/gbp-grep-panel.ui
index 90e1a29c7..e14d525cf 100644
--- a/src/plugins/grep/gbp-grep-panel.ui
+++ b/src/plugins/grep/gbp-grep-panel.ui
@@ -1,12 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="GbpGrepPanel" parent="DzlDockWidget">
+  <template class="GbpGrepPanel" parent="IdePane">
     <property name="icon-name">edit-find-symbolic</property>
     <property name="title" translatable="yes">Find in Files</property>
     <child>
       <object class="GtkBox">
         <property name="orientation">vertical</property>
         <property name="vexpand">true</property>
+        <property name="hexpand">true</property>
         <property name="visible">true</property>
         <child>
           <object class="GtkStack" id="stack">
@@ -125,14 +126,11 @@
                   <object class="GtkEntry" id="find_entry">
                     <property name="visible">true</property>
                     <property name="hexpand">true</property>
-                    <accessibility>
-                      <relation target="find_button" type="labelled-by"/>
-                    </accessibility>
+                    <layout>
+                      <property name="column">0</property>
+                      <property name="row">0</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">0</property>
-                    <property name="top-attach">0</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkButton" id="find_button">
@@ -140,24 +138,21 @@
                     <property name="sensitive">false</property>
                     <property name="label" translatable="yes">_Find in Project</property>
                     <property name="use-underline">True</property>
+                    <layout>
+                      <property name="column">1</property>
+                      <property name="row">0</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">1</property>
-                    <property name="top-attach">0</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="replace_entry">
                     <property name="visible">true</property>
                     <property name="hexpand">true</property>
-                    <accessibility>
-                      <relation target="replace_button" type="labelled-by"/>
-                    </accessibility>
+                    <layout>
+                      <property name="column">0</property>
+                      <property name="row">1</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">0</property>
-                    <property name="top-attach">1</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkButton" id="replace_button">
@@ -168,11 +163,11 @@
                     <style>
                       <class name="destructive-action"/>
                     </style>
+                    <layout>
+                      <property name="column">1</property>
+                      <property name="row">1</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">1</property>
-                    <property name="top-attach">1</property>
-                  </packing>
                 </child>
               </object>
             </child>
diff --git a/src/plugins/grep/gbp-grep-popover.c b/src/plugins/grep/gbp-grep-popover.c
index 1f9ea7d62..6345ed427 100644
--- a/src/plugins/grep/gbp-grep-popover.c
+++ b/src/plugins/grep/gbp-grep-popover.c
@@ -60,11 +60,10 @@ gbp_grep_popover_button_clicked_cb (GbpGrepPopover *self,
                                     GtkButton      *button)
 {
   g_autoptr(GbpGrepModel) model = NULL;
-  IdeSurface *editor;
+  g_autoptr(IdePanelPosition) position = NULL;
   IdeWorkspace *workspace;
   IdeContext *context;
   GtkWidget *panel;
-  GtkWidget *utils;
   gboolean use_regex;
   gboolean at_word_boundaries;
   gboolean case_sensitive;
@@ -74,21 +73,22 @@ gbp_grep_popover_button_clicked_cb (GbpGrepPopover *self,
   g_assert (GTK_IS_BUTTON (button));
 
   workspace = ide_widget_get_workspace (GTK_WIDGET (self));
-  editor = ide_workspace_get_surface_by_name (workspace, "editor");
-  utils = ide_editor_surface_get_utilities (IDE_EDITOR_SURFACE (editor));
   context = ide_widget_get_context (GTK_WIDGET (workspace));
 
-  use_regex = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->regex_button));
-  at_word_boundaries = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->whole_button));
-  case_sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->case_button));
-  recursive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->recursive_button));
+  position = ide_panel_position_new ();
+  ide_panel_position_set_edge (position, PANEL_DOCK_POSITION_BOTTOM);
+
+  use_regex = gtk_check_button_get_active (GTK_CHECK_BUTTON (self->regex_button));
+  at_word_boundaries = gtk_check_button_get_active (GTK_CHECK_BUTTON (self->whole_button));
+  case_sensitive = gtk_check_button_get_active (GTK_CHECK_BUTTON (self->case_button));
+  recursive = gtk_check_button_get_active (GTK_CHECK_BUTTON (self->recursive_button));
 
   model = gbp_grep_model_new (context);
   gbp_grep_model_set_directory (model, self->file);
   gbp_grep_model_set_use_regex (model, use_regex);
   gbp_grep_model_set_at_word_boundaries (model, at_word_boundaries);
   gbp_grep_model_set_case_sensitive (model, case_sensitive);
-  gbp_grep_model_set_query (model, gtk_entry_get_text (self->entry));
+  gbp_grep_model_set_query (model, gtk_editable_get_text (GTK_EDITABLE (self->entry)));
 
   if (gtk_widget_get_visible (GTK_WIDGET (self->recursive_button)))
     gbp_grep_model_set_recursive (model, recursive);
@@ -96,12 +96,12 @@ gbp_grep_popover_button_clicked_cb (GbpGrepPopover *self,
     gbp_grep_model_set_recursive (model, FALSE);
 
   panel = gbp_grep_panel_new ();
-  gtk_container_add (GTK_CONTAINER (utils), panel);
+  ide_workspace_add_pane (workspace, IDE_PANE (panel), position);
   gbp_grep_panel_set_model (GBP_GREP_PANEL (panel), model);
-  gtk_widget_show (panel);
+  panel_widget_raise (PANEL_WIDGET (panel));
+
+  gtk_popover_popdown (GTK_POPOVER (self));
 
-  /* gtk_popover_popdown (GTK_POPOVER (self)); */
-  gtk_widget_destroy (GTK_WIDGET (self));
   gbp_grep_panel_launch_search (GBP_GREP_PANEL (panel));
 }
 
diff --git a/src/plugins/grep/gbp-grep-workspace-addin.c b/src/plugins/grep/gbp-grep-workspace-addin.c
new file mode 100644
index 000000000..9d67044d3
--- /dev/null
+++ b/src/plugins/grep/gbp-grep-workspace-addin.c
@@ -0,0 +1,116 @@
+/* gbp-grep-workspace-addin.c
+ *
+ * Copyright 2018-2019 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-grep-workspace-addin"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include <libide-foundry.h>
+#include <libide-gui.h>
+
+#include "gbp-grep-workspace-addin.h"
+#include "gbp-grep-panel.h"
+
+#define I_(s) g_intern_static_string(s)
+
+struct _GbpGrepWorkspaceAddin
+{
+  GObject    parent_instance;
+  GtkWidget *panel;
+};
+
+static void
+gbp_grep_workspace_page_addin_show_project_panel_action (GSimpleAction *action,
+                                                         GVariant      *variant,
+                                                         gpointer       user_data)
+{
+  GbpGrepWorkspaceAddin *self = GBP_GREP_WORKSPACE_ADDIN (user_data);
+
+  g_assert (GBP_IS_GREP_WORKSPACE_ADDIN (self));
+
+  panel_widget_raise (PANEL_WIDGET (self->panel));
+}
+
+static const GActionEntry actions[] = {
+  { "show-project-panel", gbp_grep_workspace_page_addin_show_project_panel_action },
+};
+
+static void
+gbp_grep_workspace_addin_load (IdeWorkspaceAddin *addin,
+                               IdeWorkspace      *workspace)
+{
+  GbpGrepWorkspaceAddin *self = (GbpGrepWorkspaceAddin *)addin;
+  g_autoptr(GSimpleActionGroup) group = NULL;
+  g_autoptr(IdePanelPosition) position = NULL;
+
+  g_assert (GBP_IS_GREP_WORKSPACE_ADDIN (self));
+  g_assert (IDE_IS_WORKSPACE (workspace));
+
+  self->panel = gbp_grep_panel_new ();
+
+  position = ide_panel_position_new ();
+  ide_panel_position_set_edge (position, PANEL_DOCK_POSITION_BOTTOM);
+  ide_workspace_add_pane (workspace, IDE_PANE (self->panel), position);
+
+  group = g_simple_action_group_new ();
+  g_action_map_add_action_entries (G_ACTION_MAP (group),
+                                   actions,
+                                   G_N_ELEMENTS (actions),
+                                   self);
+  gtk_widget_insert_action_group (GTK_WIDGET (workspace),
+                                  "grep",
+                                  G_ACTION_GROUP (group));
+}
+
+static void
+gbp_grep_workspace_addin_unload (IdeWorkspaceAddin *addin,
+                                 IdeWorkspace      *workspace)
+{
+  GbpGrepWorkspaceAddin *self = (GbpGrepWorkspaceAddin *)addin;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_GREP_WORKSPACE_ADDIN (self));
+
+  gtk_widget_insert_action_group (GTK_WIDGET (workspace), "grep", NULL);
+
+  g_clear_pointer ((IdePane **)&self->panel, ide_pane_destroy);
+}
+
+static void
+workspace_addin_iface_init (IdeWorkspaceAddinInterface *iface)
+{
+  iface->load = gbp_grep_workspace_addin_load;
+  iface->unload = gbp_grep_workspace_addin_unload;
+}
+
+G_DEFINE_TYPE_WITH_CODE (GbpGrepWorkspaceAddin, gbp_grep_workspace_addin, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKSPACE_ADDIN, workspace_addin_iface_init))
+
+static void
+gbp_grep_workspace_addin_class_init (GbpGrepWorkspaceAddinClass *klass)
+{
+}
+
+static void
+gbp_grep_workspace_addin_init (GbpGrepWorkspaceAddin *self)
+{
+}
diff --git a/src/plugins/grep/gbp-grep-editor-addin.h b/src/plugins/grep/gbp-grep-workspace-addin.h
similarity index 79%
rename from src/plugins/grep/gbp-grep-editor-addin.h
rename to src/plugins/grep/gbp-grep-workspace-addin.h
index 152273203..e929c955c 100644
--- a/src/plugins/grep/gbp-grep-editor-addin.h
+++ b/src/plugins/grep/gbp-grep-workspace-addin.h
@@ -1,4 +1,4 @@
-/* gbp-grep-editor-addin.h
+/* gbp-grep-workspace-addin.h
  *
  * Copyright 2018-2019 Christian Hergert <chergert redhat com>
  *
@@ -24,8 +24,8 @@
 
 G_BEGIN_DECLS
 
-#define GBP_TYPE_GREP_EDITOR_ADDIN (gbp_grep_editor_addin_get_type())
+#define GBP_TYPE_GREP_WORKSPACE_ADDIN (gbp_grep_workspace_addin_get_type())
 
-G_DECLARE_FINAL_TYPE (GbpGrepEditorAddin, gbp_grep_editor_addin, GBP, GREP_EDITOR_ADDIN, GObject)
+G_DECLARE_FINAL_TYPE (GbpGrepWorkspaceAddin, gbp_grep_workspace_addin, GBP, GREP_WORKSPACE_ADDIN, GObject)
 
 G_END_DECLS
diff --git a/src/plugins/grep/grep-plugin.c b/src/plugins/grep/grep-plugin.c
index 71dfcb95f..a9d8ad30e 100644
--- a/src/plugins/grep/grep-plugin.c
+++ b/src/plugins/grep/grep-plugin.c
@@ -20,12 +20,13 @@
 
 #include "config.h"
 
+#include <libpeas/peas.h>
+
 #include <libide-tree.h>
 #include <libide-editor.h>
-#include <libpeas/peas.h>
 
 #include "gbp-grep-tree-addin.h"
-#include "gbp-grep-editor-addin.h"
+#include "gbp-grep-workspace-addin.h"
 
 _IDE_EXTERN void
 _gbp_grep_register_types (PeasObjectModule *module)
@@ -34,6 +35,6 @@ _gbp_grep_register_types (PeasObjectModule *module)
                                               IDE_TYPE_TREE_ADDIN,
                                               GBP_TYPE_GREP_TREE_ADDIN);
   peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_EDITOR_ADDIN,
-                                              GBP_TYPE_GREP_EDITOR_ADDIN);
+                                              IDE_TYPE_WORKSPACE_ADDIN,
+                                              GBP_TYPE_GREP_WORKSPACE_ADDIN);
 }
diff --git a/src/plugins/grep/grep.plugin b/src/plugins/grep/grep.plugin
index 0e1a371b8..63c5ecc7b 100644
--- a/src/plugins/grep/grep.plugin
+++ b/src/plugins/grep/grep.plugin
@@ -7,3 +7,4 @@ Embedded=_gbp_grep_register_types
 Module=grep
 Name=Find in Files
 X-Tree-Kind=project-tree;
+X-Workspace-Kind=editor;primary;
diff --git a/src/plugins/grep/meson.build b/src/plugins/grep/meson.build
index 54a1e1f9b..1279411ae 100644
--- a/src/plugins/grep/meson.build
+++ b/src/plugins/grep/meson.build
@@ -5,7 +5,7 @@ plugins_sources += files([
   'gbp-grep-panel.c',
   'gbp-grep-popover.c',
   'gbp-grep-tree-addin.c',
-  'gbp-grep-editor-addin.c',
+  'gbp-grep-workspace-addin.c',
   'grep-plugin.c',
 ])
 
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index f9341c86e..04b6a1653 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -81,7 +81,7 @@ subdir('go-langserv')
 subdir('gjs-symbols')
 subdir('gradle')
 subdir('greeter')
-#subdir('grep')
+subdir('grep')
 #subdir('gvls')
 #subdir('history')
 subdir('html-completion')


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