[gnome-builder/wip/chergert/perspective] prefs: start plumbing vcs attribution
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/perspective] prefs: start plumbing vcs attribution
- Date: Sat, 7 Nov 2015 11:46:41 +0000 (UTC)
commit eb7a17ef19d4bf61a0b3a3265f2415184992ff56
Author: Christian Hergert <chergert redhat com>
Date: Sat Nov 7 03:41:06 2015 -0800
prefs: start plumbing vcs attribution
We will likely need to determine how many of these widgets we want to
expose in public API. I didn't wnat to do any of them, but they might
be useful for the custom ones.
Especially when you have to integrate with external systems like git
configs.
data/theme/shared.css | 5 +
data/ui/ide-preferences-entry.ui | 25 +++++
libide/Makefile.am | 2 +
libide/preferences/ide-preferences-builtin.c | 25 +++++-
libide/preferences/ide-preferences-entry.c | 122 ++++++++++++++++++++++++++
libide/preferences/ide-preferences-entry.h | 39 ++++++++
libide/resources/libide.gresource.xml | 5 +-
7 files changed, 220 insertions(+), 3 deletions(-)
---
diff --git a/data/theme/shared.css b/data/theme/shared.css
index 304830f..3bba22e 100644
--- a/data/theme/shared.css
+++ b/data/theme/shared.css
@@ -195,3 +195,8 @@ workbench IdePreferencesPerspective IdePreferencesGroup row {
workbench IdePreferencesPerspective IdePreferencesGroup row:last-child {
border-bottom: none;
}
+
+workbench IdePreferencesContainer entry {
+ background: none;
+ opacity: 0.50;
+}
diff --git a/data/ui/ide-preferences-entry.ui b/data/ui/ide-preferences-entry.ui
new file mode 100644
index 0000000..446c8ac
--- /dev/null
+++ b/data/ui/ide-preferences-entry.ui
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.18 -->
+ <template class="IdePreferencesEntry" parent="IdePreferencesContainer">
+ <child>
+ <object class="GtkBox">
+ <property name="spacing">12</property>
+ <property name="orientation">horizontal</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkLabel" id="title">
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="has-frame">false</property>
+ <property name="hexpand">true</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 2f10411..e6a9797 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -274,6 +274,8 @@ libide_1_0_la_SOURCES = \
preferences/ide-preferences-builtin.h \
preferences/ide-preferences-container.c \
preferences/ide-preferences-container.h \
+ preferences/ide-preferences-entry.c \
+ preferences/ide-preferences-entry.h \
preferences/ide-preferences-font-button.c \
preferences/ide-preferences-font-button.h \
preferences/ide-preferences-group.c \
diff --git a/libide/preferences/ide-preferences-builtin.c b/libide/preferences/ide-preferences-builtin.c
index 6958004..181cb74 100644
--- a/libide/preferences/ide-preferences-builtin.c
+++ b/libide/preferences/ide-preferences-builtin.c
@@ -21,6 +21,7 @@
#include <libpeas/peas.h>
#include "ide-preferences-builtin.h"
+#include "ide-preferences-entry.h"
static void
ide_preferences_builtin_register_plugins (IdePreferences *preferences)
@@ -162,6 +163,28 @@ ide_preferences_builtin_register_snippets (IdePreferences *preferences)
ide_preferences_add_switch (preferences, "snippets", "completion", "org.gnome.builder.code-insight",
"snippet-completion", NULL, NULL, _("Suggest code snippets"), _("Improve your efficiency by using the current
word to suggest snippets"), NULL, 0);
}
+static void
+ide_preferences_builtin_register_vcs (IdePreferences *preferences)
+{
+ GtkWidget *author;
+ GtkWidget *email;
+
+ ide_preferences_add_page (preferences, "vcs", _("Version Control"), 600);
+
+ author = g_object_new (IDE_TYPE_PREFERENCES_ENTRY,
+ "title", "Author",
+ "visible", TRUE,
+ NULL);
+ email = g_object_new (IDE_TYPE_PREFERENCES_ENTRY,
+ "title", "Email",
+ "visible", TRUE,
+ NULL);
+
+ ide_preferences_add_list_group (preferences, "vcs", "attribution", _("Attribution"), 0);
+ ide_preferences_add_custom (preferences, "vcs", "attribution", author, NULL, 0);
+ ide_preferences_add_custom (preferences, "vcs", "attribution", email, NULL, 0);
+}
+
void
_ide_preferences_builtin_register (IdePreferences *preferences)
{
@@ -171,6 +194,6 @@ _ide_preferences_builtin_register (IdePreferences *preferences)
ide_preferences_builtin_register_code_insight (preferences);
ide_preferences_builtin_register_snippets (preferences);
ide_preferences_builtin_register_keyboard (preferences);
- ide_preferences_add_page (preferences, "vcs", _("Version Control"), 600);
+ ide_preferences_builtin_register_vcs (preferences);
ide_preferences_builtin_register_plugins (preferences);
}
diff --git a/libide/preferences/ide-preferences-entry.c b/libide/preferences/ide-preferences-entry.c
new file mode 100644
index 0000000..b684097
--- /dev/null
+++ b/libide/preferences/ide-preferences-entry.c
@@ -0,0 +1,122 @@
+/* ide-preferences-entry.c
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "ide-preferences-entry.h"
+
+typedef struct
+{
+ GtkEntry *entry;
+ GtkLabel *title;
+} IdePreferencesEntryPrivate;
+
+enum {
+ PROP_0,
+ PROP_TITLE,
+ PROP_TEXT,
+ LAST_PROP
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (IdePreferencesEntry, ide_preferences_entry, IDE_TYPE_PREFERENCES_CONTAINER)
+
+static GParamSpec *properties [LAST_PROP];
+
+static void
+ide_preferences_entry_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ IdePreferencesEntry *self = IDE_PREFERENCES_ENTRY (object);
+ IdePreferencesEntryPrivate *priv = ide_preferences_entry_get_instance_private (self);
+
+ switch (prop_id)
+ {
+ case PROP_TEXT:
+ g_value_set_string (value, gtk_entry_get_text (priv->entry));
+ break;
+
+ case PROP_TITLE:
+ g_value_set_string (value, gtk_label_get_text (priv->title));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_preferences_entry_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IdePreferencesEntry *self = IDE_PREFERENCES_ENTRY (object);
+ IdePreferencesEntryPrivate *priv = ide_preferences_entry_get_instance_private (self);
+
+ switch (prop_id)
+ {
+ case PROP_TEXT:
+ gtk_entry_set_text (priv->entry, g_value_get_string (value));
+ break;
+
+ case PROP_TITLE:
+ gtk_label_set_label (priv->title, g_value_get_string (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_preferences_entry_class_init (IdePreferencesEntryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = ide_preferences_entry_get_property;
+ object_class->set_property = ide_preferences_entry_set_property;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/ide-preferences-entry.ui");
+ gtk_widget_class_bind_template_child_private (widget_class, IdePreferencesEntry, entry);
+ gtk_widget_class_bind_template_child_private (widget_class, IdePreferencesEntry, title);
+
+ properties [PROP_TITLE] =
+ g_param_spec_string ("title",
+ "Title",
+ "Title",
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ properties [PROP_TEXT] =
+ g_param_spec_string ("text",
+ "Text",
+ "Text",
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, LAST_PROP, properties);
+}
+
+static void
+ide_preferences_entry_init (IdePreferencesEntry *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/libide/preferences/ide-preferences-entry.h b/libide/preferences/ide-preferences-entry.h
new file mode 100644
index 0000000..0a1dafb
--- /dev/null
+++ b/libide/preferences/ide-preferences-entry.h
@@ -0,0 +1,39 @@
+/* ide-preferences-entry.h
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+#ifndef IDE_PREFERENCES_ENTRY_H
+#define IDE_PREFERENCES_ENTRY_H
+
+#include <gtk/gtk.h>
+
+#include "ide-preferences-container.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_PREFERENCES_ENTRY (ide_preferences_entry_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (IdePreferencesEntry, ide_preferences_entry, IDE, PREFERENCES_ENTRY,
IdePreferencesContainer)
+
+struct _IdePreferencesEntryClass
+{
+ IdePreferencesContainerClass parent_class;
+};
+
+G_END_DECLS
+
+#endif /* IDE_PREFERENCES_ENTRY_H */
diff --git a/libide/resources/libide.gresource.xml b/libide/resources/libide.gresource.xml
index 24b9646..ad89009 100644
--- a/libide/resources/libide.gresource.xml
+++ b/libide/resources/libide.gresource.xml
@@ -25,12 +25,13 @@
<file alias="ui/ide-editor-perspective.ui">../../data/ui/ide-editor-perspective.ui</file>
<file alias="ui/ide-greeter-perspective.ui">../../data/ui/ide-greeter-perspective.ui</file>
<file alias="ui/ide-greeter-project-row.ui">../../data/ui/ide-greeter-project-row.ui</file>
+ <file alias="ui/ide-preferences-entry.ui">../../data/ui/ide-preferences-entry.ui</file>
<file alias="ui/ide-preferences-font-button.ui">../../data/ui/ide-preferences-font-button.ui</file>
+ <file alias="ui/ide-preferences-group.ui">../../data/ui/ide-preferences-group.ui</file>
<file alias="ui/ide-preferences-page.ui">../../data/ui/ide-preferences-page.ui</file>
<file alias="ui/ide-preferences-perspective.ui">../../data/ui/ide-preferences-perspective.ui</file>
- <file alias="ui/ide-preferences-group.ui">../../data/ui/ide-preferences-group.ui</file>
<file alias="ui/ide-preferences-switch.ui">../../data/ui/ide-preferences-switch.ui</file>
- <file alias="ui/ide-workbench.ui">../../data/ui/ide-workbench.ui</file>
<file alias="ui/ide-workbench-header-bar.ui">../../data/ui/ide-workbench-header-bar.ui</file>
+ <file alias="ui/ide-workbench.ui">../../data/ui/ide-workbench.ui</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]