[gnome-builder/wip/chergert/ls] ls: start on directory listing plugin
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/ls] ls: start on directory listing plugin
- Date: Wed, 31 Oct 2018 05:48:33 +0000 (UTC)
commit 921b35d46963839cd641de69a8bd4899a84b9aef
Author: Christian Hergert <chergert redhat com>
Date: Tue Oct 30 22:47:58 2018 -0700
ls: start on directory listing plugin
meson_options.txt | 1 +
src/plugins/ls/gbp-ls-plugin.c | 29 ++++++++
src/plugins/ls/gbp-ls-view.c | 142 ++++++++++++++++++++++++++++++++++++++++
src/plugins/ls/gbp-ls-view.h | 36 ++++++++++
src/plugins/ls/gbp-ls-view.ui | 16 +++++
src/plugins/ls/gtk/menus.ui | 3 +
src/plugins/ls/ls.gresource.xml | 10 +++
src/plugins/ls/ls.plugin | 9 +++
src/plugins/ls/meson.build | 17 +++++
src/plugins/meson.build | 2 +
10 files changed, 265 insertions(+)
---
diff --git a/meson_options.txt b/meson_options.txt
index ae5c8d73a..68fe4227c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -58,6 +58,7 @@ option('with_html_completion', type: 'boolean')
option('with_html_preview', type: 'boolean')
option('with_jedi', type: 'boolean')
option('with_jhbuild', type: 'boolean')
+option('with_ls', type: 'boolean')
option('with_make', type: 'boolean')
option('with_maven', type: 'boolean')
option('with_meson', type: 'boolean')
diff --git a/src/plugins/ls/gbp-ls-plugin.c b/src/plugins/ls/gbp-ls-plugin.c
new file mode 100644
index 000000000..d8a513ce2
--- /dev/null
+++ b/src/plugins/ls/gbp-ls-plugin.c
@@ -0,0 +1,29 @@
+/* gbp-ls-plugin.c
+ *
+ * Copyright © 2018 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
+ */
+
+#include "config.h"
+
+#include <libpeas/peas.h>
+#include <ide.h>
+
+void
+gbp_ls_register_types (PeasObjectModule *module)
+{
+}
diff --git a/src/plugins/ls/gbp-ls-view.c b/src/plugins/ls/gbp-ls-view.c
new file mode 100644
index 000000000..3b23aac79
--- /dev/null
+++ b/src/plugins/ls/gbp-ls-view.c
@@ -0,0 +1,142 @@
+/* gbp-ls-view.c
+ *
+ * Copyright © 2018 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
+ */
+
+#include "config.h"
+
+#define G_LOG_DOMAIN "gbp-ls-view"
+
+#include "gbp-ls-view.h"
+
+struct _GbpLsView
+{
+ IdeLayoutView parent_instance;
+
+ GtkScrolledWindow *scroller;
+ GtkTreeView *tree_view;
+};
+
+enum {
+ PROP_0,
+ PROP_DIRECTORY,
+ N_PROPS
+};
+
+G_DEFINE_TYPE (GbpLsView, gbp_ls_view, IDE_TYPE_LAYOUT_VIEW)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+gbp_ls_view_finalize (GObject *object)
+{
+ GbpLsView *self = (GbpLsView *)object;
+
+ G_OBJECT_CLASS (gbp_ls_view_parent_class)->finalize (object);
+}
+
+static void
+gbp_ls_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbpLsView *self = GBP_LS_VIEW (object);
+
+ switch (prop_id)
+ {
+ case PROP_DIRECTORY:
+ g_value_set_object (value, gbp_ls_view_get_directory (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gbp_ls_view_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbpLsView *self = GBP_LS_VIEW (object);
+
+ switch (prop_id)
+ {
+ case PROP_DIRECTORY:
+ gbp_ls_view_set_directory (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gbp_ls_view_class_init (GbpLsViewClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gbp_ls_view_finalize;
+ object_class->get_property = gbp_ls_view_get_property;
+ object_class->set_property = gbp_ls_view_set_property;
+
+ properties [PROP_DIRECTORY] =
+ g_param_spec_object ("directory",
+ "Directory",
+ "The directory to be displayed",
+ G_TYPE_FILE,
+ (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/plugins/ls/gbp-ls-view.ui");
+ gtk_widget_class_bind_template_child (widget_class, GbpLsView, scroller);
+ gtk_widget_class_bind_template_child (widget_class, GbpLsView, tree_view);
+}
+
+static void
+gbp_ls_view_init (GbpLsView *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+GtkWidget *
+gbp_ls_view_new (void)
+{
+ return g_object_new (GBP_TYPE_LS_VIEW, NULL);
+}
+
+GFile *
+gbp_ls_view_get_directory (GbpLsView *self)
+{
+ g_return_val_if_fail (GBP_IS_LS_VIEW (self), NULL);
+
+ return NULL;
+}
+
+void
+gbp_ls_view_set_directory (GbpLsView *self,
+ GFile *directory)
+{
+ g_return_if_fail (GBP_IS_LS_VIEW (self));
+ g_return_if_fail (!directory || G_IS_FILE (directory));
+
+}
diff --git a/src/plugins/ls/gbp-ls-view.h b/src/plugins/ls/gbp-ls-view.h
new file mode 100644
index 000000000..231004753
--- /dev/null
+++ b/src/plugins/ls/gbp-ls-view.h
@@ -0,0 +1,36 @@
+/* gbp-ls-view.h
+ *
+ * Copyright © 2018 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 <ide.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_LS_VIEW (gbp_ls_view_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpLsView, gbp_ls_view, GBP, LS_VIEW, IdeLayoutView)
+
+GtkWidget *gbp_ls_view_new (void);
+GFile *gbp_ls_view_get_directory (GbpLsView *self);
+void gbp_ls_view_set_directory (GbpLsView *self,
+ GFile *directory);
+
+G_END_DECLS
diff --git a/src/plugins/ls/gbp-ls-view.ui b/src/plugins/ls/gbp-ls-view.ui
new file mode 100644
index 000000000..2e816cb0f
--- /dev/null
+++ b/src/plugins/ls/gbp-ls-view.ui
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GbpLsView" parent="IdeLayoutView">
+ <child>
+ <object class="GtkScrolledWindow" id="scroller">
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkTreeView" id="tree_view">
+ <property name="headers-visible">true</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/plugins/ls/gtk/menus.ui b/src/plugins/ls/gtk/menus.ui
new file mode 100644
index 000000000..b2e03ef3a
--- /dev/null
+++ b/src/plugins/ls/gtk/menus.ui
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+</interface>
diff --git a/src/plugins/ls/ls.gresource.xml b/src/plugins/ls/ls.gresource.xml
new file mode 100644
index 000000000..b54e57438
--- /dev/null
+++ b/src/plugins/ls/ls.gresource.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/builder/plugins">
+ <file>ls.plugin</file>
+ </gresource>
+ <gresource prefix="/org/gnome/builder/plugins/ls">
+ <file preprocess="xml-stripblanks">gbp-ls-view.ui</file>
+ <file preprocess="xml-stripblanks">gtk/menus.ui</file>
+ </gresource>
+</gresources>
diff --git a/src/plugins/ls/ls.plugin b/src/plugins/ls/ls.plugin
new file mode 100644
index 000000000..18af04853
--- /dev/null
+++ b/src/plugins/ls/ls.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Module=ls
+Name=View Directory Listings
+Description=List files in a directory as a view
+Authors=Christian Hergert <christian hergert me>
+Copyright=Copyright © 2018 Christian Hergert
+Builtin=true
+Depends=editor;
+Embedded=gbp_ls_register_types
diff --git a/src/plugins/ls/meson.build b/src/plugins/ls/meson.build
new file mode 100644
index 000000000..b78c66b27
--- /dev/null
+++ b/src/plugins/ls/meson.build
@@ -0,0 +1,17 @@
+if get_option('with_ls')
+
+grep_resources = gnome.compile_resources(
+ 'ls-resources',
+ 'ls.gresource.xml',
+ c_name: 'gbp_ls',
+)
+
+grep_sources = [
+ 'gbp-ls-view.c',
+ 'gbp-ls-plugin.c',
+]
+
+gnome_builder_plugins_sources += files(grep_sources)
+gnome_builder_plugins_sources += grep_resources[0]
+
+endif
diff --git a/src/plugins/meson.build b/src/plugins/meson.build
index 76603122e..14e7061a1 100644
--- a/src/plugins/meson.build
+++ b/src/plugins/meson.build
@@ -43,6 +43,7 @@ subdir('html-completion')
subdir('html-preview')
subdir('jedi')
subdir('jhbuild')
+subdir('ls')
subdir('make')
subdir('maven')
subdir('meson')
@@ -129,6 +130,7 @@ status += [
'HTML Preview .......... : @0@'.format(get_option('with_html_preview')),
'Python Jedi ........... : @0@'.format(get_option('with_jedi')),
'JHBuild ............... : @0@'.format(get_option('with_jhbuild')),
+ 'Directory View ........ : @0@'.format(get_option('with_ls')),
'Make .................. : @0@'.format(get_option('with_make')),
'Maven.................. : @0@'.format(get_option('with_maven')),
'Meson ................. : @0@'.format(get_option('with_meson')),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]