Commit 921b35d4 authored by Christian Hergert's avatar Christian Hergert

ls: start on directory listing plugin

parent e5e95707
Pipeline #38308 passed with stages
in 35 minutes and 12 seconds
......@@ -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')
......
/* 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)
{
}
/* 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));
}
/* 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
<?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>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
</interface>
<?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>
[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
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
......@@ -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')),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment