Merge pull request 'devel' (#29) from devel into master

Reviewed-on: YanTheKaller/ubl-settings-manager#29
pull/28/head
commit 00a9613b43

@ -37,6 +37,7 @@ int stld=0;
int cmld=0; int cmld=0;
void on_plug_added(GtkSocket* self, actionWidgets *builder){ void on_plug_added(GtkSocket* self, actionWidgets *builder){
gtk_widget_show(builder->socketbutton); gtk_widget_show(builder->socketbutton);
gtk_widget_show(builder->ThirdSocket); 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","LabelDensity",fromint);
g_key_file_set_string(gfile,"window","User",login); g_key_file_set_string(gfile,"window","User",login);
for (int i=0;i<removalsize;i++) g_key_file_remove_group(gfile, "sections",NULL);
g_key_file_remove_key(gfile, "sections",sectionremoval[i] ,NULL);
removalsize=0;
sectionremoval=NULL;
for (dictionary *dict=widgets->ICSys->first;dict!=NULL;dict=dict->next){ for (dictionary *dict=widgets->ICSys->first;dict!=NULL;dict=dict->next){
IVGraphicals *IV=(IVGraphicals*)dict->data; IVGraphicals *IV=(IVGraphicals*)dict->data;
g_key_file_set_string(gfile,"sections",IV->sectionName,IV->categories); g_key_file_set_string(gfile,"sections",IV->sectionName,IV->categories);
@ -352,22 +350,23 @@ void on_caution_understand(GtkWidget *button,actionWidgets *widgets){
void on_section_settings_open(GtkButton* self,dictionary *cWidgets){ void on_section_settings_open(GtkButton* self,dictionary *cWidgets){
actionWidgets *widgets=(actionWidgets*)cWidgets->data; actionWidgets *widgets=(actionWidgets*)cWidgets->data;
if (widgets->SettingsSections==NULL){ if (main_config.SettingsSections->first->data==NULL){
dictionary *dict=yon_dictionary_create_empty(); char *name=((IconSection*)main_config.sections->first->data)->section;
widgets->SettingsSections=dict; char *categories=((IconSection*)main_config.sections->first->data)->categories;
for (dictionary *pointer=widgets->ICSys->first;pointer!=NULL;pointer=pointer->next){ main_config.SettingsSections->first->data=yon_create_section_setting(name, categories);
IVGraphicals *IV=(IVGraphicals*)pointer->data; main_config.SettingsSections->first->key=name;
SectionSettingSegment *Sgm=yon_create_section_setting(IV->sectionName,IV->categories); yon_segments_hide(widgets);
yon_segment_show(widgets,Sgm); yon_segment_show(widgets, (SectionSettingSegment*)main_config.SettingsSections->data);
dict->data=Sgm; for (dictionary *dct=main_config.sections->first->next;dct!=NULL;dct=dct->next){ // ошибка если меньше двух
dict->key=(char*)gtk_label_get_text(GTK_LABEL(Sgm->NameLabel)); name=((IconSection*)dct->data)->section;
dict->next=malloc(sizeof(dictionary)); categories=((IconSection*)dct->data)->categories;
dict->next->prev=dict; main_config.SettingsSections=yon_dictionary_create_with_data_connected(main_config.SettingsSections,name,yon_create_section_setting(name, categories));
dict->next->first=dict->first; main_config.SettingsSections->key=name;
dict=dict->next; yon_segment_show(widgets, (SectionSettingSegment*)main_config.SettingsSections->data);
} }
dict=dict->prev; yon_segments_show(widgets);
dict->next=NULL;
} }
gtk_window_present(GTK_WINDOW(widgets->SectionSettingsWindow)); gtk_window_present(GTK_WINDOW(widgets->SectionSettingsWindow));
} }
@ -399,8 +398,21 @@ void on_sections_accept(GtkWidget *button, actionWidgets *widgets){
SectionSettingSegment *segment=(SectionSettingSegment*)dct->data; SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
if (segment!=NULL){ if (segment!=NULL){
if (button==segment->EditButtonAccept){ 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->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_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->NameLabel);
gtk_widget_show(segment->CategoriesLabel); gtk_widget_show(segment->CategoriesLabel);
gtk_widget_hide(segment->NameEntry); gtk_widget_hide(segment->NameEntry);
@ -444,108 +456,53 @@ void on_sections_cancel(GtkWidget *button, actionWidgets *widgets){
}; };
void on_sections_move_up(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; SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
if (segment!=NULL){ if (segment!=NULL){
if (button==segment->DragUpButton){ if (button==segment->DragUpButton){
if (dct->prev!=NULL){ yon_dictionary_switch_places(yon_dictionary_find(&main_config.sections,(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel))),-1);
if (dct->prev==dct->first){ yon_dictionary_switch_places(yon_dictionary_find(&main_config.SettingsSections,(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel))),-1);
yon_dictionary_make_first(dct); yon_segments_hide(widgets);
dct->next->prev=dct->prev; yon_segments_show(widgets);
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){ void on_sections_move_down(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; SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
if (segment!=NULL){ if (segment!=NULL){
if (button==segment->DragDownButton){ if (button==segment->DragDownButton){
if (dct->next!=NULL){ yon_dictionary_switch_places(yon_dictionary_find(&main_config.sections,(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel))),1);
if (dct->next->next==NULL){ yon_dictionary_switch_places(yon_dictionary_find(&main_config.SettingsSections,(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel))),1);
dct->next->prev=dct->prev; yon_segments_hide(widgets);
dct->prev->next=dct->next; yon_segments_show(widgets);
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_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){ void on_sections_add(GtkWidget *button, actionWidgets *widgets){
dictionary *dict=yon_dictionary_create_empty(); char *category_name = yon_char_get_augumented((char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry)),"");
dictionary *dct=NULL; if (strcmp(category_name,"")!=0){
SectionSettingSegment *segment=yon_create_section_setting((char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry)),(char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry))); char *category_categories=yon_char_get_augumented((char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry)),"");
for (dct=widgets->SettingsSections->first;dct->next!=NULL;dct=dct->next){} if (category_categories[strlen(category_categories)-1]!=';')
dict->data=segment; category_categories=yon_char_get_augumented(category_categories,";");
dict->key=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel)); SectionSettingSegment *segment=yon_create_section_setting(category_name,category_categories);
dct->next=dict; dictionary *newsection = yon_dictionary_get_last(main_config.SettingsSections);
dict->prev=dct; newsection=yon_dictionary_create_with_data_connected(newsection,category_name,segment);
dict->first=dct->first; printf("%s\n",category_name);
yon_segments_hide(widgets); dictionary *newsec=yon_dictionary_create_empty();
yon_segments_show(widgets); newsec=yon_section_new(newsec,category_name,category_categories);
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),""); main_config.sections=yon_dictionary_create_with_data_connected(main_config.sections,category_name,newsec->data);
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),"");
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),"");
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),"");
yon_segment_show(widgets, segment);
yon_segments_hide(widgets);
yon_segments_show(widgets);
}
} }
void on_sections_new_clear(GtkWidget *button, actionWidgets *widgets){ void on_sections_new_clear(GtkWidget *button, actionWidgets *widgets){
@ -558,80 +515,31 @@ void on_sections_close(GtkWidget *button, actionWidgets *widgets){
} }
void on_sections_save(GtkWidget *button, dictionary *widgetsD){ void on_sections_save(GtkWidget *button, dictionary *widgetsD){
actionWidgets *widgets=(actionWidgets*)widgetsD->data; for (dictionary *dict=widgetsD->first;dict!=NULL;dict=dict->next){
GKeyFile *gfile=g_key_file_new(); actionWidgets *widgets=(actionWidgets*)dict->data;
main_config.sections=yon_dictionary_create_empty(); for (dictionary *ICSys=widgets->ICSys->first;ICSys!=NULL;ICSys=ICSys->next){
for (dictionary *dict=widgets->SettingsSections;dict!=NULL;dict=dict->next){ gtk_container_remove(GTK_CONTAINER(widgets->icvpack),((IVGraphicals*)ICSys->data)->Box);
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);
}
widgets->ICSys=yon_create_icon_section_list(main_config.sections); widgets->ICSys=yon_create_icon_section_list(main_config.sections);
for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){ for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){
load_apps_with_clear((IVGraphicals*)cur->data,widgets->applist,widgets->appssize); load_apps((IVGraphicals*)cur->data,widgets->applist,widgets->appssize);
} }
yon_show_icon_views(widgets->ICSys,widgets); yon_show_icon_views(widgets->ICSys,widgets);
dictionary *yond=yon_dictionary_create_empty(); hide_if_unfound(widgetsD);
yond->data=widgets;
hide_if_unfound(yond);
} }
main_config.WindowTheme=curtheme;
} }
void on_section_delete(GtkWidget *button, actionWidgets *widgets){ 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; SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
if (segment!=NULL){ if (segment!=NULL){
if (button==segment->ButtonDelete){ if (button==segment->ButtonDelete){
if (dct->prev==NULL&&dct->next==NULL){ main_config.sections=yon_dictionary_rip(yon_dictionary_find(&main_config.sections, dct->key));
}else if (dct->next==NULL){ main_config.SettingsSections=yon_dictionary_rip(yon_dictionary_find(&main_config.SettingsSections, dct->key));
dct->prev->next=NULL; break;
}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);
} }
} }
} }
} }
@ -962,7 +870,7 @@ int setup_config(){
FILE *file; FILE *file;
GError *err=NULL; GError *err=NULL;
main_config.sections=yon_dictionary_create_empty(); 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(); GKeyFile *configfile = g_key_file_new();
char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin())); char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath); sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
@ -1130,6 +1038,7 @@ IVGraphicals *yon_create_single_section_IV(char *name,char *cats){
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
GtkBuilder *builder = gtk_builder_new_from_file(GladePath); GtkBuilder *builder = gtk_builder_new_from_file(GladePath);
GtkWidget *iv = GTK_WIDGET(gtk_builder_get_object(builder,"iconTemplate")); GtkWidget *iv = GTK_WIDGET(gtk_builder_get_object(builder,"iconTemplate"));
gtk_widget_show(iv);
GtkWidget *label = gtk_label_new(_(name)); GtkWidget *label = gtk_label_new(_(name));
GtkCellRendererPixbuf *iconRender = GTK_CELL_RENDERER_PIXBUF(gtk_builder_get_object(builder, "iconPic")); GtkCellRendererPixbuf *iconRender = GTK_CELL_RENDERER_PIXBUF(gtk_builder_get_object(builder, "iconPic"));
PangoAttrList *attrs = pango_attr_list_new(); PangoAttrList *attrs = pango_attr_list_new();
@ -1194,10 +1103,7 @@ dictionary *yon_create_icon_section_list(dictionary *sections){
IVDict->data=IVSections; IVDict->data=IVSections;
IVDict->first=IVDict; IVDict->first=IVDict;
} else { } else {
IVDict->next=malloc(sizeof(dictionary)); IVDict=yon_dictionary_create_conneced(IVDict);
IVDict->next->prev=IVDict;
IVDict->next->first=IVDict->first;
IVDict=IVDict->next;
IVDict->key=name->section; IVDict->key=name->section;
IVDict->data=IVSections; IVDict->data=IVSections;
} }
@ -1288,6 +1194,31 @@ dictionary *yon_dictionary_find(dictionary **dict, char *key){
return NULL; 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){ void yon_switch_theme(dictionary **dict, dictionary *newone){
dictionary *dct=*dict; dictionary *dct=*dict;
actionWidgets *widgets=(actionWidgets*)dct->data; actionWidgets *widgets=(actionWidgets*)dct->data;
@ -1383,9 +1314,7 @@ SectionSettingSegment *yon_create_section_setting(char *name, char *categories){
segment->NameLabel=gtk_label_new(name); segment->NameLabel=gtk_label_new(name);
segment->CategoriesEntry=gtk_entry_new(); segment->CategoriesEntry=gtk_entry_new();
if (categories[strlen(categories)-1]!=';'){ if (categories[strlen(categories)-1]!=';'){
char *tmp=malloc(strlen(categories)+1); categories=yon_char_get_augumented(categories,";");
sprintf(tmp,"%s;",categories);
categories=realloc(tmp,strlen(tmp));
} }
gtk_entry_set_text(GTK_ENTRY(segment->CategoriesEntry),categories); gtk_entry_set_text(GTK_ENTRY(segment->CategoriesEntry),categories);
segment->CategoriesLabel=gtk_label_new(categories); segment->CategoriesLabel=gtk_label_new(categories);
@ -1438,6 +1367,8 @@ SectionSettingSegment *yon_create_section_setting(char *name, char *categories){
gtk_widget_set_halign(segment->NameEntry,GTK_ALIGN_START); gtk_widget_set_halign(segment->NameEntry,GTK_ALIGN_START);
gtk_widget_set_halign(segment->NameLabel,GTK_ALIGN_END); gtk_widget_set_halign(segment->NameLabel,GTK_ALIGN_END);
gtk_widget_set_valign(segment->OptionBox,GTK_ALIGN_CENTER);
gtk_widget_set_valign(segment->OptionBox,GTK_ALIGN_CENTER);
gtk_widget_set_valign(segment->OptionBox,GTK_ALIGN_CENTER); gtk_widget_set_valign(segment->OptionBox,GTK_ALIGN_CENTER);
gtk_label_set_xalign(GTK_LABEL(segment->NameLabel),0); gtk_label_set_xalign(GTK_LABEL(segment->NameLabel),0);
@ -1503,8 +1434,8 @@ void yon_segments_show(actionWidgets *widgets){
}; };
void yon_segments_hide(actionWidgets *widgets){ void yon_segments_hide(actionWidgets *widgets){
if(widgets->SettingsSections) if(main_config.SettingsSections)
for (dictionary *dict=widgets->SettingsSections->first;dict!=NULL;dict=dict->next){ for (dictionary *dict=main_config.SettingsSections->first;dict!=NULL;dict=dict->next){
SectionSettingSegment *sgm=(SectionSettingSegment*)dict->data; SectionSettingSegment *sgm=(SectionSettingSegment*)dict->data;
if (sgm!=NULL){ if (sgm!=NULL){
g_object_ref(G_OBJECT(sgm->MainFrame)); g_object_ref(G_OBJECT(sgm->MainFrame));
@ -1518,26 +1449,111 @@ void yon_dictionary_make_first(dictionary *dict){
dct->first=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){ dictionary *yon_dictionary_create_with_data(char *key, void *data){
int sum=0; dictionary *dct=yon_dictionary_create_empty();
int size=0; dct->key=key;
for (dictionary *i=times->first;i!=NULL;i=i->next){ dct->data=data;
sum+=(time_t)i->data; return dct;
size++;
}
return (float)sum/size;
} }
void yon_time_reg_for_average(dictionary *listofregs, int size, time_t tm){ dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data){
yon_dictionary_switch_to_last(&listofregs); dictionary *dct=yon_dictionary_create_conneced(dict);
time_t prev=(time_t)listofregs->data; dct->key=key;
listofregs=yon_dictionary_create_conneced(listofregs); dct->data=data;
listofregs->data=(void*)(tm-prev); 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){ void yon_main_quit(actionWidgets *widgets){
@ -1573,7 +1589,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->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->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->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){ if (main_config.lock_settings==1){
gtk_widget_set_sensitive(curWidgets->MenuItemSettings,0); gtk_widget_set_sensitive(curWidgets->MenuItemSettings,0);
} }
@ -1672,22 +1688,35 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them
} }
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
gtk_init(&argc, &argv); local=setlocale(LC_ALL, "");
if (setup_config()==0){ textdomain (LocaleName);
printf("Ошибка загрузки конфига!\n");
return -1;
}
static struct option long_options[] = { static struct option long_options[] = {
{"lock-settings", 0, 0, 'l'}, {"lock-settings", 0, 0, 'l'},
{"help", 0, 0, 'h'},
{"version", 0, 0, 'v'},
}; };
int socket_find; int socket_find;
int option_index=0; int option_index=0;
for (int i=0;i<argc;i++){ for (int i=0;i<argc;i++){
socket_find=getopt_long(argc,argv,"",long_options,&option_index); socket_find=getopt_long(argc,argv,"lhv",long_options,&option_index);
if (socket_find=='l') main_config.lock_settings=1; 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; actionWidgets *widget=NULL;
widget=malloc(sizeof(actionWidgets)); widget=malloc(sizeof(actionWidgets));
dictionary *widgets=yon_dictionary_create_empty(); dictionary *widgets=yon_dictionary_create_empty();

@ -5,7 +5,8 @@
#include <time.h> #include <time.h>
#include <getopt.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 GladePath "/usr/share/ubl-settings-manager/ui/ubl-settings-manager.glade"
#define CssPath "/usr/share/ubl-settings-manager/css/ubl-settings-manager.css" #define CssPath "/usr/share/ubl-settings-manager/css/ubl-settings-manager.css"
#define GlobalConfigPath "/etc/xdg/ubl-settings-manager/ubl-settings-manager.conf" #define GlobalConfigPath "/etc/xdg/ubl-settings-manager/ubl-settings-manager.conf"
@ -22,6 +23,7 @@
typedef char* string; typedef char* string;
string version_application = ; string version_application = ;
typedef struct apps{ typedef struct apps{
char *Name; char *Name;
int Type; int Type;
@ -81,6 +83,7 @@ typedef struct {
int changed; int changed;
int fullscreen; int fullscreen;
int lock_settings; int lock_settings;
dictionary *SettingsSections;
} config; } config;
typedef struct { typedef struct {
@ -200,6 +203,7 @@ void sort_apps(apps *applist,int size);
apps *find_apps(int *sizef); apps *find_apps(int *sizef);
int check_categories(apps app, char *catstocheck); int check_categories(apps app, char *catstocheck);
int setup_config(); 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); 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_char_get_augumented(char *source, char *append);
char *yon_cut(char *source, int size, int startpos); 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); dictionary *yon_dictionary_find(dictionary **dict, char *key);
void yon_segment_show(actionWidgets *widgets, SectionSettingSegment *sgm); void yon_segment_show(actionWidgets *widgets, SectionSettingSegment *sgm);
dictionary *yon_dictionary_create_empty(); 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); SectionSettingSegment *yon_create_section_setting(char *name, char *categories);
void yon_segments_show(actionWidgets *widgets); void yon_segments_show(actionWidgets *widgets);
void yon_segments_hide(actionWidgets *widgets); void yon_segments_hide(actionWidgets *widgets);

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

Loading…
Cancel
Save