diff --git a/ubl-settings-manager.c b/ubl-settings-manager.c new file mode 100644 index 0000000..b93938a --- /dev/null +++ b/ubl-settings-manager.c @@ -0,0 +1,1431 @@ +#ifndef UBL_SETTINGS_MANAGER_MAIN +#define UBL_SETTINGS_MANAGER_MAIN +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "ubl-settings-manager.h" + +#define _(String) gettext(String) + +char **sectionremoval=NULL; +int removalsize=0; +char *local; +config main_config; + +char *cats[2]={"XFCE","GTK"}; +char *ubcatsPersonal[2]={"X-UBL-SettingsManager","X-UBL-PersonalSettings"}; +char *ubcatsSystem[2]={"X-UBL-SettingsManager","X-UBL-SystemSettings"}; +char *ubcatsHardware[2]={"X-UBL-SettingsManager","X-UBL-HardwareSettings"}; +char *ubcatsMisc[1]={NULL}; +int gnld=0; +int stld=0; +int cmld=0; + + +void on_plug_added(GtkSocket* self, actionWidgets *builder){ + printf("Plug has been added!\n"); + 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); + + if (builder->ButtonBackToMain!=NULL) gtk_widget_set_sensitive(builder->ButtonBackToMain,1); + gtk_widget_show(GTK_WIDGET(self)); +} + +void on_plug_removed(GtkSocket* self, actionWidgets *widgets){ + + //gtk_box_pack_start(GTK_BOX(widgets->workingwindow),widgets->HideWhileLaunch,TRUE,TRUE,10); + gtk_widget_show(widgets->HideWhileLaunch); + //gtk_widget_hide(widgets->socketplace); + gtk_widget_set_vexpand(widgets->socketplace,0); + gtk_widget_set_vexpand(widgets->HideWhileLaunch,1); + printf("Plug has been removed!\n\n\n"); + +} + +void on_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *applist){ + printf("\n\n\nActivated\n\n\n"); + GtkTreeIter iter; + char *name; + gtk_tree_model_get_iter(gtk_icon_view_get_model(self),&iter,path); + gtk_tree_model_get(gtk_icon_view_get_model(self),&iter,1,&name,-1); + + apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize); + if (!tempapp){}else{ + char arg[100]; + memset(arg,0,100); + sprintf(arg,"--socket-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket))); + + if (tempapp[0].Type==2) + if (tempapp->Pluggable==1) + py_launch_app(tempapp[0].Exec,arg); + else py_launch_app(tempapp[0].Exec,""); + else if (tempapp[0].Type==1){ + if (tempapp->Pluggable==1) + launch_app_with_arguments(tempapp[0].Exec,arg); + else launch_app(tempapp[0].Exec); + } + } +}; + +void on_gnome_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *applist){ + GtkTreeIter iter; + char *name; + if (!applist->socket){}else{ + 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,1,&name,-1); + + apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize); + char arg[100]; + memset(arg,0,100); + sprintf(arg,"--socket-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket))); + + if (tempapp[0].Type==1) + if (tempapp->Pluggable==1) + py_launch_app(tempapp[0].Exec,arg); + else py_launch_app(tempapp[0].Exec,""); + else{ + if (tempapp->Pluggable==1) + launch_app_with_arguments(tempapp[0].Exec,arg); + else launch_app(tempapp[0].Exec); + } +} + +void on_item_selection_changed(GtkIconView *IV, actionWidgets *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 (IVG->IV!=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_ButtonOpenHelp_activated(GtkWidget *button, GtkBuilder *builder){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,"AlwaysOpenHelpCheckbox")))) + { + system("xdg-open http://ublinux.com"); + } else + { + GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"HelpSureWindow")); + gtk_widget_show(window); + }; +}; + +void on_backToSettingsButton_clicked(GtkWidget *button,actionWidgets *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=GTK_WIDGET(create_socket(sctb)); + GtkWidget *backbutton=sctb->ButtonBackToMain; + gtk_widget_set_sensitive(backbutton,0); +}; + +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){ + system("xdg-open http://ublinux.com"); + GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"HelpSureWindow")); + gtk_widget_hide(window); +}; + +int on_settings_accept(GtkWidget *button, dictionary *widgetsD){ + printf("Saving config...\n"); + actionWidgets *widgets=(actionWidgets*)widgetsD->data; + gtk_window_get_size(GTK_WINDOW(widgets->window),&main_config.windowWidth,&main_config.windowHeight); + gtk_window_get_position(GTK_WINDOW(widgets->window),&main_config.windowPosX,&main_config.windowPosY); + int theme=gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->settingsThemeChooser)); + + 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); + gtk_window_present(GTK_WINDOW(widgets->SettingsWindow)); + gtk_widget_hide(widgets->window); + if (yon_dictionary_find(&widgetsD,main_config.curThemeName)==NULL){ + widgetsD->next=yon_theme_new(yon_dictionary_create_empty(),widgets->builder,main_config.curThemeName,widgets->applist,widgets->appssize); + widgetsD->next->prev=widgetsD; + yon_switch_theme(&widgetsD,yon_dictionary_find(&widgetsD,main_config.curThemeName)); + widgets=(actionWidgets*)widgetsD->data; + 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); + + } + yon_switch_theme(&widgetsD,yon_dictionary_find(&widgetsD,main_config.curThemeName)); + if (widgets!=(actionWidgets*)widgetsD->data) widgets=(actionWidgets*)widgetsD->data; + gtk_widget_show(widgets->window); + gtk_widget_hide(loaderWindow); + main_config.WindowTheme=theme; + } + GKeyFile *gfile=g_key_file_new(); + int sz; + if (main_config.iconsize==64) sz=4; + if (main_config.iconsize==48) sz=3; + if (main_config.iconsize==32) sz=2; + if (main_config.iconsize==24) sz=1; + char *fromint=malloc(5); + memset(fromint,0,5); + g_key_file_load_from_file(gfile,ConfigPath,G_KEY_FILE_NONE,NULL); + 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","IconSize",fromint); + sprintf(fromint,"%d",main_config.iconSegmentSize); + g_key_file_set_string(gfile,"window","IconSegmentSize",fromint); + 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); + load_apps_with_clear(IV,widgets->applist,widgets->appssize); + } + g_key_file_save_to_file(gfile,ConfigPath,NULL); + gtk_window_present(GTK_WINDOW(widgets->SettingsWindow)); +}; + +void on_paned_move(GtkPaned* self, GtkScrollType* scroll_type, actionWidgets *widgets){ /* TODO */ + int position=gtk_paned_get_position(GTK_PANED(widgets->GnomePaned)); + printf("Paned moved to %d\n",position); + position-=70; + if (position <115) position=115; + 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),position); + } + + +} + +int on_settingsOpen(GtkWidget *button, actionWidgets *widgets){ + gtk_window_set_title(GTK_WINDOW(widgets->SettingsWindow),"UBLinux Settings Manager"); + gtk_widget_set_size_request(widgets->SettingsWindow,400,250); + gtk_window_set_icon_from_file(GTK_WINDOW(widgets->SettingsWindow),AppIconPath,NULL); + gtk_widget_show_all(widgets->SettingsWindow); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->settingsThemeChooser),main_config.WindowTheme); + int sz=1; + if (main_config.iconsize==64) sz=4; + if (main_config.iconsize==48) sz=3; + if (main_config.iconsize==32) sz=2; + if (main_config.iconsize==24) sz=1; + gtk_range_set_value(GTK_RANGE(widgets->settingsSizeSlider),sz); + char *tmp=malloc(6); + sprintf(tmp,"%dx%d\0",main_config.iconsize,main_config.iconsize); + gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),tmp); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale("/usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg",main_config.iconsize,main_config.iconsize,1,NULL)); + + gtk_window_present(GTK_WINDOW(widgets->SettingsWindow)); +}; + +int on_settings_icon_size_changed(GtkWidget* self, actionWidgets *widgets){ + int val=(int)gtk_range_get_value(GTK_RANGE(self)); + if ((int)val==1||(int)val==0){ + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale("/usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg",24,24,1,NULL)); + gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"24x24"); + main_config.iconsize=24; + } + if ((int)val==2){ + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale("/usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg",32,32,1,NULL)); + gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"32x32"); + main_config.iconsize=32; + } + if ((int)val==3){ + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale("/usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg",48,48,1,NULL)); + gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"48x48"); + main_config.iconsize=48; + } + if ((int)val==4){ + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale("/usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg",64,64,1,NULL)); + gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"64x64"); + main_config.iconsize=64; + } +}; + +int on_settings_cancel(GtkWidget *button, actionWidgets *widgets){ + gtk_widget_hide(widgets->SettingsWindow); + setup_config(); +}; + +void on_section_settings_open(GtkButton* self,dictionary *cWidgets){ + actionWidgets *widgets=(actionWidgets*)cWidgets->data; + if (widgets->SettingsSections==NULL){ + dictionary *dict=yon_dictionary_create_empty(); + widgets->SettingsSections=dict; + for (dictionary *pointer=widgets->ICSys->first;pointer!=NULL;pointer=pointer->next){ + IVGraphicals *IV=(IVGraphicals*)pointer->data; + SectionSettingSegment *Sgm=yon_create_section_setting(IV->sectionName,IV->categories); + yon_segment_show(widgets,Sgm); + dict->data=Sgm; + dict->key=gtk_label_get_text(GTK_LABEL(Sgm->NameLabel)); + dict->next=malloc(sizeof(dictionary)); + dict->next->prev=dict; + dict->next->first=dict->first; + dict=dict->next; + } + dict=dict->prev; + dict->next=NULL; + } + gtk_widget_show(widgets->SectionSettingsWindow); +} + +void on_sections_edit(GtkWidget *button, actionWidgets *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, actionWidgets *widgets){ + for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ + SectionSettingSegment *segment=(SectionSettingSegment*)dct->data; + if (segment!=NULL){ + if (button==segment->EditButtonAccept){ + 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))); + 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, actionWidgets *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_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, actionWidgets *widgets){ + for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ + SectionSettingSegment *segment=(SectionSettingSegment*)dct->data; + if (segment!=NULL){ + if (button==segment->DragUpButton){ + if (dct->prev!=NULL){ + if (dct->prev==dct->first){ + yon_dictionary_make_first(dct); + dct->next->prev=dct->prev; + dct->prev->next=dct->next; + dct->next=dct->prev; + dct->prev=NULL; + dct->next->prev=dct; + } else if (dct->next==NULL){ + dct->next=dct->prev; + dct->next->next=NULL; + dct->next->prev->next=dct; + dct->prev=dct->prev->prev; + dct->next->prev=dct; + } else{ + dct->next->prev=dct->prev; + dct->prev->next=dct->next; + dct->next=dct->prev; + dct->prev=dct->prev->prev; + dct->prev->next=dct; + dct->next->prev=dct; + } + + + yon_segments_hide(widgets); + yon_segments_show(widgets); + } + } + } else return; + } +}; + +void on_sections_move_down(GtkWidget *button, actionWidgets *widgets){ +for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ + SectionSettingSegment *segment=(SectionSettingSegment*)dct->data; + if (segment!=NULL){ + if (button==segment->DragDownButton){ + if (dct->next!=NULL){ + if (dct->next->next==NULL){ + dct->next->prev=dct->prev; + dct->prev->next=dct->next; + dct->prev=dct->next; + dct->next=NULL; + //dct->next->prev=dct; + dct->prev->next=dct; + } else if (dct->prev==NULL){ + yon_dictionary_make_first(dct->next); + dct->prev=dct->next; + dct->next=dct->next->next; + dct->prev->prev=NULL; + dct->next->prev=dct; + dct->prev->next=dct; + + } else{ + dct->next->prev=dct->prev; + dct->prev->next=dct->next; + dct->prev=dct->next; + dct->next=dct->next->next; + dct->next->prev=dct; + dct->prev->next=dct; + } + + + yon_segments_hide(widgets); + yon_segments_show(widgets); + } + } + } else return; + } +}; + +void on_sections_delete(GtkWidget *button, actionWidgets *widgets){ +for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ + SectionSettingSegment *segment=(SectionSettingSegment*)dct->data; + if (segment!=NULL){ + if (button==segment->DragDownButton){ + dct->prev->next=dct->next; + dct->next->prev=dct->prev; + + gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),segment->MainFrame); + } + } +} +}; +void on_sections_add(GtkWidget *button, actionWidgets *widgets){ + dictionary *dict=yon_dictionary_create_empty(); + dictionary *dct=NULL; + SectionSettingSegment *segment=yon_create_section_setting((char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry)),(char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry))); + for (dct=widgets->SettingsSections->first;dct->next!=NULL;dct=dct->next){} + dict->data=segment; + dict->key=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel)); + dct->next=dict; + dict->prev=dct; + dict->first=dct->first; + yon_segments_hide(widgets); + yon_segments_show(widgets); + gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),""); + gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),""); +} + +void on_sections_new_clear(GtkWidget *button, actionWidgets *widgets){ + printf("w54y3563sthts\n"); + gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),""); + gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),""); +} + +void on_sections_close(GtkWidget *button, actionWidgets *widgets){ + printf("snnnnnnthtsgyuilgg\n"); + gtk_widget_hide(widgets->SectionSettingsWindow); +} + +void on_sections_save(GtkWidget *button, actionWidgets *widgets){ + GKeyFile *gfile=g_key_file_new(); + g_key_file_load_from_file(gfile,ConfigPath,G_KEY_FILE_NONE,NULL); + main_config.sections=yon_dictionary_create_empty(); + for (dictionary *dict=widgets->SettingsSections;dict!=NULL;dict=dict->next){ + SectionSettingSegment *segment=(SectionSettingSegment*)dict->data; + char *nm=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel)); + char *ct=(char*)gtk_label_get_text(GTK_LABEL(segment->CategoriesLabel)); + main_config.sections=yon_section_new(main_config.sections,nm,ct); + g_key_file_set_string(gfile,"sections",nm,ct); + for( int i=0;inext=NULL; + g_key_file_save_to_file(gfile,ConfigPath,NULL); + for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){ + IVGraphicals *IV=cur->data; + gtk_container_remove(GTK_CONTAINER(widgets->icvpack),IV->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); + +} + +void on_section_delete(GtkWidget *button, actionWidgets *widgets){ + for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ + SectionSettingSegment *segment=(SectionSettingSegment*)dct->data; + if (segment!=NULL){ + if (button==segment->ButtonDelete){ + if (dct->prev==NULL&&dct->next==NULL){ + }else if (dct->next==NULL){ + dct->prev->next=NULL; + }else if (dct->prev==NULL){ + dct->next->prev=NULL; + } else if (dct->prev==NULL){ + dct->next->prev=NULL; + }else { + dct->prev->next=dct->next; + dct->next->prev=dct->prev; + } + if (sectionremoval==NULL){ + removalsize++; + sectionremoval=malloc(removalsize*sizeof(char**)); + char *nm=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel)); + sectionremoval[0]=malloc(strlen(nm)); + memset(sectionremoval[0],0,strlen(nm)); + sprintf(sectionremoval[0],"%s",nm); + } else { + removalsize++; + sectionremoval=realloc(sectionremoval,removalsize*sizeof(char**)); + char *nm=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel)); + sectionremoval[removalsize-1]=malloc(strlen(nm)); + memset(sectionremoval[removalsize-1],0,strlen(nm)); + sprintf(sectionremoval[removalsize-1],"%s",nm); + } + gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),segment->MainFrame); + + } + } + } +} + +void launch_app_with_arguments(char *name, char *args){ + char *path=malloc(strlen(name)+strlen(args)+4); + memset(path,0,strlen(name)+strlen(args)+4); + memcpy(path,name,strlen(name)); + memcpy(path+strlen(name)," ",1); + strcat(args," &"); + strcat(path,args); + system(("/usr/bin/%s",path)); +}; + +void launch_app(char *name){ + strcat(name," &"); + system(name); +}; + +void 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); + system(path); +}; + + +apps *get_app_by_name(apps *applist,char *name, int size){ + for (int i=0;iIV),GTK_TREE_MODEL(section->LV)); + gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(section->IV),0); + gtk_icon_view_set_text_column(GTK_ICON_VIEW(section->IV),1); +} + +int load_apps(IVGraphicals *section, apps *applist, int size){ + int catstofind=sizeof(section->categories)/sizeof(char*); + int i=0; + for (int i=0;icategories)==1){ + GError *err=NULL; + char *path=malloc(strlen(IconPicturesPath)+strlen(applist[i].Icon)+7); + memset(path,0,strlen(IconPicturesPath)+strlen(applist[i].Icon)+7); + memcpy(path,IconPicturesPath,strlen(IconPicturesPath)); + path=yon_char_get_augumented(path,applist[i].Icon); + path=yon_char_get_augumented(path,PictureFormatMain); + GdkPixbuf *pixbuf; + pixbuf=gdk_pixbuf_new_from_file_at_size(path,main_config.iconsize,main_config.iconsize,NULL); + if (!pixbuf) { + pixbuf=gdk_pixbuf_new_from_file_at_size(ErrIconPicturePath,main_config.iconsize,main_config.iconsize,NULL); + }; + GtkTreeIter iter; + gtk_list_store_append(section->LV,&iter); + char *ChosenName; + ChosenName=applist[i].Name; + gtk_list_store_set(section->LV,&iter,0,pixbuf,1,ChosenName,-1); + } + } + gtk_icon_view_set_model(GTK_ICON_VIEW(section->IV),GTK_TREE_MODEL(section->LV)); + gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(section->IV),0); + gtk_icon_view_set_text_column(GTK_ICON_VIEW(section->IV),1); +}; + +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(IVGraphicals *section){ + GtkTreeIter iter; + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(section->LV),&iter)==0){ + gtk_widget_hide(section->IV); + gtk_widget_hide(section->label); + gtk_widget_hide(GTK_WIDGET(section->sep)); + } +} + +GtkWidget *create_socket(actionWidgets *builder){ + GtkWidget *socket; + socket = 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); + return socket; +}; + +void sort_apps(apps *applist,int size){ + apps tmp; + if (size>2) + { + for (int i=1;id_name); + file=fopen(path,"r"); + //printf("%s\n",path); + 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==NULL) tempapp.Pluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "X-XfcePluggable",NULL); + if (size==0){ + applist=(apps*)malloc(size+1*sizeof(apps)); + applist[0].Name=malloc(strlen(tempapp.Name)+1); + applist[0].Categories=malloc(strlen(tempapp.Categories)+1); + applist[0].Exec=malloc(strlen(tempapp.Exec)+1); + applist[0].Icon=malloc(strlen(tempapp.Icon)+1); + strncpy(applist[0].Name,tempapp.Name,strlen(tempapp.Name)); + applist[0].Name[strlen(tempapp.Name)]='\0'; + strncpy(applist[0].Categories,tempapp.Categories,strlen(tempapp.Categories)); + applist[0].Categories[strlen(tempapp.Categories)]='\0'; + strncpy(applist[0].Exec,tempapp.Exec,strlen(tempapp.Exec)); + applist[0].Exec[strlen(tempapp.Exec)]='\0'; + strncpy(applist[0].Icon,tempapp.Icon,strlen(tempapp.Icon)); + applist[0].Icon[strlen(tempapp.Icon)]='\0'; + applist[0].Type=tempapp.Type; + applist[0].Pluggable=tempapp.Pluggable; + size++; + } else { + applist=(apps*)realloc(applist,(size+1)*sizeof(apps)); + applist[size].Name=malloc(strlen(tempapp.Name)+1); + applist[size].Categories=malloc(strlen(tempapp.Categories)+1); + applist[size].Exec=malloc(strlen(tempapp.Exec)+1); + applist[size].Icon=malloc(strlen(tempapp.Icon)+1); + strncpy(applist[size].Name,tempapp.Name,strlen(tempapp.Name)); + applist[size].Name[strlen(tempapp.Name)]='\0'; + printf("%s\n",applist[size].Name); + strncpy(applist[size].Categories,tempapp.Categories,strlen(tempapp.Categories)); + applist[size].Categories[strlen(tempapp.Categories)]='\0'; + strncpy(applist[size].Exec,tempapp.Exec,strlen(tempapp.Exec)); + applist[size].Exec[strlen(tempapp.Exec)]='\0'; + strncpy(applist[size].Icon,tempapp.Icon,strlen(tempapp.Icon)); + applist[size].Icon[strlen(tempapp.Icon)]='\0'; + applist[size].Pluggable=tempapp.Pluggable; + applist[size].Type=tempapp.Type; + size++; + } + } + } + } + } + } + //printf("Closing apps configuration...\n"); + *sizef=size; + return applist; +}; + +int check_categories(apps app, char *catstocheck){ + if (!catstocheck){ // TODO + 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 0; + return 1; + } 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){ + char *fcat=strstr(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')==0) break; + + } + if (to_find==n_found) return 1; else return 0; + } +}; + +int setup_config(){ + main_config.sections=malloc(sizeof(dictionary)); + main_config.sections->data=NULL; + main_config.sections->next=NULL; + main_config.sections->prev=NULL; + main_config.sections->first=NULL; + FILE *file; + char *foroutput=NULL; + char path[100]=ConfigPath; + file=fopen(path,"r"); + char *line=NULL; + if (!file) { + file=fopen(path,"w"); + fclose(file); + } + file=fopen(path,"r"); + fseek(file,0L,SEEK_END); + int lsize=(int)ftell(file); + if (lsize==0){ + main_config.windowPosX=0; + main_config.windowPosY=0; + main_config.windowWidth=800; + main_config.windowHeight=600; + main_config.WindowTheme=0; + main_config.iconsize=32; + main_config.iconSegmentSize=150; + return 2; + } + line=malloc(lsize+1); + line[lsize]=-1; + fseek(file,0L,SEEK_SET); + fread(line,1,lsize,file); + line[lsize]='\0'; + char *nmline; + char *minus; + int leng; + nmline=strstr(line,"WindowPosX=")+11; + if (nmline==0xb){main_config.windowPosX=0;}else{ + minus=strstr(nmline,"\n"); + if (!minus) minus=""; + leng=strlen(nmline)-strlen(minus); + foroutput=malloc(leng+2); + strncpy(foroutput,nmline,leng); + foroutput[leng]='\0'; + main_config.windowPosX=atoi(foroutput); + free(foroutput); + fseek(file,0L,SEEK_SET); + } + nmline=strstr(line,"WindowPosY=")+11; + if (nmline==0xb){main_config.windowPosY=0;}else{ + minus=strstr(nmline,"\n"); + if (!minus) minus=""; + leng=strlen(nmline)-strlen(minus); + foroutput=malloc(leng+2); + strncpy(foroutput,nmline,leng); + foroutput[leng]='\0'; + main_config.windowPosY=atoi(foroutput); + free(foroutput); + fseek(file,0L,SEEK_SET); + } + nmline=strstr(line,"WindowHeight=")+13; + if (nmline==0xd){main_config.windowHeight=600;}else{ + minus=strstr(nmline,"\n"); + if (!minus) minus=""; + leng=strlen(nmline)-strlen(minus); + foroutput=malloc(leng+2); + strncpy(foroutput,nmline,leng); + foroutput[leng]='\0'; + main_config.windowHeight=atoi(foroutput); + free(foroutput); + fseek(file,0L,SEEK_SET); + } + nmline=strstr(line,"WindowWidth=")+12; + if (nmline==0xd){main_config.windowWidth=800;}else{ + minus=strstr(nmline,"\n"); + if (!minus) minus=""; + leng=strlen(nmline)-strlen(minus); + foroutput=malloc(leng+2); + strncpy(foroutput,nmline,leng); + foroutput[leng]='\0'; + main_config.windowWidth=atoi(foroutput); + free(foroutput); + fseek(file,0L,SEEK_SET); + } + nmline=strstr(line,"WindowTheme=")+12; + if (nmline==0xc){main_config.WindowTheme=1;}else{ + minus=strstr(nmline,"\n"); + if (!minus) minus=""; + foroutput=malloc(leng+2); + strncpy(foroutput,nmline,leng); + foroutput[leng]='\0'; + main_config.WindowTheme=atoi(foroutput); + free(foroutput); + fseek(file,0L,SEEK_SET); + } + nmline=strstr(line,"IconSize=")+9; + if (nmline==0x9){main_config.iconsize=1;}else{ + minus=strstr(nmline,"\n"); + if (!minus) minus=""; + leng=strlen(nmline)-strlen(minus); + foroutput=malloc(leng+2); + strncpy(foroutput,nmline,leng); + foroutput[leng]='\0'; + main_config.iconsize=atoi(foroutput); + if (main_config.iconsize==1)main_config.iconsize=24; + else if (main_config.iconsize==2)main_config.iconsize=32; + else if (main_config.iconsize==3)main_config.iconsize=48; + else if (main_config.iconsize==4)main_config.iconsize=64; + free(foroutput); + fseek(file,0L,SEEK_SET); + } + nmline=strstr(line,"IconSegmentSize=")+16; + if (nmline==0x9){main_config.iconsize=1;}else{ + minus=strstr(nmline,"\n"); + if (!minus) minus=""; + leng=strlen(nmline)-strlen(minus); + foroutput=malloc(leng+2); + strncpy(foroutput,nmline,leng); + foroutput[leng]='\0'; + main_config.iconSegmentSize=atoi(foroutput); + free(foroutput); + fseek(file,0L,SEEK_SET); + } + nmline=strstr(line,"[sections]\n"); + if (!nmline){yon_set_default_sections(main_config.sections);} else { + nmline+=11; + minus=strstr(nmline,"["); + if (!minus) minus=""; + leng=strlen(nmline)-strlen(minus); + char *sectionsline=yon_cut(nmline,leng,0); + while (strcmp(sectionsline,"")!=0){ + nmline=yon_char_divide_search(sectionsline,"\n",1); + char *name=yon_char_divide_search(nmline, "=",1); + if (strcmp(name,"")!=0 || strcmp(nmline,"")!=0) + main_config.sections=yon_section_new(main_config.sections,name, nmline); + } + main_config.sections->next=NULL; + } + + +}; + +int yon_theme_copy_undependent(actionWidgets *source, actionWidgets *dest){ + dest->DialogOpenDocumentation=source->DialogOpenDocumentation; + dest->CancelHelpButton=source->CancelHelpButton; + dest->ReadHelpButton=source->ReadHelpButton; + dest->AlwaysOpenDocumentation=source->AlwaysOpenDocumentation; + dest->helpHeader=source->helpHeader; + dest->helpText=source->helpText; + dest->appSettings=source->appSettings; + dest->SettingsWindow=source->SettingsWindow; + dest->settingsSizeSlider=source->settingsSizeSlider; + dest->settingsThemeChooser=source->settingsThemeChooser; + dest->settingsCancel=source->settingsCancel; + dest->settingsAccept=source->settingsAccept; + dest->MenuItemSettings=source->MenuItemSettings; + dest->MenuItemDocumentation=source->MenuItemDocumentation; + dest->LabelTitle=source->LabelTitle; + dest->settingsSubmenuLabelSize=source->settingsSubmenuLabelSize; + dest->settingsSubmenuLabelTheme=source->settingsSubmenuLabelTheme; +}; + +char *yon_cut(char *source, int size, int startpos){ + char *cut=NULL; + cut=malloc(size+1); + memset(cut,0,size+1); + memcpy(cut,source+startpos,size); + return cut; +} + +char *yon_char_divide(char *source, int dividepos){ + char *cut=malloc(dividepos+1); + memset(cut,0,dividepos+1); + memcpy(cut,source,dividepos); + char *left=malloc(strlen(source)-strlen(cut)); + memset(left,0,strlen(source)-strlen(cut)); + memcpy(left,source+dividepos+1,(strlen(source)-dividepos)); + memset(source,0,strlen(source)); + memcpy(source,left,strlen(left)); + return cut; +} + +char *yon_char_divide_search(char *source, char* dividepos, int delete_divider){ + char *cut=strstr(source,dividepos); + int leng=strlen(source)-strlen(cut); + cut=yon_char_divide(source,leng); + return cut; +} + +void yon_set_default_sections(dictionary *section){ + section=malloc(sizeof(dictionary)); + IconSection *sec=malloc(sizeof(IconSection)); + sec->section="Personal"; + sec->categories="X-UBL-SettingsManager;X-UBL-PersonalSettings;"; + section->data=sec; + section->first=section; + section->next=malloc(sizeof(dictionary)); + section->next->prev=section; + section->next->first=section->first; + section=section->next; + sec=malloc(sizeof(IconSection)); + sec->section="Hardware"; + sec->categories="X-UBL-SettingsManager;X-UBL-HardwareSettings;"; + section->data=sec; + section->next=malloc(sizeof(dictionary)); + section->next->prev=section; + section->next->first=section->first; + section=section->next; + sec=malloc(sizeof(IconSection)); + sec->section="System"; + sec->categories="X-UBL-SettingsManager;X-UBL-SystemSettings;"; + section->data=sec; + section->next=malloc(sizeof(dictionary)); + section->next->prev=section; + section->next->first=section->first; + section=section->next; + sec=malloc(sizeof(IconSection)); + sec->section="Misc"; + sec->categories="X-UBL-SettingsManager;"; + section->data=sec; + section=section->first; +} + +IVGraphicals *yon_create_single_section_IV(char *name,char *cats){ + IVGraphicals *IVG=malloc(sizeof(IVGraphicals)); + GtkWidget *box=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + GtkWidget *iv=gtk_icon_view_new(); + if (main_config.WindowTheme==1) { + gtk_icon_view_set_columns(GTK_ICON_VIEW(iv),1); + gtk_icon_view_set_item_orientation(GTK_ICON_VIEW(iv),GTK_ORIENTATION_HORIZONTAL); + } + GtkWidget *label=gtk_label_new(_(name)); + GtkWidget *sep=gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + GtkListStore *lv=gtk_list_store_new(2, GDK_TYPE_PIXBUF,G_TYPE_STRING); + gtk_widget_set_halign(box,0); + gtk_widget_set_valign(box,1); + gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(iv),0); + gtk_icon_view_set_text_column(GTK_ICON_VIEW(iv),1); + gtk_icon_view_set_item_width(GTK_ICON_VIEW(iv),75); + 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; + return IVG; +} + +dictionary *yon_create_icon_section_list(dictionary *sections){ + 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); + // loadapps(IVSections,// applist,size //); + if (!IVDict) { + IVDict=yon_dictionary_create_empty(); + IVDict->key=name->section; + IVDict->data=IVSections; + IVDict->first=IVDict; + } else { + IVDict->next=malloc(sizeof(dictionary)); + IVDict->next->prev=IVDict; + IVDict->next->first=IVDict->first; + IVDict=IVDict->next; + IVDict->key=name->section; + IVDict->data=IVSections; + } + sections=sections->next; + } + IVDict->next=NULL; + return IVDict->first; +} + +dictionary *yon_section_new(dictionary *section, char *section_name, char *categories){ + section->next=NULL; + IconSection *sct=malloc(sizeof(IconSection)); + dictionary *dict=malloc(sizeof(dictionary)); + sct->section=section_name; + sct->categories=categories; + dict->data=sct; + if (!section->data){ + section->data=dict->data; + section->first=section; + section->key=section_name; + } else { + dict->first=section->first; + section->next=dict; + dict->prev=section; + dict->key=section_name; + section=section->next; + } + + return section; +} + +char *yon_char_get_augumented(char *source, char *append){ + int size=strlen(source)+strlen(append)+1; + char *final=malloc(size); + memset(final,0,size); + sprintf(final,"%s%s",source,append); + return final; +} + +int yon_show_icon_views(dictionary *IVS,actionWidgets *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); + g_signal_connect(G_OBJECT(iv->IV),"item-activated",G_CALLBACK(on_Item_activated),widgets); + g_signal_connect(G_OBJECT(iv->IV),"selection-changed",G_CALLBACK(on_item_selection_changed),widgets); + + } +} + +dictionary *yon_dictionary_find(dictionary **dict, char *key){ + dictionary *dct=*dict; + for (dictionary *pointer=dct->first;pointer!=NULL;pointer=pointer->next){ + if (strcmp(pointer->key,key)==0){ + *dict=pointer; + return pointer; + } + } + return NULL; +} +void yon_switch_theme(dictionary **dict, dictionary *newone){ + *dict=newone; +} + +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("gtk-goto-top",GTK_ICON_SIZE_BUTTON); + segment->DragDownButton=gtk_button_new_from_icon_name("gtk-goto-bottom",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]!=';'){ + char *tmp=malloc(strlen(categories)+1); + sprintf(tmp,"%s;",categories); + printf("\n\n"); + categories=realloc(tmp,strlen(tmp)); + } + 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("dialog-ok",GTK_ICON_SIZE_BUTTON); + segment->EditButtonCancel=gtk_button_new_from_icon_name("dialog-no",GTK_ICON_SIZE_BUTTON); + segment->ButtonEdit=gtk_button_new_from_icon_name("gtk-edit",GTK_ICON_SIZE_BUTTON); + segment->DeleditBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + segment->ButtonDelete=gtk_button_new_from_icon_name("edit-delete",GTK_ICON_SIZE_BUTTON); + + 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_start(GTK_BOX(segment->ElemBox),segment->CategoriesBox,FALSE,FALSE,0); + + gtk_box_pack_start(GTK_BOX(segment->ElemBox),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->ElemBox,GTK_ALIGN_FILL); + gtk_widget_set_halign(segment->NameBox,GTK_ALIGN_START); + gtk_widget_set_halign(segment->CategoriesBox,GTK_ALIGN_START); + gtk_widget_set_halign(segment->NameEntry,GTK_ALIGN_START); + gtk_widget_set_halign(segment->NameLabel,GTK_ALIGN_START); + gtk_widget_set_halign(segment->CategoriesEntry,GTK_ALIGN_START); + gtk_widget_set_halign(segment->CategoriesLabel,GTK_ALIGN_START); + gtk_widget_set_halign(segment->EditButtonAccept,GTK_ALIGN_END); + gtk_widget_set_halign(segment->EditButtonBox,GTK_ALIGN_END); + gtk_widget_set_halign(segment->EditButtonCancel,GTK_ALIGN_END); + gtk_widget_set_halign(segment->ButtonEdit,GTK_ALIGN_END); + + gtk_widget_set_valign(segment->ElemBox,GTK_ALIGN_CENTER); + gtk_widget_set_valign(segment->NameBox,GTK_ALIGN_CENTER); + gtk_widget_set_valign(segment->CategoriesBox,GTK_ALIGN_CENTER); + gtk_widget_set_valign(segment->NameEntry,GTK_ALIGN_CENTER); + gtk_widget_set_valign(segment->NameLabel,GTK_ALIGN_CENTER); + gtk_widget_set_valign(segment->CategoriesEntry,GTK_ALIGN_CENTER); + gtk_widget_set_valign(segment->CategoriesLabel,GTK_ALIGN_CENTER); + + gtk_widget_set_hexpand(segment->ElemBox,1); + gtk_widget_set_hexpand(segment->CategoriesEntry,1); + gtk_widget_set_hexpand(segment->CategoriesLabel,1); + + + 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; +} + +dictionary *yon_dictionary_create_empty(){ + dictionary *dict=malloc(sizeof(dictionary)); + dict->data=NULL; + dict->key=NULL; + dict->next=NULL; + dict->prev=NULL; + dict->first=dict; + return dict; +} + +void yon_segment_show(actionWidgets *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(actionWidgets *widgets){ + 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(actionWidgets *widgets){ + for (dictionary *dict=widgets->SettingsSections->first;dict!=NULL;dict=dict->next){ + SectionSettingSegment *sgm=(SectionSettingSegment*)dict->data; + if (sgm!=NULL){ + //GKeyFile *gfile=g_key_file_new(); + //g_key_file_load_from_file(gfile,".config/ubconfig-main/ubconfig-main.conf",G_KEY_FILE_NONE,NULL); + //g_key_file_set_string(gfile,"sections",gtk_label_get_text(GTK_LABEL(sgm->NameLabel)),gtk_label_get_text(GTK_LABEL(sgm->CategoriesLabel))); + g_object_ref(G_OBJECT(sgm->MainFrame)); + gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),sgm->MainFrame); + } else return; + } +} +void yon_dictionary_make_first(dictionary *dict){ + for (dictionary *dct=dict->first;dct!=NULL;dct=dct->next){ + dct->first=dict; + } +} + + + +dictionary *yon_theme_new(dictionary *widgets, GtkBuilder *builder, char *theme_id, apps *applist, int appsize){ + actionWidgets *curWidgets=(actionWidgets*)widgets->data; + if (!curWidgets) { + curWidgets=malloc(sizeof(actionWidgets)); + widgets->data=curWidgets; + } + widgets->key=theme_id; + curWidgets->builder=builder; + curWidgets->window=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"Window"))); + curWidgets->DesktopBasic=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"HideWhileLaunch"))); + curWidgets->DesktopSocket=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"socketplace"))); + curWidgets->ButtonBackToMain=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"backToSettingsButton"))); + curWidgets->appSettings=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"appSettings"))); + curWidgets->socketplace=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"socketplace"))); + curWidgets->HideWhileLaunch=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"HideWhileLaunch"))); + curWidgets->workingwindow=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"workingwindow"))); + curWidgets->icvpack=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"icvpack"))); + curWidgets->GnomePaned=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"Paned"))); + curWidgets->GnomeInfoLabel=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"Paned"))); + curWidgets->SettingsSections=NULL; + + if (curWidgets->GnomeInfoLabel!=NULL){ + struct utsname sysinfo; + uname(&sysinfo); + struct seq_file *fl; + show_cpuinfo(fl); + printf("System Name = %s\n", sysinfo.sysname); + printf("Node Name = %s\n", sysinfo.nodename); + printf("Version = %s\n", sysinfo.version); + printf("Release = %s\n", sysinfo.release); + printf("Machine = %s\n", sysinfo.machine); + } + if (curWidgets->ButtonBackToMain!=NULL) + gtk_button_set_label(GTK_BUTTON(curWidgets->ButtonBackToMain),_("Back to settings")); + gtk_window_set_title(GTK_WINDOW(curWidgets->window),"UBLinux Settings Manager"); + g_signal_connect(G_OBJECT(curWidgets->window), "destroy", G_CALLBACK(gtk_main_quit), NULL); + if (curWidgets->ButtonBackToMain!=NULL) + g_signal_connect(G_OBJECT(curWidgets->ButtonBackToMain), "clicked", G_CALLBACK(on_backToSettingsButton_clicked), curWidgets); + curWidgets->LabelTitle=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"LabelTitle")); + gtk_window_set_title(GTK_WINDOW(curWidgets->window),"UBLinux Settings Manager GNOME"); + if (curWidgets->GnomePaned!=NULL) + g_signal_connect(G_OBJECT(curWidgets->GnomePaned), "notify::position", G_CALLBACK(on_paned_move), curWidgets); + // Standard for all themes + + curWidgets->settingsThemeChooser=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsThemeChooser")); + curWidgets->SettingsWindow=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SettingsWindow")); + curWidgets->MenuItemSettings=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"MenuItemSettings")); + curWidgets->MenuItemDocumentation=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"MenuItemDocumentation")); + curWidgets->DialogOpenDocumentation=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"HelpSureWindow")); + curWidgets->CancelHelpButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"CancelHelpButton")); + curWidgets->ReadHelpButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"ReadHelpButton")); + curWidgets->AlwaysOpenDocumentation=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"AlwaysOpenHelpCheckbox")); + curWidgets->helpHeader=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"helpHeader")); + curWidgets->helpText=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"helpText")); + curWidgets->settingsSizeInfoLabel=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSizeInfoLabel")); + curWidgets->settingsIcon=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsIcon")); + curWidgets->settingsSectionsSettingsButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSectionsSettingsButton")); + curWidgets->SectionSettingsWindow=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsWindow")); + curWidgets->SectionSettingsPack=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsPack")); + curWidgets->settingsSizeSlider=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSizeSlider")); + curWidgets->settingsAccept=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsAccept")); + curWidgets->settingsCancel=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsCancel")); + curWidgets->settingsSubmenuLabelSize=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSubmenuLabelSize")); + curWidgets->settingsSubmenuLabelTheme=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSubmenuLabelTheme")); + curWidgets->SectionSettingAddButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsAddButton")); + curWidgets->SectionSettingAddNameEntry=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsAddNameEntry")); + curWidgets->SectionSettingAddCategoriesEntry=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsAddCategoriesEntry")); + curWidgets->SectionSettingsClearEntryButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsClearEntryButton")); + curWidgets->SectionSettingsSaveButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsSaveButton")); + curWidgets->SectionSettingsCloseButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsCloseButton")); + curWidgets->applist=applist; + curWidgets->appssize=appsize; + curWidgets->socket=GTK_WIDGET(create_socket(curWidgets)); + gtk_widget_set_size_request(curWidgets->window,800,600); + gtk_window_resize(GTK_WINDOW(curWidgets->window),main_config.windowWidth,main_config.windowHeight); + gtk_window_set_icon_from_file(GTK_WINDOW(curWidgets->window),AppIconPath,NULL); + gtk_window_set_icon_from_file(GTK_WINDOW(curWidgets->SectionSettingsWindow),AppIconPath,NULL); + + // hide_if_unfound(GTK_TREE_MODEL(curWidgets); + + g_signal_connect(G_OBJECT(curWidgets->MenuItemDocumentation), "activate", G_CALLBACK(on_ButtonOpenHelp_activated), curWidgets->builder); + g_signal_connect(G_OBJECT(curWidgets->CancelHelpButton), "clicked", G_CALLBACK(on_CancelHelpButton_activated), curWidgets->builder); + g_signal_connect(G_OBJECT(curWidgets->ReadHelpButton), "clicked", G_CALLBACK(on_ReadHelpButton_activated), curWidgets->builder); + g_signal_connect(G_OBJECT(curWidgets->MenuItemSettings), "activate", G_CALLBACK(on_settingsOpen), curWidgets); + g_signal_connect(G_OBJECT(curWidgets->settingsSizeSlider), "value-changed", G_CALLBACK(on_settings_icon_size_changed), curWidgets); + g_signal_connect(G_OBJECT(curWidgets->settingsCancel), "clicked", G_CALLBACK(on_settings_cancel), curWidgets); + g_signal_connect(G_OBJECT(curWidgets->settingsAccept), "clicked", G_CALLBACK(on_settings_accept), widgets); + g_signal_connect(G_OBJECT(curWidgets->settingsSectionsSettingsButton), "clicked", G_CALLBACK(on_section_settings_open), widgets); + g_signal_connect(G_OBJECT(curWidgets->SectionSettingAddButton), "clicked", G_CALLBACK(on_sections_add), curWidgets); + g_signal_connect(G_OBJECT(curWidgets->SectionSettingsClearEntryButton), "clicked", G_CALLBACK(on_sections_new_clear), curWidgets); + g_signal_connect(G_OBJECT(curWidgets->SectionSettingsCloseButton), "clicked", G_CALLBACK(on_sections_close), curWidgets); + g_signal_connect(G_OBJECT(curWidgets->SectionSettingsSaveButton), "clicked", G_CALLBACK(on_sections_save), curWidgets); + // сделать функцию для сигналов окна секций, секции для настроек в словарь + gtk_label_set_text(GTK_LABEL(curWidgets->LabelTitle),_("UBLinux Settings Manager")); + gtk_label_set_text(GTK_LABEL(curWidgets->settingsSubmenuLabelSize),_("Icon size")); + gtk_label_set_text(GTK_LABEL(curWidgets->settingsSubmenuLabelTheme),_("Window theme")); + gtk_label_set_text(GTK_LABEL(curWidgets->helpHeader),_("Would you like to read documentation in the Web?")); + gtk_label_set_text(GTK_LABEL(curWidgets->helpText),_("You will be redirected to documentation site, where user help pages are translated and supported by community.")); + gtk_button_set_label(GTK_BUTTON(curWidgets->ReadHelpButton),_("Read online")); + gtk_button_set_label(GTK_BUTTON(curWidgets->CancelHelpButton),_("Cancel")); + gtk_button_set_label(GTK_BUTTON(curWidgets->settingsCancel),_("Close without saving")); + gtk_button_set_label(GTK_BUTTON(curWidgets->settingsAccept),_("Save and reload")); + gtk_button_set_label(GTK_BUTTON(curWidgets->AlwaysOpenDocumentation),_("Always redirect")); + gtk_menu_item_set_label(GTK_MENU_ITEM(curWidgets->MenuItemSettings),_("Settings")); + gtk_menu_item_set_label(GTK_MENU_ITEM(curWidgets->MenuItemDocumentation),_("About...")); + return widgets; +} + +int main(int argc, char *argv[]){ + gtk_init(&argc, &argv); + setup_config(); + local=setlocale(LC_ALL, ""); + bindtextdomain (LocaleName, LocalePath); + textdomain (LocaleName); + actionWidgets *widget=malloc(sizeof(actionWidgets)); + dictionary *widgets=malloc(sizeof(dictionary)); + widgets->data=widget; + widgets->first=widgets; + widgets->next=NULL; + widgets->prev=NULL; + int *size=malloc(sizeof(int)); + apps *applist=find_apps(size); + sort_apps(applist,*size); + GtkBuilder *builder=gtk_builder_new_from_file(GladePath); + actionWidgets *widg=(actionWidgets*)widgets->first->data; + char *theme; + if (main_config.WindowTheme==0) theme="Main"; + else if (main_config.WindowTheme==1) theme="Gnome"; + else theme="Main"; + yon_theme_new(widgets->first, builder,theme,applist,*size); + widg->applist=applist; + widg->appssize=*size; + widg->ICSys=yon_create_icon_section_list(main_config.sections); + for (dictionary *cur=widg->ICSys->first; cur!=NULL;cur=cur->next){ + load_apps((IVGraphicals*)cur->data,widg->applist,widg->appssize); + } + yon_show_icon_views(widg->ICSys,widg); + + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widg->settingsThemeChooser),NULL,_("Standard theme")); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widg->settingsThemeChooser),NULL,_("GNOME theme")); + + gtk_widget_show_all(widg->window); + // hide_if_unfound(GTK_TREE_MODEL(widgets->ModelPersonal),&Personal); + + GtkCssProvider *css=gtk_css_provider_new(); + gtk_css_provider_load_from_path(css,CssPath,NULL); + gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), + GTK_STYLE_PROVIDER(css), + GTK_STYLE_PROVIDER_PRIORITY_USER); + gtk_main(); + +} +#endif \ No newline at end of file diff --git a/ubl-settings-manager.h b/ubl-settings-manager.h new file mode 100644 index 0000000..fb15281 --- /dev/null +++ b/ubl-settings-manager.h @@ -0,0 +1,190 @@ +#ifndef UBL_SETTINGS_MANAGER +#define UBL_SETTINGS_MANAGER + +#include + +#define GladePath "ui/ubl-settings-manager.glade" +#define CssPath "./css/gtk-widgets.css" +#define ConfigPath ".config/ubconfig-main/ubconfig-main.conf" +#define AppIconPath "/usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg" +#define DesktopPath "/usr/share/applications/" +#define IconPicturesPath "/usr/share/icons/hicolor/32x32/apps/" +#define ErrIconPicturePath "/usr/share/icons/Faenza/emblems/32/emblem-important.png" +#define PictureFormatMain ".png" +#define PictureFormatExtra ".svg" +#define LocalePath "locale/" +#define LocaleName "base" + + +typedef struct apps{ + char *Name; + int Type; + char *Categories; + char *Exec; + char *Icon; + int Pluggable; + + } apps; + +typedef struct dictionary { + char *key; + void *data; + struct dictionary *next; + struct dictionary *prev; + struct dictionary *first; +} dictionary; + +typedef struct IVGrapgicals{ + char *sectionName; + char *categories; + GtkListStore *LV; + GtkWidget *Box; + GtkWidget *IV; + GtkWidget *label; + GtkWidget *sep; +} IVGraphicals; + +typedef struct IconSection{ + char *section; + char *categories; +} IconSection; + +typedef struct { + int windowWidth; + int windowHeight; + int windowPosX; + int windowPosY; + int WindowTheme; + char *curThemeName; + int iconsize; + int iconSegmentSize; + dictionary *sections; + +} config; + +typedef struct { + GtkWidget *MainFrame; + GtkWidget *MainBox; + GtkWidget *ElemBox; + GtkWidget *DragButtonBox; + GtkWidget *DragUpButton; + GtkWidget *DragDownButton; + GtkWidget *NameBox; + GtkWidget *CategoriesBox; + GtkWidget *OptionBox; + GtkWidget *NameEntry; + GtkWidget *NameLabel; + GtkWidget *CategoriesEntry; + GtkWidget *CategoriesLabel; + GtkWidget *EditButtonBox; + GtkWidget *EditButtonAccept; + GtkWidget *EditButtonCancel; + GtkWidget *ButtonEdit; + GtkWidget *ButtonDelete; + GtkWidget *DeleditBox; +} SectionSettingSegment; + +typedef struct { + GtkBuilder *builder; + GtkWidget *window; + dictionary *ICSys; + GtkWidget *DesktopBasic; + GtkWidget *DesktopSocket; + GtkWidget *ButtonBackToMain; + GtkWidget *DialogOpenDocumentation; + GtkWidget *CancelHelpButton; + GtkWidget *ReadHelpButton; + GtkWidget *AlwaysOpenDocumentation; + GtkWidget *helpHeader; + GtkWidget *helpText; + GtkWidget *appSettings; + GtkWidget *SettingsWindow; + GtkWidget *settingsSizeSlider; + GtkWidget *settingsSizeInfoLabel; + GtkWidget *settingsThemeChooser; + GtkWidget *settingsCancel; + GtkWidget *settingsAccept; + GtkWidget *settingsIcon; + GtkWidget *socket; + GtkWidget *socketplace; + GtkWidget *HideWhileLaunch; + GtkWidget *MenuItemSettings; + GtkWidget *MenuItemDocumentation; + GtkWidget *LabelTitle; + GtkWidget *settingsSubmenuLabelSize; + GtkWidget *settingsSubmenuLabelTheme; + GtkWidget *GnomePaned; + GtkWidget *GnomeInfoLabel; + GtkWidget *workingwindow; + GtkWidget *settingsSectionsSettingsButton; + GtkWidget *SectionSettingsWindow; + GtkWidget *SectionSettingsPack; + dictionary *SettingsSections; + GtkWidget *SectionSettingAddButton; + GtkWidget *SectionSettingAddNameEntry; + GtkWidget *SectionSettingAddCategoriesEntry; + GtkWidget *SectionSettingsClearEntryButton; + GtkWidget *SectionSettingsSaveButton; + GtkWidget *SectionSettingsCloseButton; + + int appssize; + apps *applist; + GtkWidget *icvpack; + + +} actionWidgets; + +typedef enum { + ACTIONWIDGETS, + ICONSECTION, + IVGRAPHICALS, + OTHER + +} DICT_TYPE; + +void on_plug_added(GtkSocket* self, actionWidgets *builder); +void on_plug_removed(GtkSocket* self, actionWidgets *widgets); +void on_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *applist); +void on_gnome_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *applist); +void on_item_selection_changed(GtkIconView *IV, actionWidgets *widgets); +void on_ButtonOpenHelp_activated(GtkWidget *button, GtkBuilder *builder); +void on_backToSettingsButton_clicked(GtkWidget *button,actionWidgets *sctb); +void on_CancelHelpButton_activated(GtkWidget *button,GtkBuilder *builder); +void on_ReadHelpButton_activated(GtkWidget *button, GtkBuilder *builder); +void launch_app_with_arguments(char *name, char *args); +void launch_app(char *name); +void py_launch_app(char *name,char *args); +int on_settings_accept(GtkWidget *button, dictionary *widgetsD); +void on_paned_move(GtkPaned* self, GtkScrollType* scroll_type, actionWidgets *widgets); +int on_settingsOpen(GtkWidget *button, actionWidgets *widgets); +int on_settings_icon_size_changed(GtkWidget* self, actionWidgets *widgets); +int on_settings_cancel(GtkWidget *button, actionWidgets *widgets); +apps *get_app_by_name(apps *applist,char *name, int size); +int reload_list(IVGraphicals *section); +int load_apps(IVGraphicals *section, apps *applist, int size); +int load_apps_with_clear(IVGraphicals *section, apps *applist, int size); +int hide_if_unfound(IVGraphicals *section); +GtkWidget *create_socket(actionWidgets *builder); +void sort_apps(apps *applist,int size); +apps *find_apps(int *sizef); +int check_categories(apps app, char *catstocheck); +int setup_config(); +dictionary *yon_theme_new(dictionary *widgets, GtkBuilder *builder, char *theme_id, apps *applist, int appsize); +char *yon_char_get_augumented(char *source, char *append); +char *yon_cut(char *source, int size, int startpos); +int yon_set_sections(IconSection *section); +void yon_set_default_sections(dictionary *section); +char *yon_char_divide_search(char *source, char* dividepos, int delete_divider); +char *yon_char_divide(char *source, int dividepos); +dictionary *yon_section_new(dictionary *section, char *section_name, char *categories); +void yon_switch_theme(dictionary **dict, dictionary *newone); +dictionary *yon_dictionary_find(dictionary **dict, char *key); +void yon_segment_show(actionWidgets *widgets, SectionSettingSegment *sgm); +dictionary *yon_dictionary_create_empty(); +SectionSettingSegment *yon_create_section_setting(char *name, char *categories); +void yon_segments_show(actionWidgets *widgets); +void yon_segments_hide(actionWidgets *widgets); +void yon_dictionary_make_first(dictionary *dict); +dictionary *yon_create_icon_section_list(dictionary *sections); +int yon_show_icon_views(dictionary *IVS,actionWidgets *widgets); +#endif \ No newline at end of file