[gnome-builder] plugins/editorui: start on space style tweaks
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/editorui: start on space style tweaks
- Date: Tue, 16 Aug 2022 00:31:44 +0000 (UTC)
commit 7505f78d3b8396eace47a92de2da5d26cfcff911
Author: Christian Hergert <chergert redhat com>
Date: Mon Aug 15 17:31:31 2022 -0700
plugins/editorui: start on space style tweaks
This still isn't quite right because we're not getting the proper path
for the settings due to how the settings object is (not) cloned.
src/plugins/editorui/gbp-editorui-tweaks-addin.c | 59 ++++++++++++++++++++++++
src/plugins/editorui/tweaks-language.ui | 10 ++++
2 files changed, 69 insertions(+)
---
diff --git a/src/plugins/editorui/gbp-editorui-tweaks-addin.c
b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
index 149a9f21d..002b7d79b 100644
--- a/src/plugins/editorui/gbp-editorui-tweaks-addin.c
+++ b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
@@ -80,6 +80,64 @@ create_language_caption (IdeTweaks *tweaks,
NULL);
}
+static GtkWidget *
+create_spaces_style (IdeTweaksSettings *settings,
+ IdeTweaksWidget *widget)
+{
+ static const struct {
+ const char *nick;
+ const char *title;
+ } flags[] = {
+ { "before-left-paren", N_("Space before opening parentheses") },
+ { "before-left-bracket", N_("Space before opening brackets") },
+ { "before-left-brace", N_("Space before opening braces") },
+ { "before-left-angle", N_("Space before opening angles") },
+ { "before-colon", N_("Prefer a space before colon") },
+ { "before-comma", N_("Prefer a space before commas") },
+ { "before-semicolon", N_("Prefer a space before semicolons") },
+ };
+ g_autoptr(GSimpleActionGroup) group = NULL;
+ GtkListBox *list_box;
+
+ list_box = g_object_new (GTK_TYPE_LIST_BOX,
+ "css-classes", IDE_STRV_INIT ("boxed-list"),
+ "selection-mode", GTK_SELECTION_NONE,
+ NULL);
+ group = g_simple_action_group_new ();
+ gtk_widget_insert_action_group (GTK_WIDGET (list_box),
+ "spaces-style",
+ G_ACTION_GROUP (group));
+
+ for (guint i = 0; i < G_N_ELEMENTS (flags); i++)
+ {
+ g_autoptr(IdeSettingsFlagAction) action = NULL;
+ const char *schema_id = ide_tweaks_settings_get_schema_id (settings);
+ const char *schema_path = ide_tweaks_settings_get_schema_path (settings);
+ g_autofree char *action_name = g_strdup_printf ("spaces-style.%s", flags[i].nick);
+ GtkCheckButton *button = NULL;
+ AdwActionRow *row;
+
+ action = ide_settings_flag_action_new (schema_id, "spaces-style", schema_path, flags[i].nick);
+ g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
+
+ button = g_object_new (GTK_TYPE_CHECK_BUTTON,
+ "action-name", action_name,
+ "can-target", FALSE,
+ "valign", GTK_ALIGN_CENTER,
+ NULL);
+ gtk_widget_add_css_class (GTK_WIDGET (button), "checkimage");
+
+ row = g_object_new (ADW_TYPE_ACTION_ROW,
+ "title", g_dgettext (GETTEXT_PACKAGE, flags[i].title),
+ "activatable-widget", button,
+ NULL);
+ adw_action_row_add_suffix (row, GTK_WIDGET (button));
+ gtk_list_box_append (list_box, GTK_WIDGET (row));
+ }
+
+ return GTK_WIDGET (list_box);
+}
+
static void
gbp_editorui_tweaks_addin_load (IdeTweaksAddin *addin,
IdeTweaks *tweaks)
@@ -109,6 +167,7 @@ gbp_editorui_tweaks_addin_load (IdeTweaksAddin *addin,
ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), editorui_create_style_scheme_preview);
ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), editorui_create_style_scheme_selector);
ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), create_language_caption);
+ ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), create_spaces_style);
ide_tweaks_expose_object (tweaks, "GtkSourceLanguages", G_OBJECT (store));
IDE_TWEAKS_ADDIN_CLASS (gbp_editorui_tweaks_addin_parent_class)->load (addin, tweaks);
diff --git a/src/plugins/editorui/tweaks-language.ui b/src/plugins/editorui/tweaks-language.ui
index 2a447a0e6..692947102 100644
--- a/src/plugins/editorui/tweaks-language.ui
+++ b/src/plugins/editorui/tweaks-language.ui
@@ -144,6 +144,16 @@
</child>
</object>
</child>
+ <child>
+ <object class="IdeTweaksGroup" id="language_spaces_style_group">
+ <property name="title" translatable="yes">Spaces</property>
+ <child>
+ <object class="IdeTweaksWidget">
+ <signal name="create" handler="create_spaces_style" swapped="true"
object="language_page_settings"/>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]