-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: inherit from ValentResource
Refactor a number of classes, namely extensions and adapters, to inherit from `ValentResource`.
- Loading branch information
1 parent
d0c32f7
commit 699ad7c
Showing
55 changed files
with
376 additions
and
564 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ | |
|
||
#include "valent-context.h" | ||
#include "valent-core-enums.h" | ||
#include "valent-extension.h" | ||
#include "valent-object.h" | ||
#include "valent-resource.h" | ||
|
||
#include "valent-extension.h" | ||
|
||
|
||
/** | ||
|
@@ -60,8 +62,6 @@ | |
|
||
typedef struct | ||
{ | ||
GObject *object; | ||
|
||
PeasPluginInfo *plugin_info; | ||
ValentPluginState plugin_state; | ||
GError *plugin_error; | ||
|
@@ -74,15 +74,14 @@ typedef struct | |
static void g_action_group_iface_init (GActionGroupInterface *iface); | ||
static void g_action_map_iface_init (GActionMapInterface *iface); | ||
|
||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ValentExtension, valent_extension, VALENT_TYPE_OBJECT, | ||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ValentExtension, valent_extension, VALENT_TYPE_RESOURCE, | ||
G_ADD_PRIVATE (ValentExtension) | ||
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, | ||
PROP_OBJECT, | ||
PROP_PLUGIN_INFO, | ||
PROP_PLUGIN_STATE, | ||
PROP_SETTINGS, | ||
|
@@ -289,25 +288,6 @@ g_action_map_iface_init (GActionMapInterface *iface) | |
iface->remove_action = valent_extension_remove_action; | ||
} | ||
|
||
/* | ||
* ValentExtension | ||
*/ | ||
static void | ||
valent_extension_set_object (ValentExtension *self, | ||
gpointer object) | ||
{ | ||
ValentExtensionPrivate *priv = valent_extension_get_instance_private (self); | ||
|
||
g_assert (VALENT_IS_EXTENSION (self)); | ||
g_assert (object == NULL || G_IS_OBJECT (object)); | ||
|
||
if (priv->object == object) | ||
return; | ||
|
||
priv->object = object; | ||
g_object_add_weak_pointer (G_OBJECT (priv->object), (gpointer *)&priv->object); | ||
} | ||
|
||
/* | ||
* ValentObject | ||
*/ | ||
|
@@ -343,7 +323,6 @@ valent_extension_finalize (GObject *object) | |
ValentExtension *self = VALENT_EXTENSION (object); | ||
ValentExtensionPrivate *priv = valent_extension_get_instance_private (self); | ||
|
||
g_clear_weak_pointer (&priv->object); | ||
g_clear_error (&priv->plugin_error); | ||
g_clear_pointer (&priv->actions, g_hash_table_unref); | ||
g_clear_object (&priv->context); | ||
|
@@ -368,10 +347,6 @@ valent_extension_get_property (GObject *object, | |
g_value_set_object (value, valent_extension_get_context (self)); | ||
break; | ||
|
||
case PROP_OBJECT: | ||
g_value_set_object (value, priv->object); | ||
break; | ||
|
||
case PROP_PLUGIN_INFO: | ||
g_value_set_object (value, priv->plugin_info); | ||
break; | ||
|
@@ -404,10 +379,6 @@ valent_extension_set_property (GObject *object, | |
priv->context = g_value_dup_object (value); | ||
break; | ||
|
||
case PROP_OBJECT: | ||
valent_extension_set_object (self, g_value_get_object (value)); | ||
break; | ||
|
||
case PROP_PLUGIN_INFO: | ||
priv->plugin_info = g_value_dup_object (value); | ||
break; | ||
|
@@ -444,21 +415,6 @@ valent_extension_class_init (ValentExtensionClass *klass) | |
G_PARAM_EXPLICIT_NOTIFY | | ||
G_PARAM_STATIC_STRINGS)); | ||
|
||
/** | ||
* ValentExtension:object: (getter get_object) | ||
* | ||
* The [[email protected]] this plugin is bound to. | ||
* | ||
* Since: 1.0 | ||
*/ | ||
properties [PROP_OBJECT] = | ||
g_param_spec_object ("object", NULL, NULL, | ||
G_TYPE_OBJECT, | ||
(G_PARAM_READWRITE | | ||
G_PARAM_CONSTRUCT_ONLY | | ||
G_PARAM_EXPLICIT_NOTIFY | | ||
G_PARAM_STATIC_STRINGS)); | ||
|
||
/** | ||
* ValentExtension:plugin-info: | ||
* | ||
|
@@ -547,26 +503,6 @@ valent_extension_get_context (ValentExtension *extension) | |
return priv->context; | ||
} | ||
|
||
/** | ||
* valent_extension_get_object: (get-property object) | ||
* @extension: a `ValentExtension` | ||
* | ||
* Get the object this plugin is bound to. | ||
* | ||
* Returns: (type GObject.Object) (transfer none) (nullable): a `GObject` | ||
* | ||
* Since: 1.0 | ||
*/ | ||
gpointer | ||
valent_extension_get_object (ValentExtension *extension) | ||
{ | ||
ValentExtensionPrivate *priv = valent_extension_get_instance_private (extension); | ||
|
||
g_return_val_if_fail (VALENT_IS_EXTENSION (extension), NULL); | ||
|
||
return priv->object; | ||
} | ||
|
||
/** | ||
* valent_extension_get_settings: (get-property settings) | ||
* @extension: a `ValentExtension` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,6 @@ | |
#include "valent-device-plugin.h" | ||
#include "valent-packet.h" | ||
|
||
#define PLUGIN_SETTINGS_KEY "X-DevicePluginSettings" | ||
|
||
|
||
/** | ||
* ValentDevicePlugin: | ||
* | ||
|
@@ -151,8 +148,9 @@ valent_device_plugin_init (ValentDevicePlugin *self) | |
* | ||
* Queue a KDE Connect packet to be sent to the device this plugin is bound to. | ||
* | ||
* For notification of success call [[email protected]_object] and | ||
* then [[email protected]_packet]. | ||
* For notification of success, you may call [[email protected]_source] | ||
* and then [[email protected]_packet], but note that there can be no | ||
* guarantee the remote device has received the packet. | ||
* | ||
* Since: 1.0 | ||
*/ | ||
|
@@ -166,7 +164,7 @@ valent_device_plugin_queue_packet (ValentDevicePlugin *plugin, | |
g_return_if_fail (VALENT_IS_DEVICE_PLUGIN (plugin)); | ||
g_return_if_fail (VALENT_IS_PACKET (packet)); | ||
|
||
if ((device = valent_extension_get_object (VALENT_EXTENSION (plugin))) == NULL) | ||
if ((device = valent_resource_get_source (VALENT_RESOURCE (plugin))) == NULL) | ||
return; | ||
|
||
destroy = valent_object_ref_cancellable (VALENT_OBJECT (plugin)); | ||
|
@@ -211,8 +209,8 @@ valent_device_plugin_show_notification (ValentDevicePlugin *plugin, | |
return; | ||
|
||
g_object_get (plugin, | ||
"object", &device, | ||
"plugin-info", &plugin_info, | ||
"source", &device, | ||
NULL); | ||
notification_id = g_strdup_printf ("%s::%s::%s", | ||
valent_device_get_id (device), | ||
|
@@ -249,8 +247,8 @@ valent_device_plugin_hide_notification (ValentDevicePlugin *plugin, | |
return; | ||
|
||
g_object_get (plugin, | ||
"object", &device, | ||
"plugin-info", &plugin_info, | ||
"source", &device, | ||
NULL); | ||
notification_id = g_strdup_printf ("%s::%s::%s", | ||
valent_device_get_id (device), | ||
|
@@ -411,7 +409,7 @@ valent_device_plugin_set_menu_item (ValentDevicePlugin *plugin, | |
g_return_if_fail (item == NULL || G_IS_MENU_ITEM (item)); | ||
|
||
/* NOTE: this method may be called by plugins in their `dispose()` */ | ||
if ((device = valent_extension_get_object (VALENT_EXTENSION (plugin))) == NULL) | ||
if ((device = valent_resource_get_source (VALENT_RESOURCE (plugin))) == NULL) | ||
return; | ||
|
||
menu = valent_device_get_menu (device); | ||
|
Oops, something went wrong.