[gnome-builder/wip/gtk4-port: 1467/1774] plugins/shellcmd: start on dedicated list widget
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1467/1774] plugins/shellcmd: start on dedicated list widget
- Date: Mon, 11 Jul 2022 22:31:46 +0000 (UTC)
commit 7f2f11c1cbacfb485b97b2bacc9752c93ed4e360
Author: Christian Hergert <chergert redhat com>
Date: Fri Jun 10 17:52:19 2022 -0700
plugins/shellcmd: start on dedicated list widget
src/plugins/shellcmd/gbp-shellcmd-list.c | 126 +++++++++++++++++++++
src/plugins/shellcmd/gbp-shellcmd-list.h | 33 ++++++
src/plugins/shellcmd/gbp-shellcmd-list.ui | 39 +++++++
.../shellcmd/gbp-shellcmd-preferences-addin.c | 5 +-
src/plugins/shellcmd/meson.build | 1 +
src/plugins/shellcmd/shellcmd.gresource.xml | 1 +
6 files changed, 204 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/shellcmd/gbp-shellcmd-list.c b/src/plugins/shellcmd/gbp-shellcmd-list.c
new file mode 100644
index 000000000..bac1009c2
--- /dev/null
+++ b/src/plugins/shellcmd/gbp-shellcmd-list.c
@@ -0,0 +1,126 @@
+/* gbp-shellcmd-list.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-shellcmd-list"
+
+#include "config.h"
+
+#include "gbp-shellcmd-list.h"
+
+struct _GbpShellcmdList
+{
+ GtkWidget parent_instance;
+
+ GSettings *settings;
+
+ GtkListView *list_view;
+ GtkStack *stack;
+};
+
+enum {
+ PROP_0,
+ PROP_SETTINGS,
+ N_PROPS
+};
+
+G_DEFINE_FINAL_TYPE (GbpShellcmdList, gbp_shellcmd_list, GTK_TYPE_WIDGET)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+gbp_shellcmd_list_dispose (GObject *object)
+{
+ GbpShellcmdList *self = (GbpShellcmdList *)object;
+
+ g_clear_pointer ((GtkWidget **)&self->stack, gtk_widget_unparent);
+
+ g_clear_object (&self->settings);
+
+ G_OBJECT_CLASS (gbp_shellcmd_list_parent_class)->dispose (object);
+}
+
+static void
+gbp_shellcmd_list_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbpShellcmdList *self = GBP_SHELLCMD_LIST (object);
+
+ switch (prop_id)
+ {
+ case PROP_SETTINGS:
+ g_value_set_object (value, self->settings);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gbp_shellcmd_list_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbpShellcmdList *self = GBP_SHELLCMD_LIST (object);
+
+ switch (prop_id)
+ {
+ case PROP_SETTINGS:
+ self->settings = g_value_dup_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gbp_shellcmd_list_class_init (GbpShellcmdListClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->dispose = gbp_shellcmd_list_dispose;
+ object_class->get_property = gbp_shellcmd_list_get_property;
+ object_class->set_property = gbp_shellcmd_list_set_property;
+
+ properties [PROP_SETTINGS] =
+ g_param_spec_object ("settings", NULL, NULL,
+ G_TYPE_SETTINGS,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/plugins/shellcmd/gbp-shellcmd-list.ui");
+ gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
+ gtk_widget_class_bind_template_child (widget_class, GbpShellcmdList, list_view);
+ gtk_widget_class_bind_template_child (widget_class, GbpShellcmdList, stack);
+}
+
+static void
+gbp_shellcmd_list_init (GbpShellcmdList *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/plugins/shellcmd/gbp-shellcmd-list.h b/src/plugins/shellcmd/gbp-shellcmd-list.h
new file mode 100644
index 000000000..9e54442cb
--- /dev/null
+++ b/src/plugins/shellcmd/gbp-shellcmd-list.h
@@ -0,0 +1,33 @@
+/* gbp-shellcmd-list.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 <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_SHELLCMD_LIST (gbp_shellcmd_list_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpShellcmdList, gbp_shellcmd_list, GBP, SHELLCMD_LIST, GtkWidget)
+
+GbpShellcmdList *gbp_shellcmd_list_new (GSettings *settings);
+
+G_END_DECLS
diff --git a/src/plugins/shellcmd/gbp-shellcmd-list.ui b/src/plugins/shellcmd/gbp-shellcmd-list.ui
new file mode 100644
index 000000000..1d8e5c738
--- /dev/null
+++ b/src/plugins/shellcmd/gbp-shellcmd-list.ui
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GbpShellcmdList" parent="GtkWidget">
+ <child>
+ <object class="GtkStack" id="stack">
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">empty</property>
+ <property name="child">
+ <object class="GtkListBox">
+ <style>
+ <class name="boxed-list"/>
+ </style>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">No Commands</property>
+ <property name="sensitive">false</property>
+ </object>
+ </child>
+ </object>
+ </property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">list</property>
+ <property name="child">
+ <object class="GtkListView" id="list_view">
+ <style>
+ <class name="boxed-list"/>
+ </style>
+ </object>
+ </property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/plugins/shellcmd/gbp-shellcmd-preferences-addin.c
b/src/plugins/shellcmd/gbp-shellcmd-preferences-addin.c
index 9931ca9f1..d970afd2c 100644
--- a/src/plugins/shellcmd/gbp-shellcmd-preferences-addin.c
+++ b/src/plugins/shellcmd/gbp-shellcmd-preferences-addin.c
@@ -26,6 +26,7 @@
#include <libide-gui.h>
+#include "gbp-shellcmd-list.h"
#include "gbp-shellcmd-preferences-addin.h"
struct _GbpShellcmdPreferencesAddin
@@ -56,7 +57,9 @@ handle_shellcmd_list (const char *page_name,
"css-classes", IDE_STRV_INIT ("flat"),
NULL));
- adw_preferences_group_add (group, gtk_label_new ("empty"));
+ adw_preferences_group_add (group,
+ g_object_new (GBP_TYPE_SHELLCMD_LIST,
+ NULL));
IDE_EXIT;
}
diff --git a/src/plugins/shellcmd/meson.build b/src/plugins/shellcmd/meson.build
index cecc199aa..75abde37c 100644
--- a/src/plugins/shellcmd/meson.build
+++ b/src/plugins/shellcmd/meson.build
@@ -2,6 +2,7 @@ if get_option('plugin_shellcmd')
plugins_sources += files([
'shellcmd-plugin.c',
+ 'gbp-shellcmd-list.c',
'gbp-shellcmd-preferences-addin.c',
'gbp-shellcmd-run-command.c',
'gbp-shellcmd-run-command-provider.c',
diff --git a/src/plugins/shellcmd/shellcmd.gresource.xml b/src/plugins/shellcmd/shellcmd.gresource.xml
index 4af547c31..acb44fae4 100644
--- a/src/plugins/shellcmd/shellcmd.gresource.xml
+++ b/src/plugins/shellcmd/shellcmd.gresource.xml
@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/plugins/shellcmd">
<file>shellcmd.plugin</file>
+ <file preprocess="xml-stripblanks">gbp-shellcmd-list.ui</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]