[gnome-builder] plugins/git: add tweaks for user/email
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/git: add tweaks for user/email
- Date: Sat, 27 Aug 2022 09:12:02 +0000 (UTC)
commit 7b4835279eccb1420b135868e46c2c16c4cc63df
Author: Christian Hergert <chergert redhat com>
Date: Sat Aug 27 02:11:24 2022 -0700
plugins/git: add tweaks for user/email
src/libide/gui/tweaks.ui | 6 ++
src/plugins/git/gbp-git-tweaks-addin.c | 149 +++++++++++++++++++++++++++++++++
src/plugins/git/gbp-git-tweaks-addin.h | 31 +++++++
src/plugins/git/git-plugin.c | 4 +
src/plugins/git/git.gresource.xml | 1 +
src/plugins/git/meson.build | 1 +
src/plugins/git/tweaks.ui | 43 ++++++++++
7 files changed, 235 insertions(+)
---
diff --git a/src/libide/gui/tweaks.ui b/src/libide/gui/tweaks.ui
index 5c6332c27..8b3517d61 100644
--- a/src/libide/gui/tweaks.ui
+++ b/src/libide/gui/tweaks.ui
@@ -42,6 +42,12 @@
<property name="hidden-when">project</property>
</object>
</child>
+ <child>
+ <object class="IdeTweaksSection" id="vcs_section">
+ <property name="title">vcs</property>
+ <property name="hidden-when">app</property>
+ </object>
+ </child>
<child>
<object class="IdeTweaksSection" id="foundry_section">
<property name="title">foundry</property>
diff --git a/src/plugins/git/gbp-git-tweaks-addin.c b/src/plugins/git/gbp-git-tweaks-addin.c
new file mode 100644
index 000000000..85bdee20d
--- /dev/null
+++ b/src/plugins/git/gbp-git-tweaks-addin.c
@@ -0,0 +1,149 @@
+/* gbp-git-tweaks-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-tweaks-addin"
+
+#include "config.h"
+
+#include <libide-vcs.h>
+
+#include "gbp-git-tweaks-addin.h"
+#include "gbp-git-vcs.h"
+
+struct _GbpGitTweaksAddin
+{
+ IdeTweaksAddin parent_instance;
+ IdeVcsConfig *config;
+};
+
+G_DEFINE_FINAL_TYPE (GbpGitTweaksAddin, gbp_git_tweaks_addin, IDE_TYPE_TWEAKS_ADDIN)
+
+enum {
+ PROP_0,
+ PROP_AUTHOR,
+ PROP_EMAIL,
+ N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+gbp_git_tweaks_addin_load (IdeTweaksAddin *addin,
+ IdeTweaks *tweaks)
+{
+ GbpGitTweaksAddin *self = (GbpGitTweaksAddin *)addin;
+ IdeVcsConfig *config = NULL;
+ IdeContext *context = NULL;
+ IdeVcs *vcs = NULL;
+
+ g_assert (GBP_IS_GIT_TWEAKS_ADDIN (self));
+ g_assert (IDE_IS_TWEAKS (tweaks));
+
+ if ((context = ide_tweaks_get_context (tweaks)) &&
+ (vcs = ide_vcs_from_context (context)) &&
+ GBP_IS_GIT_VCS (vcs) &&
+ (config = ide_vcs_get_config (vcs)))
+ {
+ self->config = g_object_ref (config);
+ ide_tweaks_addin_set_resource_paths (IDE_TWEAKS_ADDIN (self),
+ IDE_STRV_INIT ("/plugins/git/tweaks.ui"));
+ }
+
+ IDE_TWEAKS_ADDIN_CLASS (gbp_git_tweaks_addin_parent_class)->load (addin, tweaks);
+}
+
+static void
+gbp_git_tweaks_addin_dispose (GObject *object)
+{
+ GbpGitTweaksAddin *self = (GbpGitTweaksAddin *)object;
+
+ g_clear_object (&self->config);
+
+ G_OBJECT_CLASS (gbp_git_tweaks_addin_parent_class)->dispose (object);
+}
+
+static void
+gbp_git_tweaks_addin_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbpGitTweaksAddin *self = GBP_GIT_TWEAKS_ADDIN (object);
+
+ switch (prop_id)
+ {
+ case PROP_AUTHOR:
+ ide_vcs_config_get_config (self->config, IDE_VCS_CONFIG_FULL_NAME, value);
+ break;
+
+ case PROP_EMAIL:
+ ide_vcs_config_get_config (self->config, IDE_VCS_CONFIG_EMAIL, value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gbp_git_tweaks_addin_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbpGitTweaksAddin *self = GBP_GIT_TWEAKS_ADDIN (object);
+
+ switch (prop_id)
+ {
+ case PROP_AUTHOR:
+ ide_vcs_config_set_config (self->config, IDE_VCS_CONFIG_FULL_NAME, value);
+ break;
+
+ case PROP_EMAIL:
+ ide_vcs_config_set_config (self->config, IDE_VCS_CONFIG_EMAIL, value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gbp_git_tweaks_addin_class_init (GbpGitTweaksAddinClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ IdeTweaksAddinClass *tweaks_addin_class = IDE_TWEAKS_ADDIN_CLASS (klass);
+
+ object_class->dispose = gbp_git_tweaks_addin_dispose;
+ object_class->get_property = gbp_git_tweaks_addin_get_property;
+ object_class->set_property = gbp_git_tweaks_addin_set_property;
+
+ tweaks_addin_class->load = gbp_git_tweaks_addin_load;
+
+ IDE_DEFINE_STRING_PROPERTY ("author", NULL, G_PARAM_READWRITE, AUTHOR);
+ IDE_DEFINE_STRING_PROPERTY ("email", NULL, G_PARAM_READWRITE, EMAIL);
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+gbp_git_tweaks_addin_init (GbpGitTweaksAddin *self)
+{
+}
diff --git a/src/plugins/git/gbp-git-tweaks-addin.h b/src/plugins/git/gbp-git-tweaks-addin.h
new file mode 100644
index 000000000..7f7e8b4ca
--- /dev/null
+++ b/src/plugins/git/gbp-git-tweaks-addin.h
@@ -0,0 +1,31 @@
+/* gbp-git-tweaks-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 <libide-tweaks.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_GIT_TWEAKS_ADDIN (gbp_git_tweaks_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpGitTweaksAddin, gbp_git_tweaks_addin, GBP, GIT_TWEAKS_ADDIN, IdeTweaksAddin)
+
+G_END_DECLS
diff --git a/src/plugins/git/git-plugin.c b/src/plugins/git/git-plugin.c
index d0d5fec05..fa1803f2c 100644
--- a/src/plugins/git/git-plugin.c
+++ b/src/plugins/git/git-plugin.c
@@ -31,6 +31,7 @@
#include "gbp-git-dependency-updater.h"
#include "gbp-git-pipeline-addin.h"
#include "gbp-git-preferences-addin.h"
+#include "gbp-git-tweaks-addin.h"
#include "gbp-git-vcs-cloner.h"
#include "gbp-git-vcs-config.h"
#include "gbp-git-vcs-initializer.h"
@@ -65,4 +66,7 @@ _gbp_git_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_PREFERENCES_ADDIN,
GBP_TYPE_GIT_PREFERENCES_ADDIN);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_TWEAKS_ADDIN,
+ GBP_TYPE_GIT_TWEAKS_ADDIN);
}
diff --git a/src/plugins/git/git.gresource.xml b/src/plugins/git/git.gresource.xml
index 73415c06f..4228d9587 100644
--- a/src/plugins/git/git.gresource.xml
+++ b/src/plugins/git/git.gresource.xml
@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/plugins/git">
<file>git.plugin</file>
+ <file preprocess="xml-stripblanks">tweaks.ui</file>
</gresource>
</gresources>
diff --git a/src/plugins/git/meson.build b/src/plugins/git/meson.build
index ad9ce6450..84be8da45 100644
--- a/src/plugins/git/meson.build
+++ b/src/plugins/git/meson.build
@@ -14,6 +14,7 @@ plugins_sources += files([
'gbp-git-progress.c',
'gbp-git-submodule-stage.c',
'gbp-git-tag.c',
+ 'gbp-git-tweaks-addin.c',
'gbp-git-vcs-cloner.c',
'gbp-git-vcs-config.c',
'gbp-git-vcs-initializer.c',
diff --git a/src/plugins/git/tweaks.ui b/src/plugins/git/tweaks.ui
new file mode 100644
index 000000000..b2476947d
--- /dev/null
+++ b/src/plugins/git/tweaks.ui
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="IdeTweaks">
+ <child internal-child="vcs_section">
+ <object class="IdeTweaksSection">
+ <child>
+ <object class="IdeTweaksPage" id="git_page">
+ <property name="hidden-when">app</property>
+ <property name="icon-name">builder-vcs-git-symbolic</property>
+ <property name="title" translatable="yes">Version Control</property>
+ <child>
+ <object class="IdeTweaksGroup">
+ <property name="title" translatable="yes">Authorship</property>
+ <child>
+ <object class="IdeTweaksEntry">
+ <property name="title" translatable="yes">Name</property>
+ <property name="binding">
+ <object class="IdeTweaksProperty">
+ <property name="object">GbpGitTweaksAddin</property>
+ <property name="name">author</property>
+ </object>
+ </property>
+ </object>
+ </child>
+ <child>
+ <object class="IdeTweaksEntry">
+ <property name="title" translatable="yes">Email</property>
+ <property name="binding">
+ <object class="IdeTweaksProperty">
+ <property name="object">GbpGitTweaksAddin</property>
+ <property name="name">email</property>
+ </object>
+ </property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]