Apply formatting
This commit is contained in:
parent
fa19fd23b1
commit
4cc5c6efd4
9 changed files with 66 additions and 35 deletions
|
@ -73,7 +73,7 @@ G_DEFINE_TYPE(KotoConfig, koto_config, G_TYPE_OBJECT);
|
||||||
|
|
||||||
KotoConfig * config;
|
KotoConfig * config;
|
||||||
|
|
||||||
static void koto_config_constructed(GObject *obj);
|
static void koto_config_constructed(GObject * obj);
|
||||||
|
|
||||||
static void koto_config_get_property(
|
static void koto_config_get_property(
|
||||||
GObject * obj,
|
GObject * obj,
|
||||||
|
@ -89,7 +89,7 @@ static void koto_config_set_property(
|
||||||
GParamSpec * spec
|
GParamSpec * spec
|
||||||
);
|
);
|
||||||
|
|
||||||
static void koto_config_class_init(KotoConfigClass *c) {
|
static void koto_config_class_init(KotoConfigClass * c) {
|
||||||
GObjectClass * gobject_class;
|
GObjectClass * gobject_class;
|
||||||
gobject_class = G_OBJECT_CLASS(c);
|
gobject_class = G_OBJECT_CLASS(c);
|
||||||
gobject_class->constructed = koto_config_constructed;
|
gobject_class->constructed = koto_config_constructed;
|
||||||
|
@ -145,7 +145,7 @@ static void koto_config_init(KotoConfig * self) {
|
||||||
self->finalized = FALSE;
|
self->finalized = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void koto_config_constructed(GObject *obj) {
|
static void koto_config_constructed(GObject * obj) {
|
||||||
KotoConfig * self = KOTO_CONFIG(obj);
|
KotoConfig * self = KOTO_CONFIG(obj);
|
||||||
self->finalized = TRUE;
|
self->finalized = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -216,8 +216,11 @@ static void koto_config_set_property(
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load our TOML file from the specified path into our KotoConfig
|
* 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
|
if (!koto_utils_is_string_valid(path)) { // Path is not valid
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +251,8 @@ void koto_config_load(KotoConfig * self, gchar *path) {
|
||||||
|
|
||||||
GError * file_info_query_err;
|
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,
|
self->config_file,
|
||||||
G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
||||||
G_FILE_QUERY_INFO_NONE,
|
G_FILE_QUERY_INFO_NONE,
|
||||||
|
@ -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) monitor;
|
||||||
(void) file;
|
(void) file;
|
||||||
(void) other_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
|
* Refresh will handle any FS notify change on our Koto config file and call load
|
||||||
**/
|
**/
|
||||||
void koto_config_refresh(KotoConfig * self) {
|
void koto_config_refresh(KotoConfig * self) {
|
||||||
koto_config_load(self, self->path);
|
koto_config_load(self, self->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save will write our config back out
|
* 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
|
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
|
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;
|
int i;
|
||||||
for (i = 0; i < N_PROPS; i++) { // For each property
|
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
|
if (!G_IS_PARAM_SPEC(spec)) { // Not a spec
|
||||||
continue; // Skip
|
continue; // Skip
|
||||||
|
@ -447,7 +457,7 @@ void koto_config_save(KotoConfig *self) {
|
||||||
|
|
||||||
while (g_hash_table_iter_next(&iter, §ion_name, §ion_props)) {
|
while (g_hash_table_iter_next(&iter, §ion_name, §ion_props)) {
|
||||||
GStrvBuilder * section_builder = g_strv_builder_new(); // Make our string builder
|
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;
|
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
|
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 = 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);
|
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() {
|
KotoConfig * koto_config_new() {
|
||||||
return g_object_new (KOTO_TYPE_CONFIG, NULL);
|
return g_object_new(KOTO_TYPE_CONFIG, NULL);
|
||||||
}
|
}
|
|
@ -30,9 +30,21 @@ G_BEGIN_DECLS
|
||||||
G_DECLARE_FINAL_TYPE(KotoConfig, koto_config, KOTO, CONFIG, GObject)
|
G_DECLARE_FINAL_TYPE(KotoConfig, koto_config, KOTO, CONFIG, GObject)
|
||||||
|
|
||||||
KotoConfig* koto_config_new();
|
KotoConfig* koto_config_new();
|
||||||
void koto_config_load(KotoConfig * self, gchar *path);
|
void koto_config_load(
|
||||||
void koto_config_monitor_handle_changed(GFileMonitor * monitor, GFile * file, GFile *other_file, GFileMonitorEvent ev, gpointer user_data);
|
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_refresh(KotoConfig * self);
|
||||||
|
|
||||||
void koto_config_save(KotoConfig * self);
|
void koto_config_save(KotoConfig * self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
|
@ -65,7 +65,6 @@ static void koto_library_set_property(
|
||||||
static void koto_library_class_init(KotoLibraryClass * c) {
|
static void koto_library_class_init(KotoLibraryClass * c) {
|
||||||
GObjectClass * gobject_class;
|
GObjectClass * gobject_class;
|
||||||
|
|
||||||
|
|
||||||
gobject_class = G_OBJECT_CLASS(c);
|
gobject_class = G_OBJECT_CLASS(c);
|
||||||
gobject_class->set_property = koto_library_set_property;
|
gobject_class->set_property = koto_library_set_property;
|
||||||
gobject_class->get_property = koto_library_get_property;
|
gobject_class->get_property = koto_library_get_property;
|
||||||
|
@ -99,7 +98,6 @@ void koto_library_add_artist(
|
||||||
gchar * artist_name;
|
gchar * artist_name;
|
||||||
gchar * artist_uuid;
|
gchar * artist_uuid;
|
||||||
|
|
||||||
|
|
||||||
g_object_get(artist, "name", &artist_name, "uuid", &artist_uuid, NULL);
|
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
|
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
|
gchar * artist_uuid = g_hash_table_lookup(self->music_artists, artist_name); // Get the UUID from our music artists
|
||||||
|
|
||||||
|
|
||||||
if (artist_uuid != NULL) {
|
if (artist_uuid != NULL) {
|
||||||
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Return any artist from cartographer
|
KotoArtist * artist = koto_cartographer_get_artist_by_uuid(koto_maps, artist_uuid); // Return any artist from cartographer
|
||||||
return artist;
|
return artist;
|
||||||
|
|
|
@ -30,10 +30,10 @@ gchar * koto_path_to_db;
|
||||||
|
|
||||||
void koto_paths_setup() {
|
void koto_paths_setup() {
|
||||||
koto_rev_dns = "com.github.joshstrobl.koto";
|
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();
|
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_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_conf = g_build_filename(koto_path_config, "config.toml", NULL);
|
||||||
koto_path_to_db = g_build_filename( koto_path_cache, "db", NULL);
|
koto_path_to_db = g_build_filename( koto_path_cache, "db", NULL);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
extern KotoAddRemoveTrackPopover * koto_add_remove_track_popup;
|
extern KotoAddRemoveTrackPopover * koto_add_remove_track_popup;
|
||||||
extern KotoCartographer * koto_maps;
|
extern KotoCartographer * koto_maps;
|
||||||
extern KotoConfig *config;
|
extern KotoConfig * config;
|
||||||
extern KotoCurrentPlaylist * current_playlist;
|
extern KotoCurrentPlaylist * current_playlist;
|
||||||
extern KotoPlaybackEngine * playback_engine;
|
extern KotoPlaybackEngine * playback_engine;
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,11 @@ void koto_window_add_page(
|
||||||
gtk_stack_add_named(GTK_STACK(self->pages), page, page_name);
|
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;
|
(void) prop_id;
|
||||||
|
|
||||||
if (!KOTO_IS_WINDOW(self)) { // Not a Koto Window
|
if (!KOTO_IS_WINDOW(self)) { // Not a Koto Window
|
||||||
|
@ -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, "gruvbox");
|
||||||
themes = g_list_append(themes, "light");
|
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
|
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
|
gtk_widget_add_css_class(GTK_WIDGET(self), theme_class_name); // Add the CSS class
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_remove_css_class(GTK_WIDGET(self), theme_class_name); // Remove the CSS class
|
gtk_widget_remove_css_class(GTK_WIDGET(self), theme_class_name); // Remove the CSS class
|
||||||
|
|
|
@ -35,7 +35,7 @@ struct _KotoAlbumView {
|
||||||
GtkWidget * album_tracks_box;
|
GtkWidget * album_tracks_box;
|
||||||
GtkWidget * discs;
|
GtkWidget * discs;
|
||||||
|
|
||||||
KotoCoverArtButton *album_cover;
|
KotoCoverArtButton * album_cover;
|
||||||
|
|
||||||
GtkWidget * album_label;
|
GtkWidget * album_label;
|
||||||
GHashTable * cd_to_track_listbox;
|
GHashTable * cd_to_track_listbox;
|
||||||
|
|
|
@ -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);
|
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) current_pl;
|
||||||
(void) prop_id;
|
(void) prop_id;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,11 @@ void koto_playback_engine_apply_configuration_state(
|
||||||
|
|
||||||
void koto_playback_engine_backwards(KotoPlaybackEngine * self);
|
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);
|
void koto_playback_engine_forwards(KotoPlaybackEngine * self);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue