|
|
|
@ -876,7 +876,51 @@ config_str yon_ubl_get_all_slices(int *slices_size){
|
|
|
|
|
|
|
|
|
|
|
|
// parsing functions
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_key_file_free(gfile);
|
|
|
|
|
|
|
|
gfile = g_key_file_new();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (apps_dict) return apps_dict;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int scanned_size=0;
|
|
|
|
|
|
|
|
static apps *scanned_application = NULL;
|
|
|
|
apps *yon_apps_scan_and_parse_desktops(int *sizef)
|
|
|
|
apps *yon_apps_scan_and_parse_desktops(int *sizef)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int size = 0;
|
|
|
|
int size = 0;
|
|
|
|
@ -899,68 +943,75 @@ apps *yon_apps_scan_and_parse_desktops(int *sizef)
|
|
|
|
apps tempapp;
|
|
|
|
apps tempapp;
|
|
|
|
GKeyFile *gfile = g_key_file_new();
|
|
|
|
GKeyFile *gfile = g_key_file_new();
|
|
|
|
GError *err = NULL;
|
|
|
|
GError *err = NULL;
|
|
|
|
g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
|
|
|
|
g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, &err);
|
|
|
|
char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err);
|
|
|
|
if (!err){
|
|
|
|
if (err)
|
|
|
|
char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err);
|
|
|
|
{
|
|
|
|
if (err)
|
|
|
|
printf("%s\n", err->message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(Type, "Application") == 0)
|
|
|
|
|
|
|
|
tempapp.Type = 1;
|
|
|
|
|
|
|
|
else if (strcmp(Type, "pyApplication") == 0)
|
|
|
|
|
|
|
|
tempapp.Type = 2;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL);
|
|
|
|
|
|
|
|
if (tempapp.Name == NULL)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL);
|
|
|
|
|
|
|
|
if (tempapp.Categories == NULL)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL);
|
|
|
|
|
|
|
|
if (tempapp.Exec == NULL)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL);
|
|
|
|
|
|
|
|
if (tempapp.Icon == NULL)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL);
|
|
|
|
|
|
|
|
if (!tempapp.Pluggable)
|
|
|
|
|
|
|
|
tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL);
|
|
|
|
|
|
|
|
if (tempapp.Pluggable)
|
|
|
|
|
|
|
|
tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL);
|
|
|
|
|
|
|
|
if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0)
|
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
applist = (apps *)malloc(size + 1 * sizeof(apps));
|
|
|
|
printf("%s\n", err->message);
|
|
|
|
applist[0].filename = yon_char_new(path);
|
|
|
|
} else {
|
|
|
|
applist[0].Name = yon_char_new(tempapp.Name);
|
|
|
|
if (strcmp(Type, "Application") == 0)
|
|
|
|
applist[0].Categories = yon_char_new(tempapp.Categories);
|
|
|
|
tempapp.Type = 1;
|
|
|
|
applist[0].Exec = yon_char_new(tempapp.Exec);
|
|
|
|
else if (strcmp(Type, "pyApplication") == 0)
|
|
|
|
applist[0].Icon = yon_char_new(tempapp.Icon);
|
|
|
|
tempapp.Type = 2;
|
|
|
|
applist[0].Type = tempapp.Type;
|
|
|
|
else
|
|
|
|
applist[0].Pluggable = tempapp.Pluggable;
|
|
|
|
continue;
|
|
|
|
applist[0].DualPluggable = tempapp.DualPluggable;
|
|
|
|
tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL);
|
|
|
|
size++;
|
|
|
|
if (tempapp.Name == NULL)
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL);
|
|
|
|
{
|
|
|
|
if (tempapp.Categories == NULL)
|
|
|
|
applist = (apps *)realloc(applist, (size + 1) * sizeof(apps));
|
|
|
|
continue;
|
|
|
|
applist[size].filename = yon_char_new(path);
|
|
|
|
tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL);
|
|
|
|
applist[size].Name = yon_char_new(tempapp.Name);
|
|
|
|
if (tempapp.Exec == NULL)
|
|
|
|
applist[size].Categories = yon_char_new(tempapp.Categories);
|
|
|
|
continue;
|
|
|
|
applist[size].Exec = yon_char_new(tempapp.Exec);
|
|
|
|
tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL);
|
|
|
|
applist[size].Icon = yon_char_new(tempapp.Icon);
|
|
|
|
if (tempapp.Icon == NULL)
|
|
|
|
applist[size].Pluggable = tempapp.Pluggable;
|
|
|
|
continue;
|
|
|
|
applist[size].DualPluggable = tempapp.DualPluggable;
|
|
|
|
tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL);
|
|
|
|
applist[size].Type = tempapp.Type;
|
|
|
|
if (!tempapp.Pluggable)
|
|
|
|
size++;
|
|
|
|
tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL);
|
|
|
|
|
|
|
|
if (tempapp.Pluggable)
|
|
|
|
|
|
|
|
tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL);
|
|
|
|
|
|
|
|
if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0)
|
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
applist = (apps *)malloc(size + 1 * sizeof(apps));
|
|
|
|
|
|
|
|
applist[0].filename = yon_char_new(path);
|
|
|
|
|
|
|
|
applist[0].Name = yon_char_new(tempapp.Name);
|
|
|
|
|
|
|
|
applist[0].Categories = yon_char_new(tempapp.Categories);
|
|
|
|
|
|
|
|
applist[0].Exec = yon_char_new(tempapp.Exec);
|
|
|
|
|
|
|
|
applist[0].Icon = yon_char_new(tempapp.Icon);
|
|
|
|
|
|
|
|
applist[0].Type = tempapp.Type;
|
|
|
|
|
|
|
|
applist[0].Pluggable = tempapp.Pluggable;
|
|
|
|
|
|
|
|
applist[0].DualPluggable = tempapp.DualPluggable;
|
|
|
|
|
|
|
|
size++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
applist = (apps *)realloc(applist, (size + 1) * sizeof(apps));
|
|
|
|
|
|
|
|
applist[size].filename = yon_char_new(path);
|
|
|
|
|
|
|
|
applist[size].Name = yon_char_new(tempapp.Name);
|
|
|
|
|
|
|
|
applist[size].Categories = yon_char_new(tempapp.Categories);
|
|
|
|
|
|
|
|
applist[size].Exec = yon_char_new(tempapp.Exec);
|
|
|
|
|
|
|
|
applist[size].Icon = yon_char_new(tempapp.Icon);
|
|
|
|
|
|
|
|
applist[size].Pluggable = tempapp.Pluggable;
|
|
|
|
|
|
|
|
applist[size].DualPluggable = tempapp.DualPluggable;
|
|
|
|
|
|
|
|
applist[size].Type = tempapp.Type;
|
|
|
|
|
|
|
|
size++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_key_file_free(gfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*sizef = size;
|
|
|
|
*sizef = size;
|
|
|
|
|
|
|
|
scanned_application = applist;
|
|
|
|
|
|
|
|
scanned_size=size;
|
|
|
|
return applist;
|
|
|
|
return applist;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@ -1003,6 +1054,9 @@ void __yon_on_app_chooser_selection(GtkTreeView *self, GtkTreeStore *store){
|
|
|
|
if (gtk_tree_model_iter_nth_child(model,&parentiter,&iter,0))
|
|
|
|
if (gtk_tree_model_iter_nth_child(model,&parentiter,&iter,0))
|
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(self),&parentiter);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1023,9 +1077,13 @@ char *yon_app_chooser_open_with_sections(char *section_name, char *section_filte
|
|
|
|
gtk_dialog_add_buttons(GTK_DIALOG(dialog),_("Cancel"),0,_("Accept"),1,NULL);
|
|
|
|
gtk_dialog_add_buttons(GTK_DIALOG(dialog),_("Cancel"),0,_("Accept"),1,NULL);
|
|
|
|
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"ApplicationsWindow"));
|
|
|
|
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"ApplicationsWindow"));
|
|
|
|
GtkWidget *box = GTK_WIDGET(gtk_builder_get_object(builder,"box"));
|
|
|
|
GtkWidget *box = GTK_WIDGET(gtk_builder_get_object(builder,"box"));
|
|
|
|
|
|
|
|
GtkWidget *header = GTK_WIDGET(gtk_builder_get_object(builder,"ApplicationsHeaderBar"));
|
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog),_("Application"));
|
|
|
|
|
|
|
|
gtk_window_set_titlebar(GTK_WINDOW(dialog),header);
|
|
|
|
g_object_ref(box);
|
|
|
|
g_object_ref(box);
|
|
|
|
gtk_container_remove(GTK_CONTAINER(window),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_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),box,1,1,5);
|
|
|
|
|
|
|
|
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"));
|
|
|
|
GtkWidget *main_tree = GTK_WIDGET(gtk_builder_get_object(builder,"MainTree"));
|
|
|
|
GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(builder,"treestore1"));
|
|
|
|
GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(builder,"treestore1"));
|
|
|
|
va_list args;
|
|
|
|
va_list args;
|
|
|
|
@ -1046,16 +1104,22 @@ char *yon_app_chooser_open_with_sections(char *section_name, char *section_filte
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
va_end(args);
|
|
|
|
int size;
|
|
|
|
int size=scanned_size;
|
|
|
|
apps *app_list = yon_apps_scan_and_parse_desktops(&size);
|
|
|
|
apps *app_list = scanned_application ? scanned_application : yon_apps_scan_and_parse_desktops(&size);
|
|
|
|
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store),&iter);
|
|
|
|
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store),&iter);
|
|
|
|
for (; valid; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store),&iter)){
|
|
|
|
for (; valid; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store),&iter)){
|
|
|
|
char *cur_categories;
|
|
|
|
char *cur_categories;
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(store),&iter,2,&cur_categories,-1);
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(store),&iter,2,&cur_categories,-1);
|
|
|
|
for (int i=0; i<size;i++){
|
|
|
|
for (int i=0; i<size;i++){
|
|
|
|
if (strstr(app_list[i].Categories,cur_categories)){
|
|
|
|
if (strstr(app_list[i].Categories,cur_categories)){
|
|
|
|
gtk_tree_store_append(store,&childiter,&iter);
|
|
|
|
if (i>0&&strcmp(app_list[i].Name,app_list[i-1].Name)){
|
|
|
|
gtk_tree_store_set(store,&childiter,0,app_list[i].Icon, 1,app_list[i].Name, 2, app_list[i].filename, -1);
|
|
|
|
if (strstr(app_list[i].Icon,"/")){
|
|
|
|
|
|
|
|
yon_char_divide(app_list[i].Icon,yon_char_find_last(app_list[i].Icon,'/'));
|
|
|
|
|
|
|
|
app_list[i].Icon = yon_char_divide(app_list[i].Icon,yon_char_find_last(app_list[i].Icon,'.'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_store_append(store,&childiter,&iter);
|
|
|
|
|
|
|
|
gtk_tree_store_set(store,&childiter,0,app_list[i].Icon, 1,app_list[i].Name, 2, app_list[i].filename, -1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1070,9 +1134,12 @@ char *yon_app_chooser_open_with_sections(char *section_name, char *section_filte
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
return path;
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
yon_subwindow_close(box);
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|