Commit 609037fc authored by Christian Hergert's avatar Christian Hergert

buildui: start on plugin for builtin build config

parent 5910952a
Pipeline #32370 passed with stages
in 32 minutes
/* ide-build-config-view-addin.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 "ide-build-config-view-addin"
#include <glib/gi18n.h>
#include "ide-context.h"
#include "buildsystem/ide-build-system.h"
#include "config/ide-config-view-addin.h"
#include "buildui/ide-build-config-view-addin.h"
#include "runtimes/ide-runtime-manager.h"
#include "threading/ide-task.h"
#include "vcs/ide-vcs.h"
struct _IdeBuildConfigViewAddin
{
IdeObject parent_instance;
};
static void
add_description_row (DzlPreferences *preferences,
const gchar *page,
const gchar *group,
const gchar *title,
const gchar *value)
{
GtkWidget *widget;
g_assert (DZL_IS_PREFERENCES (preferences));
g_assert (title);
g_assert (value);
widget = g_object_new (GTK_TYPE_LABEL,
"xalign", 0.0f,
"label", title,
"visible", TRUE,
"margin-right", 12,
NULL);
dzl_gtk_widget_add_style_class (widget, "dim-label");
dzl_preferences_add_table_row (preferences, page, group, widget,
g_object_new (GTK_TYPE_LABEL,
"hexpand", TRUE,
"label", value,
"xalign", 0.0f,
"visible", TRUE,
NULL),
NULL);
}
static void
ide_build_config_view_addin_load_async (IdeConfigViewAddin *addin,
DzlPreferences *preferences,
IdeConfiguration *config,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
IdeBuildConfigViewAddin *self = (IdeBuildConfigViewAddin *)addin;
g_autoptr(DzlListModelFilter) filter = NULL;
g_autoptr(IdeTask) task = NULL;
IdeRuntimeManager *runtime_manager;
IdeBuildSystem *build_system;
IdeContext *context;
IdeVcs *vcs;
GFile *workdir;
g_assert (IDE_IS_BUILD_CONFIG_VIEW_ADDIN (addin));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, ide_build_config_view_addin_load_async);
/* Get our manager objects */
context = ide_object_get_context (IDE_OBJECT (self));
runtime_manager = ide_context_get_runtime_manager (context);
build_system = ide_context_get_build_system (context);
vcs = ide_context_get_vcs (context);
workdir = ide_vcs_get_working_directory (vcs);
/* Add our pages */
dzl_preferences_add_page (preferences, "general", _("General"), 0);
/* Add groups to pages */
dzl_preferences_add_list_group (preferences, "general", "general", _("General"), GTK_SELECTION_NONE, 0);
/* Add description info */
add_description_row (preferences, "general", "general", _("Source Directory"), g_file_peek_path (workdir));
add_description_row (preferences, "general", "general", _("Build System"), ide_build_system_get_display_name (build_system));
add_description_row (preferences, "general", "general", _("Prefix"), "/app");
/* Setup runtime selection */
dzl_preferences_add_list_group (preferences, "general", "runtime", _("Application Runtime"), GTK_SELECTION_NONE, 0);
filter = dzl_list_model_filter_new (G_LIST_MODEL (runtime_manager));
#if 0
dzl_preferences_add_list_group (preferences, "general", "general", _("General"), GTK_SELECTION_NONE, 0);
dzl_preferences_add_custom (preferences, "general", "general", g_object_new (GTK_TYPE_LABEL, "visible", TRUE, NULL), NULL, 0);
dzl_preferences_add_custom (preferences, "general", "general", g_object_new (GTK_TYPE_LABEL, "visible", TRUE, NULL), NULL, 0);
#endif
ide_task_return_boolean (task, TRUE);
}
static gboolean
ide_build_config_view_addin_load_finish (IdeConfigViewAddin *addin,
GAsyncResult *result,
GError **error)
{
g_assert (IDE_IS_BUILD_CONFIG_VIEW_ADDIN (addin));
g_assert (IDE_IS_TASK (result));
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
static void
config_view_addin_iface_init (IdeConfigViewAddinInterface *iface)
{
iface->load_async = ide_build_config_view_addin_load_async;
iface->load_finish = ide_build_config_view_addin_load_finish;
}
G_DEFINE_TYPE_WITH_CODE (IdeBuildConfigViewAddin, ide_build_config_view_addin, IDE_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (IDE_TYPE_CONFIG_VIEW_ADDIN,
config_view_addin_iface_init))
static void
ide_build_config_view_addin_class_init (IdeBuildConfigViewAddinClass *klass)
{
}
static void
ide_build_config_view_addin_init (IdeBuildConfigViewAddin *self)
{
}
/* ide-build-config-view-addin.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 <glib-object.h>
G_BEGIN_DECLS
#define IDE_TYPE_BUILD_CONFIG_VIEW_ADDIN (ide_build_config_view_addin_get_type())
G_DECLARE_FINAL_TYPE (IdeBuildConfigViewAddin, ide_build_config_view_addin, IDE, BUILD_CONFIG_VIEW_ADDIN, IdeObject)
G_END_DECLS
......@@ -23,6 +23,8 @@
#include "object-modules.h"
#include "buildui/ide-build-workbench-addin.h"
#include "buildui/ide-build-config-view-addin.h"
#include "config/ide-config-view-addin.h"
#include "workbench/ide-workbench-addin.h"
void
......@@ -31,4 +33,7 @@ ide_build_tool_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_WORKBENCH_ADDIN,
IDE_TYPE_BUILD_WORKBENCH_ADDIN);
peas_object_module_register_extension_type (module,
IDE_TYPE_CONFIG_VIEW_ADDIN,
IDE_TYPE_BUILD_CONFIG_VIEW_ADDIN);
}
buildui_private_sources = [
'ide-build-configuration-row.c',
'ide-build-configuration-view.c',
'ide-build-config-view-addin.c',
'ide-build-log-panel.c',
'ide-build-panel.c',
'ide-build-perspective.c',
......
......@@ -112,7 +112,7 @@ ide_config_view_addin_load_finish (IdeConfigViewAddin *self,
GError **error)
{
g_return_val_if_fail (IDE_IS_CONFIG_VIEW_ADDIN (self), FALSE);
g_return_val_if_fail (G_IS_TASK (result), FALSE);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
return IDE_CONFIG_VIEW_ADDIN_GET_IFACE (self)->load_finish (self, result, error);
}
......
......@@ -25,6 +25,7 @@
#include <glib/gi18n.h>
#include <libpeas/peas.h>
#include "application/ide-application.h"
#include "config/ide-config-view.h"
#include "config/ide-config-view-addin.h"
#include "util/ide-gtk.h"
......@@ -73,6 +74,7 @@ ide_config_view_destroy (GtkWidget *widget)
{
IdeConfigView *self = (IdeConfigView *)widget;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (IDE_IS_CONFIG_VIEW (self));
if (self->config)
......@@ -86,6 +88,7 @@ ide_config_view_finalize (GObject *object)
{
IdeConfigView *self = (IdeConfigView *)object;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (self->addins == NULL);
g_assert (self->config == NULL);
g_assert (self->cancellable == NULL);
......@@ -101,6 +104,8 @@ ide_config_view_get_property (GObject *object,
{
IdeConfigView *self = IDE_CONFIG_VIEW (object);
g_assert (IDE_IS_MAIN_THREAD ());
switch (prop_id)
{
case PROP_CONFIG:
......@@ -120,6 +125,8 @@ ide_config_view_set_property (GObject *object,
{
IdeConfigView *self = IDE_CONFIG_VIEW (object);
g_assert (IDE_IS_MAIN_THREAD ());
switch (prop_id)
{
case PROP_CONFIG:
......@@ -168,6 +175,7 @@ ide_config_view_load_cb (GObject *object,
g_autoptr(GError) error = NULL;
IdeContext *context;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (IDE_IS_CONFIG_VIEW_ADDIN (addin));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (IDE_IS_CONFIG_VIEW (self));
......@@ -187,6 +195,7 @@ ide_config_view_addin_added_cb (PeasExtensionSet *set,
IdeConfigViewAddin *addin = (IdeConfigViewAddin *)exten;
IdeConfigView *self = user_data;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (PEAS_IS_EXTENSION_SET (set));
g_assert (plugin_info != NULL);
g_assert (IDE_IS_CONFIG_VIEW_ADDIN (addin));
......@@ -210,6 +219,7 @@ ide_config_view_addin_removed_cb (PeasExtensionSet *set,
IdeConfigViewAddin *addin = (IdeConfigViewAddin *)exten;
IdeConfigView *self = user_data;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (PEAS_IS_EXTENSION_SET (set));
g_assert (plugin_info != NULL);
g_assert (IDE_IS_CONFIG_VIEW_ADDIN (addin));
......@@ -222,6 +232,7 @@ ide_config_view_addin_removed_cb (PeasExtensionSet *set,
static void
ide_config_view_disconnect (IdeConfigView *self)
{
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (IDE_IS_CONFIG_VIEW (self));
g_assert (IDE_IS_CONFIGURATION (self->config));
......@@ -240,6 +251,7 @@ ide_config_view_connect (IdeConfigView *self,
{
IdeContext *context;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (IDE_IS_CONFIG_VIEW (self));
g_assert (IDE_IS_CONFIGURATION (config));
g_assert (self->cancellable == NULL);
......@@ -288,6 +300,7 @@ ide_config_view_connect (IdeConfigView *self,
IdeConfiguration *
ide_config_view_get_config (IdeConfigView *self)
{
g_return_val_if_fail (IDE_IS_MAIN_THREAD (), NULL);
g_return_val_if_fail (IDE_IS_CONFIG_VIEW (self), NULL);
return self->config;
......@@ -297,6 +310,7 @@ void
ide_config_view_set_config (IdeConfigView *self,
IdeConfiguration *config)
{
g_return_if_fail (IDE_IS_MAIN_THREAD ());
g_return_if_fail (IDE_IS_CONFIG_VIEW (self));
g_return_if_fail (!config || IDE_IS_CONFIGURATION (config));
......
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