[gnome-builder] plugins/recent: port to GTK 4



commit 517e41fd9077fd2d466a393124a75a317fc5f122
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 11 23:15:21 2022 -0700

    plugins/recent: port to GTK 4
    
     - Remove libdazzle usage

 src/plugins/recent/gbp-recent-section.c  | 380 +++++++++++++++----------------
 src/plugins/recent/gbp-recent-section.h  |   2 +-
 src/plugins/recent/gbp-recent-section.ui |  62 +----
 src/plugins/recent/recent-plugin.c       |   1 +
 4 files changed, 193 insertions(+), 252 deletions(-)
---
diff --git a/src/plugins/recent/gbp-recent-section.c b/src/plugins/recent/gbp-recent-section.c
index 40ed6dca6..0401570a7 100644
--- a/src/plugins/recent/gbp-recent-section.c
+++ b/src/plugins/recent/gbp-recent-section.c
@@ -20,25 +20,28 @@
 
 #define G_LOG_DOMAIN "gbp-recent-section"
 
+#include "config.h"
+
 #include <glib/gi18n.h>
+
+#include <libide-gtk.h>
 #include <libide-greeter.h>
 #include <libide-projects.h>
 
 #include "ide-project-info-private.h"
 
-#include "ide-truncate-model.h"
-
 #include "gbp-recent-section.h"
 
 struct _GbpRecentSection
 {
-  GtkBin            parent_instance;
+  GtkWidget            parent_instance;
 
-  IdeTruncateModel *truncate;
+  IdeTruncateModel    *truncate;
 
-  GtkListBox       *listbox;
+  AdwPreferencesGroup *group;
+  GtkListBox          *listbox;
 
-  guint             selection_mode : 1;
+  guint                selection_mode : 1;
 };
 
 enum {
@@ -68,29 +71,27 @@ clear_settings_with_path (const gchar *schema_id,
     g_settings_reset (settings, keys[i]);
 }
 
-static void
-gbp_recent_section_get_has_selection_cb (GtkWidget *widget,
-                                         gpointer   user_data)
-{
-  gboolean *has_selection = user_data;
-  gboolean selected = FALSE;
-
-  g_object_get (widget, "selected", &selected, NULL);
-  *has_selection |= selected;
-}
-
 static gboolean
 gbp_recent_section_get_has_selection (GbpRecentSection *self)
 {
-  gboolean has_selection = FALSE;
-
   g_assert (GBP_IS_RECENT_SECTION (self));
 
-  gtk_container_foreach (GTK_CONTAINER (self->listbox),
-                         gbp_recent_section_get_has_selection_cb,
-                         &has_selection);
+  for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox));
+       child != NULL;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      if (IDE_IS_GREETER_ROW (child))
+        {
+          gboolean selected;
+
+          g_object_get (child, "selected", &selected, NULL);
+
+          if (selected)
+            return TRUE;
+        }
+    }
 
-  return has_selection;
+  return FALSE;
 }
 
 static gint
@@ -99,43 +100,12 @@ gbp_recent_section_get_priority (IdeGreeterSection *section)
   return -100;
 }
 
-static void
-gbp_recent_section_filter_cb (GtkListBoxRow *row,
-                              gpointer       user_data)
-{
-  struct {
-    DzlPatternSpec *spec;
-    gboolean found;
-  } *filter = user_data;
-  gboolean match = TRUE;
-
-  if (!IDE_IS_GREETER_ROW (row))
-    return;
-
-  g_assert (filter != NULL);
-
-  if (filter->spec != NULL)
-    {
-      g_autofree gchar *search_text = NULL;
-
-      if ((search_text = ide_greeter_row_get_search_text (IDE_GREETER_ROW (row))))
-        match = dzl_pattern_spec_match (filter->spec, search_text);
-    }
-
-  gtk_widget_set_visible (GTK_WIDGET (row), match);
-
-  filter->found |= match;
-}
-
 static gboolean
 gbp_recent_section_filter (IdeGreeterSection *section,
-                           DzlPatternSpec    *spec)
+                           IdePatternSpec    *spec)
 {
   GbpRecentSection *self = (GbpRecentSection *)section;
-  struct {
-    DzlPatternSpec *spec;
-    gboolean found;
-  } filter = { spec, FALSE };
+  gboolean found = FALSE;
 
   g_assert (GBP_IS_RECENT_SECTION (self));
 
@@ -147,72 +117,55 @@ gbp_recent_section_filter (IdeGreeterSection *section,
    * rows matched. We have to hide our widget if there are
    * no visible matches.
    */
+  for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox));
+       child != NULL;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      if (IDE_IS_GREETER_ROW (child))
+        {
+          gboolean match = spec == NULL;
 
-  gtk_container_foreach (GTK_CONTAINER (self->listbox),
-                         (GtkCallback) gbp_recent_section_filter_cb,
-                         &filter);
-
-  return filter.found;
-}
-
-static void
-gbp_recent_section_activate_first_cb (GtkWidget *widget,
-                                      gpointer   user_data)
-{
-  IdeProjectInfo *project_info;
-  struct {
-    GbpRecentSection *self;
-    gboolean handled;
-  } *activate = user_data;
+          if (spec != NULL)
+            {
+              g_autofree gchar *search_text = NULL;
 
-  g_assert (activate != NULL);
+              if ((search_text = ide_greeter_row_get_search_text (IDE_GREETER_ROW (child))))
+                match = ide_pattern_spec_match (spec, search_text);
+            }
 
-  if (!IDE_IS_GREETER_ROW (widget) ||
-      activate->handled ||
-      !gtk_widget_get_visible (widget))
-    return;
+          gtk_widget_set_visible (child, match);
 
-  project_info = ide_greeter_row_get_project_info (IDE_GREETER_ROW (widget));
-  ide_greeter_section_emit_project_activated (IDE_GREETER_SECTION (activate->self), project_info);
+          found |= match;
+        }
+    }
 
-  activate->handled = TRUE;
+  return found;
 }
 
 static gboolean
 gbp_recent_section_activate_first (IdeGreeterSection *section)
 {
   GbpRecentSection *self = (GbpRecentSection *)section;
-  struct {
-    GbpRecentSection *self;
-    gboolean handled;
-  } activate;
 
   g_return_val_if_fail (GBP_IS_RECENT_SECTION (self), FALSE);
 
-  activate.self = self;
-  activate.handled = FALSE;
-
-  gtk_container_foreach (GTK_CONTAINER (self->listbox),
-                         gbp_recent_section_activate_first_cb,
-                         &activate);
-
-  return activate.handled;
-}
-
-static void
-gbp_recent_section_set_selection_mode_cb (GtkWidget *widget,
-                                          gpointer   user_data)
-{
-  IdeGreeterRow *row = (IdeGreeterRow *)widget;
-  gboolean *selection_mode = user_data;
+  for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox));
+       child != NULL;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      if (IDE_IS_GREETER_ROW (child) &&
+          gtk_widget_get_visible (child))
+        {
+          IdeProjectInfo *project_info;
 
-  g_assert (selection_mode != NULL);
+          project_info = ide_greeter_row_get_project_info (IDE_GREETER_ROW (child));
+          ide_greeter_section_emit_project_activated (IDE_GREETER_SECTION (self), project_info);
 
-  if (!IDE_IS_GREETER_ROW (row))
-    return;
+          return TRUE;
+        }
+    }
 
-  ide_greeter_row_set_selection_mode (row, *selection_mode);
-  g_object_set (row, "selected", FALSE, NULL);
+  return FALSE;
 }
 
 static void
@@ -223,39 +176,22 @@ gbp_recent_section_set_selection_mode (IdeGreeterSection *section,
 
   g_assert (GBP_IS_RECENT_SECTION (self));
 
-  gtk_container_foreach (GTK_CONTAINER (self->listbox),
-                         gbp_recent_section_set_selection_mode_cb,
-                         &selection_mode);
+  for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox));
+       child != NULL;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      if (IDE_IS_GREETER_ROW (child))
+        {
+          ide_greeter_row_set_selection_mode (IDE_GREETER_ROW (child), selection_mode);
+          g_object_set (child, "selected", FALSE, NULL);
+        }
+    }
 
   self->selection_mode = selection_mode;
 
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_HAS_SELECTION]);
 }
 
-static void
-gbp_recent_section_collect_selected_cb (GtkWidget *widget,
-                                        gpointer   user_data)
-{
-  IdeGreeterRow *row = (IdeGreeterRow *)widget;
-  GList **list = user_data;
-  gboolean selected = FALSE;
-
-  g_assert (list != NULL);
-
-  if (!IDE_IS_GREETER_ROW (row))
-    return;
-
-  g_object_get (row, "selected", &selected, NULL);
-
-  if (selected)
-    {
-      IdeProjectInfo *project_info;
-
-      project_info = ide_greeter_row_get_project_info (row);
-      *list = g_list_prepend (*list, g_object_ref (project_info));
-    }
-}
-
 static gboolean
 can_purge_project_directory (GFile *directory)
 {
@@ -303,17 +239,21 @@ gbp_recent_section_reap_cb (GObject      *object,
                             GAsyncResult *result,
                             gpointer      user_data)
 {
-  DzlDirectoryReaper *reaper = (DzlDirectoryReaper *)object;
+  IdeDirectoryReaper *reaper = (IdeDirectoryReaper *)object;
   g_autoptr(GPtrArray) directories = user_data;
   g_autoptr(GError) error = NULL;
+  GtkDialog *dialog;
 
   IDE_ENTRY;
 
-  g_assert (DZL_IS_DIRECTORY_REAPER (reaper));
+  g_assert (IDE_IS_DIRECTORY_REAPER (reaper));
   g_assert (G_IS_ASYNC_RESULT (result));
   g_assert (directories != NULL);
 
-  if (!dzl_directory_reaper_execute_finish (reaper, result, &error))
+  if ((dialog = g_object_get_data (G_OBJECT (reaper), "DIALOG")))
+    gtk_window_set_title (GTK_WINDOW (dialog), _("Removed Files"));
+
+  if (!ide_directory_reaper_execute_finish (reaper, result, &error))
     {
       g_warning ("Failed to purge directories: %s", error->message);
       return;
@@ -330,14 +270,14 @@ gbp_recent_section_reap_cb (GObject      *object,
 }
 
 static void
-gbp_recent_section_remove_file (DzlDirectoryReaper *reaper,
+gbp_recent_section_remove_file (IdeDirectoryReaper *reaper,
                                 GFile              *file,
                                 GtkTextBuffer      *buffer)
 {
   GtkTextIter iter;
 
   g_assert (IDE_IS_MAIN_THREAD ());
-  g_assert (DZL_IS_DIRECTORY_REAPER (reaper));
+  g_assert (IDE_IS_DIRECTORY_REAPER (reaper));
   g_assert (G_IS_FILE (file));
   g_assert (GTK_IS_TEXT_BUFFER (buffer));
 
@@ -363,7 +303,7 @@ gbp_recent_section_purge_selected_full (IdeGreeterSection *section,
                                         gboolean           purge_sources)
 {
   GbpRecentSection *self = (GbpRecentSection *)section;
-  g_autoptr(DzlDirectoryReaper) reaper = NULL;
+  g_autoptr(IdeDirectoryReaper) reaper = NULL;
   g_autoptr(GPtrArray) directories = NULL;
   IdeRecentProjects *projects;
   GtkWidget *workspace;
@@ -371,17 +311,33 @@ gbp_recent_section_purge_selected_full (IdeGreeterSection *section,
 
   g_assert (GBP_IS_RECENT_SECTION (self));
 
-  workspace = gtk_widget_get_toplevel (GTK_WIDGET (section));
+  workspace = GTK_WIDGET (gtk_widget_get_native (GTK_WIDGET (section)));
+
+  for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox));
+       child != NULL;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      if (IDE_IS_GREETER_ROW (child))
+        {
+          gboolean selected;
+
+          g_object_get (child, "selected", &selected, NULL);
 
-  gtk_container_foreach (GTK_CONTAINER (self->listbox),
-                         gbp_recent_section_collect_selected_cb,
-                         &infos);
+          if (selected)
+            {
+              IdeProjectInfo *info;
+
+              if ((info = ide_greeter_row_get_project_info (IDE_GREETER_ROW (child))))
+                infos = g_list_prepend (infos, g_object_ref (info));
+            }
+        }
+    }
 
   /* Remove the projects from the list of recent projects */
   projects = ide_recent_projects_get_default ();
 
   /* Now asynchronously remove all the project files */
-  reaper = dzl_directory_reaper_new ();
+  reaper = ide_directory_reaper_new ();
   directories = g_ptr_array_new_with_free_func (g_object_unref);
 
   for (const GList *iter = infos; iter != NULL; iter = iter->next)
@@ -422,7 +378,7 @@ gbp_recent_section_purge_selected_full (IdeGreeterSection *section,
         {
           if (can_purge_project_directory (directory))
             {
-              dzl_directory_reaper_add_directory (reaper, directory, 0);
+              ide_directory_reaper_add_directory (reaper, directory, 0);
               g_ptr_array_add (directories, g_object_ref (directory));
             }
         }
@@ -444,7 +400,7 @@ gbp_recent_section_purge_selected_full (IdeGreeterSection *section,
                                              "projects",
                                              id,
                                              NULL);
-          dzl_directory_reaper_add_directory (reaper, cache, 0);
+          ide_directory_reaper_add_directory (reaper, cache, 0);
           g_ptr_array_add (directories, g_steal_pointer (&cache));
         }
 
@@ -464,26 +420,41 @@ gbp_recent_section_purge_selected_full (IdeGreeterSection *section,
       GtkWidget *content_area;
       GtkTextBuffer *buffer;
 
-      dialog = GTK_DIALOG (gtk_dialog_new ());
-      gtk_window_set_title (GTK_WINDOW (dialog), _("Removing Files…"));
-      gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (workspace));
+      dialog = g_object_new (GTK_TYPE_DIALOG,
+                             "title", _("Removing Files…"),
+                             "transient-for", workspace,
+                             "default-width", 700,
+                             "default-height", 500,
+                             "use-header-bar", TRUE,
+                             NULL);
+#if DEVELOPMENT_BUILD
+      gtk_widget_add_css_class (GTK_WIDGET (dialog), "devel");
+#endif
       gtk_dialog_add_button (dialog, _("_Close"), GTK_RESPONSE_CLOSE);
-      gtk_window_set_default_size (GTK_WINDOW (dialog), 700, 500);
       content_area = gtk_dialog_get_content_area (dialog);
-      gtk_container_set_border_width (GTK_CONTAINER (content_area), 12);
-      gtk_box_set_spacing (GTK_BOX (content_area), 12);
-
-      scroller = gtk_scrolled_window_new (NULL, NULL);
-      gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroller), GTK_SHADOW_IN);
+      g_object_set (content_area,
+                    "margin-top", 0,
+                    "margin-bottom", 0,
+                    "margin-start", 0,
+                    "margin-end", 0,
+                    NULL);
+      gtk_box_set_spacing (GTK_BOX (content_area), 0);
+
+      scroller = g_object_new (GTK_TYPE_SCROLLED_WINDOW, NULL);
       gtk_widget_set_vexpand (scroller, TRUE);
-      gtk_container_add (GTK_CONTAINER (content_area), scroller);
+      gtk_box_append (GTK_BOX (content_area), scroller);
       gtk_widget_show (scroller);
 
-      view = gtk_text_view_new ();
-      gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
-      gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
+      view = g_object_new (GTK_TYPE_TEXT_VIEW,
+                           "editable", FALSE,
+                           "cursor-visible", FALSE,
+                           "left-margin", 12,
+                           "right-margin", 12,
+                           "top-margin", 12,
+                           "bottom-margin", 12,
+                           NULL);
       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-      gtk_container_add (GTK_CONTAINER (scroller), view);
+      gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroller), view);
       gtk_widget_show (view);
 
       g_signal_connect_object (reaper,
@@ -494,13 +465,18 @@ gbp_recent_section_purge_selected_full (IdeGreeterSection *section,
 
       g_signal_connect (dialog,
                         "response",
-                        G_CALLBACK (gtk_widget_destroy),
+                        G_CALLBACK (gtk_window_destroy),
                         NULL);
 
+      g_object_set_data_full (G_OBJECT (reaper),
+                              "DIALOG",
+                              g_object_ref (dialog),
+                              g_object_unref);
+
       ide_gtk_window_present (GTK_WINDOW (dialog));
     }
 
-  dzl_directory_reaper_execute_async (reaper,
+  ide_directory_reaper_execute_async (reaper,
                                       NULL,
                                       gbp_recent_section_reap_cb,
                                       g_steal_pointer (&directories));
@@ -532,9 +508,8 @@ greeter_section_iface_init (IdeGreeterSectionInterface *iface)
   iface->purge_selected = gbp_recent_section_purge_selected;
 }
 
-G_DEFINE_FINAL_TYPE_WITH_CODE (GbpRecentSection, gbp_recent_section, GTK_TYPE_BIN,
-                         G_IMPLEMENT_INTERFACE (IDE_TYPE_GREETER_SECTION,
-                                                greeter_section_iface_init))
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpRecentSection, gbp_recent_section, GTK_TYPE_WIDGET,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_GREETER_SECTION, greeter_section_iface_init))
 
 static void
 gbp_recent_section_notify_row_selected (GbpRecentSection *self,
@@ -550,10 +525,10 @@ gbp_recent_section_notify_row_selected (GbpRecentSection *self,
 static void
 gbp_recent_section_row_activated (GbpRecentSection *self,
                                   IdeGreeterRow    *row,
-                                  GtkListBox       *list_box)
+                                  GtkListBox       *listbox)
 {
   g_assert (GBP_IS_RECENT_SECTION (self));
-  g_assert (GTK_IS_LIST_BOX (list_box));
+  g_assert (GTK_IS_LIST_BOX (listbox));
 
   if (!IDE_IS_GREETER_ROW (row))
     {
@@ -606,13 +581,14 @@ create_widget_func (gpointer item,
 }
 
 static void
-gbp_recent_section_destroy (GtkWidget *widget)
+gbp_recent_section_dispose (GObject *object)
 {
-  GbpRecentSection *self = (GbpRecentSection *)widget;
+  GbpRecentSection *self = (GbpRecentSection *)object;
 
   g_clear_object (&self->truncate);
+  g_clear_pointer ((GtkWidget **)&self->group, gtk_widget_unparent);
 
-  GTK_WIDGET_CLASS (gbp_recent_section_parent_class)->destroy (widget);
+  G_OBJECT_CLASS (gbp_recent_section_parent_class)->dispose (object);
 }
 
 static void
@@ -637,12 +613,15 @@ gbp_recent_section_constructed (GObject *object)
                       "visible", TRUE,
                       NULL);
   image = g_object_new (GTK_TYPE_IMAGE,
-                        "margin", 8,
+                        "margin-top", 12,
+                        "margin-bottom", 12,
+                        "margin-start", 8,
+                        "margin-end", 8,
                         "icon-name", "view-more-symbolic",
                         "visible", TRUE,
                         NULL);
-  gtk_container_add (GTK_CONTAINER (row), GTK_WIDGET (image));
-  gtk_container_add (GTK_CONTAINER (self->listbox), GTK_WIDGET (row));
+  gtk_list_box_row_set_child (row, GTK_WIDGET (image));
+  gtk_list_box_append (self->listbox, GTK_WIDGET (row));
 
   g_object_bind_property (self->truncate, "can-expand", row, "visible",
                           G_BINDING_SYNC_CREATE);
@@ -674,10 +653,9 @@ gbp_recent_section_class_init (GbpRecentSectionClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   object_class->constructed = gbp_recent_section_constructed;
+  object_class->dispose = gbp_recent_section_dispose;
   object_class->get_property = gbp_recent_section_get_property;
 
-  widget_class->destroy = gbp_recent_section_destroy;
-
   properties [PROP_HAS_SELECTION] =
     g_param_spec_boolean ("has-selection", NULL, NULL,
                           FALSE,
@@ -685,47 +663,53 @@ gbp_recent_section_class_init (GbpRecentSectionClass *klass)
 
   g_object_class_install_properties (object_class, N_PROPS, properties);
 
+  gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
   gtk_widget_class_set_css_name (widget_class, "recent");
   gtk_widget_class_set_template_from_resource (widget_class, "/plugins/recent/gbp-recent-section.ui");
+  gtk_widget_class_bind_template_child (widget_class, GbpRecentSection, group);
   gtk_widget_class_bind_template_child (widget_class, GbpRecentSection, listbox);
   gtk_widget_class_bind_template_callback (widget_class, gbp_recent_section_row_activated);
 }
 
-static gboolean
-on_button_press_event_cb (GtkListBox       *listbox,
-                          GdkEventButton   *ev,
-                          GbpRecentSection *self)
+static void
+gbp_recent_section_click_pressed_cb (GbpRecentSection *self,
+                                     int               n_presses,
+                                     double            x,
+                                     double            y,
+                                     GtkGestureClick  *gesture)
 {
-  GtkListBoxRow *row;
+  IdeWorkspace *workspace;
+  GtkWidget *pick;
 
-  g_assert (GTK_IS_LIST_BOX (listbox));
   g_assert (GBP_IS_RECENT_SECTION (self));
+  g_assert (GTK_IS_GESTURE_CLICK (gesture));
 
-  if (ev->button == GDK_BUTTON_SECONDARY)
-    {
-      GtkWidget *workspace;
-
-      workspace = gtk_widget_get_ancestor (GTK_WIDGET (self), IDE_TYPE_GREETER_WORKSPACE);
-      ide_greeter_workspace_set_selection_mode (IDE_GREETER_WORKSPACE (workspace), TRUE);
+  pick = gtk_widget_pick (GTK_WIDGET (self), x, y, GTK_PICK_NON_TARGETABLE);
+  if (!GTK_IS_LIST_BOX_ROW (pick))
+    pick = gtk_widget_get_ancestor (pick, GTK_TYPE_LIST_BOX_ROW);
 
-      if ((row = gtk_list_box_get_row_at_y (listbox, ev->y)))
-        {
-          g_object_set (row, "selected", TRUE, NULL);
-          return GDK_EVENT_STOP;
-        }
-    }
+  if (pick == NULL)
+    return;
 
-  return GDK_EVENT_PROPAGATE;
+  workspace = ide_widget_get_workspace (GTK_WIDGET (self));
+  ide_greeter_workspace_set_selection_mode (IDE_GREETER_WORKSPACE (workspace), TRUE);
+  g_object_set (pick, "selected", TRUE, NULL);
 }
 
-
 static void
 gbp_recent_section_init (GbpRecentSection *self)
 {
+  GtkGesture *gesture;
+
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  g_signal_connect (self->listbox,
-                    "button-press-event",
-                    G_CALLBACK (on_button_press_event_cb),
-                    self);
+  gesture = gtk_gesture_click_new ();
+  gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 3);
+  gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_CAPTURE);
+  g_signal_connect_object (gesture,
+                           "pressed",
+                           G_CALLBACK (gbp_recent_section_click_pressed_cb),
+                           self,
+                           G_CONNECT_SWAPPED);
+  gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
 }
diff --git a/src/plugins/recent/gbp-recent-section.h b/src/plugins/recent/gbp-recent-section.h
index 3892a1108..a9ff76927 100644
--- a/src/plugins/recent/gbp-recent-section.h
+++ b/src/plugins/recent/gbp-recent-section.h
@@ -26,6 +26,6 @@ G_BEGIN_DECLS
 
 #define GBP_TYPE_RECENT_SECTION (gbp_recent_section_get_type())
 
-G_DECLARE_FINAL_TYPE (GbpRecentSection, gbp_recent_section, GBP, RECENT_SECTION, GtkBin)
+G_DECLARE_FINAL_TYPE (GbpRecentSection, gbp_recent_section, GBP, RECENT_SECTION, GtkWidget)
 
 G_END_DECLS
diff --git a/src/plugins/recent/gbp-recent-section.ui b/src/plugins/recent/gbp-recent-section.ui
index 9dc6564a1..8a2fbea64 100644
--- a/src/plugins/recent/gbp-recent-section.ui
+++ b/src/plugins/recent/gbp-recent-section.ui
@@ -1,60 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="GbpRecentSection" parent="GtkBin">
-    <property name="halign">center</property>
+  <template class="GbpRecentSection" parent="GtkWidget">
     <child>
-      <object class="GtkBox">
-        <property name="hexpand">true</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">6</property>
-        <property name="visible">true</property>
+      <object class="AdwPreferencesGroup" id="group">
+        <property name="title" translatable="yes">Recent Projects</property>
         <child>
-          <object class="DzlBox">
-            <property name="halign">center</property>
-            <property name="hexpand">false</property>
-            <property name="orientation">vertical</property>
-            <property name="visible">true</property>
-            <property name="max-width-request">600</property>
-            <child>
-              <object class="GtkBox">
-                <property name="orientation">vertical</property>
-                <property name="spacing">6</property>
-                <property name="visible">true</property>
-                <child>
-                  <object class="GtkBox">
-                    <property name="visible">true</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="label" translatable="yes">Recent Projects</property>
-                        <property name="visible">true</property>
-                        <property name="xalign">0.0</property>
-                        <property name="hexpand">true</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                        <attributes>
-                          <attribute name="weight" value="bold"/>
-                        </attributes>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkFrame">
-                    <property name="halign">center</property>
-                    <property name="visible">true</property>
-                    <property name="width-request">600</property>
-                    <child>
-                      <object class="GtkListBox" id="listbox">
-                        <property name="visible">true</property>
-                        <property name="selection-mode">none</property>
-                        <signal name="row-activated" swapped="true" object="GbpRecentSection" 
handler="gbp_recent_section_row_activated"/>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-              </object>
-            </child>
+          <object class="GtkListBox" id="listbox">
+            <property name="selection-mode">none</property>
+            <signal name="row-activated" swapped="true" object="GbpRecentSection" 
handler="gbp_recent_section_row_activated"/>
+            <style>
+              <class name="boxed-list"/>
+            </style>
           </object>
         </child>
       </object>
diff --git a/src/plugins/recent/recent-plugin.c b/src/plugins/recent/recent-plugin.c
index 47ae53258..1618d25ae 100644
--- a/src/plugins/recent/recent-plugin.c
+++ b/src/plugins/recent/recent-plugin.c
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include <libpeas/peas.h>
+
 #include <libide-greeter.h>
 #include <libide-gui.h>
 


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