Sections management redone

pull/28/head
parent d8fc95e1c9
commit 1a91ca3f85

@ -37,6 +37,7 @@ int stld=0;
int cmld=0;
void on_plug_added(GtkSocket* self, actionWidgets *builder){
gtk_widget_show(builder->socketbutton);
gtk_widget_show(builder->ThirdSocket);
@ -257,10 +258,7 @@ int on_settings_accept(GtkWidget *button, dictionary **widgetsDs){
g_key_file_set_string(gfile,"window","LabelDensity",fromint);
g_key_file_set_string(gfile,"window","User",login);
for (int i=0;i<removalsize;i++)
g_key_file_remove_key(gfile, "sections",sectionremoval[i] ,NULL);
removalsize=0;
sectionremoval=NULL;
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);
@ -352,23 +350,39 @@ void on_caution_understand(GtkWidget *button,actionWidgets *widgets){
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=(char*)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;
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);
}
dict=dict->prev;
dict->next=NULL;
yon_segments_show(widgets);
}
// 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=yon_dictionary_create_with_data((char*)gtk_label_get_text(GTK_LABEL(Sgm->NameLabel),Sgm);
// dict->data=Sgm;
// dict->key=(char*)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_window_present(GTK_WINDOW(widgets->SectionSettingsWindow));
}
@ -399,8 +413,21 @@ void on_sections_accept(GtkWidget *button, actionWidgets *widgets){
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);
@ -444,108 +471,136 @@ void on_sections_cancel(GtkWidget *button, actionWidgets *widgets){
};
void on_sections_move_up(GtkWidget *button, actionWidgets *widgets){
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
for (dictionary *dct=main_config.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);
}
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);
}
} 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->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;
}
// 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;
}
// 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){
void on_sections_move_down(GtkWidget *button, actionWidgets *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){
dct->prev->next=dct->next;
dct->next->prev=dct->prev;
gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),segment->MainFrame);
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);
}
}
}
// 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->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_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),"");
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);
printf("%s\n",category_name);
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);
//if (main_config.sections->prev) main_config.sections->first=main_config.sections->prev->first;
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);
}
// 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){
@ -558,82 +613,106 @@ void on_sections_close(GtkWidget *button, actionWidgets *widgets){
}
void on_sections_save(GtkWidget *button, dictionary *widgetsD){
actionWidgets *widgets=(actionWidgets*)widgetsD->data;
GKeyFile *gfile=g_key_file_new();
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);
}
main_config.sections->next=NULL;
int curtheme=main_config.WindowTheme;
for (dictionary *widgetsd=widgetsD->first;widgetsd!=NULL;widgetsd=widgetsd->next){
if (strcmp(widgetsd->key,"Gnome")==0){
main_config.WindowTheme=1;
main_config.currentThemeIconSize=&main_config.Gnomeiconsize;
main_config.currentThemeLabelSize=&main_config.GnomelabelSize;
}
else{
main_config.WindowTheme=0;
main_config.currentThemeIconSize=&main_config.Mainiconsize;
main_config.currentThemeLabelSize=&main_config.MainlabelSize;
// main_config.changed=1;
for (dictionary *dict=widgetsD->first;dict!=NULL;dict=dict->next){
actionWidgets *widgets=(actionWidgets*)dict->data;
for (dictionary *ICSys=widgets->ICSys->first;ICSys!=NULL;ICSys=ICSys->next){
gtk_container_remove(GTK_CONTAINER(widgets->icvpack),((IVGraphicals*)ICSys->data)->Box);
}
widgets=(actionWidgets*)widgetsd->data;
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_with_clear((IVGraphicals*)cur->data,widgets->applist,widgets->appssize);
}
yon_show_icon_views(widgets->ICSys,widgets);
dictionary *yond=yon_dictionary_create_empty();
yond->data=widgets;
hide_if_unfound(yond);
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);
}
main_config.WindowTheme=curtheme;
// actionWidgets *widgets=(actionWidgets*)widgetsD->data;
// GKeyFile *gfile=g_key_file_new();
// 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);
// }
// main_config.sections->next=NULL;
// int curtheme=main_config.WindowTheme;
// for (dictionary *widgetsd=widgetsD->first;widgetsd!=NULL;widgetsd=widgetsd->next){
// if (strcmp(widgetsd->key,"Gnome")==0){
// main_config.WindowTheme=1;
// main_config.currentThemeIconSize=&main_config.Gnomeiconsize;
// main_config.currentThemeLabelSize=&main_config.GnomelabelSize;
// }
// else{
// main_config.WindowTheme=0;
// main_config.currentThemeIconSize=&main_config.Mainiconsize;
// main_config.currentThemeLabelSize=&main_config.MainlabelSize;
// }
// widgets=(actionWidgets*)widgetsd->data;
// for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){
// IVGraphicals *IV=cur->data;
// gtk_container_remove(GTK_CONTAINER(widgets->icvpack),IV->Box);
// yon_dictionary_rip(cur);
// }
// widgets->ICSys=yon_create_icon_section_list(main_config.sections);
// for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){
// yon_icv_resize_item(widgets->ICSys,widgets->GnomePaned);
// load_apps_with_clear((IVGraphicals*)cur->data,widgets->applist,widgets->appssize);
// }
// yon_show_icon_views(widgets->ICSys,widgets);
// dictionary *yond=yon_dictionary_create_empty();
// yond->data=widgets;
// hide_if_unfound(yond);
// }
// main_config.WindowTheme=curtheme;
}
void on_section_delete(GtkWidget *button, actionWidgets *widgets){
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
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){
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);
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;
}
}
}
// 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 on_resized (GtkWidget *window, GdkEventConfigure *event, dictionary *widgetsD){
@ -962,7 +1041,7 @@ int setup_config(){
FILE *file;
GError *err=NULL;
main_config.sections=yon_dictionary_create_empty();
main_config.lock_settings=0;
main_config.SettingsSections=yon_dictionary_create_empty();
GKeyFile *configfile = g_key_file_new();
char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
@ -1130,6 +1209,7 @@ IVGraphicals *yon_create_single_section_IV(char *name,char *cats){
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
GtkBuilder *builder = gtk_builder_new_from_file(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();
@ -1194,10 +1274,7 @@ dictionary *yon_create_icon_section_list(dictionary *sections){
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=yon_dictionary_create_conneced(IVDict);
IVDict->key=name->section;
IVDict->data=IVSections;
}
@ -1288,6 +1365,31 @@ dictionary *yon_dictionary_find(dictionary **dict, char *key){
return NULL;
}
dictionary *yon_dictionary_rip(dictionary *dict){
if (!dict->next){
dictionary *prev=dict->prev;
if (prev){
prev->next=NULL;
return prev;
} else return dict;
}
else if (!dict->prev){
dictionary *next=dict->next;
if (next){
yon_dictionary_make_first(next);
next->prev=NULL;
return next;
}
else return dict;
}
else {
dictionary *next=dict->next, *prev=dict->prev;
next->prev=prev;
prev->next=next;
return next;
}
}
void yon_switch_theme(dictionary **dict, dictionary *newone){
dictionary *dct=*dict;
actionWidgets *widgets=(actionWidgets*)dct->data;
@ -1383,9 +1485,7 @@ SectionSettingSegment *yon_create_section_setting(char *name, char *categories){
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);
categories=realloc(tmp,strlen(tmp));
categories=yon_char_get_augumented(categories,";");
}
gtk_entry_set_text(GTK_ENTRY(segment->CategoriesEntry),categories);
segment->CategoriesLabel=gtk_label_new(categories);
@ -1438,6 +1538,8 @@ SectionSettingSegment *yon_create_section_setting(char *name, char *categories){
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_label_set_xalign(GTK_LABEL(segment->NameLabel),0);
@ -1503,8 +1605,8 @@ void yon_segments_show(actionWidgets *widgets){
};
void yon_segments_hide(actionWidgets *widgets){
if(widgets->SettingsSections)
for (dictionary *dict=widgets->SettingsSections->first;dict!=NULL;dict=dict->next){
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));
@ -1518,26 +1620,111 @@ void yon_dictionary_make_first(dictionary *dict){
dct->first=dict;
}
}
void yon_dictionary_make_nth(dictionary *dict, int nth){
dictionary *dct=dict->first;
for (int i=0;i<nth;i++){if (dct==NULL) return; else dct=dct->next;}
yon_dictionary_rip(dict);
dictionary *prev=dct->prev;
prev->next=dict;
dict->prev=prev;
dict->next=dct;
dct->prev=dict;
}
float yon_time_average(dictionary *times){
int sum=0;
int size=0;
for (dictionary *i=times->first;i!=NULL;i=i->next){
sum+=(time_t)i->data;
size++;
}
return (float)sum/size;
dictionary *yon_dictionary_create_with_data(char *key, void *data){
dictionary *dct=yon_dictionary_create_empty();
dct->key=key;
dct->data=data;
return dct;
}
void yon_time_reg_for_average(dictionary *listofregs, int size, time_t tm){
yon_dictionary_switch_to_last(&listofregs);
time_t prev=(time_t)listofregs->data;
listofregs=yon_dictionary_create_conneced(listofregs);
listofregs->data=(void*)(tm-prev);
dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data){
dictionary *dct=yon_dictionary_create_conneced(dict);
dct->key=key;
dct->data=data;
return dct;
}
dictionary *yon_dictionary_switch_places(dictionary *dict,int aim){
if (aim<0){
if (dict->prev){
if (dict->prev->prev){
dictionary *next = dict->next,*prev=dict->prev,*preprev=prev->prev;
if (next){
preprev->next=dict;
dict->prev=preprev;
dict->next=prev;
prev->prev=dict;
prev->next=next;
next->prev=prev;
} else {
preprev->next=dict;
dict->prev=preprev;
dict->next=prev;
prev->prev=dict;
prev->next=NULL;
}
return prev;
} else {
dictionary *next = dict->next,*prev=dict->prev;
if (next){
yon_dictionary_make_first(dict);
dict->prev=NULL;
dict->next=prev;
prev->prev=dict;
prev->next=next;
next->prev=prev;
} else {
dict->prev=NULL;
dict->next=prev;
prev->prev=dict;
prev->next=NULL;
}
return prev;
}
}
} else if (aim>0){
if (dict->next){
if (dict->next->next){
dictionary *next = dict->next,*prev=dict->prev,*afnext=next->next;
if (prev){
prev->next=next;
next->prev=prev;
next->next=dict;
dict->prev=next;
dict->next=afnext;
afnext->prev=dict;
} else {
yon_dictionary_make_first(next);
next->prev=NULL;
next->next=dict;
dict->prev=next;
dict->next=afnext;
afnext->prev=dict;
}
return next;
} else {
dictionary *next = dict->next,*prev=dict->prev;
if (prev){
prev->next=next;
next->prev=prev;
next->next=dict;
dict->prev=next;
dict->next=NULL;
} else {
next->prev=NULL;
next->next=dict;
dict->prev=next;
dict->next=NULL;
}
}
}
}
}
void yon_small_window_theme_change(actionWidgets *widgets){
dictionary *yon_dictionary_get_last(dictionary *dict){
for (dictionary *dct=dict;dct!=NULL;dct=dct->next){}
return dict;
}
void yon_main_quit(actionWidgets *widgets){
@ -1573,7 +1760,7 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them
curWidgets->MenuItemSettings=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"MenuItemSettings")));
curWidgets->MenuItemDocumentation=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"MenuItemDocumentation")));
curWidgets->MenuItemAboutSystem=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"MenuItemAboutSystem")));
curWidgets->SettingsSections=NULL;
curWidgets->SettingsSections=main_config.SettingsSections;
if (main_config.lock_settings==1){
gtk_widget_set_sensitive(curWidgets->MenuItemSettings,0);
}
@ -1672,22 +1859,35 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them
}
int main(int argc, char *argv[]){
gtk_init(&argc, &argv);
if (setup_config()==0){
printf("Ошибка загрузки конфига!\n");
return -1;
}
local=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,"",long_options,&option_index);
if (socket_find=='l') main_config.lock_settings=1;
socket_find=getopt_long(argc,argv,"lhv",long_options,&option_index);
if (socket_find=='l')
main_config.lock_settings=1;
else
main_config.lock_settings=0;
if (socket_find=='h') {
printf(cmdHelpText);
exit(0);
}
if (socket_find=='v') {
printf(cmdVersionText);
exit(0);
}
}
gtk_init(&argc, &argv);
if (setup_config()==0){
printf("Ошибка загрузки конфига!\n");
return -1;
}
local=setlocale(LC_ALL, "");
textdomain (LocaleName);
actionWidgets *widget=NULL;
widget=malloc(sizeof(actionWidgets));
dictionary *widgets=yon_dictionary_create_empty();

@ -5,7 +5,8 @@
#include <time.h>
#include <getopt.h>
#define cmdVersionText yon_char_get_augumented(yon_char_get_augumented(_("Version: "),version_application),"\n")
#define cmdHelpText yon_char_get_augumented(yon_char_get_augumented(_("ubl-settings-manager version: "),version_application),_("\nGTK settings manager for UBLinux\nUsage: ubl-settings-manager [OPTIONS...]\nOptions:\n -h, --help Show this help\n -V, --version Show package version\n --lock-settings Lock menu settings\n"))
#define GladePath "/usr/share/ubl-settings-manager/ui/ubl-settings-manager.glade"
#define CssPath "/usr/share/ubl-settings-manager/css/ubl-settings-manager.css"
#define GlobalConfigPath "/etc/xdg/ubl-settings-manager/ubl-settings-manager.conf"
@ -22,6 +23,7 @@
typedef char* string;
string version_application = ;
typedef struct apps{
char *Name;
int Type;
@ -81,6 +83,7 @@ typedef struct {
int changed;
int fullscreen;
int lock_settings;
dictionary *SettingsSections;
} config;
typedef struct {
@ -200,6 +203,7 @@ void sort_apps(apps *applist,int size);
apps *find_apps(int *sizef);
int check_categories(apps app, char *catstocheck);
int setup_config();
void yon_icv_resize_item(dictionary *icdict, GtkWidget *paned);
dictionary *yon_theme_new(dictionary **widgetss, 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);
@ -212,6 +216,11 @@ 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();
dictionary *yon_dictionary_rip(dictionary *dict);
dictionary *yon_dictionary_get_last(dictionary *dict);
dictionary *yon_dictionary_switch_places(dictionary *dict,int aim);
dictionary *yon_dictionary_create_with_data(char *key, void *data);
dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data);
SectionSettingSegment *yon_create_section_setting(char *name, char *categories);
void yon_segments_show(actionWidgets *widgets);
void yon_segments_hide(actionWidgets *widgets);

@ -4,108 +4,126 @@
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgid "translateinfo\n"
msgstr ""
"Project-Id-Version: 1.2\n"
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-03-13 10:24+0600\n"
"POT-Creation-Date: 2023-03-16 12:28+0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: ru\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: source/ubl-settings-manager.c:730
#: source/ubl-settings-manager.c:724
msgid "Settings manager for UBLinux"
msgstr "Менеджер настроек для UBLinux"
#: source/ubl-settings-manager.c:731 source/ubl-settings-manager.c:1615
#: source/ubl-settings-manager.c:1630 source/ubl-settings-manager.c:1685
#: source/ubl-settings-manager.c:725 source/ubl-settings-manager.c:1584
#: source/ubl-settings-manager.c:1598 source/ubl-settings-manager.c:1657
msgid "UBLinux Settings Manager"
msgstr "Настройки UBLinux"
#: source/ubl-settings-manager.c:733
#: source/ubl-settings-manager.c:728
msgid "Project Home Page"
msgstr "Домашняя станица проекта"
msgstr "Домашняя страница проекта"
#: source/ubl-settings-manager.c:1614
#: source/ubl-settings-manager.c:1583
msgid "Back to all settings"
msgstr "Назад ко всем настройкам"
#: source/ubl-settings-manager.c:1686
#: source/ubl-settings-manager.c:1658
msgid "Icon size"
msgstr "Размер иконок"
#: source/ubl-settings-manager.c:1687
#: source/ubl-settings-manager.c:1659
msgid "Window theme"
msgstr "Выбор темы"
#: source/ubl-settings-manager.c:1688
#: source/ubl-settings-manager.c:1660
msgid "Would you like to read documentation in the Web?"
msgstr "Вы хотите прочитать руководство в сети?"
msgstr "Вы хотите прочитать документацию в Сети?"
#: source/ubl-settings-manager.c:1689
#: source/ubl-settings-manager.c:1661
msgid ""
"You will be redirected to documentation site, where user help pages are "
"translated and supported by community."
msgstr "Вы будете перенаправлены на сайт с документацией, где страницы помощи переводятся и поддерживаются сообществом."
msgstr "Вы будете перенаправлены на сайт с документацией где страницы помощи переводятся и поддерживаются сообществом."
#: source/ubl-settings-manager.c:1690
#: source/ubl-settings-manager.c:1662
msgid "Read online"
msgstr "Прочитать онлайн"
#: source/ubl-settings-manager.c:1691
#: source/ubl-settings-manager.c:1663
msgid "Cancel"
msgstr "Отменить"
#: source/ubl-settings-manager.c:1692
#: source/ubl-settings-manager.c:1664
msgid "Close"
msgstr "Закрыть"
#: source/ubl-settings-manager.c:1693
#: source/ubl-settings-manager.c:1665
msgid "Save and apply"
msgstr "Сохранить и применить"
#: source/ubl-settings-manager.c:1694
#: source/ubl-settings-manager.c:1666
msgid "Always redirect"
msgstr "Всегда перенаправлять"
#: source/ubl-settings-manager.c:1695
#: source/ubl-settings-manager.c:1667
msgid "Settings"
msgstr "Настройки"
#: source/ubl-settings-manager.c:1696
#: source/ubl-settings-manager.c:1668
msgid "About..."
msgstr "О программе"
#: source/ubl-settings-manager.c:1697
msgid "Looks like you don't have ubl-settings-info installed on your PC."
msgstr "В вашей системе не обнаружен UBLinux Settings Info."
#: source/ubl-settings-manager.c:1697
msgid "About system"
msgstr "О системе"
#: source/ubl-settings-manager.c:1669
msgid "Understood"
msgstr "Понятно"
#: source/ubl-settings-manager.c:1719
#: source/ubl-settings-manager.c:1670
msgid "Sections management"
msgstr "Настройка разделов"
#: source/ubl-settings-manager.c:1698
msgid "Understood"
msgstr "Понятно"
#: source/ubl-settings-manager.c:1782
#: source/ubl-settings-manager.c:1768
msgid "Standard theme"
msgstr "Стандартная тема"
#: source/ubl-settings-manager.c:1783
#: source/ubl-settings-manager.c:1769
msgid "GNOME theme"
msgstr "GNOME тема"
#: source/ubl-settings-manager.h:8
msgid "Version: "
msgstr "Версия: "
#: source/ubl-settings-manager.h:8
msgid "ubl-settings-manager version: "
msgstr "ubl-settings-manager версия: "
#: source/ubl-settings-manager.h:8
msgid ""
"\n"
"GTK settings manager for UBLinux\n"
"Usage: ubl-settings-manager [OPTIONS...]\n"
"Options:\n"
" -h, --help\t\t Show this help\n"
" -V, --version\t \t Show package version\n"
" --lock-settings Lock menu settings\n"
msgstr ""
"\n"
"GTK Менеджер настроек для UBLinux\n"
"Использование: ubl-settings-manager [АРГУМЕНТЫ...]\n"
"Аргументы:\n"
" -h, --help\t\t Показать помощь\n"
" -V, --version\t \t Показать версию пакета\n"
" --lock-settings \t Заблокировать окно настроек\n"
msgid "Personal"
msgstr "Личные"
msgstr "Персональные"
msgid "Hardware"
msgstr "Оборудование"
@ -115,4 +133,3 @@ msgstr "Система"
msgid "Misc"
msgstr "Прочее"

Loading…
Cancel
Save