[gnome-builder/wip/gtk4-port: 970/1774] plugins/buildui: add overview information page
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 970/1774] plugins/buildui: add overview information page
- Date: Mon, 11 Jul 2022 22:31:30 +0000 (UTC)
commit 59a3ca4cf71c39638a96d6de6e741c063f6746dd
Author: Christian Hergert <chergert redhat com>
Date: Tue May 10 17:20:22 2022 -0700
plugins/buildui: add overview information page
We probably want to add more here later on, but this gets us something
in place so that we don't land on a subpage when opening the window.
src/libide/gui/ide-preferences-builtin.c | 5 +-
.../buildui/gbp-buildui-preferences-addin.c | 82 ++++++++++++++++++++++
2 files changed, 85 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/gui/ide-preferences-builtin.c b/src/libide/gui/ide-preferences-builtin.c
index 5f043c00d..1e89de475 100644
--- a/src/libide/gui/ide-preferences-builtin.c
+++ b/src/libide/gui/ide-preferences-builtin.c
@@ -665,8 +665,9 @@ static const IdePreferencePageEntry pages[] = {
};
static const IdePreferencePageEntry project_pages[] = {
- { NULL, "config", "build", "builder-build-symbolic", 0, N_("Configurations") },
- { NULL, "code", "languages", "org.gnome.Builder-languages-symbolic", 100, N_("Languages") },
+ { NULL, "config", "overview", "org.gnome.Builder-overview-symbolic", 0, N_("Overview") },
+ { NULL, "config", "build", "builder-build-symbolic", 100, N_("Configurations") },
+ { NULL, "code", "languages", "org.gnome.Builder-languages-symbolic", 200, N_("Languages") },
};
static const IdePreferenceGroupEntry groups[] = {
diff --git a/src/plugins/buildui/gbp-buildui-preferences-addin.c
b/src/plugins/buildui/gbp-buildui-preferences-addin.c
index 1a1c9bb49..fb5608b4e 100644
--- a/src/plugins/buildui/gbp-buildui-preferences-addin.c
+++ b/src/plugins/buildui/gbp-buildui-preferences-addin.c
@@ -36,6 +36,78 @@ struct _GbpBuilduiPreferencesAddin
GObject parent_instance;
};
+static GtkWidget *
+create_overview_row (const char *title,
+ const char *value)
+{
+ GtkWidget *row;
+
+ row = g_object_new (ADW_TYPE_ENTRY_ROW,
+ "title", title,
+ "text", value,
+ "editable", FALSE,
+ "show-apply-button", FALSE,
+ NULL);
+
+ return row;
+}
+
+static void
+overview_func (const char *page_name,
+ const IdePreferenceItemEntry *entry,
+ AdwPreferencesGroup *group,
+ gpointer user_data)
+{
+ IdeContext *context = user_data;
+
+ g_assert (IDE_IS_CONTEXT (context));
+ g_assert (ADW_IS_PREFERENCES_GROUP (group));
+
+ if (FALSE) {}
+ else if (g_strcmp0 (entry->name, "kind") == 0)
+ {
+ IdeBuildSystem *build_system = ide_build_system_from_context (context);
+ g_autofree char *name = ide_build_system_get_display_name (build_system);
+
+ adw_preferences_group_add (group, create_overview_row (entry->title, name));
+ }
+ else if (g_strcmp0 (entry->name, "srcdir") == 0)
+ {
+ g_autoptr(GFile) workdir = ide_context_ref_workdir (context);
+ g_autofree char *text = NULL;
+
+ if (g_file_is_native (workdir))
+ text = ide_path_collapse (g_file_peek_path (workdir));
+ else
+ text = g_file_get_uri (workdir);
+
+ adw_preferences_group_add (group, create_overview_row (entry->title, text));
+ }
+ else if (g_strcmp0 (entry->name, "vcsuri") == 0)
+ {
+ IdeVcs *vcs = ide_vcs_from_context (context);
+ g_autofree char *name = NULL;
+
+ if (vcs != NULL)
+ name = ide_vcs_get_display_name (vcs);
+ else
+ name = g_strdup (_("No Version Control"));
+
+ adw_preferences_group_add (group, create_overview_row (entry->title, name));
+ }
+}
+
+static const IdePreferenceGroupEntry overview_groups[] = {
+ { "overview", "project", 0, N_("Project") },
+ { "overview", "runtime", 100, N_("Runtime") },
+};
+
+static const IdePreferenceItemEntry overview_items[] = {
+ { "overview", "project", "kind", 0, overview_func, N_("Build System") },
+ { "overview", "project", "srcdir", 0, overview_func, N_("Source Directory") },
+ { "overview", "project", "vcsuri", 0, overview_func, N_("Version Control") },
+};
+
static gboolean
treat_null_as_empty (GBinding *binding,
const GValue *from_value,
@@ -328,6 +400,16 @@ gbp_buildui_preferences_addin_load (IdePreferencesAddin *addin,
g_assert (!context || IDE_IS_CONTEXT (context));
g_assert (ide_preferences_window_get_mode (window) == IDE_PREFERENCES_MODE_PROJECT);
+ ide_preferences_window_add_groups (window,
+ overview_groups,
+ G_N_ELEMENTS (overview_groups),
+ NULL);
+ ide_preferences_window_add_items (window,
+ overview_items,
+ G_N_ELEMENTS (overview_items),
+ g_object_ref (context),
+ g_object_unref);
+
config_manager = ide_config_manager_from_context (context);
n_configs = g_list_model_get_n_items (G_LIST_MODEL (config_manager));
pages = g_new0 (IdePreferencePageEntry, n_configs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]