[gnome-builder/wip/gtk4-port: 517/736] plugins/quick-highlight: port quick-highlight plugin
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 517/736] plugins/quick-highlight: port quick-highlight plugin
- Date: Tue, 26 Apr 2022 01:46:29 +0000 (UTC)
commit 37dc8410aaa36a6d4ac10390478413c93c428bcd
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 7 16:16:52 2022 -0700
plugins/quick-highlight: port quick-highlight plugin
src/plugins/meson.build | 2 +-
.../gbp-quick-highlight-editor-page-addin.c | 54 ++++++++--------
.../gbp-quick-highlight-preferences.c | 75 ++++++++--------------
3 files changed, 53 insertions(+), 78 deletions(-)
---
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index 5840fd950..dbb31583d 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -111,7 +111,7 @@ subdir('project-tree')
#subdir('python-gi-imports-completion')
#subdir('python-pack')
subdir('qemu')
-#subdir('quick-highlight')
+subdir('quick-highlight')
subdir('recent')
subdir('restore-cursor')
subdir('retab')
diff --git a/src/plugins/quick-highlight/gbp-quick-highlight-editor-page-addin.c
b/src/plugins/quick-highlight/gbp-quick-highlight-editor-page-addin.c
index bb5f0882d..7b0022135 100644
--- a/src/plugins/quick-highlight/gbp-quick-highlight-editor-page-addin.c
+++ b/src/plugins/quick-highlight/gbp-quick-highlight-editor-page-addin.c
@@ -35,8 +35,8 @@ struct _GbpQuickHighlightEditorPageAddin
IdeEditorPage *view;
- DzlSignalGroup *buffer_signals;
- DzlSignalGroup *search_signals;
+ IdeSignalGroup *buffer_signals;
+ IdeSignalGroup *search_signals;
GtkSourceSearchContext *search_context;
guint queued_match_source;
@@ -137,25 +137,23 @@ do_delayed_quick_highlight (GbpQuickHighlightEditorPageAddin *self)
static void
buffer_cursor_moved (GbpQuickHighlightEditorPageAddin *self,
- const GtkTextIter *location,
IdeBuffer *buffer)
{
g_assert (GBP_IS_QUICK_HIGHLIGHT_EDITOR_PAGE_ADDIN (self));
- g_assert (location != NULL);
g_assert (IDE_IS_BUFFER (buffer));
if (self->has_selection && !self->search_active)
{
if (self->queued_match_source == 0)
self->queued_match_source =
- gdk_threads_add_idle_full (G_PRIORITY_LOW + 100,
- (GSourceFunc) do_delayed_quick_highlight,
- g_object_ref (self),
- g_object_unref);
+ g_idle_add_full (G_PRIORITY_LOW + 100,
+ (GSourceFunc) do_delayed_quick_highlight,
+ g_object_ref (self),
+ g_object_unref);
}
else
{
- dzl_clear_source (&self->queued_match_source);
+ g_clear_handle_id (&self->queued_match_source, g_source_remove);
g_clear_object (&self->search_context);
}
}
@@ -192,6 +190,7 @@ buffer_notify_has_selection (GbpQuickHighlightEditorPageAddin *self,
self->has_selection = gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buffer));
}
+#if 0
static void
search_notify_active (GbpQuickHighlightEditorPageAddin *self,
GParamSpec *pspec,
@@ -203,6 +202,7 @@ search_notify_active (GbpQuickHighlightEditorPageAddin *self,
self->search_active = ide_editor_search_get_active (search);
do_delayed_quick_highlight (self);
}
+#endif
static void
gbp_quick_highlight_editor_page_addin_load (IdeEditorPageAddin *addin,
@@ -217,32 +217,29 @@ gbp_quick_highlight_editor_page_addin_load (IdeEditorPageAddin *addin,
self->settings = g_settings_new ("org.gnome.builder.editor");
- self->buffer_signals = dzl_signal_group_new (IDE_TYPE_BUFFER);
-
- dzl_signal_group_connect_swapped (self->buffer_signals,
+ self->buffer_signals = ide_signal_group_new (IDE_TYPE_BUFFER);
+ ide_signal_group_connect_swapped (self->buffer_signals,
"notify::has-selection",
G_CALLBACK (buffer_notify_has_selection),
self);
-
- dzl_signal_group_connect_swapped (self->buffer_signals,
+ ide_signal_group_connect_swapped (self->buffer_signals,
"notify::style-scheme",
G_CALLBACK (buffer_notify_style_scheme),
self);
-
- dzl_signal_group_connect_swapped (self->buffer_signals,
+ ide_signal_group_connect_swapped (self->buffer_signals,
"cursor-moved",
G_CALLBACK (buffer_cursor_moved),
self);
+ ide_signal_group_set_target (self->buffer_signals, ide_editor_page_get_buffer (view));
- self->search_signals = dzl_signal_group_new (IDE_TYPE_EDITOR_SEARCH);
-
- dzl_signal_group_connect_swapped (self->search_signals,
+#if 0
+ self->search_signals = ide_signal_group_new (IDE_TYPE_EDITOR_SEARCH);
+ ide_signal_group_connect_swapped (self->search_signals,
"notify::active",
G_CALLBACK (search_notify_active),
self);
-
- dzl_signal_group_set_target (self->buffer_signals, ide_editor_page_get_buffer (view));
- dzl_signal_group_set_target (self->search_signals, ide_editor_page_get_search (view));
+ ide_signal_group_set_target (self->search_signals, ide_editor_page_get_search (view));
+#endif
}
static void
@@ -255,12 +252,12 @@ gbp_quick_highlight_editor_page_addin_unload (IdeEditorPageAddin *addin,
g_assert (IDE_IS_EDITOR_PAGE (view));
g_clear_object (&self->search_context);
- dzl_clear_source (&self->queued_match_source);
+ g_clear_handle_id (&self->queued_match_source, g_source_remove);
- dzl_signal_group_set_target (self->buffer_signals, NULL);
+ ide_signal_group_set_target (self->buffer_signals, NULL);
g_clear_object (&self->buffer_signals);
- dzl_signal_group_set_target (self->search_signals, NULL);
+ ide_signal_group_set_target (self->search_signals, NULL);
g_clear_object (&self->search_signals);
g_clear_object (&self->settings);
@@ -276,10 +273,9 @@ editor_view_addin_iface_init (IdeEditorPageAddinInterface *iface)
}
G_DEFINE_FINAL_TYPE_WITH_CODE (GbpQuickHighlightEditorPageAddin,
- gbp_quick_highlight_editor_page_addin,
- G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_PAGE_ADDIN,
- editor_view_addin_iface_init))
+ gbp_quick_highlight_editor_page_addin,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_PAGE_ADDIN,
editor_view_addin_iface_init))
static void
gbp_quick_highlight_editor_page_addin_class_init (GbpQuickHighlightEditorPageAddinClass *klass)
diff --git a/src/plugins/quick-highlight/gbp-quick-highlight-preferences.c
b/src/plugins/quick-highlight/gbp-quick-highlight-preferences.c
index 313035ee2..224401979 100644
--- a/src/plugins/quick-highlight/gbp-quick-highlight-preferences.c
+++ b/src/plugins/quick-highlight/gbp-quick-highlight-preferences.c
@@ -22,77 +22,56 @@
#include <glib/gi18n.h>
+#include <libide-gui.h>
+
#include "gbp-quick-highlight-preferences.h"
struct _GbpQuickHighlightPreferences
{
GObject parent_instance;
- guint enable_switch;
- guint min_char_spin_button;
};
-static void
-gbp_quick_highlight_preferences_load (IdePreferencesAddin *addin,
- DzlPreferences *preferences)
-{
- GbpQuickHighlightPreferences *self = (GbpQuickHighlightPreferences *)addin;
-
- g_assert (IDE_IS_PREFERENCES_ADDIN (self));
- g_assert (DZL_IS_PREFERENCES (preferences));
-
- self->enable_switch =
- dzl_preferences_add_switch (preferences,
- "editor",
- "highlight",
- "org.gnome.builder.extension-type",
- "enabled",
- "/org/gnome/builder/extension-types/quick-highlight/IdeEditorPageAddin/",
- NULL,
- _("Words matching selection"),
- _("Highlight all occurrences of words matching the current selection"),
- /* Translators: the following are keywords used for searching to locate this
preference */
- _("quick highlight words matching current selection"),
- 10);
+static const IdePreferenceGroupEntry groups[] = {
+ { "editing", "quick-highlight", 0, N_("Highlighting") },
+};
- self->min_char_spin_button =
- dzl_preferences_add_spin_button (preferences,
- "editor",
- "highlight",
- "org.gnome.builder.editor",
- "min-char-selected",
- "/org/gnome/builder/editor/",
- _("Minimum length for highlight"),
- _("Highlight words matching at least this number of characters"),
- /* Translators: the following are keywords used for searching to locate
this preference */
- _("quick highlight words matching current selection minimum length"),
- 10);
-}
+static const IdePreferenceItemEntry items[] = {
+ { "editing", "quick-highlight", "enabled", 0, ide_preferences_window_toggle,
+ N_("Highlight Words Matching Selection"),
+ N_("Highlight all occurrences of words matching the current selection"),
+ "org.gnome.builder.extension-type",
+ "/org/gnome/builder/extension-types/quick-highlight/IdeEditorPageAddin/",
+ "enabled" },
+
+ { "editing", "quick-highlight", "min-length", 0, ide_preferences_window_spin,
+ N_("Minimum Length for Highlight"),
+ N_("Highlight words matching at least this number of characters"),
+ "org.gnome.builder.editor",
+ NULL,
+ "min-char-selected" },
+};
static void
-gbp_quick_highlight_preferences_unload (IdePreferencesAddin *addin,
- DzlPreferences *preferences)
+gbp_quick_highlight_preferences_load (IdePreferencesAddin *addin,
+ IdePreferencesWindow *window)
{
GbpQuickHighlightPreferences *self = (GbpQuickHighlightPreferences *)addin;
g_assert (IDE_IS_PREFERENCES_ADDIN (self));
- g_assert (DZL_IS_PREFERENCES (preferences));
-
- dzl_preferences_remove_id (preferences, self->enable_switch);
- self->enable_switch = 0;
+ g_assert (IDE_IS_PREFERENCES_WINDOW (window));
- dzl_preferences_remove_id (preferences, self->min_char_spin_button);
- self->min_char_spin_button = 0;
+ ide_preferences_window_add_groups (window, groups, G_N_ELEMENTS (groups), NULL);
+ ide_preferences_window_add_items (window, items, G_N_ELEMENTS (items), window, NULL);
}
static void
preferences_addin_iface_init (IdePreferencesAddinInterface *iface)
{
iface->load = gbp_quick_highlight_preferences_load;
- iface->unload = gbp_quick_highlight_preferences_unload;
}
-G_DEFINE_TYPE_EXTENDED (GbpQuickHighlightPreferences, gbp_quick_highlight_preferences, G_TYPE_OBJECT,
G_TYPE_FLAG_FINAL,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN, preferences_addin_iface_init))
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpQuickHighlightPreferences, gbp_quick_highlight_preferences, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN,
preferences_addin_iface_init))
static void
gbp_quick_highlight_preferences_class_init (GbpQuickHighlightPreferencesClass *klass)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]