You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ubl-settings-manager/source/ubl-settings-manager.c

1432 lines
70 KiB

#include "ubl-settings-manager.h"
config main_config;
// void on_plug_added(GtkSocket* self, main_window *builder){
// gtk_widget_show(builder->socketbutton);
// gtk_widget_show(builder->ThirdSocket);
// gtk_widget_set_vexpand(builder->HideWhileLaunch,0);
// gtk_widget_hide(builder->HideWhileLaunch);
// gtk_widget_set_vexpand(GTK_WIDGET(builder->socketplace),1);
// gtk_widget_set_vexpand(GTK_WIDGET(self),1);
// gtk_widget_show(builder->socketplace);
// gtk_widget_hide(builder->appSettings);
// if (builder->ButtonBackToMain!=NULL) gtk_widget_show(builder->ButtonBackToMain);
// gtk_widget_show(GTK_WIDGET(self));
// gtk_widget_show(builder->socketbuttonplace);
// gtk_widget_show(builder->ThirdSocketPlace);
// gtk_widget_show(builder->socketbutton);
// gtk_widget_show(builder->ThirdSocket);
// }
// void on_plug_removed(GtkSocket* self, main_window *widgets){
// on_backToSettingsButton_clicked(widgets->ButtonBackToMain,widgets);
// gtk_widget_show(widgets->socketbuttonplace);
// gtk_widget_show(widgets->appSettings);
// gtk_widget_show(widgets->HideWhileLaunch);
// gtk_widget_set_vexpand(widgets->socketplace,0);
// gtk_widget_set_vexpand(widgets->HideWhileLaunch,1);
// }
// void on_Item_activated(GtkIconView* self, GtkTreePath* path, main_window *applist){
// GtkTreeIter iter;
// char *name;
// if (applist->socket){
// gtk_widget_destroy(applist->socket);
// }
// applist->socket=create_socket(applist);
// gtk_tree_model_get_iter(gtk_icon_view_get_model(self),&iter,path);
// gtk_tree_model_get(gtk_icon_view_get_model(self),&iter,0,&name,-1);
// apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize);
// if (!tempapp){}else{
// char *arg=NULL;
// arg=yon_char_get_augumented("--socket-id=",yon_char_from_int((int)gtk_socket_get_id(GTK_SOCKET(applist->socket))));
// if (tempapp[0].Type==1){
// if (tempapp->Pluggable==1)
// if (tempapp->DualPluggable==1){
// char *dualarg=NULL;
// dualarg=yon_char_get_augumented("--socket-id=",yon_char_get_augumented(yon_char_from_int((int)gtk_socket_get_id(GTK_SOCKET(applist->socket))),yon_char_get_augumented(" --socket-ext-id=",yon_char_get_augumented(yon_char_from_int((int)gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))),yon_char_get_augumented(" --socket-trd-id=",yon_char_from_int((int)gtk_socket_get_id(GTK_SOCKET(applist->ThirdSocket))))))));
// launch_app_with_arguments(tempapp[0].Exec,dualarg);
// } else
// launch_app_with_arguments(tempapp[0].Exec,arg);
// else launch_app(tempapp[0].Exec);
// }
// }
// };
// void on_gnome_Item_activated(GtkIconView* self, GtkTreePath* path, main_window *applist){
// GtkTreeIter iter;
// char *name;
// if (applist->socket){
// gtk_widget_destroy(applist->socket);
// }
// applist->socket=create_socket(applist);
// gtk_tree_model_get_iter(gtk_icon_view_get_model(self),&iter,path);
// gtk_tree_model_get(gtk_icon_view_get_model(self),&iter,0,&name,-1);
// apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize);
// char *arg=NULL;
// arg=yon_char_get_augumented("--socket-id=",yon_char_from_int((int)gtk_socket_get_id(GTK_SOCKET(applist->socket))));
// if (tempapp[0].Type==1){
// if (tempapp->Pluggable==1){
// if (tempapp->DualPluggable==1){
// char *dualarg=NULL;
// dualarg=yon_char_get_augumented("--socket-id=",yon_char_get_augumented(yon_char_from_int((int)gtk_socket_get_id(GTK_SOCKET(applist->socket))),yon_char_get_augumented(" --socket-ext-id=",yon_char_get_augumented(yon_char_from_int((int)gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))),yon_char_get_augumented(" --socket-trd-id=",yon_char_from_int((int)gtk_socket_get_id(GTK_SOCKET(applist->ThirdSocket))))))));
// if (launch_app_with_arguments(tempapp[0].Exec,dualarg)==32512)
// gtk_widget_show(applist->infoWarningWindow);
// }
// else{
// launch_app_with_arguments(tempapp[0].Exec,arg);
// gtk_widget_destroy(applist->socketbutton);
// }
// }
// else {
// launch_app(tempapp[0].Exec);
// gtk_widget_destroy(applist->socketbutton);
// }
// }
// }
// void on_item_selection_changed(GtkIconView *IV, main_window *widgets){
// if (gtk_icon_view_get_selected_items(IV)>0){
// dictionary *next=widgets->ICSys->first;
// for (dictionary *dct=next;dct!=NULL;dct=dct->next){
// IVGraphicals *IVG=(IVGraphicals*)dct->data;
// if (GTK_ICON_VIEW(IVG->IV)!=GTK_ICON_VIEW(IV))
// if (gtk_icon_view_get_selected_items(GTK_ICON_VIEW(IVG->IV))>0)
// gtk_icon_view_unselect_all(GTK_ICON_VIEW(IVG->IV));
// }
// }
// };
// void on_about_link(GtkWidget* self,gchar* uri,gpointer user_data){
// gtk_widget_destroy(self);
// on_ButtonOpenHelp_activated(NULL,user_data);
// }
// void on_ButtonOpenHelp_activated(GtkWidget *button, GtkBuilder *builder){
// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,"AlwaysOpenHelpCheckbox"))))
// {
// #ifdef WEBKIT_FOUND
// GtkBuilder *web_builder=gtk_builder_new_from_resource(GladePath);
// GtkWidget *browser=GTK_WIDGET(gtk_builder_get_object(web_builder,"Web_Window"));
// GtkWidget *web_place=GTK_WIDGET(gtk_builder_get_object(web_builder,"Web_Place"));
// GtkWidget *WebView=webkit_web_view_new();
// webkit_web_view_load_uri(WEBKIT_WEB_VIEW(WebView),UBLINUX_WIKI_LINK);
// gtk_box_pack_start(GTK_BOX(web_place),WebView,1,1,0);
// gtk_widget_show_all(browser);
// #else
// if(system(UBLINUX_WIKI_COMMAND)){};
// #endif
// } else
// {
// GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"HelpSureWindow"));
// gtk_widget_show(window);
// };
// };
// void on_backToSettingsButton_clicked(GtkWidget *button,main_window *sctb){
// GtkWidget *window=GTK_WIDGET(gtk_builder_get_object(sctb->builder,"HideWhileLaunch"));
// GtkWidget *socketplace=GTK_WIDGET(gtk_builder_get_object(sctb->builder,"socketplace"));
// gtk_widget_destroy(sctb->socket);
// sctb->socket=NULL;
// GtkWidget *backbutton=sctb->ButtonBackToMain;
// gtk_widget_hide(backbutton);
// };
// void on_CancelHelpButton_activated(GtkWidget *button,GtkBuilder *builder){
// GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"HelpSureWindow"));
// gtk_widget_hide(window);
// };
// void on_ReadHelpButton_activated(GtkWidget *button, GtkBuilder *builder){
// #ifdef WEBKIT_FOUND
// GtkBuilder *web_builder=gtk_builder_new_from_resource(GladePath);
// GtkWidget *browser=GTK_WIDGET(gtk_builder_get_object(web_builder,"Web_Window"));
// GtkWidget *web_place=GTK_WIDGET(gtk_builder_get_object(web_builder,"Web_Place"));
// GtkWidget *WebView=webkit_web_view_new();
// webkit_web_view_load_uri(WEBKIT_WEB_VIEW(WebView),UBLINUX_WIKI_LINK);
// gtk_box_pack_start(GTK_BOX(web_place),WebView,1,1,0);
// gtk_widget_show_all(browser);
// #else
// if(system(UBLINUX_WIKI_COMMAND)){};
// #endif
// GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"HelpSureWindow"));
// gtk_widget_hide(window);
// };
// int on_settings_accept(GtkWidget *button, dictionary **widgetsDs){
// if (main_config.WindowTheme==0)
// main_config.curThemeName="Main";
// else if (main_config.WindowTheme==1)
// main_config.curThemeName="Gnome";
// dictionary *widgetsD=yon_dictionary_find(widgetsDs,main_config.curThemeName);
// main_window *widgets=(main_window*)widgetsD->data;
// int theme=gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->settingsThemeChooser));
// gtk_window_get_position(GTK_WINDOW(widgets->window),&main_config.windowPosX,&main_config.windowPosY);
// gtk_window_get_size(GTK_WINDOW(widgets->window),&main_config.windowWidth,&main_config.windowHeight);
// if (theme==0)
// main_config.curThemeName="Main";
// else if (theme==1)
// main_config.curThemeName="Gnome";
// if (main_config.WindowTheme!=theme){
// main_config.WindowTheme=theme;
// GtkWidget *loaderWindow=GTK_WIDGET(gtk_builder_get_object(widgets->builder,"LoaderWindow"));
// gtk_window_resize(GTK_WINDOW(loaderWindow),main_config.windowWidth,main_config.windowHeight);
// gtk_window_move(GTK_WINDOW(loaderWindow),main_config.windowPosX,main_config.windowPosY);
// gtk_widget_show(loaderWindow);
// yon_switch_theme(widgetsDs,yon_dictionary_find(&widgetsD,main_config.curThemeName));
// if (widgets!=(main_window*)widgetsD->data) widgets=(main_window*)widgetsD->data;
// gtk_widget_hide(loaderWindow);
// gtk_window_present(GTK_WINDOW(widgets->SettingsWindow));
// }
// GKeyFile *gfile=g_key_file_new();
// int sz=1,szm=1;
// if (main_config.Gnomeiconsize==64) sz=4;
// else if (main_config.Gnomeiconsize==48) sz=3;
// else if (main_config.Gnomeiconsize==32) sz=2;
// else if (main_config.Gnomeiconsize==24) sz=1;
// if (main_config.Mainiconsize==64) szm=4;
// else if (main_config.Mainiconsize==48) szm=3;
// else if (main_config.Mainiconsize==32) szm=2;
// else if (main_config.Mainiconsize==24) szm=1;
// char *fromint=malloc(5);
// memset(fromint,0,5);
// GError *err=NULL;
// char *login=getlogin();
// if (geteuid()==0){
// login=main_config.lastUser;
// } else {
// main_config.lastUser=login;
// }
// char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
// sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
// g_key_file_load_from_file(gfile,pth,G_KEY_FILE_NONE,&err);
// if (err){
// struct stat st = {0};
// char *ptdir=malloc(36+strlen(getlogin()));
// sprintf(ptdir,"%s%s%s","/home/",getlogin(),"/.config/ubl-settings-manager");
// if (stat(ptdir, &st) == -1) {
// mkdir(ptdir, 0777);
// }
// FILE *fp;
// fp=fopen(pth,"w");
// fclose(fp);
// }
// g_key_file_load_from_file(gfile,pth,G_KEY_FILE_NONE,&err);
// if (gtk_window_is_maximized(GTK_WINDOW(widgets->window))==0){
// sprintf(fromint,"%d",main_config.windowPosX);
// g_key_file_set_string(gfile,"window","WindowPosX",fromint);
// sprintf(fromint,"%d",main_config.windowPosY);
// g_key_file_set_string(gfile,"window","WindowPosY",fromint);
// sprintf(fromint,"%d",main_config.windowWidth);
// g_key_file_set_string(gfile,"window","WindowWidth",fromint);
// sprintf(fromint,"%d",main_config.windowHeight);
// g_key_file_set_string(gfile,"window","WindowHeight",fromint);
// }
// sprintf(fromint,"%d",main_config.WindowTheme);
// g_key_file_set_string(gfile,"window","WindowTheme",fromint);
// sprintf(fromint,"%d",sz);
// g_key_file_set_string(gfile,"window","GnomeIconSize",fromint);
// sprintf(fromint,"%d",szm);
// g_key_file_set_string(gfile,"window","MainIconSize",fromint);
// sprintf(fromint,"%d",main_config.iconSegmentSize);
// g_key_file_set_string(gfile,"window","IconSegmentSize",fromint);
// sprintf(fromint,"%d",(int)((float)main_config.GnomelabelSize/1000));
// g_key_file_set_string(gfile,"window","GnomeLabelSize",fromint);
// sprintf(fromint,"%d",(int)((float)main_config.MainlabelSize/1000));
// g_key_file_set_string(gfile,"window","MainLabelSize",fromint);
// sprintf(fromint,"%d",(int)((float)main_config.labelDensity/1000));
// g_key_file_set_string(gfile,"window","LabelDensity",fromint);
// g_key_file_set_string(gfile,"window","User",login);
// g_key_file_set_boolean(gfile,"window","GnomeDoubleClick",main_config.GnomeDoubleClick);
// g_key_file_set_boolean(gfile,"window","MainDoubleClick",main_config.MainDoubleClick);
// g_key_file_remove_group(gfile, "sections",NULL);
// for (dictionary *dict=widgets->ICSys->first;dict!=NULL;dict=dict->next){
// IVGraphicals *IV=(IVGraphicals*)dict->data;
// g_key_file_set_string(gfile,"sections",IV->sectionName,IV->categories);
// if (main_config.changed==1){
// load_apps_with_clear(IV,widgets->applist,widgets->appssize);
// }
// }
// main_config.changed=0;
// g_key_file_save_to_file(gfile,pth,NULL);
// gtk_widget_hide(widgets->SettingsWindow);
// };
// void on_paned_move(GtkPaned* self, GtkScrollType* scroll_type, main_window *widgets){
// int position=gtk_paned_get_position(GTK_PANED(widgets->GnomePaned));
// if (position<200) {position=200; gtk_paned_set_position(GTK_PANED(widgets->GnomePaned),200);}
// main_config.iconSegmentSize=position;
// double pos=((double)position-20);
// if (pos<50) pos=50;
// for (dictionary *dict=widgets->ICSys;dict!=NULL;dict=dict->next){
// IVGraphicals *IV=(IVGraphicals*)dict->data;
// gtk_icon_view_set_item_width(GTK_ICON_VIEW(IV->IV),pos);
// }
// }
// int on_settingsOpen(GtkWidget *button, main_window *widgets){
// gtk_window_set_title(GTK_WINDOW(widgets->SettingsWindow),UBL_SETTINGS_MANAGER_TITLE);
// gtk_widget_set_size_request(widgets->SettingsWindow,400,250);
// GtkIconTheme *icthm=gtk_icon_theme_get_default();
// gtk_window_set_icon(GTK_WINDOW(widgets->SettingsWindow),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(32),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_widget_show_all(widgets->SettingsWindow);
// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->settingsThemeChooser),main_config.WindowTheme);
// gtk_switch_set_state(GTK_SWITCH(widgets->settingsDoubleClickSwitch),*main_config.currentDoubleClick);
// int sz=1;
// if (*main_config.currentThemeIconSize==64) sz=4;
// if (*main_config.currentThemeIconSize==48) sz=3;
// if (*main_config.currentThemeIconSize==32) sz=2;
// if (*main_config.currentThemeIconSize==24) sz=1;
// gtk_range_set_value(GTK_RANGE(widgets->settingsSizeSlider),sz);
// char *tmp=malloc(6);
// sprintf(tmp,"%dx%d\0",*main_config.currentThemeIconSize,*main_config.currentThemeIconSize);
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),tmp);
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(*main_config.currentThemeIconSize),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_window_present(GTK_WINDOW(widgets->SettingsWindow));
// };
// int on_settings_icon_size_changed(GtkWidget* self, main_window *widgets){
// int val=(int)gtk_range_get_value(GTK_RANGE(self));
// GtkIconTheme *icthm=gtk_icon_theme_get_default();
// if ((int)val==1||(int)val==0){
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(24),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"24x24");
// if (*main_config.currentThemeIconSize!=24)
// main_config.changed=1;
// *main_config.currentThemeIconSize=24;
// }
// if ((int)val==2){
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(32),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"32x32");
// if (*main_config.currentThemeIconSize!=32)
// main_config.changed=1;
// *main_config.currentThemeIconSize=32;
// }
// if ((int)val==3){
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(48),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"48x48");
// if (*main_config.currentThemeIconSize!=48)
// main_config.changed=1;
// *main_config.currentThemeIconSize=48;
// }
// if ((int)val==4){
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(64),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"64x64");
// if (*main_config.currentThemeIconSize!=64)
// main_config.changed=1;
// *main_config.currentThemeIconSize=64;
// }
// };
// int on_settings_cancel(GtkWidget *button, main_window *widgets){
// gtk_widget_hide(widgets->SettingsWindow);
// setup_config();
// };
// void on_caution_understand(GtkWidget *button,main_window *widgets){
// gtk_widget_hide(widgets->CautionWindow);
// }
// void on_section_settings_open(GtkButton* self,dictionary *cWidgets){
// main_window *widgets=(main_window*)cWidgets->data;
// if (main_config.SettingsSections->first->data==NULL){
// char *name=((IconSection*)main_config.sections->first->data)->section;
// char *categories=((IconSection*)main_config.sections->first->data)->categories;
// main_config.SettingsSections->first->data=yon_create_section_setting(name, categories);
// main_config.SettingsSections->first->key=name;
// yon_segments_hide(widgets);
// yon_segment_show(widgets, (SectionSettingSegment*)main_config.SettingsSections->data);
// for (dictionary *dct=main_config.sections->first->next;dct!=NULL;dct=dct->next){
// name=((IconSection*)dct->data)->section;
// categories=((IconSection*)dct->data)->categories;
// main_config.SettingsSections=yon_dictionary_create_with_data_connected(main_config.SettingsSections,name,yon_create_section_setting(name, categories));
// main_config.SettingsSections->key=name;
// yon_segment_show(widgets, (SectionSettingSegment*)main_config.SettingsSections->data);
// }
// yon_segments_show(widgets);
// }
// gtk_window_present(GTK_WINDOW(widgets->SectionSettingsWindow));
// }
// void on_sections_edit(GtkWidget *button, main_window *widgets){
// for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
// SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
// if (segment!=NULL){
// if (button==segment->ButtonEdit){
// gtk_widget_hide(segment->NameLabel);
// gtk_widget_hide(segment->CategoriesLabel);
// gtk_widget_show(segment->NameEntry);
// gtk_widget_show(segment->CategoriesEntry);
// gtk_widget_show(segment->EditButtonBox);
// gtk_widget_hide(segment->DeleditBox);
// gtk_widget_set_sensitive(segment->DragButtonBox,0);
// } else {
// gtk_widget_set_sensitive(segment->OptionBox,0);
// gtk_widget_set_sensitive(segment->DragButtonBox,0);
// }
// }
// }
// };
// void on_sections_accept(GtkWidget *button, main_window *widgets){
// for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
// SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
// if (segment!=NULL){
// if (button==segment->EditButtonAccept){
// char *name=yon_char_get_augumented((char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel)),"");
// char *newname=yon_char_get_augumented((char*)gtk_entry_get_text(GTK_ENTRY(segment->NameEntry)),"");
// char *newcats=yon_char_get_augumented((char*)gtk_entry_get_text(GTK_ENTRY(segment->CategoriesEntry)),"");
// if (newcats[strlen(newcats)-1]!=';')
// newcats=yon_char_get_augumented(newcats,";");
// gtk_label_set_text(GTK_LABEL(segment->NameLabel),gtk_entry_get_text(GTK_ENTRY(segment->NameEntry)));
// gtk_label_set_text(GTK_LABEL(segment->CategoriesLabel),gtk_entry_get_text(GTK_ENTRY(segment->CategoriesEntry)));
// dictionary *toedit=yon_dictionary_find(&main_config.sections,name);
// toedit->key=newname;
// ((IconSection*)toedit->data)->section=newname;
// ((IconSection*)toedit->data)->categories=newcats;
// toedit=yon_dictionary_find(&main_config.SettingsSections,name);
// toedit->key=newname;
// ((IconSection*)toedit->data)->section=newname;
// ((IconSection*)toedit->data)->categories=newcats;
// gtk_widget_show(segment->NameLabel);
// gtk_widget_show(segment->CategoriesLabel);
// gtk_widget_hide(segment->NameEntry);
// gtk_widget_hide(segment->CategoriesEntry);
// gtk_widget_hide(segment->EditButtonBox);
// gtk_widget_show(segment->DeleditBox);
// gtk_widget_set_sensitive(segment->DragButtonBox,1);
// }else {
// gtk_widget_set_sensitive(segment->OptionBox,1);
// gtk_widget_set_sensitive(segment->DragButtonBox,1);
// }
// }
// }
// };
// void on_sections_cancel(GtkWidget *button, main_window *widgets){
// for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
// SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
// if (segment!=NULL){
// if (button==segment->EditButtonCancel){
// gtk_entry_set_text(GTK_ENTRY(segment->NameEntry),gtk_label_get_text(GTK_LABEL(segment->NameLabel)));
// gtk_entry_set_text(GTK_ENTRY(segment->CategoriesEntry),gtk_label_get_text(GTK_LABEL(segment->CategoriesLabel)));
// gtk_widget_show(segment->NameLabel);
// gtk_widget_show(segment->CategoriesLabel);
// gtk_widget_hide(segment->NameEntry);
// gtk_widget_hide(segment->CategoriesEntry);
// gtk_widget_hide(segment->EditButtonBox);
// gtk_widget_show(segment->ButtonEdit);
// gtk_widget_show(segment->DeleditBox);
// gtk_widget_set_sensitive(segment->DragButtonBox,1);
// }else {
// gtk_widget_set_sensitive(segment->OptionBox,1);
// gtk_widget_set_sensitive(segment->DragButtonBox,1);
// }
// }
// }
// };
// void on_sections_move_up(GtkWidget *button, main_window *widgets){
// for (dictionary *dct=main_config.SettingsSections->first;dct!=NULL;dct=dct->next){
// SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
// if (segment!=NULL){
// if (button==segment->DragUpButton){
// yon_dictionary_switch_places(yon_dictionary_find(&main_config.sections,(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel))),-1);
// yon_dictionary_switch_places(yon_dictionary_find(&main_config.SettingsSections,(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel))),-1);
// yon_segments_hide(widgets);
// yon_segments_show(widgets);
// }
// }
// }
// };
// void on_sections_move_down(GtkWidget *button, main_window *widgets){
// for (dictionary *dct=main_config.SettingsSections->first;dct!=NULL;dct=dct->next){
// SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
// if (segment!=NULL){
// if (button==segment->DragDownButton){
// yon_dictionary_switch_places(yon_dictionary_find(&main_config.sections,(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel))),1);
// yon_dictionary_switch_places(yon_dictionary_find(&main_config.SettingsSections,(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel))),1);
// yon_segments_hide(widgets);
// yon_segments_show(widgets);
// }
// }
// }
// };
// void on_sections_add(GtkWidget *button, main_window *widgets){
// char *category_name = yon_char_get_augumented((char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry)),"");
// if (strcmp(category_name,"")!=0){
// char *category_categories=yon_char_get_augumented((char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry)),"");
// if (category_categories[strlen(category_categories)-1]!=';')
// category_categories=yon_char_get_augumented(category_categories,";");
// SectionSettingSegment *segment=yon_create_section_setting(category_name,category_categories);
// dictionary *newsection = yon_dictionary_get_last(main_config.SettingsSections);
// newsection=yon_dictionary_create_with_data_connected(newsection,category_name,segment);
// dictionary *newsec=yon_dictionary_create_empty();
// newsec=yon_section_new(newsec,category_name,category_categories);
// main_config.sections=yon_dictionary_create_with_data_connected(main_config.sections,category_name,newsec->data);
// gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),"");
// gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),"");
// yon_segment_show(widgets, segment);
// yon_segments_hide(widgets);
// yon_segments_show(widgets);
// }
// }
// void on_sections_new_clear(GtkWidget *button, main_window *widgets){
// gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),"");
// gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),"");
// }
// void on_sections_close(GtkWidget *button, main_window *widgets){
// gtk_widget_hide(widgets->SectionSettingsWindow);
// }
// void on_sections_save(GtkWidget *button, dictionary *widgetsD){
// int temptheme=main_config.WindowTheme;
// for (dictionary *dict=widgetsD->first;dict!=NULL;dict=dict->next){
// main_window *widgets=(main_window*)dict->data;
// if (strcmp(dict->key,"Gnome")==0) main_config.WindowTheme=1;
// else main_config.WindowTheme=0;
// for (dictionary *ICSys=widgets->ICSys->first;ICSys!=NULL;ICSys=ICSys->next){
// gtk_container_remove(GTK_CONTAINER(widgets->icvpack),((IVGraphicals*)ICSys->data)->Box);
// }
// widgets->ICSys=yon_create_icon_section_list(main_config.sections);
// for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){
// load_apps((IVGraphicals*)cur->data,widgets->applist,widgets->appssize);
// }
// yon_show_icon_views(widgets->ICSys,widgets);
// hide_if_unfound(widgetsD);
// if (main_config.WindowTheme==1)
// yon_icv_resize_item(dict,widgets->GnomePaned);
// }
// main_config.WindowTheme=temptheme;
// }
// void on_section_delete(GtkWidget *button, main_window *widgets){
// gtk_widget_destroy(gtk_widget_get_parent(gtk_widget_get_parent(gtk_widget_get_parent(gtk_widget_get_parent(button)))));
// for (dictionary *dct=main_config.SettingsSections->first;dct!=NULL;dct=dct->next){
// SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
// if (segment!=NULL){
// if (button==segment->ButtonDelete){
// main_config.sections=yon_dictionary_rip(yon_dictionary_find(&main_config.sections, dct->key));
// main_config.SettingsSections=yon_dictionary_rip(yon_dictionary_find(&main_config.SettingsSections, dct->key));
// break;
// }
// }
// }
// }
// void on_resized (GtkWidget *window, GdkEventConfigure *event, dictionary *widgetsD){
// main_window *widgets=(main_window*)widgetsD->data;
// if (gtk_window_is_maximized(GTK_WINDOW(widgets->window))==0){
// main_config.fullscreen=0;
// gtk_window_get_size(GTK_WINDOW(window),&main_config.windowWidth,&main_config.windowHeight);
// gtk_window_get_position(GTK_WINDOW(window),&main_config.windowPosX,&main_config.windowPosY);
// }
// else
// main_config.fullscreen=1;
// gtk_revealer_set_reveal_child(GTK_REVEALER(widgets->Revealer),!gtk_revealer_get_child_revealed(GTK_REVEALER(widgets->Revealer)));
// gtk_revealer_set_reveal_child(GTK_REVEALER(widgets->Revealer),gtk_revealer_get_child_revealed(GTK_REVEALER(widgets->Revealer)));
// }
// void on_resized_done (GtkWidget *window, GdkEvent *event, dictionary *widgetsD){
// main_window *widgets=(main_window*)widgetsD->data;
// if (event->type==GDK_CONFIGURE){
// if (stld==1){
// gtk_window_set_resizable(GTK_WINDOW(window),1);
// }
// }
// }
// void on_theme_selection_changed(GtkWidget *self, main_window *widgets){
// int *icsize;
// int curthm=gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->settingsThemeChooser));
// if (curthm==0){
// main_config.currentThemeIconSize=&main_config.Mainiconsize;
// main_config.currentThemeLabelSize=&main_config.MainlabelSize;
// main_config.currentDoubleClick=&main_config.MainDoubleClick;
// icsize=main_config.currentThemeIconSize;
// }
// else if (curthm==1){
// main_config.currentThemeIconSize=&main_config.Gnomeiconsize;
// main_config.currentThemeLabelSize=&main_config.GnomelabelSize;
// main_config.currentDoubleClick=&main_config.GnomeDoubleClick;
// icsize=main_config.currentThemeIconSize;
// }
// gtk_switch_set_state(GTK_SWITCH(widgets->settingsDoubleClickSwitch),*main_config.currentDoubleClick);
// GtkIconTheme *icthm=gtk_icon_theme_get_default();
// if (*icsize==24 || *icsize==1){
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"24x24");
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(24),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_scale_set_value_pos(GTK_SCALE(widgets->settingsSizeSlider),1.0);
// *icsize=24;
// } else if (*icsize==32 || *icsize==2){
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"32x32");
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(32),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_scale_set_value_pos(GTK_SCALE(widgets->settingsSizeSlider),2.0);
// *icsize=32;
// } else if (*icsize==48 || *icsize==3){
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"48x48");
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(48),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_scale_set_value_pos(GTK_SCALE(widgets->settingsSizeSlider),3.0);
// *icsize=48;
// } else{
// gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"64x64");
// gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, AppIconPath,yon_get_icon_size(64),1,GTK_ICON_LOOKUP_FORCE_SVG),NULL));
// gtk_scale_set_value_pos(GTK_SCALE(widgets->settingsSizeSlider),4.0);
// *icsize=64;
// }
// }
void on_reveal_banner(GtkWidget *, main_window *widgets){
if (gtk_revealer_get_reveal_child(GTK_REVEALER(widgets->BannerRevealer))){
gtk_revealer_set_transition_type(GTK_REVEALER(widgets->BannerRevealer),GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
gtk_revealer_set_reveal_child(GTK_REVEALER(widgets->BannerRevealer),0);
gtk_menu_button_set_direction(GTK_MENU_BUTTON(widgets->BannerArrow),GTK_ARROW_RIGHT);
int banner = 1;
yon_window_config_add_instant_parameter("HideBanner","Settings",&banner,YON_TYPE_BOOLEAN);
} else {
gtk_revealer_set_transition_type(GTK_REVEALER(widgets->BannerRevealer),GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
gtk_revealer_set_reveal_child(GTK_REVEALER(widgets->BannerRevealer),1);
gtk_menu_button_set_direction(GTK_MENU_BUTTON(widgets->BannerArrow),GTK_ARROW_LEFT);
int banner = 0;
yon_window_config_add_instant_parameter("HideBanner","Settings",&banner,YON_TYPE_BOOLEAN);
}
}
// void on_double_click_changed(GtkWidget *Switch, gboolean state, dictionary *widgetsD){
// *main_config.currentDoubleClick=state;
// update_double_clicks(widgetsD);
// }
// void on_about(GtkWidget *button, GtkBuilder *buildr){
// GtkBuilder *builder = gtk_builder_new_from_resource(GladePath);
// GtkWidget *AboutButtons = GTK_WIDGET(gtk_builder_get_object(builder,"AboutButtons"));
// GtkWidget *AboutHeadLabel = GTK_WIDGET(gtk_builder_get_object(builder,"aboutHeadLabel"));
// GtkWidget *About = GTK_WIDGET(gtk_builder_get_object(builder, "ublAbloutWindow"));
// gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(About),_(ABOUT_PROJECT_COMMENTS_LABEL));
// gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(About),_(UBL_SETTINGS_MANAGER_TITLE));
// gtk_label_set_text(GTK_LABEL(AboutHeadLabel),UBL_SETTINGS_MANAGER_ABOUT_TITLE);
// gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(About),version_application);
// gtk_widget_show(About);
// GList *list = gtk_container_get_children(GTK_CONTAINER(AboutButtons));
// gtk_widget_destroy(AboutButtons);
// g_signal_connect(G_OBJECT(About), "activate-link", G_CALLBACK(on_about_link), buildr);
// gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(About),_(ABOUT_PROJECT_HOME_PAGE_LABEL));
// }
// int launch(thread_output *thread){
// int a=0;
// a=system(thread->command);
// *thread->exitcode=a;
// return *thread->exitcode;
// }
// int launch_app_with_arguments(char *name, char *args){
// char *path=yon_char_get_augumented("/usr/bin/",name);
// path=yon_char_get_augumented(path," ");
// path=yon_char_get_augumented(path,args);
// pthread_t thread_id;
// thread_output *thread=malloc(sizeof(thread_output));
// thread->command=path;
// thread->exitcode=malloc(sizeof(int));
// pthread_create(&thread_id, NULL, (void*)launch, thread);
// return *thread->exitcode;
// };
// int launch_app(char *name){
// char *path=name;
// thread_output *thread=malloc(sizeof(thread_output));
// thread->command=path;
// thread->exitcode=malloc(sizeof(int));
// pthread_t thread_id;
// pthread_create(&thread_id, NULL, (void*)launch, thread);
// return *thread->exitcode;
// };
// int py_launch_app(char *name,char *args){
// char *path=malloc(strlen("python ./")+strlen(name)+6+strlen(args));
// sprintf(path,"python ./%s.py %s &",name,args);
// pthread_t thread_id;
// thread_output *thread=malloc(sizeof(thread_output));
// thread->command=path;
// thread->exitcode=malloc(sizeof(int));
// pthread_create(&thread_id, NULL, (void*)launch, thread);
// return *thread->exitcode;
// };
// apps *get_app_by_name(apps *applist,char *name, int size){
// for (int i=0;i<size;i++){
// if (strcmp(applist[i].Name,name)==0) return &applist[i];
// }
// return NULL;
// };
// int reload_list(IVGraphicals *section){
// gtk_icon_view_set_model(GTK_ICON_VIEW(section->IV),GTK_TREE_MODEL(section->LV));
// }
// void update_double_clicks(dictionary *widgetsD){
// for (dictionary *dict=widgetsD->first;dict!=NULL;dict=dict->next){
// main_window *widgets=(main_window*)dict->data;
// for (dictionary *ivdct=widgets->ICSys->first;ivdct!=NULL;ivdct=ivdct->next){
// IVGraphicals *IV=(IVGraphicals*)ivdct->data;
// if (strcmp(dict->key,"Gnome")==0){
// gtk_icon_view_set_activate_on_single_click(GTK_ICON_VIEW(IV->IV),!main_config.GnomeDoubleClick);
// } else{
// gtk_icon_view_set_activate_on_single_click(GTK_ICON_VIEW(IV->IV),!main_config.MainDoubleClick);
// }
// }
// }
// }
// int load_apps(IVGraphicals *section, apps *applist, int size){
// int catstofind=sizeof(section->categories)/sizeof(char*);
// int i=0,sz=0;
// for (int i=0;i<size;i++){
// if (check_categories(applist[i],section->categories)==1){
// GError *err=NULL;
// GtkTreeIter iter;
// gtk_list_store_append(section->LV,&iter);
// int sz= yon_get_icon_size(*main_config.currentThemeIconSize)+3;
// if (sz<34) sz=34;
// GtkIconTheme *icthm=gtk_icon_theme_get_default();
// GdkPixbuf *pixbuf=gtk_icon_info_load_icon(gtk_icon_theme_lookup_icon_for_scale(icthm, applist[i].Icon,yon_get_icon_size(*main_config.currentThemeIconSize),1,GTK_ICON_LOOKUP_FORCE_SIZE),NULL);
// GtkTreePath *pth = gtk_tree_model_get_path(GTK_TREE_MODEL(section->LV),&iter);
// gtk_list_store_set(section->LV,&iter,0,applist[i].Name,1,0.0,2,0.5, 3, sz+5, 4, pixbuf, 5,yon_get_icon_size(*main_config.currentThemeIconSize)+10, -1);
// int cols = gtk_icon_view_get_columns(GTK_ICON_VIEW(section->IV));
// gtk_icon_view_set_columns(GTK_ICON_VIEW(section->IV), -1);
// gtk_icon_view_set_columns(GTK_ICON_VIEW(section->IV), cols);
// }
// }
// gtk_icon_view_set_model(GTK_ICON_VIEW(section->IV),GTK_TREE_MODEL(section->LV));
// };
// int load_apps_with_clear(IVGraphicals *section, apps *applist, int size){
// gtk_list_store_clear(section->LV);
// load_apps(section,applist,size);
// };
// int hide_if_unfound(dictionary *widgetsD){
// for (dictionary *widgetsDc=widgetsD->first;widgetsDc!=NULL;widgetsDc=widgetsDc->next){
// main_window *widgets=(main_window*)widgetsDc->data;
// for (dictionary *icvd=widgets->ICSys->first;icvd!=NULL;icvd=icvd->next){
// IVGraphicals *icv=icvd->data;
// GtkTreeIter iter;
// if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(icv->LV),&iter)==0){
// gtk_widget_hide(icv->Box);
// gtk_widget_hide(GTK_WIDGET(icv->sep));
// }
// }
// }
// }
// GtkWidget *create_socket(main_window *builder){
// GtkWidget *socket;
// socket = gtk_socket_new();
// GtkWidget *socketbutton=gtk_socket_new();
// GtkWidget *ThirdSocket=gtk_socket_new();
// g_signal_connect(G_OBJECT(socket),"plug-added",G_CALLBACK(on_plug_added),builder);
// g_signal_connect(G_OBJECT(socket),"plug-removed",G_CALLBACK(on_plug_removed),builder);
// g_signal_connect(G_OBJECT(socket),"destroy",G_CALLBACK(on_plug_removed),builder);
// gtk_box_pack_start(GTK_BOX(builder->socketplace),socket,true,true,0);
// gtk_box_pack_start(GTK_BOX(builder->socketbuttonplace),socketbutton,1,1,0);
// builder->socketbutton=socketbutton;
// gtk_box_pack_start(GTK_BOX(builder->ThirdSocketPlace),ThirdSocket,1,1,0);
// builder->ThirdSocket=ThirdSocket;
// return socket;
// };
// void sort_apps(apps *applist,int size){
// apps tmp;
// if (size>2)
// {
// for (int i=1;i<size;i++)
// {
// for (int j=1;j<size;j++)
// {
// if (strcmp(applist[j].Name,applist[j-1].Name)<0){
// tmp=applist[j];
// applist[j]=applist[j-1];
// applist[j-1]=tmp;
// };
// }
// };
// }
// };
// apps *find_apps(int *sizef){
// int size=0;
// struct apps *applist;
// {
// DIR *directory=opendir(DesktopPath);
// struct dirent *de;
// while ((de = readdir(directory)))
// {
// FILE *file;
// char *path=yon_char_get_augumented(DesktopPath,de->d_name);
// file=fopen(path,"r");
// if (strlen(de->d_name)>9)
// {
// char *extension=strstr(path,".");
// if (extension!=NULL)
// {
// if (strcmp(extension,".desktop")==0)
// {
// apps tempapp;
// GKeyFile *gfile=g_key_file_new();
// g_key_file_load_from_file(gfile,path,G_KEY_FILE_KEEP_TRANSLATIONS,NULL);
// char *Type=g_key_file_get_string(gfile,"Desktop Entry", "Type",NULL);
// 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));
// 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].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++;
// }
// }
// }
// }
// }
// }
// *sizef=size;
// return applist;
// };
// int check_categories(apps app, char *catstocheck){
// if (!catstocheck || strcmp(catstocheck,"")==0||strcmp(catstocheck,";")==0){
// char *found=strstr(app.Categories,"X-UBL-SettingsManager");
// char *perfound=strstr(app.Categories,"X-UBL-PersonalSettings");
// char *harfound=strstr(app.Categories,"X-UBL-HardwareSettings");
// char *sysfound=strstr(app.Categories,"X-UBL-SystemSettings");
// if (found!=NULL&&(perfound==NULL&&harfound==NULL&&sysfound==NULL)) return 1;
// else if (found==NULL)return 0;
// } else
// {
// char *left_cats=catstocheck;
// char *cat=strstr(left_cats,";");
// if (!cat) return 0;
// char *find_it=yon_cut(left_cats,(strlen(left_cats)-strlen(cat)),0);
// char *found=strstr(app.Categories,find_it);
// int to_find=0, n_found=0;
// to_find++;
// if (!found) return 0;
// n_found++;
// while (cat){
// left_cats=cat+1;
// char *fcat=app.Categories;
// cat=strstr(cat+1,";");
// if (!cat) break;
// find_it=yon_cut(left_cats,(strlen(left_cats)-strlen(cat)),0);
// char *found=strstr(app.Categories,find_it);
// to_find++;
// if (!found) break;
// n_found++;
// left_cats=cat+1;
// if (strlen(left_cats)==0 ||strcmp(left_cats,"")==0) break;
// }
// if (to_find==n_found) return 1; else return 0;
// }
// };
void config_init(){
main_config.sections=NULL;
main_config.SettingsSections=NULL;
main_config.double_click=0;
main_config.apps_icon_size=24;
main_config.labelDensity=0;
main_config.themes = g_hash_table_new(g_str_hash,g_str_equal);
yon_theme_init();
};
// // void save_config(main_window *widgets){
// // if (main_config.lock_settings==1)
// // return;
// // GKeyFile *gfile=g_key_file_new();
// // int sz=1,szm=1;
// // if (main_config.Gnomeiconsize==64) sz=4;
// // else if (main_config.Gnomeiconsize==48) sz=3;
// // else if (main_config.Gnomeiconsize==32) sz=2;
// // else if (main_config.Gnomeiconsize==24) sz=1;
// // else sz=3;
// // if (main_config.Mainiconsize==64) szm=4;
// // else if (main_config.Mainiconsize==48) szm=3;
// // else if (main_config.Mainiconsize==32) szm=2;
// // else if (main_config.Mainiconsize==24) szm=1;
// // else szm=3;
// // char *fromint=malloc(5);
// // memset(fromint,0,5);
// // GError *err=NULL;
// // char *login=getlogin();
// // if (geteuid()==0){
// // login=main_config.lastUser;
// // } else {
// // main_config.lastUser=login;
// // }
// // char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
// // sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
// // g_key_file_load_from_file(gfile,pth,G_KEY_FILE_NONE,&err);
// // if (err){
// // struct stat st = {0};
// // char *ptdir=malloc(36+strlen(getlogin()));
// // sprintf(ptdir,"%s%s%s","/home/",getlogin(),"/.config/ubl-settings-manager");
// // if (stat(ptdir, &st) == -1) {
// // mkdir(ptdir, 0777);
// // }
// // FILE *fp;
// // fp=fopen(pth,"w");
// // fclose(fp);
// // }
// // g_key_file_load_from_file(gfile,pth,G_KEY_FILE_NONE,&err);
// // if (main_config.fullscreen==0){
// // sprintf(fromint,"%d",main_config.windowPosX);
// // g_key_file_set_string(gfile,"window","WindowPosX",fromint);
// // sprintf(fromint,"%d",main_config.windowPosY);
// // g_key_file_set_string(gfile,"window","WindowPosY",fromint);
// // sprintf(fromint,"%d",main_config.windowWidth);
// // g_key_file_set_string(gfile,"window","WindowWidth",fromint);
// // sprintf(fromint,"%d",main_config.windowHeight);
// // g_key_file_set_string(gfile,"window","WindowHeight",fromint);
// // }
// // g_key_file_set_boolean(gfile,"window","fullscreen",main_config.fullscreen);
// // g_key_file_set_boolean(gfile,"window","BannerHidden",main_config.BannerHidden);
// // g_key_file_set_boolean(gfile,"window","MainDoubleClick",main_config.MainDoubleClick);
// // g_key_file_set_boolean(gfile,"window","GnomeDoubleClick",main_config.GnomeDoubleClick);
// // sprintf(fromint,"%d",main_config.WindowTheme);
// // g_key_file_set_string(gfile,"window","WindowTheme",fromint);
// // sprintf(fromint,"%d",sz);
// // g_key_file_set_string(gfile,"window","GnomeIconSize",fromint);
// // sprintf(fromint,"%d",szm);
// // g_key_file_set_string(gfile,"window","MainIconSize",fromint);
// // sprintf(fromint,"%d",main_config.iconSegmentSize);
// // g_key_file_set_string(gfile,"window","IconSegmentSize",fromint);
// // sprintf(fromint,"%d",(int)((float)main_config.GnomelabelSize/1000));
// // g_key_file_set_string(gfile,"window","GnomeLabelSize",fromint);
// // sprintf(fromint,"%d",(int)((float)main_config.MainlabelSize/1000));
// // g_key_file_set_string(gfile,"window","MainLabelSize",fromint);
// // sprintf(fromint,"%d",(int)((float)main_config.labelDensity/1000));
// // g_key_file_set_string(gfile,"window","LabelDensity",fromint);
// // g_key_file_set_string(gfile,"window","User",login);
// // if (main_config.lock_settings==0)
// // g_key_file_save_to_file(gfile,pth,NULL);
// // }
// void yon_set_default_sections(dictionary *section){
// yon_section_new(section,"Personal","X-UBL-SettingsManager;X-UBL-PersonalSettings;");
// yon_section_new(section,"Hardware","X-UBL-SettingsManager;X-UBL-HardwareSettings;");
// yon_section_new(section,"System","X-UBL-SettingsManager;X-UBL-SystemSettings;");
// yon_section_new(section,"Misc","");
// }
// IVGraphicals *yon_create_single_section_IV(char *name,char *cats){
// IVGraphicals *IVG = malloc(sizeof(IVGraphicals));
// GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
// GtkBuilder *builder = gtk_builder_new_from_resource(GladePath);
// GtkWidget *iv = GTK_WIDGET(gtk_builder_get_object(builder,"iconTemplate"));
// gtk_widget_show(iv);
// GtkWidget *label = gtk_label_new(_(name));
// GtkCellRendererPixbuf *iconRender = GTK_CELL_RENDERER_PIXBUF(gtk_builder_get_object(builder, "iconPic"));
// PangoAttrList *attrs = pango_attr_list_new();
// PangoFontDescription *descr = pango_font_description_new();
// pango_font_description_set_weight(descr,PANGO_WEIGHT_BOLD);
// int stretch = main_config.labelDensity;
// if (stretch>8)
// stretch = 4;
// pango_font_description_set_stretch(descr,main_config.labelDensity);
// pango_attr_list_insert(attrs,pango_attr_size_new(*main_config.currentThemeLabelSize));
// pango_attr_list_insert(attrs, pango_attr_font_desc_new(descr));
// gtk_label_set_attributes(GTK_LABEL(label),attrs);
// gtk_widget_set_margin_end(label,6);
// gtk_widget_set_margin_start(label,6);
// gtk_widget_set_margin_bottom(label,2);
// gtk_icon_view_set_spacing(GTK_ICON_VIEW(iv),20);
// if (main_config.WindowTheme==1) {
// gtk_icon_view_set_columns(GTK_ICON_VIEW(iv),1);
// gtk_widget_set_name(iv,"GnomeIcon");
// gtk_icon_view_set_activate_on_single_click(GTK_ICON_VIEW(iv),!main_config.GnomeDoubleClick);
// gtk_icon_view_set_item_orientation(GTK_ICON_VIEW(iv),GTK_ORIENTATION_HORIZONTAL);
// } else {
// gtk_icon_view_set_item_padding(GTK_ICON_VIEW(iv),3);
// gtk_icon_view_set_item_orientation(GTK_ICON_VIEW(iv),GTK_ORIENTATION_HORIZONTAL);
// gtk_icon_view_set_activate_on_single_click(GTK_ICON_VIEW(iv),!main_config.MainDoubleClick);
// gtk_icon_view_set_row_spacing(GTK_ICON_VIEW(iv),2);
// }
// GtkWidget *sep=gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
// GtkListStore *lv=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststoreTemplate"));
// gtk_widget_set_name(sep,"SepIcon");
// gtk_widget_set_halign(box,0);
// gtk_widget_set_valign(box,1);
// gtk_widget_set_margin_end(sep,6);
// gtk_widget_set_margin_start(sep,6);
// gtk_icon_view_set_model(GTK_ICON_VIEW(iv),GTK_TREE_MODEL(lv));
// gtk_label_set_xalign(GTK_LABEL(label),0);
// gtk_box_pack_start(GTK_BOX(box),label,FALSE,FALSE,0);
// gtk_box_pack_start(GTK_BOX(box),sep,FALSE,FALSE,0);
// gtk_box_pack_start(GTK_BOX(box),iv,FALSE,FALSE,0);
// IVG->sectionName=name;
// IVG->categories=cats;
// IVG->LV = lv;
// IVG->Box = box;
// IVG->IV = iv;
// IVG->label = label;
// IVG->sep = sep;
// IVG->iconRender = iconRender;
// return IVG;
// }
// dictionary *yon_create_icon_section_list(dictionary *sections){
// if (!sections)
// return NULL;
// IVGraphicals *IVSections;
// dictionary *IVDict=NULL;
// sections=sections->first;
// while (sections!=NULL){
// IconSection *name=(IconSection*)sections->data;
// IVSections=yon_create_single_section_IV(name->section,name->categories);
// if (!IVDict) {
// IVDict=yon_dictionary_create_empty();
// IVDict->key=name->section;
// IVDict->data=IVSections;
// IVDict->first=IVDict;
// } else {
// IVDict=yon_dictionary_create_conneced(IVDict);
// IVDict->key=name->section;
// IVDict->data=IVSections;
// }
// sections=sections->next;
// }
// IVDict->next=NULL;
// return IVDict->first;
// }
// void yon_check_path(char *path){
// FILE *fp;
// char *pth=malloc(255);
// memset(path,0,255);
// fp = popen("screenfetch -n -w -N", "r");
// fgets(pth, 255,fp)!=NULL;
// }
// dictionary *yon_section_new(dictionary *section, char *section_name, char *categories){
// IconSection *sct=malloc(sizeof(IconSection));
// sct->section=section_name;
// sct->categories=categories;
// if (!section->data&&!section->prev){
// section->data=sct;
// section->first=section;
// section->key=section_name;
// } else {
// section=yon_dictionary_get_last(section);
// section->next=yon_dictionary_create_conneced(section);
// section->next->data=sct;
// section->next->key=section_name;
// section=section->next;
// }
// return section;
// }
// void yon_icv_resize_item(dictionary *icdict, GtkWidget *paned){
// for (dictionary *dict=icdict->first;dict!=NULL;dict=dict->next){
// IVGraphicals *icv=(IVGraphicals*)dict->data;
// int width=gtk_paned_get_position(GTK_PANED(paned));
// int pos=(int)((double)width-20);
// if (pos < 100) pos=100;
// gtk_icon_view_set_item_width(GTK_ICON_VIEW(icv->IV),pos);
// }
// }
// int yon_show_icon_views(dictionary *IVS,main_window *widgets){
// for (dictionary *dct=IVS->first;dct!=NULL;dct=dct->next){
// IVGraphicals *iv=dct->data;
// gtk_widget_show_all(iv->Box);
// gtk_box_pack_start(GTK_BOX(widgets->icvpack),iv->Box,FALSE,FALSE,0);
// if (main_config.WindowTheme==0)
// g_signal_connect(G_OBJECT(iv->IV),"item-activated",G_CALLBACK(on_Item_activated),widgets);
// else if (main_config.WindowTheme==1)
// g_signal_connect(G_OBJECT(iv->IV),"item-activated",G_CALLBACK(on_gnome_Item_activated),widgets);
// g_signal_connect(G_OBJECT(iv->IV),"selection-changed",G_CALLBACK(on_item_selection_changed),widgets);
// }
// }
// void yon_switch_theme(dictionary **dict, dictionary *newone){
// dictionary *dct=*dict;
// main_window *widgets=(main_window*)dct->data;
// gtk_widget_hide(widgets->window);
// *dict=newone;
// dct=*dict;
// widgets=(main_window*)dct->data;
// gtk_window_resize(GTK_WINDOW(widgets->window),main_config.windowWidth,main_config.windowHeight);
// gtk_window_move(GTK_WINDOW(widgets->window),main_config.windowPosX,main_config.windowPosY);
// if (strcmp(dct->key,"Gnome")==0){
// main_config.currentThemeIconSize=&main_config.Gnomeiconsize;
// main_config.currentThemeLabelSize=&main_config.GnomelabelSize;
// int x,y;
// GdkRectangle workarea;
// gdk_monitor_get_workarea(gdk_display_get_monitor(gdk_screen_get_display(gtk_window_get_screen(GTK_WINDOW(widgets->window))),0),&workarea);
// gtk_window_get_size(GTK_WINDOW(widgets->window),&x, &y);
// if (workarea.width<1240&&workarea.height<720){
// gtk_widget_show(widgets->CautionWindow);
// dictionary *founddict=yon_dictionary_find(dict,"Main");
// dct=yon_dictionary_find(dict,"Gnome");
// yon_switch_theme(&dct,founddict);
// gtk_window_resize(GTK_WINDOW(widgets->window),main_config.windowWidth,main_config.windowHeight);
// gtk_window_move(GTK_WINDOW(widgets->window),main_config.windowPosX,main_config.windowPosY);
// main_config.WindowTheme=0;
// main_config.curThemeName="Main";
// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->settingsThemeChooser),0);
// gtk_window_present(GTK_WINDOW(widgets->CautionWindow));
// }else{
// main_config.WindowTheme=1;
// main_config.curThemeName="Gnome";
// gtk_widget_show(widgets->window);
// gtk_widget_hide(widgets->MenuItemAboutSystem);
// }
// } else {
// main_config.currentThemeIconSize=&main_config.Mainiconsize;
// main_config.currentThemeLabelSize=&main_config.MainlabelSize;
// gtk_widget_show(widgets->window);
// main_config.WindowTheme=0;
// main_config.curThemeName="Main";
// gtk_widget_show(widgets->MenuItemAboutSystem);
// }
// }
// int yon_get_icon_size(int size){
// if (size==1||size==24) return 24;
// if (size==2||size==32) return 32;
// if (size==3||size==48) return 48;
// if (size==4||size==64) return 64;
// }
// void yon_icon_size_convert(int mode){
// if (mode==0){
// if (*main_config.currentThemeIconSize==1) *main_config.currentThemeIconSize=24;
// if (*main_config.currentThemeIconSize==2) *main_config.currentThemeIconSize=32;
// if (*main_config.currentThemeIconSize==3) *main_config.currentThemeIconSize=48;
// if (*main_config.currentThemeIconSize==4) *main_config.currentThemeIconSize=64;
// } else if (mode==1){
// if (*main_config.currentThemeIconSize==24) *main_config.currentThemeIconSize=1;
// if (*main_config.currentThemeIconSize==32) *main_config.currentThemeIconSize=2;
// if (*main_config.currentThemeIconSize==48) *main_config.currentThemeIconSize=3;
// if (*main_config.currentThemeIconSize==64) *main_config.currentThemeIconSize=4;
// }
// }
// SectionSettingSegment *yon_create_section_setting(char *name, char *categories){
// SectionSettingSegment *segment=malloc(sizeof(SectionSettingSegment));
// segment->MainFrame=gtk_frame_new(NULL);
// gtk_frame_set_shadow_type(GTK_FRAME(segment->MainFrame),GTK_SHADOW_IN);
// segment->MainBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
// segment->ElemBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
// gtk_widget_set_size_request(segment->ElemBox,0,20);
// segment->DragButtonBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
// gtk_widget_set_name(segment->DragButtonBox,"noborders");
// segment->DragUpButton=gtk_button_new_from_icon_name("go-top-symbolic",GTK_ICON_SIZE_BUTTON);
// segment->DragDownButton=gtk_button_new_from_icon_name("go-bottom-symbolic",GTK_ICON_SIZE_BUTTON);
// segment->NameBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
// segment->CategoriesBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
// segment->OptionBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
// segment->NameEntry=gtk_entry_new();
// gtk_entry_set_text(GTK_ENTRY(segment->NameEntry),name);
// segment->NameLabel=gtk_label_new(name);
// segment->CategoriesEntry=gtk_entry_new();
// if (categories[strlen(categories)-1]!=';'){
// categories=yon_char_get_augumented(categories,";");
// }
// gtk_entry_set_text(GTK_ENTRY(segment->CategoriesEntry),categories);
// segment->CategoriesLabel=gtk_label_new(categories);
// segment->EditButtonBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
// segment->EditButtonAccept=gtk_button_new_from_icon_name("emblem-ok-symbolic",GTK_ICON_SIZE_BUTTON);
// segment->EditButtonCancel=gtk_button_new_from_icon_name("process-stop-symbolic",GTK_ICON_SIZE_BUTTON);
// segment->ButtonEdit=gtk_button_new_from_icon_name("document-edit-symbolic",GTK_ICON_SIZE_BUTTON);
// segment->DeleditBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
// segment->ButtonDelete=gtk_button_new_from_icon_name("edit-delete-symbolic",GTK_ICON_SIZE_BUTTON);
// gtk_widget_set_name(segment->NameLabel,"SegName");
// gtk_widget_set_name(segment->CategoriesLabel,"SegCat");
// gtk_container_add(GTK_CONTAINER(segment->MainFrame),segment->MainBox);
// gtk_box_pack_start(GTK_BOX(segment->MainBox),segment->DragButtonBox,FALSE,FALSE,0);
// gtk_box_pack_start(GTK_BOX(segment->MainBox),segment->ElemBox,TRUE,TRUE,0);
// gtk_box_pack_start(GTK_BOX(segment->DragButtonBox),segment->DragUpButton,FALSE,FALSE,0);
// gtk_box_pack_start(GTK_BOX(segment->DragButtonBox),segment->DragDownButton,FALSE,FALSE,0);
// gtk_box_pack_start(GTK_BOX(segment->ElemBox),segment->NameBox,FALSE,FALSE,0);
// gtk_box_pack_end(GTK_BOX(segment->ElemBox),segment->CategoriesBox,FALSE,FALSE,0);
// gtk_box_pack_start(GTK_BOX(segment->MainBox),segment->OptionBox,FALSE,FALSE,0);
// gtk_box_pack_start(GTK_BOX(segment->NameBox),segment->NameEntry,FALSE,FALSE,5);
// gtk_box_pack_start(GTK_BOX(segment->NameBox),segment->NameLabel,FALSE,FALSE,5);
// gtk_box_pack_start(GTK_BOX(segment->CategoriesBox),segment->CategoriesEntry,FALSE,FALSE,5);
// gtk_box_pack_start(GTK_BOX(segment->CategoriesBox),segment->CategoriesLabel,FALSE,FALSE,5);
// gtk_box_pack_start(GTK_BOX(segment->EditButtonBox),segment->EditButtonAccept,FALSE,FALSE,5);
// gtk_box_pack_start(GTK_BOX(segment->EditButtonBox),segment->EditButtonCancel,FALSE,FALSE,5);
// gtk_box_pack_start(GTK_BOX(segment->DeleditBox),segment->ButtonEdit,FALSE,FALSE,5);
// gtk_box_pack_start(GTK_BOX(segment->DeleditBox),segment->ButtonDelete,FALSE,FALSE,5);
// gtk_box_pack_start(GTK_BOX(segment->OptionBox),segment->DeleditBox,FALSE,FALSE,0);
// gtk_box_pack_start(GTK_BOX(segment->OptionBox),segment->EditButtonBox,FALSE,FALSE,0);
// gtk_widget_set_size_request(segment->NameLabel,60,10);
// gtk_widget_set_margin_start(segment->DragButtonBox,5);
// gtk_widget_set_margin_end(segment->OptionBox,5);
// gtk_widget_set_margin_bottom(segment->MainFrame,3);
// gtk_widget_set_margin_bottom(segment->DragButtonBox,3);
// gtk_widget_set_margin_top(segment->DragButtonBox,3);
// gtk_widget_set_margin_end(segment->DragUpButton,3);
// gtk_widget_set_halign(segment->NameEntry,GTK_ALIGN_START);
// gtk_widget_set_halign(segment->NameLabel,GTK_ALIGN_END);
// gtk_widget_set_valign(segment->OptionBox,GTK_ALIGN_CENTER);
// gtk_widget_set_valign(segment->OptionBox,GTK_ALIGN_CENTER);
// gtk_widget_set_valign(segment->OptionBox,GTK_ALIGN_CENTER);
// gtk_widget_set_valign(segment->ElemBox,GTK_ALIGN_CENTER);
// gtk_label_set_xalign(GTK_LABEL(segment->NameLabel),0);
// gtk_label_set_xalign(GTK_LABEL(segment->CategoriesLabel),0);
// gtk_widget_set_vexpand(segment->ElemBox,0);
// gtk_widget_set_vexpand(segment->NameBox,0);
// gtk_widget_set_vexpand(segment->CategoriesBox,0);
// gtk_widget_set_vexpand(segment->NameEntry,0);
// gtk_widget_set_vexpand(segment->NameLabel,0);
// gtk_widget_set_vexpand(segment->CategoriesEntry,0);
// gtk_widget_set_vexpand(segment->CategoriesLabel,0);
// gtk_widget_show_all(segment->MainFrame);
// gtk_widget_hide(segment->NameEntry);
// gtk_widget_hide(segment->CategoriesEntry);
// gtk_widget_hide(segment->EditButtonBox);
// return segment;
// }
// void yon_segment_show(main_window *widgets, SectionSettingSegment *sgm){
// gtk_box_pack_start(GTK_BOX(widgets->SectionSettingsPack),sgm->MainFrame,FALSE,FALSE,5);
// g_signal_connect(G_OBJECT(sgm->ButtonEdit),"clicked",G_CALLBACK(on_sections_edit), widgets);
// g_signal_connect(G_OBJECT(sgm->EditButtonAccept),"clicked",G_CALLBACK(on_sections_accept), widgets);
// g_signal_connect(G_OBJECT(sgm->EditButtonCancel),"clicked",G_CALLBACK(on_sections_cancel), widgets);
// g_signal_connect(G_OBJECT(sgm->DragUpButton),"clicked",G_CALLBACK(on_sections_move_up), widgets);
// g_signal_connect(G_OBJECT(sgm->DragDownButton),"clicked",G_CALLBACK(on_sections_move_down), widgets);
// g_signal_connect(G_OBJECT(sgm->ButtonDelete),"clicked",G_CALLBACK(on_section_delete), widgets);
// }
// void yon_segments_show(main_window *widgets){
// if(widgets->SettingsSections)
// for (dictionary *dict=widgets->SettingsSections->first;dict!=NULL;dict=dict->next){
// SectionSettingSegment *sgm=(SectionSettingSegment*)dict->data;
// if (sgm!=NULL)
// gtk_box_pack_start(GTK_BOX(widgets->SectionSettingsPack),sgm->MainFrame,FALSE,FALSE,5);
// else return;
// }
// };
// void yon_segments_hide(main_window *widgets){
// if(main_config.SettingsSections)
// for (dictionary *dict=main_config.SettingsSections->first;dict!=NULL;dict=dict->next){
// SectionSettingSegment *sgm=(SectionSettingSegment*)dict->data;
// if (sgm!=NULL){
// g_object_ref(G_OBJECT(sgm->MainFrame));
// gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),sgm->MainFrame);
// } else return;
// }
// }
// void yon_main_quit(GtkWidget *,GdkEvent*,main_window *widgets){
// if (widgets->socket){
// g_signal_handlers_disconnect_by_func(widgets->socket,on_plug_removed,widgets);
// }
// gtk_main_quit();
// }
void confugure_setings_window(main_window *widgets){
}
void yon_interface_update(main_window *widgets){
if (main_config.sections) yon_dictionary_free_all(main_config.sections,free);
gsize size;
config_str section_settings = yon_window_config_get_section("Sections",&size);
if (size){
for (gsize i=0;i<size;i++){
app_section *cur_section = yon_app_section_new();
cur_section->name = yon_char_new(section_settings[i]);
char *categories = NULL;
yon_window_config_get_parameter("Sections",cur_section->name,&categories,YON_TYPE_STRING);
cur_section->categories = yon_char_parse(categories,&cur_section->categories_size,";");
yon_dictionary_add_or_create_if_exists_with_data(main_config.sections,cur_section->name,cur_section);
}
} else {
{
app_section *cur_section = yon_app_section_new();
cur_section->name = yon_char_new("Personal");
cur_section->categories = yon_char_parse("X-UBL-SettingsManager;X-UBL-PersonalSettings;",&cur_section->categories_size,";");
yon_dictionary_add_or_create_if_exists_with_data(main_config.sections,cur_section->name,cur_section);
}
{
app_section *cur_section = yon_app_section_new();
cur_section->name = yon_char_new("Hardware");
cur_section->categories = yon_char_parse("X-UBL-SettingsManager;X-UBL-HardwareSettings;",&cur_section->categories_size,";");
yon_dictionary_add_or_create_if_exists_with_data(main_config.sections,cur_section->name,cur_section);
}
{
app_section *cur_section = yon_app_section_new();
cur_section->name = yon_char_new("System");
cur_section->categories = yon_char_parse("X-UBL-SettingsManager;X-UBL-SystemSettings;",&cur_section->categories_size,";");
yon_dictionary_add_or_create_if_exists_with_data(main_config.sections,cur_section->name,cur_section);
}
{
app_section *cur_section = yon_app_section_new();
cur_section->name = yon_char_new("Misc");
cur_section->categories = yon_char_parsed_new(&cur_section->categories_size,"",NULL);
yon_dictionary_add_or_create_if_exists_with_data(main_config.sections,cur_section->name,cur_section);
}
}
}
main_window *yon_main_window_setup(){
main_window *widgets = malloc(sizeof(main_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow");
widgets->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox");
widgets->TitleLabel = yon_gtk_builder_get_widget(builder,"TitleLabel");
widgets->ThemeBox = yon_gtk_builder_get_widget(builder,"ThemeBox");
widgets->SocketBox = yon_gtk_builder_get_widget(builder,"SocketBox");
widgets->SettingsButton = yon_gtk_builder_get_widget(builder,"SettingsButton");
widgets->BannerImage = yon_gtk_builder_get_widget(builder,"BannerImage");
widgets->BannerRevealer = yon_gtk_builder_get_widget(builder,"BannerRevealer");
widgets->BannerButton = yon_gtk_builder_get_widget(builder,"BannerButton");
widgets->BannerArrow = yon_gtk_builder_get_widget(builder,"BannerArrow");
yon_apps_init();
g_signal_connect(G_OBJECT(widgets->BannerButton),"clicked",G_CALLBACK(on_reveal_banner),widgets);
yon_window_config_setup(GTK_WINDOW(widgets->Window));
char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL);
yon_window_config_load(path);
free(path);
{
int banner_hidden = 0;
yon_window_config_get_parameter("Settings","HideBanner", &banner_hidden,YON_TYPE_BOOLEAN);
gtk_revealer_set_transition_type(GTK_REVEALER(widgets->BannerRevealer),!banner_hidden?GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT:GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
gtk_revealer_set_reveal_child(GTK_REVEALER(widgets->BannerRevealer),!banner_hidden);
gtk_menu_button_set_direction(GTK_MENU_BUTTON(widgets->BannerArrow),!banner_hidden?GTK_ARROW_LEFT:GTK_ARROW_RIGHT);
}
gtk_widget_show(widgets->Window);
widgets->current_theme = yon_theme_update(widgets);
yon_interface_update(widgets);
widgets->current_theme->list_update_func(widgets->current_theme);
return widgets;
}
int main(int argc, char *argv[]){
setlocale(LC_ALL, "");
textdomain (LocaleName);
static struct option long_options[] = {
{"lock-settings", 0, 0, 'l'},
{"help", 0, 0, 'h'},
{"version", 0, 0, 'v'},
};
int socket_find;
int option_index=0;
for (int i=0;i<argc;i++){
socket_find=getopt_long(argc,argv,"lhv",long_options,&option_index);
if (socket_find=='l')
main_config.lock_settings=1;
if (socket_find=='h') {
printf("%s\n",HELP_LABEL(NULL));
exit(0);
}
if (socket_find=='v') {
printf("%s\n",VERSION_LABEL);
exit(0);
}
}
gtk_init(&argc, &argv);
config_init();
main_window *widgets = yon_main_window_setup();
GtkCssProvider *css=gtk_css_provider_new();
gtk_css_provider_load_from_resource(css,CssPath);
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
GTK_STYLE_PROVIDER(css),
-1);
gtk_main();
}