[gnome-builder] libide/tweaks: add IdeTweaksInfo
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/tweaks: add IdeTweaksInfo
- Date: Wed, 24 Aug 2022 01:28:22 +0000 (UTC)
commit 45c2f92ae18ec1cbe9bd6a68cb0ad3e7dd57f4a3
Author: Christian Hergert <chergert redhat com>
Date: Tue Aug 23 18:28:00 2022 -0700
libide/tweaks: add IdeTweaksInfo
These are informational rows to present to the user.
src/libide/tweaks/ide-tweaks-info.c | 149 ++++++++++++++++++++++++++++++++++++
src/libide/tweaks/ide-tweaks-info.h | 49 ++++++++++++
src/libide/tweaks/ide-tweaks-init.c | 1 +
src/libide/tweaks/libide-tweaks.h | 1 +
src/libide/tweaks/meson.build | 2 +
5 files changed, 202 insertions(+)
---
diff --git a/src/libide/tweaks/ide-tweaks-info.c b/src/libide/tweaks/ide-tweaks-info.c
new file mode 100644
index 000000000..bdcb7a4ff
--- /dev/null
+++ b/src/libide/tweaks/ide-tweaks-info.c
@@ -0,0 +1,149 @@
+/* ide-tweaks-info.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 "ide-tweaks-info"
+
+#include "config.h"
+
+#include <adwaita.h>
+
+#include "ide-tweaks-info.h"
+
+struct _IdeTweaksInfo
+{
+ IdeTweaksWidget parent_instance;
+ char *title;
+ char *value;
+};
+
+enum {
+ PROP_0,
+ PROP_TITLE,
+ PROP_VALUE,
+ N_PROPS
+};
+
+G_DEFINE_FINAL_TYPE (IdeTweaksInfo, ide_tweaks_info, IDE_TYPE_TWEAKS_WIDGET)
+
+static GParamSpec *properties [N_PROPS];
+
+static GtkWidget *
+ide_tweaks_info_create_for_item (IdeTweaksWidget *widget,
+ IdeTweaksItem *for_item)
+{
+ IdeTweaksInfo *info = IDE_TWEAKS_INFO (for_item);
+ AdwActionRow *row;
+ GtkLabel *value;
+
+ value = g_object_new (GTK_TYPE_LABEL,
+ "xalign", 1.f,
+ "hexpand", TRUE,
+ "use-markup", FALSE,
+ "label", info->value,
+ "selectable", TRUE,
+ "wrap", TRUE,
+ NULL);
+ row = g_object_new (ADW_TYPE_ACTION_ROW,
+ "activatable", FALSE,
+ "title", info->title,
+ NULL);
+ adw_action_row_add_suffix (row, GTK_WIDGET (value));
+
+ return GTK_WIDGET (row);
+}
+
+static void
+ide_tweaks_info_dispose (GObject *object)
+{
+ IdeTweaksInfo *self = (IdeTweaksInfo *)object;
+
+ g_clear_pointer (&self->title, g_free);
+ g_clear_pointer (&self->value, g_free);
+
+ G_OBJECT_CLASS (ide_tweaks_info_parent_class)->dispose (object);
+}
+
+static void
+ide_tweaks_info_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ IdeTweaksInfo *self = IDE_TWEAKS_INFO (object);
+
+ switch (prop_id)
+ {
+ IDE_GET_PROPERTY_STRING (ide_tweaks_info, title, TITLE);
+ IDE_GET_PROPERTY_STRING (ide_tweaks_info, value, VALUE);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_tweaks_info_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IdeTweaksInfo *self = IDE_TWEAKS_INFO (object);
+
+ switch (prop_id)
+ {
+ IDE_SET_PROPERTY_STRING (ide_tweaks_info, title, TITLE);
+ IDE_SET_PROPERTY_STRING (ide_tweaks_info, value, VALUE);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_tweaks_info_class_init (IdeTweaksInfoClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ IdeTweaksWidgetClass *tweaks_widget_class = IDE_TWEAKS_WIDGET_CLASS (klass);
+
+ object_class->dispose = ide_tweaks_info_dispose;
+ object_class->get_property = ide_tweaks_info_get_property;
+ object_class->set_property = ide_tweaks_info_set_property;
+
+ tweaks_widget_class->create_for_item = ide_tweaks_info_create_for_item;
+
+ IDE_DEFINE_STRING_PROPERTY ("title", NULL, G_PARAM_READWRITE, TITLE);
+ IDE_DEFINE_STRING_PROPERTY ("value", NULL, G_PARAM_READWRITE, VALUE);
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+ide_tweaks_info_init (IdeTweaksInfo *self)
+{
+}
+
+IdeTweaksInfo *
+ide_tweaks_info_new (void)
+{
+ return g_object_new (IDE_TYPE_TWEAKS_INFO, NULL);
+}
+
+IDE_DEFINE_STRING_GETTER (ide_tweaks_info, IdeTweaksInfo, IDE_TYPE_TWEAKS_INFO, title)
+IDE_DEFINE_STRING_SETTER (ide_tweaks_info, IdeTweaksInfo, IDE_TYPE_TWEAKS_INFO, title, TITLE)
+IDE_DEFINE_STRING_GETTER (ide_tweaks_info, IdeTweaksInfo, IDE_TYPE_TWEAKS_INFO, value)
+IDE_DEFINE_STRING_SETTER (ide_tweaks_info, IdeTweaksInfo, IDE_TYPE_TWEAKS_INFO, value, VALUE)
diff --git a/src/libide/tweaks/ide-tweaks-info.h b/src/libide/tweaks/ide-tweaks-info.h
new file mode 100644
index 000000000..5e937dfe6
--- /dev/null
+++ b/src/libide/tweaks/ide-tweaks-info.h
@@ -0,0 +1,49 @@
+/* ide-tweaks-info.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
+
+#if !defined (IDE_TWEAKS_INSIDE) && !defined (IDE_TWEAKS_COMPILATION)
+# error "Only <libide-tweaks.h> can be included directly."
+#endif
+
+#include "ide-tweaks-widget.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_TWEAKS_INFO (ide_tweaks_info_get_type())
+
+IDE_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (IdeTweaksInfo, ide_tweaks_info, IDE, TWEAKS_INFO, IdeTweaksWidget)
+
+IDE_AVAILABLE_IN_ALL
+IdeTweaksInfo *ide_tweaks_info_new (void);
+IDE_AVAILABLE_IN_ALL
+const char *ide_tweaks_info_get_title (IdeTweaksInfo *self);
+IDE_AVAILABLE_IN_ALL
+void ide_tweaks_info_set_title (IdeTweaksInfo *self,
+ const char *title);
+IDE_AVAILABLE_IN_ALL
+const char *ide_tweaks_info_get_value (IdeTweaksInfo *self);
+IDE_AVAILABLE_IN_ALL
+void ide_tweaks_info_set_value (IdeTweaksInfo *self,
+ const char *value);
+
+G_END_DECLS
diff --git a/src/libide/tweaks/ide-tweaks-init.c b/src/libide/tweaks/ide-tweaks-init.c
index 67c98bd6b..cd59b1a20 100644
--- a/src/libide/tweaks/ide-tweaks-init.c
+++ b/src/libide/tweaks/ide-tweaks-init.c
@@ -41,6 +41,7 @@ _ide_tweaks_init (void)
g_type_ensure (IDE_TYPE_TWEAKS_FACTORY);
g_type_ensure (IDE_TYPE_TWEAKS_FONT);
g_type_ensure (IDE_TYPE_TWEAKS_GROUP);
+ g_type_ensure (IDE_TYPE_TWEAKS_INFO);
g_type_ensure (IDE_TYPE_TWEAKS_ITEM);
g_type_ensure (IDE_TYPE_TWEAKS_PAGE);
g_type_ensure (IDE_TYPE_TWEAKS_RADIO);
diff --git a/src/libide/tweaks/libide-tweaks.h b/src/libide/tweaks/libide-tweaks.h
index 10d866a76..79776ca9c 100644
--- a/src/libide/tweaks/libide-tweaks.h
+++ b/src/libide/tweaks/libide-tweaks.h
@@ -30,6 +30,7 @@
# include "ide-tweaks-factory.h"
# include "ide-tweaks-font.h"
# include "ide-tweaks-group.h"
+# include "ide-tweaks-info.h"
# include "ide-tweaks-item.h"
# include "ide-tweaks-page.h"
# include "ide-tweaks-radio.h"
diff --git a/src/libide/tweaks/meson.build b/src/libide/tweaks/meson.build
index d9a630ac2..a64d7f2e2 100644
--- a/src/libide/tweaks/meson.build
+++ b/src/libide/tweaks/meson.build
@@ -17,6 +17,7 @@ libide_tweaks_public_headers = [
'ide-tweaks-factory.h',
'ide-tweaks-font.h',
'ide-tweaks-group.h',
+ 'ide-tweaks-info.h',
'ide-tweaks-item.h',
'ide-tweaks-page.h',
'ide-tweaks-radio.h',
@@ -45,6 +46,7 @@ libide_tweaks_public_sources = [
'ide-tweaks-factory.c',
'ide-tweaks-font.c',
'ide-tweaks-group.c',
+ 'ide-tweaks-info.c',
'ide-tweaks-item.c',
'ide-tweaks-page.c',
'ide-tweaks-radio.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]