Skip to content

Commit

Permalink
chore: code style cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
andyholmes committed Dec 17, 2024
1 parent 549a464 commit d5d7d67
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 204 deletions.
10 changes: 3 additions & 7 deletions src/libvalent/core/valent-application-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

#include <gio/gio.h>

#include "valent-application-plugin.h"
#include "valent-debug.h"
#include "valent-extension.h"

#include "valent-application-plugin.h"


/**
* ValentApplicationPlugin:
Expand All @@ -35,12 +36,7 @@
* Since: 1.0
*/

typedef struct
{
gpointer reserved[1];
} ValentApplicationPluginPrivate;

G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ValentApplicationPlugin, valent_application_plugin, VALENT_TYPE_EXTENSION)
G_DEFINE_ABSTRACT_TYPE (ValentApplicationPlugin, valent_application_plugin, VALENT_TYPE_EXTENSION)

/* LCOV_EXCL_START */
static gboolean
Expand Down
6 changes: 5 additions & 1 deletion src/libvalent/core/valent-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ valent_application_disable_plugin (ValentApplication *self,
{
g_assert (VALENT_IS_APPLICATION (self));

g_clear_object (&plugin->extension);
if (plugin->extension != NULL)
{
valent_object_destroy (VALENT_OBJECT (plugin->extension));
g_clear_object (&plugin->extension);
}
}

static void
Expand Down
22 changes: 11 additions & 11 deletions src/libvalent/core/valent-component.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,16 +473,7 @@ valent_component_constructed (GObject *object)
priv->plugin_priority = g_strdup_printf ("X-%sPriority", type_name);
}

n_plugins = g_list_model_get_n_items (G_LIST_MODEL (priv->engine));
for (unsigned int i = 0; i < n_plugins; i++)
{
g_autoptr (PeasPluginInfo) info = NULL;

info = g_list_model_get_item (G_LIST_MODEL (priv->engine), i);
if (peas_plugin_info_is_loaded (info))
on_load_plugin (priv->engine, info, self);
}

priv->engine = valent_get_plugin_engine ();
g_signal_connect_object (priv->engine,
"load-plugin",
G_CALLBACK (on_load_plugin),
Expand All @@ -493,6 +484,16 @@ valent_component_constructed (GObject *object)
G_CALLBACK (on_unload_plugin),
self,
G_CONNECT_DEFAULT);

n_plugins = g_list_model_get_n_items (G_LIST_MODEL (priv->engine));
for (unsigned int i = 0; i < n_plugins; i++)
{
g_autoptr (PeasPluginInfo) info = NULL;

info = g_list_model_get_item (G_LIST_MODEL (priv->engine), i);
if (peas_plugin_info_is_loaded (info))
on_load_plugin (priv->engine, info, self);
}
}

static void
Expand Down Expand Up @@ -642,7 +643,6 @@ valent_component_init (ValentComponent *self)
{
ValentComponentPrivate *priv = valent_component_get_instance_private (self);

priv->engine = valent_get_plugin_engine ();
priv->plugins = g_hash_table_new_full (NULL, NULL, NULL, component_plugin_free);
priv->items = g_ptr_array_new_with_free_func (g_object_unref);
}
Expand Down
12 changes: 7 additions & 5 deletions src/libvalent/core/valent-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ valent_context_constructed (GObject *object)
ValentContext *self = VALENT_CONTEXT (object);
ValentContextPrivate *priv = valent_context_get_instance_private (self);

G_OBJECT_CLASS (valent_context_parent_class)->constructed (object);

if (priv->parent != NULL)
{
const char *base_path;
Expand All @@ -138,12 +140,10 @@ valent_context_constructed (GObject *object)
PACKAGE_NAME,
priv->path,
NULL);

G_OBJECT_CLASS (valent_context_parent_class)->constructed (object);
}

static void
valent_context_finalize (GObject *object)
valent_context_destroy (ValentObject *object)
{
ValentContext *self = VALENT_CONTEXT (object);
ValentContextPrivate *priv = valent_context_get_instance_private (self);
Expand All @@ -155,7 +155,7 @@ valent_context_finalize (GObject *object)
g_clear_pointer (&priv->domain, g_free);
g_clear_pointer (&priv->id, g_free);

G_OBJECT_CLASS (valent_context_parent_class)->finalize (object);
VALENT_OBJECT_CLASS (valent_context_parent_class)->destroy (object);
}

static void
Expand Down Expand Up @@ -217,12 +217,14 @@ static void
valent_context_class_init (ValentContextClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ValentObjectClass *vobject_class = VALENT_OBJECT_CLASS (klass);

object_class->constructed = valent_context_constructed;
object_class->finalize = valent_context_finalize;
object_class->get_property = valent_context_get_property;
object_class->set_property = valent_context_set_property;

vobject_class->destroy = valent_context_destroy;

/**
* ValentContext:domain: (getter get_domain)
*
Expand Down
19 changes: 9 additions & 10 deletions src/libvalent/core/valent-extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,14 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ValentExtension, valent_extension, VALENT_TYPE
G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, g_action_group_iface_init)
G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_MAP, g_action_map_iface_init))

enum {
PROP_0,
PROP_CONTEXT,
typedef enum {
PROP_CONTEXT = 1,
PROP_PLUGIN_INFO,
PROP_PLUGIN_STATE,
PROP_SETTINGS,
N_PROPERTIES
};
} ValentExtensionProperty;

static GParamSpec *properties[N_PROPERTIES] = { NULL, };
static GParamSpec *properties[PROP_SETTINGS + 1] = { NULL, };


/*
Expand Down Expand Up @@ -301,7 +299,6 @@ valent_extension_destroy (ValentObject *object)
GAction *action;

g_hash_table_iter_init (&iter, priv->actions);

while (g_hash_table_iter_next (&iter, (void **)&action_name, (void **)&action))
{
g_action_group_action_removed (G_ACTION_GROUP (self), action_name);
Expand Down Expand Up @@ -341,7 +338,7 @@ valent_extension_get_property (GObject *object,
ValentExtension *self = VALENT_EXTENSION (object);
ValentExtensionPrivate *priv = valent_extension_get_instance_private (self);

switch (prop_id)
switch ((ValentExtensionProperty)prop_id)
{
case PROP_CONTEXT:
g_value_set_object (value, valent_extension_get_context (self));
Expand Down Expand Up @@ -373,7 +370,7 @@ valent_extension_set_property (GObject *object,
ValentExtension *self = VALENT_EXTENSION (object);
ValentExtensionPrivate *priv = valent_extension_get_instance_private (self);

switch (prop_id)
switch ((ValentExtensionProperty)prop_id)
{
case PROP_CONTEXT:
priv->context = g_value_dup_object (value);
Expand All @@ -383,6 +380,8 @@ valent_extension_set_property (GObject *object,
priv->plugin_info = g_value_dup_object (value);
break;

case PROP_PLUGIN_STATE:
case PROP_SETTINGS:
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
Expand Down Expand Up @@ -459,7 +458,7 @@ valent_extension_class_init (ValentExtensionClass *klass)
G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS));

g_object_class_install_properties (object_class, N_PROPERTIES, properties);
g_object_class_install_properties (object_class, G_N_ELEMENTS (properties), properties);
}

static void
Expand Down
Loading

0 comments on commit d5d7d67

Please sign in to comment.