[gnome-builder/wip/chergert/configview: 8/8] buildui: start on plugin for builtin build config



commit 8be9777f0aa07abe3da7437cd168105c21629e7e
Author: Christian Hergert <chergert redhat com>
Date:   Tue Sep 11 13:45:02 2018 -0700

    buildui: start on plugin for builtin build config

 src/libide/buildui/ide-build-config-view-addin.c | 156 +++++++++++++++++++++++
 src/libide/buildui/ide-build-config-view-addin.h |  31 +++++
 src/libide/buildui/ide-build-plugin.c            |   5 +
 src/libide/buildui/meson.build                   |   1 +
 src/libide/config/ide-config-view-addin.c        |   2 +-
 src/libide/config/ide-config-view.c              |  19 ++-
 6 files changed, 208 insertions(+), 6 deletions(-)
---
diff --git a/src/libide/buildui/ide-build-config-view-addin.c 
b/src/libide/buildui/ide-build-config-view-addin.c
new file mode 100644
index 000000000..c91766ef8
--- /dev/null
+++ b/src/libide/buildui/ide-build-config-view-addin.c
@@ -0,0 +1,156 @@
+/* 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)
+{
+}
diff --git a/src/libide/buildui/ide-build-config-view-addin.h 
b/src/libide/buildui/ide-build-config-view-addin.h
new file mode 100644
index 000000000..c69bc66a5
--- /dev/null
+++ b/src/libide/buildui/ide-build-config-view-addin.h
@@ -0,0 +1,31 @@
+/* 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
diff --git a/src/libide/buildui/ide-build-plugin.c b/src/libide/buildui/ide-build-plugin.c
index d31691c4e..f982bdfe5 100644
--- a/src/libide/buildui/ide-build-plugin.c
+++ b/src/libide/buildui/ide-build-plugin.c
@@ -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);
 }
diff --git a/src/libide/buildui/meson.build b/src/libide/buildui/meson.build
index 23a9e036a..78128fc3f 100644
--- a/src/libide/buildui/meson.build
+++ b/src/libide/buildui/meson.build
@@ -1,6 +1,7 @@
 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',
diff --git a/src/libide/config/ide-config-view-addin.c b/src/libide/config/ide-config-view-addin.c
index fa1ecd645..1062e9e3b 100644
--- a/src/libide/config/ide-config-view-addin.c
+++ b/src/libide/config/ide-config-view-addin.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);
 }
diff --git a/src/libide/config/ide-config-view.c b/src/libide/config/ide-config-view.c
index 1a2b3abeb..d39c96611 100644
--- a/src/libide/config/ide-config-view.c
+++ b/src/libide/config/ide-config-view.c
@@ -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"
@@ -74,6 +75,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)
@@ -87,6 +89,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);
@@ -102,6 +105,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:
@@ -121,6 +126,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:
@@ -161,11 +168,6 @@ static void
 ide_config_view_init (IdeConfigView *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
-
-  dzl_preferences_add_page (self->preferences, "general", _("General"), 0);
-  dzl_preferences_add_list_group (self->preferences, "general", "general", _("General"), GTK_SELECTION_NONE, 
0);
-  dzl_preferences_add_custom (self->preferences, "general", "general", g_object_new (GTK_TYPE_LABEL, 
"visible", TRUE, NULL), NULL, 0);
-  dzl_preferences_add_custom (self->preferences, "general", "general", g_object_new (GTK_TYPE_LABEL, 
"visible", TRUE, NULL), NULL, 0);
 }
 
 static void
@@ -178,6 +180,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));
@@ -197,6 +200,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));
@@ -219,6 +223,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));
@@ -230,6 +235,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));
 
@@ -245,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);
@@ -283,6 +290,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;
@@ -292,6 +300,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));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]