[gnome-builder/wip/gtk4-port: 620/736] plugins/beautifier: remove some dazzle usage




commit 93a77c9c2d976878f85de220271c417a5cae8f6b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 18 14:36:52 2022 -0700

    plugins/beautifier: remove some dazzle usage
    
    This all needs redesign for using a workspace addin instead of an
    editor addin.

 .../beautifier/gb-beautifier-editor-addin.c        | 45 +++++-----------------
 src/plugins/beautifier/gb-beautifier-helper.c      | 14 +++----
 src/plugins/beautifier/gb-beautifier-process.c     | 20 ++++++----
 3 files changed, 29 insertions(+), 50 deletions(-)
---
diff --git a/src/plugins/beautifier/gb-beautifier-editor-addin.c 
b/src/plugins/beautifier/gb-beautifier-editor-addin.c
index 23fbdc938..3b46b66a3 100644
--- a/src/plugins/beautifier/gb-beautifier-editor-addin.c
+++ b/src/plugins/beautifier/gb-beautifier-editor-addin.c
@@ -22,10 +22,10 @@
 
 #include "config.h"
 
-#include <dazzle.h>
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtksourceview/gtksource.h>
+
 #include <libide-editor.h>
 
 #include "gb-beautifier-editor-addin.h"
@@ -133,7 +133,6 @@ set_default_keybinding (GbBeautifierEditorAddin *self,
                         const gchar             *action_name)
 {
   static const gchar *accel = "<primary><Alt>b";
-  DzlShortcutController *controller;
 
   g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
   g_assert (action_name != NULL);
@@ -141,12 +140,6 @@ set_default_keybinding (GbBeautifierEditorAddin *self,
   if (self->current_view == NULL)
     return;
 
-  controller = dzl_shortcut_controller_find (GTK_WIDGET (self->current_view));
-  dzl_shortcut_controller_add_command_action (controller,
-                                              "org.gnome.builder.editor-view.beautifier-default",
-                                              I_(accel),
-                                              DZL_SHORTCUT_PHASE_CAPTURE,
-                                              action_name);
 }
 
 static void
@@ -201,7 +194,7 @@ view_populate_submenu (GbBeautifierEditorAddin *self,
   if (entries == NULL)
     return;
 
-  default_menu = dzl_application_get_menu_by_id (DZL_APPLICATION_DEFAULT, "gb-beautify-default-section");
+  default_menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "gb-beautify-default-section");
   g_menu_remove_all (default_menu);
 
   lang_id = gb_beautifier_helper_get_lang_id (self, view);
@@ -269,7 +262,7 @@ view_populate_popup (GbBeautifierEditorAddin *self,
   g_assert (GTK_IS_WIDGET (popup));
   g_assert (IDE_IS_SOURCE_VIEW (source_view));
 
-  submenu = dzl_application_get_menu_by_id (DZL_APPLICATION_DEFAULT, "gb-beautify-profiles-section");
+  submenu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "gb-beautify-profiles-section");
   g_menu_remove_all (submenu);
   view_populate_submenu (self, source_view, submenu, self->entries);
 }
@@ -336,31 +329,13 @@ cleanup_view_cb (GtkWidget               *widget,
       g_action_map_remove_action (G_ACTION_MAP (actions), "beautify");
       g_action_map_remove_action (G_ACTION_MAP (actions), "beautify-default");
     }
-
-  /* TODO: if we close the view we are fine but if we desactivate the plugin, we should remove
-   * the dzl shortcut and action mapping from the controler, dzl do not have this feature yet.
-   */
 }
 
-static const DzlShortcutEntry beautifier_shortcut_entry[] = {
-  { "org.gnome.builder.editor-view.beautifier-default",
-    0,
-    "<primary><Alt>b",
-    N_("Editor shortcuts"),
-    N_("Editing"),
-    N_("Beautify the code"),
-    N_("Trigger the default entry") },
-};
-
 static void
 add_shortcut_window_entry (GbBeautifierEditorAddin *self)
 {
   g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
 
-  dzl_shortcut_manager_add_shortcut_entries (NULL,
-                                             beautifier_shortcut_entry,
-                                             G_N_ELEMENTS (beautifier_shortcut_entry),
-                                             GETTEXT_PACKAGE);
 }
 
 static void
@@ -401,15 +376,15 @@ gb_beautifier_editor_addin_reap_cb (GObject      *object,
                                     GAsyncResult *result,
                                     gpointer      user_data)
 {
-  DzlDirectoryReaper *reaper = (DzlDirectoryReaper *)object;
+  IdeDirectoryReaper *reaper = (IdeDirectoryReaper *)object;
   g_autoptr(GbBeautifierEditorAddin) self = user_data;
   g_autoptr(GError) error = NULL;
 
-  g_assert (DZL_IS_DIRECTORY_REAPER (reaper));
+  g_assert (IDE_IS_DIRECTORY_REAPER (reaper));
   g_assert (G_IS_ASYNC_RESULT (result));
   g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
 
-  if (!dzl_directory_reaper_execute_finish (reaper, result, &error))
+  if (!ide_directory_reaper_execute_finish (reaper, result, &error))
     g_warning ("Failed to reap old beautifier data: %s", error->message);
 
   if (g_mkdir_with_parents (self->tmp_dir, 0750) != 0)
@@ -431,7 +406,7 @@ gb_beautifier_editor_addin_load (IdeEditorAddin       *addin,
 {
   GbBeautifierEditorAddin *self = (GbBeautifierEditorAddin *)addin;
   IdeWorkbench *workbench;
-  g_autoptr(DzlDirectoryReaper) reaper = NULL;
+  g_autoptr(IdeDirectoryReaper) reaper = NULL;
   g_autoptr (GFile) tmp_file = NULL;
 
   g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
@@ -446,11 +421,11 @@ gb_beautifier_editor_addin_load (IdeEditorAddin       *addin,
     self->tmp_dir = ide_context_cache_filename (self->context, "beautifier", NULL);
 
   /* Cleanup old beautifier cache directory */
-  reaper = dzl_directory_reaper_new ();
+  reaper = ide_directory_reaper_new ();
   tmp_file = g_file_new_for_path (self->tmp_dir);
-  dzl_directory_reaper_add_directory (reaper, tmp_file, 0);
+  ide_directory_reaper_add_directory (reaper, tmp_file, 0);
 
-  dzl_directory_reaper_execute_async (reaper,
+  ide_directory_reaper_execute_async (reaper,
                                       NULL,
                                       gb_beautifier_editor_addin_reap_cb,
                                       g_object_ref (self));
diff --git a/src/plugins/beautifier/gb-beautifier-helper.c b/src/plugins/beautifier/gb-beautifier-helper.c
index 70cf74870..6dfa3e272 100644
--- a/src/plugins/beautifier/gb-beautifier-helper.c
+++ b/src/plugins/beautifier/gb-beautifier-helper.c
@@ -36,10 +36,10 @@ check_path_is_in_tmp_dir (const gchar *path,
 {
   g_autofree gchar *with_slash = NULL;
 
-  g_assert (!dzl_str_empty0 (path));
-  g_assert (!dzl_str_empty0 (tmp_dir));
+  g_assert (!ide_str_empty0 (path));
+  g_assert (!ide_str_empty0 (tmp_dir));
 
-  if (dzl_str_equal0 (path, tmp_dir))
+  if (ide_str_equal0 (path, tmp_dir))
     return TRUE;
 
   if (!g_str_has_suffix (tmp_dir, G_DIR_SEPARATOR_S))
@@ -125,7 +125,7 @@ gb_beautifier_helper_config_entry_remove_temp_files (GbBeautifierEditorAddin *se
         {
           const GbBeautifierCommandArg *arg = &g_array_index (config_entry->command_args, 
GbBeautifierCommandArg, i);
 
-          if (arg->is_temp && !dzl_str_empty0 (arg->str))
+          if (arg->is_temp && !ide_str_empty0 (arg->str))
             {
               if (check_path_is_in_tmp_dir (arg->str, self->tmp_dir))
                 g_unlink (arg->str);
@@ -181,7 +181,7 @@ gb_beautifier_helper_create_tmp_file_async (GbBeautifierEditorAddin *self,
   gint fd;
 
   g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
-  g_assert (!dzl_str_empty0 (text));
+  g_assert (!ide_str_empty0 (text));
   g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
   g_assert (callback != NULL);
 
@@ -235,8 +235,8 @@ gb_beautifier_helper_match_and_replace (const gchar *str,
   gchar *needle;
   gsize head_len;
 
-  g_assert (!dzl_str_empty0 (str));
-  g_assert (!dzl_str_empty0 (pattern));
+  g_assert (!ide_str_empty0 (str));
+  g_assert (!ide_str_empty0 (pattern));
 
   if (NULL != (needle = g_strstr_len (str, -1, pattern)))
     {
diff --git a/src/plugins/beautifier/gb-beautifier-process.c b/src/plugins/beautifier/gb-beautifier-process.c
index 055ee3b34..113c05f87 100644
--- a/src/plugins/beautifier/gb-beautifier-process.c
+++ b/src/plugins/beautifier/gb-beautifier-process.c
@@ -18,16 +18,20 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
+#define G_LOG_DOMAIN "gb-beautifier-process"
+
+#include "config.h"
+
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtksourceview/gtksource.h>
+#include <string.h>
+
 #include <libide-editor.h>
 #include <libide-threading.h>
-#include <string.h>
 
-#include "gb-beautifier-private.h"
 #include "gb-beautifier-helper.h"
-
+#include "gb-beautifier-private.h"
 #include "gb-beautifier-process.h"
 
 typedef struct
@@ -150,8 +154,8 @@ gb_beautifier_process_create_generic (GbBeautifierEditorAddin  *self,
 
   src_path = g_file_get_path (state->src_file);
 
-  g_assert (!dzl_str_empty0 (src_path));
-  g_assert (!dzl_str_empty0 (state->lang_id));
+  g_assert (!ide_str_empty0 (src_path));
+  g_assert (!ide_str_empty0 (state->lang_id));
 
   command_args_expand (self, state->command_args_strs, state);
 
@@ -184,7 +188,7 @@ gb_beautifier_process_create_for_clang_format (GbBeautifierEditorAddin  *self,
   g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
   g_assert (state != NULL);
 
-  g_assert (!dzl_str_empty0 (state->lang_id));
+  g_assert (!ide_str_empty0 (state->lang_id));
 
   tmp_workdir = g_build_filename (self->tmp_dir, "clang-XXXXXX.txt", NULL);
   if (g_mkdtemp (tmp_workdir) == NULL)
@@ -271,7 +275,7 @@ process_communicate_utf8_cb (GObject      *object,
   state = (ProcessState *)ide_task_get_task_data (task);
   if (stderr_gb != NULL &&
       NULL != (stderr_str = g_bytes_get_data (stderr_gb, NULL)) &&
-      !dzl_str_empty0 (stderr_str) &&
+      !ide_str_empty0 (stderr_str) &&
       g_utf8_validate (stderr_str, -1, NULL))
     {
       if (ide_subprocess_get_if_exited (process) && ide_subprocess_get_exit_status (process) != 0)
@@ -286,7 +290,7 @@ process_communicate_utf8_cb (GObject      *object,
   if (stdout_gb != NULL)
     stdout_str = g_bytes_get_data (stdout_gb, NULL);
 
-  if (stdout_gb != NULL && dzl_str_empty0 (stdout_str))
+  if (stdout_gb != NULL && ide_str_empty0 (stdout_str))
     {
       ide_object_warning (state->self, _("Beautifier plugin: the command output is empty"));
     }


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