Commit 6a99877e authored by Christian Hergert's avatar Christian Hergert

newcomers: add newcomers plugin for project grid

This adds back the newcomers feature, but as a separate plugin
utilizing the new IdeGreeterSection plugin API.
parent a6d60d30
......@@ -53,6 +53,7 @@ option('with_meson_templates', type: 'boolean')
option('with_mingw', type: 'boolean')
option('with_mono', type: 'boolean')
option('with_notification', type: 'boolean')
option('with_newcomers', type: 'boolean')
option('with_npm', type: 'boolean')
option('with_phpize', type: 'boolean')
option('with_project_tree', type: 'boolean')
......
......@@ -173,6 +173,7 @@ src/plugins/jedi/jedi_plugin.py
src/plugins/meson/gbp-meson-build-system.c
src/plugins/meson-templates/meson_templates.py
src/plugins/mingw/ide-mingw-device-provider.c
src/plugins/newcomers/gbp-newcomers-section.ui
src/plugins/notification/ide-notification-addin.c
src/plugins/project-tree/gb-new-file-popover.c
src/plugins/project-tree/gb-new-file-popover.ui
......
......@@ -46,6 +46,7 @@ subdir('meson')
subdir('meson-templates')
subdir('mingw')
subdir('mono')
subdir('newcomers')
subdir('notification')
subdir('npm')
subdir('phpize')
......
/* gbp-newcomers-project.c
*
* Copyright (C) 2017 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/>.
*/
#define G_LOG_DOMAIN "gbp-newcomers-project"
#include "gbp-newcomers-project.h"
struct _GbpNewcomersProject
{
GtkFlowBoxChild parent_instance;
gchar *uri;
GtkLabel *label;
GtkImage *icon;
};
enum {
PROP_0,
PROP_ICON_NAME,
PROP_NAME,
PROP_URI,
N_PROPS
};
G_DEFINE_TYPE (GbpNewcomersProject, gbp_newcomers_project, GTK_TYPE_FLOW_BOX_CHILD)
static GParamSpec *properties [N_PROPS];
static void
gbp_newcomers_project_destroy (GtkWidget *widget)
{
GbpNewcomersProject *self = GBP_NEWCOMERS_PROJECT (widget);
g_clear_pointer (&self->uri, g_free);
GTK_WIDGET_CLASS (gbp_newcomers_project_parent_class)->destroy (widget);
}
static void
gbp_newcomers_project_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GbpNewcomersProject *self = GBP_NEWCOMERS_PROJECT (object);
switch (prop_id)
{
case PROP_URI:
g_value_set_string (value, gbp_newcomers_project_get_uri (self));
break;
case PROP_NAME:
g_value_set_string (value, gbp_newcomers_project_get_name (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gbp_newcomers_project_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GbpNewcomersProject *self = GBP_NEWCOMERS_PROJECT (object);
switch (prop_id)
{
case PROP_URI:
self->uri = g_value_dup_string (value);
break;
case PROP_NAME:
gtk_label_set_label (self->label, g_value_get_string (value));
break;
case PROP_ICON_NAME:
g_object_set (self->icon, "icon-name", g_value_get_string (value), NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gbp_newcomers_project_class_init (GbpNewcomersProjectClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->get_property = gbp_newcomers_project_get_property;
object_class->set_property = gbp_newcomers_project_set_property;
widget_class->destroy = gbp_newcomers_project_destroy;
properties [PROP_ICON_NAME] =
g_param_spec_string ("icon-name",
"Icon Name",
"The icon to load",
NULL,
(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
properties [PROP_NAME] =
g_param_spec_string ("name",
"Name",
"The name of the newcomer project",
NULL,
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
properties [PROP_URI] =
g_param_spec_string ("uri",
"Uri",
"The URL of the project's source code repository",
NULL,
(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,
"/org/gnome/builder/plugins/newcomers-plugin/gbp-newcomers-project.ui");
gtk_widget_class_bind_template_child (widget_class, GbpNewcomersProject, label);
gtk_widget_class_bind_template_child (widget_class, GbpNewcomersProject, icon);
}
static void
gbp_newcomers_project_init (GbpNewcomersProject *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
const gchar *
gbp_newcomers_project_get_name (GbpNewcomersProject *self)
{
g_return_val_if_fail (GBP_IS_NEWCOMERS_PROJECT (self), NULL);
return self->label ? gtk_label_get_label (self->label) : NULL;
}
const gchar *
gbp_newcomers_project_get_uri (GbpNewcomersProject *self)
{
g_return_val_if_fail (GBP_IS_NEWCOMERS_PROJECT (self), NULL);
return self->uri;
}
/* ide-newcomer-project.h
*
* Copyright (C) 2017 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/>.
*/
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GBP_TYPE_NEWCOMERS_PROJECT (gbp_newcomers_project_get_type())
G_DECLARE_FINAL_TYPE (GbpNewcomersProject, gbp_newcomers_project, GBP, NEWCOMERS_PROJECT, GtkFlowBoxChild)
const gchar *gbp_newcomers_project_get_name (GbpNewcomersProject *self);
const gchar *gbp_newcomers_project_get_uri (GbpNewcomersProject *self);
GIcon *gbp_newcomers_project_get_icon (GbpNewcomersProject *self);
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GbpNewcomersProject" parent="GtkFlowBoxChild">
<property name="border-width">12</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="expand">true</property>
<property name="spacing">6</property>
<property name="visible">true</property>
<child>
<object class="GtkImage" id="icon">
<property name="expand">true</property>
<property name="pixel-size">96</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="expand">true</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
</template>
</interface>
/* gbp-newcomers-section.c
*
* Copyright (C) 2017 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/>.
*/
#define G_LOG_DOMAIN "gbp-newcomers-section"
#include <ide.h>
#include "gbp-newcomers-project.h"
#include "gbp-newcomers-section.h"
struct _GbpNewcomersSection
{
GtkBin parent_instance;
GtkFlowBox *flowbox;
};
static gint
gbp_newcomers_section_get_priority (IdeGreeterSection *section)
{
return 100;
}
static void
gbp_newcomers_section_filter_child (GtkWidget *child,
gpointer user_data)
{
DzlPatternSpec *spec = user_data;
gboolean visible = TRUE;
g_assert (GBP_IS_NEWCOMERS_PROJECT (child));
if (spec != NULL)
{
const gchar *name;
name = gbp_newcomers_project_get_name (GBP_NEWCOMERS_PROJECT (child));
visible = dzl_pattern_spec_match (spec, name);
}
gtk_widget_set_visible (child, visible);
}
static void
gbp_newcomers_section_filter (IdeGreeterSection *section,
DzlPatternSpec *spec)
{
GbpNewcomersSection *self = (GbpNewcomersSection *)section;
g_assert (GBP_IS_NEWCOMERS_SECTION (self));
gtk_container_foreach (GTK_CONTAINER (self->flowbox),
gbp_newcomers_section_filter_child,
spec);
}
static void
greeter_section_iface_init (IdeGreeterSectionInterface *iface)
{
iface->get_priority = gbp_newcomers_section_get_priority;
iface->filter = gbp_newcomers_section_filter;
}
G_DEFINE_TYPE_WITH_CODE (GbpNewcomersSection, gbp_newcomers_section, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (IDE_TYPE_GREETER_SECTION,
greeter_section_iface_init))
static void
gbp_newcomers_section_child_activated (GbpNewcomersSection *self,
GbpNewcomersProject *project,
GtkFlowBox *flowbox)
{
g_autoptr(IdeProjectInfo) project_info = NULL;
g_autoptr(IdeVcsUri) vcs_uri = NULL;
const gchar *name;
const gchar *uri;
g_assert (GBP_IS_NEWCOMERS_SECTION (self));
g_assert (GBP_IS_NEWCOMERS_PROJECT (project));
g_assert (GTK_IS_FLOW_BOX (flowbox));
name = gbp_newcomers_project_get_name (project);
uri = gbp_newcomers_project_get_uri (project);
vcs_uri = ide_vcs_uri_new (uri);
project_info = g_object_new (IDE_TYPE_PROJECT_INFO,
"vcs-uri", vcs_uri,
"name", name,
NULL);
ide_greeter_section_emit_project_activated (IDE_GREETER_SECTION (self), project_info);
}
static void
gbp_newcomers_section_class_init (GbpNewcomersSectionClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_css_name (widget_class, "newcomers");
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/plugins/newcomers-plugin/gbp-newcomers-section.ui");
gtk_widget_class_bind_template_child (widget_class, GbpNewcomersSection, flowbox);
gtk_widget_class_bind_template_callback (widget_class, gbp_newcomers_section_child_activated);
g_type_ensure (GBP_TYPE_NEWCOMERS_PROJECT);
}
static void
gbp_newcomers_section_init (GbpNewcomersSection *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
/* gbp-newcomers-section.h
*
* Copyright (C) 2017 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/>.
*/
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GBP_TYPE_NEWCOMERS_SECTION (gbp_newcomers_section_get_type())
G_DECLARE_FINAL_TYPE (GbpNewcomersSection, gbp_newcomers_section, GBP, NEWCOMERS_SECTION, GtkBin)
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GbpNewcomersSection" parent="GtkBin">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="visible">true</property>
<child>
<object class="GtkLabel">
<property name="visible">true</property>
<property name="label" translatable="yes">Newcomer Projects</property>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkFlowBox" id="flowbox">
<property name="visible">true</property>
<property name="halign">center</property>
<property name="valign">start</property>
<property name="selection-mode">browse</property>
<property name="min-children-per-line">3</property>
<property name="max-children-per-line">5</property>
<signal name="child-activated" handler="gbp_newcomers_section_child_activated" swapped="true" object="GbpNewcomersSection"/>
<child>
<object class="GbpNewcomersProject">
<property name="name" translatable="yes">Polari</property>
<property name="icon-name">org.gnome.Polari</property>
<property name="uri">https://gitlab.gnome.org/GNOME/polari.git</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GbpNewcomersProject">
<property name="name" translatable="yes">Games</property>
<property name="icon-name">org.gnome.Games</property>
<property name="uri">https://git.gnome.org/browse/gnome-games</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GbpNewcomersProject">
<property name="name" translatable="yes">Maps</property>
<property name="icon-name">org.gnome.Maps</property>
<property name="uri">https://git.gnome.org/browse/gnome-maps</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GbpNewcomersProject">
<property name="name" translatable="yes">Todo</property>
<property name="icon-name">org.gnome.Todo</property>
<property name="uri">https://gitlab.gnome.org/GNOME/gnome-todo.git</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GbpNewcomersProject">
<property name="name" translatable="yes">Music</property>
<property name="icon-name">org.gnome.Music</property>
<property name="uri">https://git.gnome.org/browse/gnome-music</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GbpNewcomersProject">
<property name="name" translatable="yes">Nautilus</property>
<property name="icon-name">org.gnome.Nautilus</property>
<property name="uri">https://gitlab.gnome.org/GNOME/nautilus.git</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GbpNewcomersProject">
<property name="name" translatable="yes">Photos</property>
<property name="icon-name">org.gnome.Photos</property>
<property name="uri">https://git.gnome.org/browse/gnome-photos</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GbpNewcomersProject">
<property name="name" translatable="yes">Calendar</property>
<property name="icon-name">org.gnome.Calendar</property>
<property name="uri">https://git.gnome.org/browse/gnome-calendar.git</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
if get_option('with_newcomers')
newcomers_resources = gnome.compile_resources(
'newcomers-resources',
'newcomers.gresource.xml',
c_name: 'gbp_newcomers',
)
newcomers_sources = [
'newcomers-plugin.c',
'gbp-newcomers-project.c',
'gbp-newcomers-project.h',
'gbp-newcomers-section.c',
'gbp-newcomers-section.h',
]
gnome_builder_plugins_sources += files(newcomers_sources)
gnome_builder_plugins_sources += newcomers_resources[0]
endif
/* newcomers-plugin.c
*
* Copyright (C) 2017 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 <libpeas/peas.h>
#include <ide.h>
#include "gbp-newcomers-section.h"
void
gbp_newcomers_register_types (PeasObjectModule *module)
{
peas_object_module_register_extension_type (module,
IDE_TYPE_GREETER_SECTION,
GBP_TYPE_NEWCOMERS_SECTION);
}
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/builder/plugins">
<file>newcomers.plugin</file>
</gresource>
<gresource prefix="/org/gnome/builder/plugins/newcomers-plugin">
<file>gbp-newcomers-project.ui</file>
<file>gbp-newcomers-section.ui</file>
</gresource>
<!-- Icons used by the greeter for newcomer projects -->
<gresource prefix="/org/gnome/builder/icons">
<file alias="256x256/apps/org.gnome.Maps.png">icons/org.gnome.Maps.png</file>
<file alias="256x256/apps/org.gnome.Music.png">icons/org.gnome.Music.png</file>
<file alias="256x256/apps/org.gnome.Photos.png">icons/org.gnome.Photos.png</file>
<file alias="512x512/apps/org.gnome.Calendar.png">icons/org.gnome.Calendar.png</file>
<file alias="512x512/apps/org.gnome.Games.png">icons/org.gnome.Games.png</file>
<file alias="512x512/apps/org.gnome.Nautilus.png">icons/org.gnome.Nautilus.png</file>
<file alias="512x512/apps/org.gnome.Polari.png">icons/org.gnome.Polari.png</file>
<file alias="512x512/apps/org.gnome.Todo.png">icons/org.gnome.Todo.png</file>
</gresource>
</gresources>
[Plugin]
Module=newcomers-plugin
Name=GNOME Newcomers
Description=Integration with GNOME newcomers initiative
Authors=Christian Hergert <christian@hergert.me>
Copyright=Copyright © 2017 Christian Hergert
Builtin=true
Embedded=gbp_newcomers_register_types
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