From 612baa543b5ea30754d0db1d445c769f2ae41680 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 5 Sep 2023 12:14:24 +0600 Subject: [PATCH] Hat visual height srinked by recoloring box background --- source/ubl-utils.c | 46 ++++++++++++++++++++++++++++++++++++++- source/ubl-utils.h | 3 +++ ublexec-application.glade | 4 +++- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 8bbf012..c444022 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -876,6 +876,46 @@ config_str yon_ubl_get_all_slices(int *slices_size){ // parsing functions +dictionary *yon_scan_desktops(){ + dictionary *apps_dict = NULL; + DIR *directory = opendir(DesktopPath); + struct dirent *de; + while ((de = readdir(directory))) + { + FILE *file; + char *path = yon_char_append(DesktopPath, de->d_name); + file = fopen(path, "r"); + if (strstr(path,".desktop")){ + apps *application = malloc(sizeof(apps)); + GKeyFile *gfile = g_key_file_new(); + GError *err = NULL; + if (!access(path,F_OK)){ + g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); + application->Type = !strcmp(g_key_file_get_string(gfile, "Desktop Entry", "Type", &err),"Application") ? 1 : 0; + if (application->Type){ + application->Name = g_key_file_get_locale_string(gfile,"Desktop Entry", "Name",setlocale(LC_ALL, NULL),&err); + application->Categories = g_key_file_get_string(gfile,"Desktop Entry", "Categories",&err); + application->Exec = g_key_file_get_string(gfile,"Desktop Entry", "Exec",&err); + application->Icon = g_key_file_get_string(gfile,"Desktop Entry", "Icon",&err); + application->Pluggable = (g_key_file_get_boolean(gfile,"Desktop Entry", "Pluggable",NULL)|| + g_key_file_get_boolean(gfile,"Desktop Entry", "X-XfcePluggable",&err)); + application->DualPluggable = g_key_file_get_boolean(gfile,"Desktop Entry", "X-UBLPluggable",NULL); + application->Hidden = g_key_file_get_boolean(gfile,"Desktop Entry", "X-X-UBL-SettingsManager-Hidden",NULL); + if (application->Name&&application->Exec){ + if (!apps_dict){ + yon_dictionary_add_or_create_if_exists_with_data(apps_dict,application->Name,application); + } else if (!yon_dictionary_get(&apps_dict,application->Name)){ + yon_dictionary_add_or_create_if_exists_with_data(apps_dict,application->Name,application); + } else { + yon_dictionary_set_data(apps_dict,application); + } + } + } + } + } + } + if (apps_dict) return apps_dict; +} apps *yon_apps_scan_and_parse_desktops(int *sizef) { @@ -956,6 +996,7 @@ apps *yon_apps_scan_and_parse_desktops(int *sizef) size++; } } + g_key_file_free(gfile); } } } @@ -1004,6 +1045,9 @@ void __yon_on_app_chooser_selection(GtkTreeView *self, GtkTreeStore *store){ if (gtk_tree_model_iter_nth_child(model,&parentiter,&iter,0)) gtk_tree_selection_select_iter(gtk_tree_view_get_selection(self),&parentiter); } + } else { + gtk_tree_model_get_iter_first(model,&iter); + gtk_tree_selection_select_iter(gtk_tree_view_get_selection(self),&iter); } } @@ -1027,7 +1071,7 @@ char *yon_app_chooser_open_with_sections(char *section_name, char *section_filte g_object_ref(box); gtk_container_remove(GTK_CONTAINER(window),box); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),box,1,1,5); - (gtk_dialog_get_content_area(GTK_DIALOG(dialog)),0); + gtk_style_context_add_class(gtk_widget_get_style_context(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),"workingbg"); GtkWidget *main_tree = GTK_WIDGET(gtk_builder_get_object(builder,"MainTree")); GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(builder,"treestore1")); va_list args; diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 7d05925..01c1f9d 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -73,6 +73,7 @@ typedef struct apps char *Icon; int Pluggable; int DualPluggable; + int Hidden; } apps; typedef char** config_str; @@ -188,6 +189,8 @@ config_str yon_ubl_get_all_slices(int *slices_size); config_str philos_list_user(int* size); +dictionary *yon_scan_desktops(); + apps *yon_apps_scan_and_parse_desktops(int *sizef); void yon_apps_sort(apps *applist, int size); diff --git a/ublexec-application.glade b/ublexec-application.glade index cae39b8..d6e2ca2 100644 --- a/ublexec-application.glade +++ b/ublexec-application.glade @@ -27,7 +27,6 @@ True True - in True @@ -35,6 +34,9 @@ treestore1 False treeviewcolumn1 + + + column