[gnome-builder/wip/gtk4-port] plugins/git: stub out configuration section for git



commit fe31d903e114f6c7462125c5a70afcf432df0174
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 10 22:57:55 2022 -0700

    plugins/git: stub out configuration section for git
    
    The goal here is to bind this to VCS settings for project overrides for
    authorship info. We can have the same data in the app preferences too.

 src/plugins/git/gbp-git-preferences-addin.c | 118 ++++++++++++++++++++++++++++
 src/plugins/git/gbp-git-preferences-addin.h |  31 ++++++++
 src/plugins/git/git-plugin.c                |   4 +
 src/plugins/git/git.plugin                  |   1 +
 src/plugins/git/meson.build                 |   1 +
 5 files changed, 155 insertions(+)
---
diff --git a/src/plugins/git/gbp-git-preferences-addin.c b/src/plugins/git/gbp-git-preferences-addin.c
new file mode 100644
index 000000000..a1e7e6d9d
--- /dev/null
+++ b/src/plugins/git/gbp-git-preferences-addin.c
@@ -0,0 +1,118 @@
+/* gbp-git-preferences-addin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-git-preferences-addin"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include <libide-gui.h>
+
+#include "gbp-git-preferences-addin.h"
+
+struct _GbpGitPreferencesAddin
+{
+  GObject parent_instance;
+};
+
+static void
+create_entry (const char                   *page_name,
+              const IdePreferenceItemEntry *entry,
+              AdwPreferencesGroup          *group,
+              gpointer                      user_data)
+{
+  IDE_TODO ("Git: setup bindings for author info");
+
+  if (FALSE) {}
+  else if (g_strcmp0 (entry->name, "name") == 0)
+    {
+      adw_preferences_group_add (group,
+                                 g_object_new (ADW_TYPE_ENTRY_ROW,
+                                               "title", entry->title,
+                                               NULL));
+    }
+  else if (g_strcmp0 (entry->name, "email") == 0)
+    {
+      adw_preferences_group_add (group,
+                                 g_object_new (ADW_TYPE_ENTRY_ROW,
+                                               "title", entry->title,
+                                               NULL));
+    }
+}
+
+static const IdePreferencePageEntry pages[] = {
+  { NULL, "sharing", "git", "builder-vcs-git-symbolic", 500, N_("Git Version Control") },
+};
+
+static const IdePreferenceGroupEntry groups[] = {
+  { "git", "author", 0, N_("Authorship") },
+};
+
+static const IdePreferenceItemEntry items[] = {
+  { "git", "author", "name", 0, create_entry, N_("Full Name") },
+  { "git", "author", "email", 10, create_entry, N_("Email Address") },
+};
+
+static void
+gbp_git_preferences_addin_load (IdePreferencesAddin  *addin,
+                                IdePreferencesWindow *window,
+                                IdeContext           *context)
+{
+  g_assert (GBP_IS_GIT_PREFERENCES_ADDIN (addin));
+  g_assert (IDE_IS_PREFERENCES_WINDOW (window));
+  g_assert (IDE_IS_CONTEXT (context));
+
+  ide_preferences_window_add_pages (window, pages, G_N_ELEMENTS (pages), NULL);
+  ide_preferences_window_add_groups (window, groups, G_N_ELEMENTS (groups), NULL);
+  ide_preferences_window_add_items (window, items, G_N_ELEMENTS (items),
+                                    g_object_ref (context), g_object_unref);
+}
+
+static void
+gbp_git_preferences_addin_unload (IdePreferencesAddin  *addin,
+                                  IdePreferencesWindow *window,
+                                  IdeContext           *context)
+{
+  g_assert (GBP_IS_GIT_PREFERENCES_ADDIN (addin));
+  g_assert (IDE_IS_PREFERENCES_WINDOW (window));
+  g_assert (IDE_IS_CONTEXT (context));
+
+}
+
+static void
+preferences_addin_iface_init (IdePreferencesAddinInterface *iface)
+{
+  iface->load = gbp_git_preferences_addin_load;
+  iface->unload = gbp_git_preferences_addin_unload;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpGitPreferencesAddin, gbp_git_preferences_addin, G_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN, 
preferences_addin_iface_init))
+
+static void
+gbp_git_preferences_addin_class_init (GbpGitPreferencesAddinClass *klass)
+{
+}
+
+static void
+gbp_git_preferences_addin_init (GbpGitPreferencesAddin *self)
+{
+}
diff --git a/src/plugins/git/gbp-git-preferences-addin.h b/src/plugins/git/gbp-git-preferences-addin.h
new file mode 100644
index 000000000..1d30f4aee
--- /dev/null
+++ b/src/plugins/git/gbp-git-preferences-addin.h
@@ -0,0 +1,31 @@
+/* gbp-git-preferences-addin.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_GIT_PREFERENCES_ADDIN (gbp_git_preferences_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpGitPreferencesAddin, gbp_git_preferences_addin, GBP, GIT_PREFERENCES_ADDIN, GObject)
+
+G_END_DECLS
diff --git a/src/plugins/git/git-plugin.c b/src/plugins/git/git-plugin.c
index fb2ebaeda..d0d5fec05 100644
--- a/src/plugins/git/git-plugin.c
+++ b/src/plugins/git/git-plugin.c
@@ -30,6 +30,7 @@
 #include "gbp-git-buffer-addin.h"
 #include "gbp-git-dependency-updater.h"
 #include "gbp-git-pipeline-addin.h"
+#include "gbp-git-preferences-addin.h"
 #include "gbp-git-vcs-cloner.h"
 #include "gbp-git-vcs-config.h"
 #include "gbp-git-vcs-initializer.h"
@@ -61,4 +62,7 @@ _gbp_git_register_types (PeasObjectModule *module)
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_WORKBENCH_ADDIN,
                                               GBP_TYPE_GIT_WORKBENCH_ADDIN);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_PREFERENCES_ADDIN,
+                                              GBP_TYPE_GIT_PREFERENCES_ADDIN);
 }
diff --git a/src/plugins/git/git.plugin b/src/plugins/git/git.plugin
index aca2c59dc..0553c9dbb 100644
--- a/src/plugins/git/git.plugin
+++ b/src/plugins/git/git.plugin
@@ -7,3 +7,4 @@ Embedded=_gbp_git_register_types
 Module=git
 Name=Git
 X-Category=vcs
+X-Preferences-Kind=project;
diff --git a/src/plugins/git/meson.build b/src/plugins/git/meson.build
index d08ba06c5..ad9ce6450 100644
--- a/src/plugins/git/meson.build
+++ b/src/plugins/git/meson.build
@@ -10,6 +10,7 @@ plugins_sources += files([
   'gbp-git-client.c',
   'gbp-git-dependency-updater.c',
   'gbp-git-pipeline-addin.c',
+  'gbp-git-preferences-addin.c',
   'gbp-git-progress.c',
   'gbp-git-submodule-stage.c',
   'gbp-git-tag.c',


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