Get to the point where we are fairly happy with our uncrustify config. Fixes #6.
This commit is contained in:
parent
d07d3dfe50
commit
62de9c2032
58 changed files with 4811 additions and 1946 deletions
|
@ -28,73 +28,78 @@
|
|||
#include "mimes.h"
|
||||
#include "mpris.h"
|
||||
|
||||
extern KotoCartographer *koto_maps;
|
||||
extern KotoCurrentPlaylist *current_playlist;
|
||||
extern GtkApplication *app;
|
||||
extern GtkWindow *main_window;
|
||||
extern KotoPlaybackEngine *playback_engine;
|
||||
extern GList *supported_mimes;
|
||||
extern KotoCartographer * koto_maps;
|
||||
extern KotoCurrentPlaylist * current_playlist;
|
||||
extern GtkApplication * app;
|
||||
extern GtkWindow * main_window;
|
||||
extern KotoPlaybackEngine * playback_engine;
|
||||
extern GList * supported_mimes;
|
||||
|
||||
GDBusConnection *dbus_conn = NULL;
|
||||
GDBusConnection * dbus_conn = NULL;
|
||||
guint mpris_bus_id = 0;
|
||||
GDBusNodeInfo *introspection_data = NULL;
|
||||
GDBusNodeInfo * introspection_data = NULL;
|
||||
|
||||
static const gchar introspection_xml[] =
|
||||
"<node>"
|
||||
" <interface name='org.mpris.MediaPlayer2'>"
|
||||
" <method name='Raise' />"
|
||||
" <method name='Quit' />"
|
||||
" <property type='b' name='CanQuit' access='read' />"
|
||||
" <property type='b' name='CanRaise' access='read' />"
|
||||
" <property type='b' name='HasTrackList' access='read' />"
|
||||
" <property type='s' name='Identity' access='read' />"
|
||||
" <property type='s' name='DesktopEntry' access='read' />"
|
||||
" <property type='as' name='SupportedUriSchemas' access='read' />"
|
||||
" <property type='as' name='SupportedMimeTypes' access='read' />"
|
||||
" </interface>"
|
||||
" <interface name='org.mpris.MediaPlayer2.Player'>"
|
||||
" <method name='Next' />"
|
||||
" <method name='Previous' />"
|
||||
" <method name='Pause' />"
|
||||
" <method name='PlayPause' />"
|
||||
" <method name='Stop' />"
|
||||
" <method name='Play' />"
|
||||
" <method name='Seek'>"
|
||||
" <arg type='x' name='offset' />"
|
||||
" </method>"
|
||||
" <method name='SetPosition'>"
|
||||
" <arg type='o' name='track_id' />"
|
||||
" <arg type='x' name='pos' />"
|
||||
" </method>"
|
||||
" <property type='s' name='PlaybackStatus' access='read' />"
|
||||
" <property type='s' name='LoopStatus' access='readwrite' />"
|
||||
" <property type='d' name='Rate' access='readwrite' />"
|
||||
" <property type='b' name='Shuffle' access='readwrite' />"
|
||||
" <property type='a{sv}' name='Metadata' access='read' />"
|
||||
" <property type='d' name='Volume' access='readwrite' />"
|
||||
" <property type='x' name='Position' access='read' />"
|
||||
" <property type='d' name='MinimumRate' access='read' />"
|
||||
" <property type='d' name='MaximumRate' access='read' />"
|
||||
" <property type='b' name='CanGoNext' access='read' />"
|
||||
" <property type='b' name='CanGoPrevious' access='read' />"
|
||||
" <property type='b' name='CanPlay' access='read' />"
|
||||
" <property type='b' name='CanPause' access='read' />"
|
||||
" <property type='b' name='CanSeek' access='read' />"
|
||||
" <property type='b' name='CanControl' access='read' />"
|
||||
" </interface>"
|
||||
"</node>";
|
||||
"<node>"
|
||||
" <interface name='org.mpris.MediaPlayer2'>"
|
||||
" <method name='Raise' />"
|
||||
" <method name='Quit' />"
|
||||
" <property type='b' name='CanQuit' access='read' />"
|
||||
" <property type='b' name='CanRaise' access='read' />"
|
||||
" <property type='b' name='HasTrackList' access='read' />"
|
||||
" <property type='s' name='Identity' access='read' />"
|
||||
" <property type='s' name='DesktopEntry' access='read' />"
|
||||
" <property type='as' name='SupportedUriSchemas' access='read' />"
|
||||
" <property type='as' name='SupportedMimeTypes' access='read' />"
|
||||
" </interface>"
|
||||
" <interface name='org.mpris.MediaPlayer2.Player'>"
|
||||
" <method name='Next' />"
|
||||
" <method name='Previous' />"
|
||||
" <method name='Pause' />"
|
||||
" <method name='PlayPause' />"
|
||||
" <method name='Stop' />"
|
||||
" <method name='Play' />"
|
||||
" <method name='Seek'>"
|
||||
" <arg type='x' name='offset' />"
|
||||
" </method>"
|
||||
" <method name='SetPosition'>"
|
||||
" <arg type='o' name='track_id' />"
|
||||
" <arg type='x' name='pos' />"
|
||||
" </method>"
|
||||
" <property type='s' name='PlaybackStatus' access='read' />"
|
||||
" <property type='s' name='LoopStatus' access='readwrite' />"
|
||||
" <property type='d' name='Rate' access='readwrite' />"
|
||||
" <property type='b' name='Shuffle' access='readwrite' />"
|
||||
" <property type='a{sv}' name='Metadata' access='read' />"
|
||||
" <property type='d' name='Volume' access='readwrite' />"
|
||||
" <property type='x' name='Position' access='read' />"
|
||||
" <property type='d' name='MinimumRate' access='read' />"
|
||||
" <property type='d' name='MaximumRate' access='read' />"
|
||||
" <property type='b' name='CanGoNext' access='read' />"
|
||||
" <property type='b' name='CanGoPrevious' access='read' />"
|
||||
" <property type='b' name='CanPlay' access='read' />"
|
||||
" <property type='b' name='CanPause' access='read' />"
|
||||
" <property type='b' name='CanSeek' access='read' />"
|
||||
" <property type='b' name='CanControl' access='read' />"
|
||||
" </interface>"
|
||||
"</node>";
|
||||
|
||||
void handle_method_call(
|
||||
GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
const gchar *object_path,
|
||||
const gchar *interface_name,
|
||||
const gchar *method_name,
|
||||
GVariant *parameters,
|
||||
GDBusMethodInvocation *invocation,
|
||||
GDBusConnection * connection,
|
||||
const gchar * sender,
|
||||
const gchar * object_path,
|
||||
const gchar * interface_name,
|
||||
const gchar * method_name,
|
||||
GVariant * parameters,
|
||||
GDBusMethodInvocation * invocation,
|
||||
gpointer user_data
|
||||
) {
|
||||
(void) connection; (void) sender; (void) object_path; (void) parameters; (void) invocation; (void) user_data;
|
||||
(void) connection;
|
||||
(void) sender;
|
||||
(void) object_path;
|
||||
(void) parameters;
|
||||
(void) invocation;
|
||||
(void) user_data;
|
||||
|
||||
if (g_strcmp0(interface_name, "org.mpris.MediaPlayer2") == 0) { // Root mediaplayer2 interface
|
||||
if (g_strcmp0(method_name, "Raise") == 0) { // Raise the window
|
||||
|
@ -140,17 +145,24 @@ void handle_method_call(
|
|||
}
|
||||
}
|
||||
|
||||
GVariant* handle_get_property(
|
||||
GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
const gchar *object_path,
|
||||
const gchar *interface_name,
|
||||
const gchar *property_name,
|
||||
GError **error,
|
||||
GVariant * handle_get_property(
|
||||
GDBusConnection * connection,
|
||||
const gchar * sender,
|
||||
const gchar * object_path,
|
||||
const gchar * interface_name,
|
||||
const gchar * property_name,
|
||||
GError ** error,
|
||||
gpointer user_data
|
||||
) {
|
||||
(void) connection; (void) sender; (void) object_path; (void) interface_name; (void) error; (void) user_data;
|
||||
GVariant *ret;
|
||||
(void) connection;
|
||||
(void) sender;
|
||||
(void) object_path;
|
||||
(void) interface_name;
|
||||
(void) error;
|
||||
(void) user_data;
|
||||
GVariant * ret;
|
||||
|
||||
|
||||
ret = NULL;
|
||||
|
||||
if (g_strcmp0(property_name, "CanQuit") == 0) { // If property is CanQuit
|
||||
|
@ -162,7 +174,7 @@ GVariant* handle_get_property(
|
|||
}
|
||||
|
||||
if (g_strcmp0(property_name, "HasTrackList") == 0) { // If property is HasTrackList
|
||||
KotoPlaylist *playlist = koto_current_playlist_get_playlist(current_playlist);
|
||||
KotoPlaylist * playlist = koto_current_playlist_get_playlist(current_playlist);
|
||||
if (KOTO_IS_PLAYLIST(playlist)) {
|
||||
ret = g_variant_new_boolean(koto_playlist_get_length(playlist) > 0);
|
||||
} else { // Don't have a playlist
|
||||
|
@ -179,15 +191,15 @@ GVariant* handle_get_property(
|
|||
}
|
||||
|
||||
if (g_strcmp0(property_name, "SupportedUriSchemas") == 0) { // Supported URI Schemas
|
||||
GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("as")); // Array of strings
|
||||
GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE("as")); // Array of strings
|
||||
g_variant_builder_add(builder, "s", "file");
|
||||
ret = g_variant_new("as", builder);
|
||||
g_variant_builder_unref(builder); // Unref builder since we no longer need it
|
||||
}
|
||||
|
||||
if (g_strcmp0(property_name, "SupportedMimeTypes") == 0) { // Supported mimetypes
|
||||
GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("as")); // Array of strings
|
||||
GList *mimes;
|
||||
GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE("as")); // Array of strings
|
||||
GList * mimes;
|
||||
mimes = NULL;
|
||||
|
||||
for (mimes = supported_mimes; mimes != NULL; mimes = mimes->next) { // For each mimetype
|
||||
|
@ -200,21 +212,21 @@ GVariant* handle_get_property(
|
|||
}
|
||||
|
||||
if (g_strcmp0(property_name, "Metadata") == 0) { // Metadata
|
||||
KotoIndexedTrack *current_track = koto_playback_engine_get_current_track(playback_engine);
|
||||
KotoIndexedTrack * current_track = koto_playback_engine_get_current_track(playback_engine);
|
||||
|
||||
if (KOTO_IS_INDEXED_TRACK(current_track)) { // Currently playing a track
|
||||
ret = koto_indexed_track_get_metadata_vardict(current_track);
|
||||
} else { // No track
|
||||
GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE_VARDICT); // Create an empty builder
|
||||
GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE_VARDICT); // Create an empty builder
|
||||
ret = g_variant_builder_end(builder); // return the vardict
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(g_strcmp0(property_name, "CanPlay") == 0) ||
|
||||
(g_strcmp0(property_name, "CanPause") == 0)
|
||||
(g_strcmp0(property_name, "CanPlay") == 0) ||
|
||||
(g_strcmp0(property_name, "CanPause") == 0)
|
||||
) {
|
||||
KotoIndexedTrack *current_track = koto_playback_engine_get_current_track(playback_engine);
|
||||
KotoIndexedTrack * current_track = koto_playback_engine_get_current_track(playback_engine);
|
||||
ret = g_variant_new_boolean(KOTO_IS_INDEXED_TRACK(current_track));
|
||||
}
|
||||
|
||||
|
@ -232,7 +244,7 @@ GVariant* handle_get_property(
|
|||
ret = g_variant_new_boolean(TRUE);
|
||||
}
|
||||
|
||||
if (g_strcmp0(property_name, "CanControl") == 0){ // Can Control
|
||||
if (g_strcmp0(property_name, "CanControl") == 0) { // Can Control
|
||||
ret = g_variant_new_boolean(TRUE);
|
||||
}
|
||||
|
||||
|
@ -252,16 +264,21 @@ GVariant* handle_get_property(
|
|||
}
|
||||
|
||||
gboolean handle_set_property(
|
||||
GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
const gchar *object_path,
|
||||
const gchar *interface_name,
|
||||
const gchar *property_name,
|
||||
GVariant *value,
|
||||
GError **error,
|
||||
GDBusConnection * connection,
|
||||
const gchar * sender,
|
||||
const gchar * object_path,
|
||||
const gchar * interface_name,
|
||||
const gchar * property_name,
|
||||
GVariant * value,
|
||||
GError ** error,
|
||||
gpointer user_data
|
||||
) {
|
||||
(void) connection; (void) sender; (void) interface_name; (void) object_path; (void) error; (void) user_data;
|
||||
(void) connection;
|
||||
(void) sender;
|
||||
(void) interface_name;
|
||||
(void) object_path;
|
||||
(void) error;
|
||||
(void) user_data;
|
||||
|
||||
if (g_strcmp0(property_name, "LoopStatus") == 0) { // Changing LoopStatus
|
||||
koto_playback_engine_set_track_repeat(playback_engine, g_variant_get_boolean(value)); // Set the loop status state
|
||||
|
@ -277,7 +294,8 @@ gboolean handle_set_property(
|
|||
}
|
||||
|
||||
void koto_update_mpris_playback_state(GstState state) {
|
||||
GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
|
||||
GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
|
||||
|
||||
|
||||
if (state == GST_STATE_PLAYING) {
|
||||
g_variant_builder_add(builder, "{sv}", "PlaybackStatus", g_variant_new_string("Playing"));
|
||||
|
@ -287,7 +305,8 @@ void koto_update_mpris_playback_state(GstState state) {
|
|||
g_variant_builder_add(builder, "{sv}", "PlaybackStatus", g_variant_new_string("Stopped"));
|
||||
}
|
||||
|
||||
g_dbus_connection_emit_signal(dbus_conn,
|
||||
g_dbus_connection_emit_signal(
|
||||
dbus_conn,
|
||||
NULL,
|
||||
"/org/mpris/MediaPlayer2",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
|
@ -297,24 +316,32 @@ void koto_update_mpris_playback_state(GstState state) {
|
|||
);
|
||||
}
|
||||
|
||||
void koto_update_mpris_info_for_track(KotoIndexedTrack *track) {
|
||||
void koto_update_mpris_info_for_track(KotoIndexedTrack * track) {
|
||||
if (!KOTO_IS_INDEXED_TRACK(track)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GVariant *metadata = koto_indexed_track_get_metadata_vardict(track); // Get the GVariantBuilder variable dict for the metadata
|
||||
GVariant * metadata = koto_indexed_track_get_metadata_vardict(track); // Get the GVariantBuilder variable dict for the metadata
|
||||
|
||||
|
||||
koto_update_mpris_info_for_track_with_metadata(track, metadata);
|
||||
}
|
||||
|
||||
void koto_update_mpris_info_for_track_with_metadata(KotoIndexedTrack *track, GVariant *metadata) {
|
||||
void koto_update_mpris_info_for_track_with_metadata(
|
||||
KotoIndexedTrack * track,
|
||||
GVariant * metadata
|
||||
) {
|
||||
if (!KOTO_IS_INDEXED_TRACK(track)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
|
||||
GVariantBuilder * builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
|
||||
|
||||
|
||||
g_variant_builder_add(builder, "{sv}", "Metadata", metadata);
|
||||
|
||||
g_dbus_connection_emit_signal(dbus_conn,
|
||||
g_dbus_connection_emit_signal(
|
||||
dbus_conn,
|
||||
NULL,
|
||||
"/org/mpris/MediaPlayer2",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
|
@ -331,10 +358,16 @@ static const GDBusInterfaceVTable main_mpris_interface_vtable = {
|
|||
{ 0 }
|
||||
};
|
||||
|
||||
void on_main_mpris_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) {
|
||||
(void) name; (void) user_data;
|
||||
void on_main_mpris_bus_acquired(
|
||||
GDBusConnection * connection,
|
||||
const gchar * name,
|
||||
gpointer user_data
|
||||
) {
|
||||
(void) name;
|
||||
(void) user_data;
|
||||
dbus_conn = connection;
|
||||
g_dbus_connection_register_object(dbus_conn,
|
||||
g_dbus_connection_register_object(
|
||||
dbus_conn,
|
||||
"/org/mpris/MediaPlayer2",
|
||||
introspection_data->interfaces[0],
|
||||
&main_mpris_interface_vtable,
|
||||
|
@ -343,7 +376,8 @@ void on_main_mpris_bus_acquired(GDBusConnection *connection, const gchar *name,
|
|||
NULL
|
||||
);
|
||||
|
||||
g_dbus_connection_register_object(dbus_conn,
|
||||
g_dbus_connection_register_object(
|
||||
dbus_conn,
|
||||
"/org/mpris/MediaPlayer2",
|
||||
introspection_data->interfaces[1],
|
||||
&main_mpris_interface_vtable,
|
||||
|
@ -357,7 +391,8 @@ void setup_mpris_interfaces() {
|
|||
introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
|
||||
g_assert(introspection_data != NULL);
|
||||
|
||||
mpris_bus_id = g_bus_own_name(G_BUS_TYPE_SESSION,
|
||||
mpris_bus_id = g_bus_own_name(
|
||||
G_BUS_TYPE_SESSION,
|
||||
"org.mpris.MediaPlayer2.koto",
|
||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
on_main_mpris_bus_acquired,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue