From 4cc5c6efd4acd66791f4c63c52dd38a5522a20a9 Mon Sep 17 00:00:00 2001 From: Joshua Strobl Date: Thu, 27 May 2021 13:03:24 +0300 Subject: [PATCH] Apply formatting --- src/config/config.c | 48 ++++++++++++++++++++++-------------- src/config/config.h | 16 ++++++++++-- src/indexer/file-indexer.c | 3 --- src/koto-paths.c | 4 +-- src/koto-playerbar.c | 2 +- src/koto-window.c | 14 +++++++---- src/pages/music/album-view.c | 2 +- src/playback/engine.c | 6 ++++- src/playback/engine.h | 6 ++++- 9 files changed, 66 insertions(+), 35 deletions(-) diff --git a/src/config/config.c b/src/config/config.c index c972b6f..cf4a05b 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -73,7 +73,7 @@ G_DEFINE_TYPE(KotoConfig, koto_config, G_TYPE_OBJECT); KotoConfig * config; -static void koto_config_constructed(GObject *obj); +static void koto_config_constructed(GObject * obj); static void koto_config_get_property( GObject * obj, @@ -89,7 +89,7 @@ static void koto_config_set_property( GParamSpec * spec ); -static void koto_config_class_init(KotoConfigClass *c) { +static void koto_config_class_init(KotoConfigClass * c) { GObjectClass * gobject_class; gobject_class = G_OBJECT_CLASS(c); gobject_class->constructed = koto_config_constructed; @@ -145,7 +145,7 @@ static void koto_config_init(KotoConfig * self) { self->finalized = FALSE; } -static void koto_config_constructed(GObject *obj) { +static void koto_config_constructed(GObject * obj) { KotoConfig * self = KOTO_CONFIG(obj); self->finalized = TRUE; } @@ -190,7 +190,7 @@ static void koto_config_set_property( switch (prop_id) { case PROP_PLAYBACK_CONTINUE_ON_PLAYLIST: - self->playback_continue_on_playlist = g_value_get_boolean(val); + self->playback_continue_on_playlist = g_value_get_boolean(val); break; case PROP_PLAYBACK_LAST_USED_VOLUME: self->playback_last_used_volume = g_value_get_double(val); @@ -202,7 +202,7 @@ static void koto_config_set_property( self->ui_theme_desired = g_strdup(g_value_get_string(val)); break; case PROP_UI_THEME_OVERRIDE: - self->ui_theme_override = g_value_get_boolean(val); + self->ui_theme_override = g_value_get_boolean(val); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); @@ -216,8 +216,11 @@ static void koto_config_set_property( /** * Load our TOML file from the specified path into our KotoConfig -**/ -void koto_config_load(KotoConfig * self, gchar *path) { + **/ +void koto_config_load( + KotoConfig * self, + gchar * path +) { if (!koto_utils_is_string_valid(path)) { // Path is not valid return; } @@ -248,7 +251,8 @@ void koto_config_load(KotoConfig * self, gchar *path) { GError * file_info_query_err; - GFileInfo * file_info = g_file_query_info( // Get the size of our TOML file + GFileInfo * file_info = g_file_query_info( + // Get the size of our TOML file self->config_file, G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, @@ -313,7 +317,7 @@ void koto_config_load(KotoConfig * self, gchar *path) { if (playback_section) { // Have playback section toml_datum_t continue_on_playlist = toml_bool_in(playback_section, "continue-on-playlist"); - toml_datum_t last_used_volume = toml_double_in(playback_section, "last-used-volume"); + toml_datum_t last_used_volume = toml_double_in(playback_section, "last-used-volume"); toml_datum_t maintain_shuffle = toml_bool_in(playback_section, "maintain-shuffle"); if (continue_on_playlist.ok && (self->playback_continue_on_playlist != continue_on_playlist.u.b)) { // If we have a continue-on-playlist set and they are different @@ -344,7 +348,7 @@ void koto_config_load(KotoConfig * self, gchar *path) { toml_datum_t override_app = toml_bool_in(ui_section, "theme-override"); if (override_app.ok && (override_app.u.b != self->ui_theme_override)) { // Changed if we are overriding theme - g_object_set(self, "ui-theme-override", override_app.u.b, NULL); + g_object_set(self, "ui-theme-override", override_app.u.b, NULL); } } @@ -367,7 +371,13 @@ monitor: } } -void koto_config_monitor_handle_changed(GFileMonitor * monitor, GFile * file, GFile *other_file, GFileMonitorEvent ev, gpointer user_data) { +void koto_config_monitor_handle_changed( + GFileMonitor * monitor, + GFile * file, + GFile * other_file, + GFileMonitorEvent ev, + gpointer user_data +) { (void) monitor; (void) file; (void) other_file; @@ -383,15 +393,15 @@ void koto_config_monitor_handle_changed(GFileMonitor * monitor, GFile * file, GF /** * Refresh will handle any FS notify change on our Koto config file and call load -**/ + **/ void koto_config_refresh(KotoConfig * self) { koto_config_load(self, self->path); } /** * Save will write our config back out -**/ -void koto_config_save(KotoConfig *self) { + **/ +void koto_config_save(KotoConfig * self) { GStrvBuilder * root_builder = g_strv_builder_new(); // Create a new strv builder GParamSpec ** props_list = g_object_class_list_properties(G_OBJECT_GET_CLASS(self), NULL); // Get the propreties associated with our settings @@ -408,7 +418,7 @@ void koto_config_save(KotoConfig *self) { int i; for (i = 0; i < N_PROPS; i++) { // For each property - GParamSpec *spec = props_list[i]; // Get the prop + GParamSpec * spec = props_list[i]; // Get the prop if (!G_IS_PARAM_SPEC(spec)) { // Not a spec continue; // Skip @@ -429,7 +439,7 @@ void koto_config_save(KotoConfig *self) { } GList * keys; - + if (g_hash_table_contains(sections_to_prop_keys, respective_prop)) { // Already has list keys = g_hash_table_lookup(sections_to_prop_keys, respective_prop); // Get the list } else { // Don't have list @@ -447,7 +457,7 @@ void koto_config_save(KotoConfig *self) { while (g_hash_table_iter_next(&iter, §ion_name, §ion_props)) { GStrvBuilder * section_builder = g_strv_builder_new(); // Make our string builder - g_strv_builder_add(section_builder, g_strdup_printf("[%s]", (gchar *) section_name)); // Add section as [section] + g_strv_builder_add(section_builder, g_strdup_printf("[%s]", (gchar*) section_name)); // Add section as [section] GList * current_section_keyname; for (current_section_keyname = section_props; current_section_keyname != NULL; current_section_keyname = current_section_keyname->next) { // Iterate over property names @@ -460,7 +470,7 @@ void koto_config_save(KotoConfig *self) { } gchar * key_name = g_strdup(current_section_keyname->data); - gchar * key_name_replaced = koto_utils_replace_string_all(key_name, g_strdup_printf("%s-", (gchar *) section_name), ""); // Remove SECTIONNAME- + gchar * key_name_replaced = koto_utils_replace_string_all(key_name, g_strdup_printf("%s-", (gchar*) section_name), ""); // Remove SECTIONNAME- const gchar * line = g_strdup_printf("\t%s = %s", key_name_replaced, prop_val); @@ -501,5 +511,5 @@ void koto_config_save(KotoConfig *self) { } KotoConfig * koto_config_new() { - return g_object_new (KOTO_TYPE_CONFIG, NULL); + return g_object_new(KOTO_TYPE_CONFIG, NULL); } \ No newline at end of file diff --git a/src/config/config.h b/src/config/config.h index 7296439..c0b6877 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -30,9 +30,21 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(KotoConfig, koto_config, KOTO, CONFIG, GObject) KotoConfig* koto_config_new(); -void koto_config_load(KotoConfig * self, gchar *path); -void koto_config_monitor_handle_changed(GFileMonitor * monitor, GFile * file, GFile *other_file, GFileMonitorEvent ev, gpointer user_data); +void koto_config_load( + KotoConfig * self, + gchar * path +); + +void koto_config_monitor_handle_changed( + GFileMonitor * monitor, + GFile * file, + GFile * other_file, + GFileMonitorEvent ev, + gpointer user_data +); + void koto_config_refresh(KotoConfig * self); + void koto_config_save(KotoConfig * self); G_END_DECLS \ No newline at end of file diff --git a/src/indexer/file-indexer.c b/src/indexer/file-indexer.c index 4050e67..6402acb 100644 --- a/src/indexer/file-indexer.c +++ b/src/indexer/file-indexer.c @@ -65,7 +65,6 @@ static void koto_library_set_property( static void koto_library_class_init(KotoLibraryClass * c) { GObjectClass * gobject_class; - gobject_class = G_OBJECT_CLASS(c); gobject_class->set_property = koto_library_set_property; gobject_class->get_property = koto_library_get_property; @@ -99,7 +98,6 @@ void koto_library_add_artist( gchar * artist_name; gchar * artist_uuid; - g_object_get(artist, "name", &artist_name, "uuid", &artist_uuid, NULL); if (g_hash_table_contains(self->music_artists, artist_name)) { // Already have the artist @@ -122,7 +120,6 @@ KotoArtist * koto_library_get_artist( gchar * artist_uuid = g_hash_table_lookup(self->music_artists, artist_name); // Get the UUID from our music artists - if (artist_uuid != NULL) { KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Return any artist from cartographer return artist; diff --git a/src/koto-paths.c b/src/koto-paths.c index 49561b9..3b5fef0 100644 --- a/src/koto-paths.c +++ b/src/koto-paths.c @@ -30,10 +30,10 @@ gchar * koto_path_to_db; void koto_paths_setup() { koto_rev_dns = "com.github.joshstrobl.koto"; - const gchar *user_cache_dir = g_get_user_data_dir(); + const gchar * user_cache_dir = g_get_user_data_dir(); const gchar * user_config_dir = g_get_user_config_dir(); - koto_path_cache = g_build_path(G_DIR_SEPARATOR_S, user_cache_dir, koto_rev_dns,NULL); + koto_path_cache = g_build_path(G_DIR_SEPARATOR_S, user_cache_dir, koto_rev_dns, NULL); koto_path_config = g_build_path(G_DIR_SEPARATOR_S, user_config_dir, koto_rev_dns, NULL); koto_path_to_conf = g_build_filename(koto_path_config, "config.toml", NULL); koto_path_to_db = g_build_filename( koto_path_cache, "db", NULL); diff --git a/src/koto-playerbar.c b/src/koto-playerbar.c index 432794a..4d8dbbf 100644 --- a/src/koto-playerbar.c +++ b/src/koto-playerbar.c @@ -29,7 +29,7 @@ extern KotoAddRemoveTrackPopover * koto_add_remove_track_popup; extern KotoCartographer * koto_maps; -extern KotoConfig *config; +extern KotoConfig * config; extern KotoCurrentPlaylist * current_playlist; extern KotoPlaybackEngine * playback_engine; diff --git a/src/koto-window.c b/src/koto-window.c index 2f2bee1..2ead509 100644 --- a/src/koto-window.c +++ b/src/koto-window.c @@ -158,7 +158,11 @@ void koto_window_add_page( gtk_stack_add_named(GTK_STACK(self->pages), page, page_name); } -void koto_window_manage_style(KotoConfig * c, guint prop_id, KotoWindow * self) { +void koto_window_manage_style( + KotoConfig * c, + guint prop_id, + KotoWindow * self +) { (void) prop_id; if (!KOTO_IS_WINDOW(self)) { // Not a Koto Window @@ -181,7 +185,7 @@ void koto_window_manage_style(KotoConfig * c, guint prop_id, KotoWindow * self) } GtkStyleContext * context = gtk_widget_get_style_context(GTK_WIDGET(self)); - + if (!overriding_theme) { // If we are not overriding the theme if (!gtk_style_context_has_class(context, "koto-theme-dark")) { // Don't have our css class for a theme gtk_style_context_add_provider_for_display(gdk_display_get_default(), GTK_STYLE_PROVIDER(self->provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -192,12 +196,12 @@ void koto_window_manage_style(KotoConfig * c, guint prop_id, KotoWindow * self) themes = g_list_append(themes, "gruvbox"); themes = g_list_append(themes, "light"); - GList *themes_head; + GList * themes_head; for (themes_head = themes; themes_head != NULL; themes_head = themes_head->next) { // For each theme - gchar * theme_class_name = g_strdup_printf("koto-theme-%s", (gchar *) themes->data); // Get the theme + gchar * theme_class_name = g_strdup_printf("koto-theme-%s", (gchar*) themes->data); // Get the theme - if (g_strcmp0((gchar *) themes->data, desired_theme) == 0) { // If we are using this theme + if (g_strcmp0((gchar*) themes->data, desired_theme) == 0) { // If we are using this theme gtk_widget_add_css_class(GTK_WIDGET(self), theme_class_name); // Add the CSS class } else { gtk_widget_remove_css_class(GTK_WIDGET(self), theme_class_name); // Remove the CSS class diff --git a/src/pages/music/album-view.c b/src/pages/music/album-view.c index 05718ac..28f36c5 100644 --- a/src/pages/music/album-view.c +++ b/src/pages/music/album-view.c @@ -35,7 +35,7 @@ struct _KotoAlbumView { GtkWidget * album_tracks_box; GtkWidget * discs; - KotoCoverArtButton *album_cover; + KotoCoverArtButton * album_cover; GtkWidget * album_label; GHashTable * cd_to_track_listbox; diff --git a/src/playback/engine.c b/src/playback/engine.c index fcb6ff7..1f9fc6f 100644 --- a/src/playback/engine.c +++ b/src/playback/engine.c @@ -287,7 +287,11 @@ void koto_playback_engine_backwards(KotoPlaybackEngine * self) { koto_playback_engine_set_track_by_uuid(self, koto_playlist_go_to_previous(playlist), FALSE); } -void koto_playback_engine_current_playlist_changed(KotoCurrentPlaylist * current_pl, guint prop_id, KotoPlaybackEngine *self) { +void koto_playback_engine_current_playlist_changed( + KotoCurrentPlaylist * current_pl, + guint prop_id, + KotoPlaybackEngine * self +) { (void) current_pl; (void) prop_id; diff --git a/src/playback/engine.h b/src/playback/engine.h index 4a84515..f90f4a7 100644 --- a/src/playback/engine.h +++ b/src/playback/engine.h @@ -52,7 +52,11 @@ void koto_playback_engine_apply_configuration_state( void koto_playback_engine_backwards(KotoPlaybackEngine * self); -void koto_playback_engine_current_playlist_changed(KotoCurrentPlaylist * current_pl, guint prop_id, KotoPlaybackEngine *self); +void koto_playback_engine_current_playlist_changed( + KotoCurrentPlaylist * current_pl, + guint prop_id, + KotoPlaybackEngine * self +); void koto_playback_engine_forwards(KotoPlaybackEngine * self);