From a3c00d1ebaad3c5be83705d70372c51e209bce7e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 14 May 2025 12:27:56 +0600 Subject: [PATCH] Services sort fixed --- source/ubl-settings-services-systemd.c | 22 +++++++++++++--------- source/ubl-settings-services.c | 5 ++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/source/ubl-settings-services-systemd.c b/source/ubl-settings-services-systemd.c index 86e8b5e..2e02265 100644 --- a/source/ubl-settings-services-systemd.c +++ b/source/ubl-settings-services-systemd.c @@ -82,15 +82,19 @@ dictionary *yon_systemd_get_list() { } } if (!found) { - systemd_struct *u = calloc(1, sizeof(systemd_struct)); - u->name = yon_char_new(name); - u->description = yon_char_new(""); - u->load = 0; - u->active = 0; - u->state = yon_char_new(""); - u->enable = 0; - - yon_dictionary_add_or_create_if_exists_with_data(dict, (char*)name, u); + char *temp_name = yon_char_new(name); + if (!yon_dictionary_get(&dict,temp_name)){ + systemd_struct *u = calloc(1, sizeof(systemd_struct)); + free(yon_char_divide(temp_name,yon_char_find_last(temp_name,'/'))); + u->name = temp_name; + u->description = yon_char_new(""); + u->load = 0; + u->active = 0; + u->state = _("disabled"); + u->enable = 0; + + yon_dictionary_add_or_create_if_exists_with_data(dict, (char*)temp_name, u); + } } sd_bus_message_exit_container(reply); } diff --git a/source/ubl-settings-services.c b/source/ubl-settings-services.c index d70246b..62ac971 100644 --- a/source/ubl-settings-services.c +++ b/source/ubl-settings-services.c @@ -2077,9 +2077,12 @@ void yon_main_window_complete(main_window *widgets){ gtk_tree_model_filter_set_visible_func(widgets->SystemFilter,(GtkTreeModelFilterVisibleFunc)yon_filter,widgets,NULL); for (int i=0;i<5;i++){ gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(widgets->SystemSort),i,(GtkTreeIterCompareFunc)sort_bool,GINT_TO_POINTER(i),NULL); + gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(widgets->UserSort),i,(GtkTreeIterCompareFunc)sort_bool,GINT_TO_POINTER(i),NULL); } gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(widgets->SystemSort),5,(GtkTreeIterCompareFunc)sort_string,GINT_TO_POINTER(13),NULL); - gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(widgets->SystemSort),6,(GtkTreeIterCompareFunc)sort_string,GINT_TO_POINTER(6),NULL); + gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(widgets->SystemSort),6,(GtkTreeIterCompareFunc)sort_string,GINT_TO_POINTER(5),NULL); + gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(widgets->UserSort),5,(GtkTreeIterCompareFunc)sort_string,GINT_TO_POINTER(13),NULL); + gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(widgets->UserSort),6,(GtkTreeIterCompareFunc)sort_string,GINT_TO_POINTER(5),NULL); gtk_tree_view_set_search_column(GTK_TREE_VIEW(widgets->UserUnitsTree),5); yon_load_proceed(YON_CONFIG_LOCAL); yon_ubl_status_box_render(LIST_LOAD_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);