Commit 83d4109d authored by Christian Hergert's avatar Christian Hergert
Browse files

config: remove IdeConfiguration:device

Now that we track selected device externally, we can drop the device from
the IdeConfiguration.
parent 51b5a0e4
......@@ -202,7 +202,6 @@ ide_buildconfig_configuration_provider_create (IdeBuildconfigConfigurationProvid
NULL);
load_string (config, self->key_file, config_id, "config-opts", "config-opts");
load_string (config, self->key_file, config_id, "device", "device-id");
load_string (config, self->key_file, config_id, "name", "display-name");
load_string (config, self->key_file, config_id, "run-opts", "run-opts");
load_string (config, self->key_file, config_id, "runtime", "runtime-id");
......@@ -282,7 +281,6 @@ add_default:
/* "Default" is not translated because .buildconfig can be checked in */
fallback = g_object_new (IDE_TYPE_BUILDCONFIG_CONFIGURATION,
"context", context,
"device-id", "local",
"display-name", "Default",
"id", "default",
"runtime-id", "host",
......@@ -415,7 +413,6 @@ ide_buildconfig_configuration_provider_save_async (IdeConfigurationProvider *pro
} G_STMT_END
PERSIST_STRING_KEY ("name", get_display_name);
PERSIST_STRING_KEY ("device", get_device_id);
PERSIST_STRING_KEY ("runtime", get_runtime_id);
PERSIST_STRING_KEY ("config-opts", get_config_opts);
PERSIST_STRING_KEY ("run-opts", get_run_opts);
......@@ -571,7 +568,6 @@ ide_buildconfig_configuration_provider_delete (IdeConfigurationProvider *provide
/* "Default" is not translated because .buildconfig can be checked in */
new_config = g_object_new (IDE_TYPE_BUILDCONFIG_CONFIGURATION,
"context", context,
"device-id", "local",
"display-name", "Default",
"id", "default",
"runtime-id", "host",
......
......@@ -36,7 +36,6 @@ struct _IdeBuildConfigurationView
GtkEntry *build_system_entry;
GtkEntry *configure_entry;
GtkListBox *device_list_box;
GtkEntry *display_name_entry;
IdeEnvironmentEditor *environment_editor;
GtkEntry *prefix_entry;
......@@ -124,83 +123,6 @@ create_runtime_row (gpointer item,
return row;
}
static GtkWidget *
create_device_row (gpointer item,
gpointer user_data)
{
IdeDevice *device = item;
IdeConfiguration *configuration = user_data;
GtkWidget *box;
GtkWidget *image;
GtkWidget *label;
GtkWidget *row;
gboolean sensitive;
g_assert (IDE_IS_DEVICE (device));
g_assert (IDE_IS_CONFIGURATION (configuration));
sensitive = ide_configuration_supports_device (configuration, device);
box = g_object_new (GTK_TYPE_BOX,
"spacing", 12,
"visible", TRUE,
NULL);
label = g_object_new (GTK_TYPE_LABEL,
"use-markup", TRUE,
"visible", TRUE,
"xalign", 0.0f,
NULL);
g_object_bind_property (device, "display-name", label, "label", G_BINDING_SYNC_CREATE);
gtk_container_add (GTK_CONTAINER (box), label);
image = g_object_new (GTK_TYPE_IMAGE,
"icon-name", "object-select-symbolic",
"visible", TRUE,
NULL);
g_object_bind_property_full (configuration, "device",
image, "visible",
G_BINDING_SYNC_CREATE,
map_pointer_to,
NULL,
g_object_ref (device),
g_object_unref);
gtk_container_add (GTK_CONTAINER (box), image);
label = g_object_new (GTK_TYPE_LABEL,
"hexpand", TRUE,
"visible", TRUE,
NULL);
gtk_container_add (GTK_CONTAINER (box), label);
row = g_object_new (GTK_TYPE_LIST_BOX_ROW,
"child", box,
"sensitive", sensitive,
"visible", TRUE,
NULL);
g_object_set_data (G_OBJECT (row), "IDE_DEVICE", device);
return row;
}
static void
device_row_activated (IdeBuildConfigurationView *self,
GtkListBoxRow *row,
GtkListBox *list_box)
{
IdeDevice *device;
g_assert (IDE_IS_BUILD_CONFIGURATION_VIEW (self));
g_assert (GTK_IS_LIST_BOX_ROW (row));
g_assert (GTK_IS_LIST_BOX (list_box));
device = g_object_get_data (G_OBJECT (row), "IDE_DEVICE");
if (self->configuration != NULL)
ide_configuration_set_device (self->configuration, device);
}
static void
runtime_row_activated (IdeBuildConfigurationView *self,
GtkListBoxRow *row,
......@@ -234,7 +156,6 @@ ide_build_configuration_view_connect (IdeBuildConfigurationView *self,
IdeConfiguration *configuration)
{
IdeRuntimeManager *runtime_manager;
IdeDeviceManager *device_manager;
IdeContext *context;
IdeEnvironment *environment;
......@@ -243,7 +164,6 @@ ide_build_configuration_view_connect (IdeBuildConfigurationView *self,
context = ide_object_get_context (IDE_OBJECT (configuration));
runtime_manager = ide_context_get_runtime_manager (context);
device_manager = ide_context_get_device_manager (context);
self->display_name_binding =
g_object_bind_property_full (configuration, "display-name",
......@@ -269,12 +189,6 @@ ide_build_configuration_view_connect (IdeBuildConfigurationView *self,
g_object_ref (configuration),
g_object_unref);
gtk_list_box_bind_model (self->device_list_box,
G_LIST_MODEL (device_manager),
create_device_row,
g_object_ref (configuration),
g_object_unref);
environment = ide_configuration_get_environment (configuration);
ide_environment_editor_set_environment (self->environment_editor, environment);
}
......@@ -286,7 +200,6 @@ ide_build_configuration_view_disconnect (IdeBuildConfigurationView *self,
g_assert (IDE_IS_BUILD_CONFIGURATION_VIEW (self));
g_assert (IDE_IS_CONFIGURATION (configuration));
gtk_list_box_bind_model (self->device_list_box, NULL, NULL, NULL, NULL);
gtk_list_box_bind_model (self->runtime_list_box, NULL, NULL, NULL, NULL);
g_clear_pointer (&self->configure_binding, g_binding_unbind);
......@@ -370,7 +283,6 @@ ide_build_configuration_view_class_init (IdeBuildConfigurationViewClass *klass)
gtk_widget_class_set_css_name (widget_class, "configurationview");
gtk_widget_class_bind_template_child (widget_class, IdeBuildConfigurationView, build_system_entry);
gtk_widget_class_bind_template_child (widget_class, IdeBuildConfigurationView, configure_entry);
gtk_widget_class_bind_template_child (widget_class, IdeBuildConfigurationView, device_list_box);
gtk_widget_class_bind_template_child (widget_class, IdeBuildConfigurationView, display_name_entry);
gtk_widget_class_bind_template_child (widget_class, IdeBuildConfigurationView, environment_editor);
gtk_widget_class_bind_template_child (widget_class, IdeBuildConfigurationView, prefix_entry);
......@@ -385,12 +297,6 @@ ide_build_configuration_view_init (IdeBuildConfigurationView *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_object (self->device_list_box,
"row-activated",
G_CALLBACK (device_row_activated),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->runtime_list_box,
"row-activated",
G_CALLBACK (runtime_row_activated),
......
......@@ -179,34 +179,6 @@
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="visible">true</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Device</property>
<property name="xalign">0.0</property>
<property name="visible">true</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkFrame">
<property name="visible">true</property>
<child>
<object class="GtkListBox" id="device_list_box">
<property name="selection-mode">none</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
......
......@@ -27,8 +27,6 @@
#include "config/ide-configuration.h"
#include "config/ide-configuration-manager.h"
#include "buildsystem/ide-environment.h"
#include "devices/ide-device-manager.h"
#include "devices/ide-device.h"
#include "runtimes/ide-runtime-manager.h"
#include "runtimes/ide-runtime.h"
#include "subprocess/ide-subprocess-launcher.h"
......@@ -38,7 +36,6 @@ typedef struct
gchar *app_id;
gchar **build_commands;
gchar *config_opts;
gchar *device_id;
gchar *display_name;
gchar *id;
gchar **post_install_commands;
......@@ -58,11 +55,10 @@ typedef struct
guint debug : 1;
/*
* These are used to determine if we can make progress building
* with this configuration. When devices are added/removed, the
* This is used to determine if we can make progress building
* with this configuration. When runtimes are added/removed, the
* IdeConfiguration:ready property will be notified.
*/
guint device_ready : 1;
guint runtime_ready : 1;
IdeBuildLocality locality : 3;
......@@ -77,8 +73,6 @@ enum {
PROP_BUILD_COMMANDS,
PROP_CONFIG_OPTS,
PROP_DEBUG,
PROP_DEVICE,
PROP_DEVICE_ID,
PROP_DIRTY,
PROP_DISPLAY_NAME,
PROP_ENVIRON,
......@@ -133,26 +127,6 @@ ide_configuration_emit_changed (IdeConfiguration *self)
g_signal_emit (self, signals [CHANGED], 0);
}
static IdeDevice *
ide_configuration_real_get_device (IdeConfiguration *self)
{
IdeConfigurationPrivate *priv = ide_configuration_get_instance_private (self);
g_return_val_if_fail (IDE_IS_CONFIGURATION (self), NULL);
if (priv->device_id != NULL)
{
IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
IdeDeviceManager *device_manager = ide_context_get_device_manager (context);
IdeDevice *device = ide_device_manager_get_device_by_id (device_manager, priv->device_id);
if (device != NULL)
return g_object_ref (device);
}
return NULL;
}
static IdeRuntime *
ide_configuration_real_get_runtime (IdeConfiguration *self)
{
......@@ -190,36 +164,6 @@ ide_configuration_set_id (IdeConfiguration *self,
}
}
static void
ide_configuration_device_manager_items_changed (IdeConfiguration *self,
guint position,
guint added,
guint removed,
IdeDeviceManager *device_manager)
{
IdeConfigurationPrivate *priv = ide_configuration_get_instance_private (self);
IdeDevice *device;
gboolean device_ready;
g_assert (IDE_IS_CONFIGURATION (self));
g_assert (IDE_IS_DEVICE_MANAGER (device_manager));
if (ide_object_is_unloading (IDE_OBJECT (self)))
return;
device = ide_device_manager_get_device_by_id (device_manager, priv->device_id);
device_ready = !!device;
if (!priv->device_ready && device_ready)
ide_device_prepare_configuration (device, self);
if (device_ready != priv->device_ready)
{
priv->device_ready = device_ready;
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_READY]);
}
}
static void
ide_configuration_runtime_manager_items_changed (IdeConfiguration *self,
guint position,
......@@ -269,21 +213,6 @@ ide_configuration_environment_changed (IdeConfiguration *self,
IDE_EXIT;
}
static void
ide_configuration_real_set_device (IdeConfiguration *self,
IdeDevice *device)
{
const gchar *device_id = "local";
g_assert (IDE_IS_CONFIGURATION (self));
g_assert (!device || IDE_IS_DEVICE (device));
if (device != NULL)
device_id = ide_device_get_id (device);
ide_configuration_set_device_id (self, device_id);
}
static void
ide_configuration_real_set_runtime (IdeConfiguration *self,
IdeRuntime *runtime)
......@@ -304,7 +233,6 @@ ide_configuration_constructed (GObject *object)
{
IdeConfiguration *self = (IdeConfiguration *)object;
IdeContext *context;
IdeDeviceManager *device_manager;
IdeRuntimeManager *runtime_manager;
G_OBJECT_CLASS (ide_configuration_parent_class)->constructed (object);
......@@ -315,22 +243,14 @@ ide_configuration_constructed (GObject *object)
/* Allow ourselves to be run from unit tests without a valid context */
if (NULL != (context = ide_object_get_context (IDE_OBJECT (self))))
{
device_manager = ide_context_get_device_manager (context);
runtime_manager = ide_context_get_runtime_manager (context);
g_signal_connect_object (device_manager,
"items-changed",
G_CALLBACK (ide_configuration_device_manager_items_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (runtime_manager,
"items-changed",
G_CALLBACK (ide_configuration_runtime_manager_items_changed),
self,
G_CONNECT_SWAPPED);
ide_configuration_device_manager_items_changed (self, 0, 0, 0, device_manager);
ide_configuration_runtime_manager_items_changed (self, 0, 0, 0, runtime_manager);
}
}
......@@ -346,7 +266,6 @@ ide_configuration_finalize (GObject *object)
g_clear_pointer (&priv->build_commands, g_strfreev);
g_clear_pointer (&priv->internal, g_hash_table_unref);
g_clear_pointer (&priv->config_opts, g_free);
g_clear_pointer (&priv->device_id, g_free);
g_clear_pointer (&priv->display_name, g_free);
g_clear_pointer (&priv->id, g_free);
g_clear_pointer (&priv->post_install_commands, g_strfreev);
......@@ -379,14 +298,6 @@ ide_configuration_get_property (GObject *object,
g_value_set_boolean (value, ide_configuration_get_debug (self));
break;
case PROP_DEVICE:
g_value_set_object (value, ide_configuration_get_device (self));
break;
case PROP_DEVICE_ID:
g_value_set_string (value, ide_configuration_get_device_id (self));
break;
case PROP_DIRTY:
g_value_set_boolean (value, ide_configuration_get_dirty (self));
break;
......@@ -470,14 +381,6 @@ ide_configuration_set_property (GObject *object,
ide_configuration_set_debug (self, g_value_get_boolean (value));
break;
case PROP_DEVICE:
ide_configuration_set_device (self, g_value_get_object (value));
break;
case PROP_DEVICE_ID:
ide_configuration_set_device_id (self, g_value_get_string (value));
break;
case PROP_DIRTY:
ide_configuration_set_dirty (self, g_value_get_boolean (value));
break;
......@@ -541,8 +444,6 @@ ide_configuration_class_init (IdeConfigurationClass *klass)
object_class->get_property = ide_configuration_get_property;
object_class->set_property = ide_configuration_set_property;
klass->get_device = ide_configuration_real_get_device;
klass->set_device = ide_configuration_real_set_device;
klass->get_runtime = ide_configuration_real_get_runtime;
klass->set_runtime = ide_configuration_real_set_runtime;
......@@ -574,20 +475,6 @@ ide_configuration_class_init (IdeConfigurationClass *klass)
TRUE,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
properties [PROP_DEVICE] =
g_param_spec_object ("device",
"Device",
"Device",
IDE_TYPE_DEVICE,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
properties [PROP_DEVICE_ID] =
g_param_spec_string ("device-id",
"Device Id",
"The identifier of the device",
"local",
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
properties [PROP_DIRTY] =
g_param_spec_boolean ("dirty",
"Dirty",
......@@ -696,7 +583,6 @@ ide_configuration_init (IdeConfiguration *self)
{
IdeConfigurationPrivate *priv = ide_configuration_get_instance_private (self);
priv->device_id = g_strdup ("local");
priv->runtime_id = g_strdup ("host");
priv->debug = TRUE;
priv->environment = ide_environment_new ();
......@@ -712,74 +598,6 @@ ide_configuration_init (IdeConfiguration *self)
G_CONNECT_SWAPPED);
}
const gchar *
ide_configuration_get_device_id (IdeConfiguration *self)
{
IdeConfigurationPrivate *priv = ide_configuration_get_instance_private (self);
g_return_val_if_fail (IDE_IS_CONFIGURATION (self), NULL);
return priv->device_id;
}
void
ide_configuration_set_device_id (IdeConfiguration *self,
const gchar *device_id)
{
IdeConfigurationPrivate *priv = ide_configuration_get_instance_private (self);
g_return_if_fail (IDE_IS_CONFIGURATION (self));
g_return_if_fail (device_id != NULL);
if (device_id == NULL)
device_id = "local";
if (g_strcmp0 (device_id, priv->device_id) != 0)
{
IdeContext *context;
IdeDeviceManager *device_manager;
g_free (priv->device_id);
priv->device_id = g_strdup (device_id);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DEVICE_ID]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DEVICE]);
context = ide_object_get_context (IDE_OBJECT (self));
device_manager = ide_context_get_device_manager (context);
ide_configuration_device_manager_items_changed (self, 0, 0, 0, device_manager);
ide_configuration_set_dirty (self, TRUE);
ide_configuration_emit_changed (self);
}
}
/**
* ide_configuration_get_device:
* @self: An #IdeConfiguration
*
* Gets the device for the configuration.
*
* Returns: (transfer none) (nullable): An #IdeDevice.
*/
IdeDevice *
ide_configuration_get_device (IdeConfiguration *self)
{
g_return_val_if_fail (IDE_IS_CONFIGURATION (self), NULL);
return IDE_CONFIGURATION_GET_CLASS (self)->get_device (self);
}
void
ide_configuration_set_device (IdeConfiguration *self,
IdeDevice *device)
{
g_return_if_fail (IDE_IS_CONFIGURATION (self));
g_return_if_fail (!device || IDE_IS_DEVICE (device));
IDE_CONFIGURATION_GET_CLASS (self)->set_device (self, device);
}
/**
* ide_configuration_get_app_id:
* @self: An #IdeConfiguration
......@@ -1479,9 +1297,7 @@ ide_configuration_set_internal_object (IdeConfiguration *self,
* ide_configuration_get_ready:
* @self: An #IdeConfiguration
*
* Determines if the configuration is ready for use. That means that the
* build device can be accessed and the runtime is loaded. This may change
* at runtime as devices and runtimes are added or removed.
* Determines if the configuration is ready for use.
*
* Returns: %TRUE if the configuration is ready for use.
*/
......@@ -1492,24 +1308,7 @@ ide_configuration_get_ready (IdeConfiguration *self)
g_return_val_if_fail (IDE_IS_CONFIGURATION (self), FALSE);
return priv->device_ready && priv->runtime_ready;
}
gboolean
ide_configuration_supports_device (IdeConfiguration *self,
IdeDevice *device)
{
gboolean ret = TRUE;
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_CONFIGURATION (self), FALSE);
g_return_val_if_fail (IDE_IS_DEVICE (device), FALSE);
if (IDE_CONFIGURATION_GET_CLASS (self)->supports_device)
ret = IDE_CONFIGURATION_GET_CLASS (self)->supports_device (self, device);
IDE_RETURN (ret);
return priv->runtime_ready;
}
gboolean
......
......@@ -42,16 +42,9 @@ struct _IdeConfigurationClass
{
IdeObjectClass parent;
IdeDevice *(*get_device) (IdeConfiguration *self);
void (*set_device) (IdeConfiguration *self,
IdeDevice *device);
IdeRuntime *(*get_runtime) (IdeConfiguration *self);
void (*set_runtime) (IdeConfiguration *self,
IdeRuntime *runtime);
gboolean (*supports_device) (IdeConfiguration *self,
IdeDevice *device);
gboolean (*supports_runtime) (IdeConfiguration *self,
IdeRuntime *runtime);
......@@ -72,16 +65,6 @@ IDE_AVAILABLE_IN_ALL
void ide_configuration_set_runtime_id (IdeConfiguration *self,
const gchar *runtime_id);
IDE_AVAILABLE_IN_ALL
const gchar *ide_configuration_get_device_id (IdeConfiguration *self);
IDE_AVAILABLE_IN_ALL
void ide_configuration_set_device_id (IdeConfiguration *self,
const gchar *device_id);
IDE_AVAILABLE_IN_ALL
IdeDevice *ide_configuration_get_device (IdeConfiguration *self);
IDE_AVAILABLE_IN_ALL
void ide_configuration_set_device (IdeConfiguration *self,
IdeDevice *device);
IDE_AVAILABLE_IN_ALL
gboolean ide_configuration_get_dirty (IdeConfiguration *self);
IDE_AVAILABLE_IN_ALL
void ide_configuration_set_dirty (IdeConfiguration *self,
......@@ -163,9 +146,6 @@ IDE_AVAILABLE_IN_3_28
void ide_configuration_apply_path (IdeConfiguration *self,
IdeSubprocessLauncher *launcher);
IDE_AVAILABLE_IN_ALL
gboolean ide_configuration_supports_device (IdeConfiguration *self,
IdeDevice *device);
IDE_AVAILABLE_IN_ALL
gboolean ide_configuration_supports_runtime (IdeConfiguration *self,
IdeRuntime *runtime);
IDE_AVAILABLE_IN_ALL
......
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