@ -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 - > categorie s) ;
yon_segment_show ( widgets , S gm) ;
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 ( widget s) ;
yon_segment_show ( widgets , ( S ectionSettingSe gment* ) 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 ( ) ;