[gnome-builder] prefs: move vcs prefs to builtin
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] prefs: move vcs prefs to builtin
- Date: Tue, 28 Jun 2016 05:08:13 +0000 (UTC)
commit 12bc151e6f02b3b714a98fd84df7e2cce563fd08
Author: Akshaya Kakkilaya <akshaya kakkilaya gmail com>
Date: Mon Jun 27 22:19:38 2016 +0530
prefs: move vcs prefs to builtin
https://bugzilla.gnome.org/show_bug.cgi?id=768106
libide/preferences/ide-preferences-builtin.c | 128 ++++++++++++++++++
plugins/git/Makefile.am | 2 -
plugins/git/ide-git-plugin.c | 4 -
plugins/git/ide-git-preferences-addin.c | 185 --------------------------
plugins/git/ide-git-preferences-addin.h | 32 -----
5 files changed, 128 insertions(+), 223 deletions(-)
---
diff --git a/libide/preferences/ide-preferences-builtin.c b/libide/preferences/ide-preferences-builtin.c
index acbc665..54c6c5d 100644
--- a/libide/preferences/ide-preferences-builtin.c
+++ b/libide/preferences/ide-preferences-builtin.c
@@ -29,6 +29,7 @@
#include "preferences/ide-preferences-entry.h"
#include "preferences/ide-preferences-language-row.h"
#include "preferences/ide-preferences-spin-button.h"
+#include "vcs/ide-vcs-config.h"
static void
ide_preferences_builtin_register_plugins (IdePreferences *preferences)
@@ -320,6 +321,132 @@ ide_preferences_builtin_register_projects (IdePreferences *preferences)
ide_preferences_add_switch (preferences, "projects", "discovery", "org.gnome.builder",
"enable-project-miners", NULL, NULL, _("Discover projects on my computer"), _("Scan your computer for
existing projects"), NULL, 0);
}
+static void
+author_changed_cb (IdePreferencesEntry *entry,
+ const gchar *text,
+ IdeVcsConfig *conf)
+{
+ GValue value = G_VALUE_INIT;
+
+ g_assert (IDE_IS_PREFERENCES_ENTRY (entry));
+ g_assert (text != NULL);
+ g_assert (IDE_IS_VCS_CONFIG (conf));
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, text);
+
+ ide_vcs_config_set_config (conf, IDE_VCS_CONFIG_FULL_NAME, &value);
+
+ g_value_unset (&value);
+}
+
+static void
+email_changed_cb (IdePreferencesEntry *entry,
+ const gchar *text,
+ IdeVcsConfig *conf)
+{
+ GValue value = G_VALUE_INIT;
+
+ g_assert (IDE_IS_PREFERENCES_ENTRY (entry));
+ g_assert (text != NULL);
+ g_assert (IDE_IS_VCS_CONFIG (conf));
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, text);
+
+ ide_vcs_config_set_config (conf, IDE_VCS_CONFIG_EMAIL, &value);
+
+ g_value_unset (&value);
+}
+
+static void
+vcs_configs_foreach_cb (PeasExtensionSet *set,
+ PeasPluginInfo *plugin_info,
+ PeasExtension *exten,
+ gpointer user_data)
+{
+ IdePreferences *preferences = user_data;
+ IdeVcsConfig *conf = (IdeVcsConfig *)exten;
+ GValue value = G_VALUE_INIT;
+ GtkWidget *fullname;
+ GtkWidget *email;
+ GtkSizeGroup *size_group;
+ g_autofree gchar *key = NULL;
+ g_autofree gchar *author_name = NULL;
+ g_autofree gchar *author_email = NULL;
+ const gchar *name;
+ const gchar *id;
+
+ g_assert (PEAS_IS_EXTENSION_SET (set));
+ g_assert (IDE_IS_PREFERENCES (preferences));
+ g_assert (IDE_IS_VCS_CONFIG (conf));
+
+ name = peas_plugin_info_get_name (plugin_info);
+ id = peas_plugin_info_get_module_name (plugin_info);
+ key = g_strdup_printf ("%s-config", id);
+
+ g_object_set_data_full (G_OBJECT (preferences), key, g_object_ref (conf), g_object_unref);
+
+ g_value_init (&value, G_TYPE_STRING);
+
+ ide_vcs_config_get_config (conf, IDE_VCS_CONFIG_FULL_NAME, &value);
+ author_name = g_strdup (g_value_get_string (&value));
+
+ g_value_reset (&value);
+
+ ide_vcs_config_get_config (conf, IDE_VCS_CONFIG_EMAIL, &value);
+ author_email = g_strdup (g_value_get_string (&value));
+
+ g_value_unset (&value);
+
+ fullname = g_object_new (IDE_TYPE_PREFERENCES_ENTRY,
+ "text", ide_str_empty0 (author_name) ? "" : author_name,
+ "title", "Author",
+ "visible", TRUE,
+ NULL);
+
+ g_signal_connect_object (fullname,
+ "changed",
+ G_CALLBACK (author_changed_cb),
+ conf,
+ 0);
+
+ email = g_object_new (IDE_TYPE_PREFERENCES_ENTRY,
+ "text", ide_str_empty0 (author_email) ? "" : author_email,
+ "title", "Email",
+ "visible", TRUE,
+ NULL);
+
+ g_signal_connect_object (email,
+ "changed",
+ G_CALLBACK (email_changed_cb),
+ conf,
+ 0);
+
+ ide_preferences_add_list_group (preferences, "vcs", id, name, 0);
+ ide_preferences_add_custom (preferences, "vcs", id, fullname, NULL, 0);
+ ide_preferences_add_custom (preferences, "vcs", id, email, NULL, 0);
+
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ gtk_size_group_add_widget (size_group, ide_preferences_entry_get_title_widget (IDE_PREFERENCES_ENTRY
(fullname)));
+ gtk_size_group_add_widget (size_group, ide_preferences_entry_get_title_widget (IDE_PREFERENCES_ENTRY
(email)));
+ g_clear_object (&size_group);
+}
+
+static void
+ide_preferences_builtin_register_vcs (IdePreferences *preferences)
+{
+ PeasEngine *engine;
+ PeasExtensionSet *extensions;
+
+ ide_preferences_add_page (preferences, "vcs", _("Version Control"), 600);
+
+ engine = peas_engine_get_default ();
+ extensions = peas_extension_set_new (engine, IDE_TYPE_VCS_CONFIG, NULL);
+ peas_extension_set_foreach (extensions, vcs_configs_foreach_cb, preferences);
+ g_clear_object (&extensions);
+}
+
void
_ide_preferences_builtin_register (IdePreferences *preferences)
{
@@ -332,4 +459,5 @@ _ide_preferences_builtin_register (IdePreferences *preferences)
ide_preferences_builtin_register_plugins (preferences);
ide_preferences_builtin_register_build (preferences);
ide_preferences_builtin_register_projects (preferences);
+ ide_preferences_builtin_register_vcs (preferences);
}
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index f313fd9..49ab936 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -17,8 +17,6 @@ libgit_plugin_la_SOURCES = \
ide-git-genesis-addin.c \
ide-git-genesis-addin.h \
ide-git-plugin.c \
- ide-git-preferences-addin.c \
- ide-git-preferences-addin.h \
ide-git-remote-callbacks.c \
ide-git-remote-callbacks.h \
ide-git-vcs.c \
diff --git a/plugins/git/ide-git-plugin.c b/plugins/git/ide-git-plugin.c
index bfaaac9..e8b5c6a 100644
--- a/plugins/git/ide-git-plugin.c
+++ b/plugins/git/ide-git-plugin.c
@@ -20,7 +20,6 @@
#include <ide.h>
#include "ide-git-genesis-addin.h"
-#include "ide-git-preferences-addin.h"
#include "ide-git-vcs.h"
#include "ide-git-vcs-config.h"
#include "ide-git-vcs-initializer.h"
@@ -65,9 +64,6 @@ peas_register_types (PeasObjectModule *module)
IDE_TYPE_VCS_INITIALIZER,
IDE_TYPE_GIT_VCS_INITIALIZER);
peas_object_module_register_extension_type (module,
- IDE_TYPE_PREFERENCES_ADDIN,
- IDE_TYPE_GIT_PREFERENCES_ADDIN);
- peas_object_module_register_extension_type (module,
IDE_TYPE_GENESIS_ADDIN,
IDE_TYPE_GIT_GENESIS_ADDIN);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]