You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1648 lines
75 KiB
1648 lines
75 KiB
#ifndef UBL_SETTINGS_MANAGER_MAIN
|
|
#define UBL_SETTINGS_MANAGER_MAIN
|
|
#include <gtk/gtk.h>
|
|
#include <gtk/gtkx.h>
|
|
#include <stdbool.h>
|
|
#include <dirent.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <locale.h>
|
|
#include <libintl.h>
|
|
#include <unistd.h>
|
|
#include <pthread.h>
|
|
#include<sys/utsname.h>
|
|
#include<sys/sysinfo.h>
|
|
#include <math.h>
|
|
#include <wctype.h>
|
|
#include <sys/stat.h>
|
|
|
|
|
|
#include "ubl-settings-manager.h"
|
|
|
|
#define _(String) gettext(String)
|
|
|
|
char **sectionremoval=NULL;
|
|
int removalsize=0;
|
|
char *local;
|
|
config main_config;
|
|
|
|
char *cats[2]={"XFCE","GTK"};
|
|
char *ubcatsPersonal[2]={"X-UBL-SettingsManager","X-UBL-PersonalSettings"};
|
|
char *ubcatsSystem[2]={"X-UBL-SettingsManager","X-UBL-SystemSettings"};
|
|
char *ubcatsHardware[2]={"X-UBL-SettingsManager","X-UBL-HardwareSettings"};
|
|
char *ubcatsMisc[1]={NULL};
|
|
int gnld=0;
|
|
int stld=0;
|
|
int cmld=0;
|
|
|
|
|
|
void on_plug_added(GtkSocket* self, actionWidgets *builder){
|
|
gtk_widget_show(builder->socketbutton);
|
|
gtk_widget_show(builder->ThirdSocket);
|
|
gtk_widget_set_vexpand(builder->HideWhileLaunch,0);
|
|
gtk_widget_hide(builder->HideWhileLaunch);
|
|
gtk_widget_set_vexpand(GTK_WIDGET(builder->socketplace),1);
|
|
gtk_widget_set_vexpand(GTK_WIDGET(self),1);
|
|
gtk_widget_show(builder->socketplace);
|
|
if (main_config.WindowTheme==0)
|
|
gtk_widget_hide(builder->appSettings);
|
|
if (builder->ButtonBackToMain!=NULL) gtk_widget_set_sensitive(builder->ButtonBackToMain,1);
|
|
gtk_widget_show(GTK_WIDGET(self));
|
|
gtk_widget_show(builder->socketbuttonplace);
|
|
gtk_widget_show(builder->ThirdSocketPlace);
|
|
gtk_widget_show(builder->socketbutton);
|
|
gtk_widget_show(builder->ThirdSocket);
|
|
}
|
|
|
|
void on_plug_removed(GtkSocket* self, actionWidgets *widgets){
|
|
gtk_widget_show(widgets->appSettings);
|
|
gtk_widget_show(widgets->HideWhileLaunch);
|
|
gtk_widget_set_vexpand(widgets->socketplace,0);
|
|
gtk_widget_set_vexpand(widgets->HideWhileLaunch,1);
|
|
if(widgets->socketbutton)
|
|
gtk_widget_destroy(widgets->socketbutton);
|
|
if(widgets->ThirdSocket)
|
|
gtk_widget_destroy(widgets->ThirdSocket);
|
|
|
|
gtk_widget_show(widgets->appSettings);
|
|
}
|
|
|
|
void on_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *applist){
|
|
GtkTreeIter iter;
|
|
char *name;
|
|
gtk_tree_model_get_iter(gtk_icon_view_get_model(self),&iter,path);
|
|
gtk_tree_model_get(gtk_icon_view_get_model(self),&iter,1,&name,-1);
|
|
|
|
apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize);
|
|
if (!tempapp){}else{
|
|
char arg[100];
|
|
memset(arg,0,100);
|
|
printf("%d\n%d\n\n\n\n",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton)));
|
|
sprintf(arg,"--socket-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton)));
|
|
|
|
if (tempapp[0].Type==1){
|
|
if (tempapp->Pluggable==1)
|
|
if (tempapp->DualPluggable==1){
|
|
char *dualarg=malloc(strlen("--socket-id= --socket-ext-id= --socket-trd-id=")+30);
|
|
sprintf(dualarg,"--socket-id=%d --socket-ext-id=%d --socket-trd-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton)),gtk_socket_get_id(GTK_SOCKET(applist->ThirdSocket)));
|
|
launch_app_with_arguments(tempapp[0].Exec,dualarg);
|
|
} else
|
|
launch_app_with_arguments(tempapp[0].Exec,arg);
|
|
else launch_app(tempapp[0].Exec);
|
|
}
|
|
}
|
|
};
|
|
|
|
void on_gnome_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *applist){
|
|
GtkTreeIter iter;
|
|
char *name;
|
|
if (!applist->socket){}else{
|
|
gtk_widget_destroy(applist->socket);
|
|
}
|
|
applist->socket=create_socket(applist);
|
|
|
|
gtk_tree_model_get_iter(gtk_icon_view_get_model(self),&iter,path);
|
|
gtk_tree_model_get(gtk_icon_view_get_model(self),&iter,1,&name,-1);
|
|
|
|
apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize);
|
|
char arg[100];
|
|
memset(arg,0,100);
|
|
sprintf(arg,"--socket-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)));
|
|
|
|
if (tempapp[0].Type==1){
|
|
if (tempapp->Pluggable==1){
|
|
|
|
if (tempapp->DualPluggable==1){
|
|
gtk_widget_hide(applist->appSettings);
|
|
char *dualarg=malloc(strlen("--socket-id= --socket-ext-id= --socket-trd-id=")+30);
|
|
sprintf(dualarg,"--socket-id=%d --socket-ext-id=%d --socket-trd-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton)),gtk_socket_get_id(GTK_SOCKET(applist->ThirdSocket)));
|
|
launch_app_with_arguments(tempapp[0].Exec,dualarg);
|
|
}
|
|
else{
|
|
launch_app_with_arguments(tempapp[0].Exec,arg);
|
|
gtk_widget_destroy(applist->socketbutton);
|
|
}
|
|
}
|
|
else {
|
|
on_about_system(NULL,applist);
|
|
launch_app(tempapp[0].Exec);
|
|
gtk_widget_destroy(applist->socketbutton);
|
|
}
|
|
}
|
|
}
|
|
|
|
void on_item_selection_changed(GtkIconView *IV, actionWidgets *widgets){
|
|
if (gtk_icon_view_get_selected_items(IV)>0){
|
|
dictionary *next=widgets->ICSys->first;
|
|
for (dictionary *dct=next;dct!=NULL;dct=dct->next){
|
|
IVGraphicals *IVG=(IVGraphicals*)dct->data;
|
|
if (GTK_ICON_VIEW(IVG->IV)!=GTK_ICON_VIEW(IV))
|
|
if (gtk_icon_view_get_selected_items(GTK_ICON_VIEW(IVG->IV))>0)
|
|
gtk_icon_view_unselect_all(GTK_ICON_VIEW(IVG->IV));
|
|
}
|
|
}
|
|
};
|
|
|
|
void on_ButtonOpenHelp_activated(GtkWidget *button, GtkBuilder *builder){
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,"AlwaysOpenHelpCheckbox"))))
|
|
{
|
|
system("xdg-open http://ublinux.com");
|
|
} else
|
|
{
|
|
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"HelpSureWindow"));
|
|
gtk_widget_show(window);
|
|
};
|
|
};
|
|
|
|
void on_backToSettingsButton_clicked(GtkWidget *button,actionWidgets *sctb){
|
|
GtkWidget *window=GTK_WIDGET(gtk_builder_get_object(sctb->builder,"HideWhileLaunch"));
|
|
GtkWidget *socketplace=GTK_WIDGET(gtk_builder_get_object(sctb->builder,"socketplace"));
|
|
gtk_widget_destroy(sctb->socket);
|
|
sctb->socket=GTK_WIDGET(create_socket(sctb));
|
|
GtkWidget *backbutton=sctb->ButtonBackToMain;
|
|
gtk_widget_set_sensitive(backbutton,0);
|
|
};
|
|
|
|
void on_CancelHelpButton_activated(GtkWidget *button,GtkBuilder *builder){
|
|
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"HelpSureWindow"));
|
|
gtk_widget_hide(window);
|
|
};
|
|
|
|
void on_ReadHelpButton_activated(GtkWidget *button, GtkBuilder *builder){
|
|
system("xdg-open http://ublinux.com");
|
|
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"HelpSureWindow"));
|
|
gtk_widget_hide(window);
|
|
};
|
|
|
|
int on_settings_accept(GtkWidget *button, dictionary **widgetsDs){
|
|
if (main_config.WindowTheme==0)
|
|
main_config.curThemeName="Main";
|
|
else if (main_config.WindowTheme==1)
|
|
main_config.curThemeName="Gnome";
|
|
dictionary *widgetsD=yon_dictionary_find(widgetsDs,main_config.curThemeName);
|
|
// printf("Saving config...\n");
|
|
actionWidgets *widgets=(actionWidgets*)widgetsD->data;
|
|
int theme=gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->settingsThemeChooser));
|
|
gtk_window_get_position(GTK_WINDOW(widgets->window),&main_config.windowPosX,&main_config.windowPosY);
|
|
gtk_window_get_size(GTK_WINDOW(widgets->window),&main_config.windowWidth,&main_config.windowHeight);
|
|
if (theme==0)
|
|
main_config.curThemeName="Main";
|
|
else if (theme==1)
|
|
main_config.curThemeName="Gnome";
|
|
if (main_config.WindowTheme!=theme){
|
|
main_config.WindowTheme=theme;
|
|
GtkWidget *loaderWindow=GTK_WIDGET(gtk_builder_get_object(widgets->builder,"LoaderWindow"));
|
|
gtk_window_resize(GTK_WINDOW(loaderWindow),main_config.windowWidth,main_config.windowHeight);
|
|
gtk_window_move(GTK_WINDOW(loaderWindow),main_config.windowPosX,main_config.windowPosY);
|
|
gtk_widget_show(loaderWindow);
|
|
yon_switch_theme(widgetsDs,yon_dictionary_find(&widgetsD,main_config.curThemeName));
|
|
if (widgets!=(actionWidgets*)widgetsD->data) widgets=(actionWidgets*)widgetsD->data;
|
|
gtk_widget_hide(loaderWindow);
|
|
gtk_window_present(GTK_WINDOW(widgets->SettingsWindow));
|
|
}
|
|
GKeyFile *gfile=g_key_file_new();
|
|
|
|
int sz=1,szm=1;
|
|
if (main_config.Gnomeiconsize==64) sz=4;
|
|
if (main_config.Gnomeiconsize==48) sz=3;
|
|
if (main_config.Gnomeiconsize==32) sz=2;
|
|
if (main_config.Gnomeiconsize==24) sz=1;
|
|
if (main_config.Mainiconsize==64) szm=4;
|
|
if (main_config.Mainiconsize==48) szm=3;
|
|
if (main_config.Mainiconsize==32) szm=2;
|
|
if (main_config.Mainiconsize==24) szm=1;
|
|
char *fromint=malloc(5);
|
|
memset(fromint,0,5);
|
|
GError *err=NULL;
|
|
char *login=getlogin();
|
|
if (geteuid()==0){
|
|
login=main_config.lastUser;
|
|
} else {
|
|
main_config.lastUser=login;
|
|
}
|
|
char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
|
|
sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
|
|
g_key_file_load_from_file(gfile,pth,G_KEY_FILE_NONE,&err);
|
|
if (err){
|
|
struct stat st = {0};
|
|
char *ptdir=malloc(36+strlen(getlogin()));
|
|
sprintf(ptdir,"%s%s%s","/home/",getlogin(),"/.config/ubl-settings-manager");
|
|
if (stat(ptdir, &st) == -1) {
|
|
mkdir(ptdir, 0777);
|
|
}
|
|
FILE *fp;
|
|
fp=fopen(pth,"w");
|
|
fclose(fp);
|
|
}
|
|
g_key_file_load_from_file(gfile,pth,G_KEY_FILE_NONE,&err);
|
|
sprintf(fromint,"%d",main_config.windowPosX);
|
|
g_key_file_set_string(gfile,"window","WindowPosX",fromint);
|
|
sprintf(fromint,"%d",main_config.windowPosY);
|
|
g_key_file_set_string(gfile,"window","WindowPosY",fromint);
|
|
sprintf(fromint,"%d",main_config.windowWidth);
|
|
g_key_file_set_string(gfile,"window","WindowWidth",fromint);
|
|
sprintf(fromint,"%d",main_config.windowHeight);
|
|
g_key_file_set_string(gfile,"window","WindowHeight",fromint);
|
|
sprintf(fromint,"%d",main_config.WindowTheme);
|
|
g_key_file_set_string(gfile,"window","WindowTheme",fromint);
|
|
sprintf(fromint,"%d",sz);
|
|
g_key_file_set_string(gfile,"window","GnomeIconSize",fromint);
|
|
sprintf(fromint,"%d",szm);
|
|
g_key_file_set_string(gfile,"window","MainIconSize",fromint);
|
|
sprintf(fromint,"%d",main_config.iconSegmentSize);
|
|
g_key_file_set_string(gfile,"window","IconSegmentSize",fromint);
|
|
sprintf(fromint,"%d",(int)((float)main_config.GnomelabelSize/1000));
|
|
g_key_file_set_string(gfile,"window","GnomeLabelSize",fromint);
|
|
sprintf(fromint,"%d",(int)((float)main_config.MainlabelSize/1000));
|
|
g_key_file_set_string(gfile,"window","MainLabelSize",fromint);
|
|
sprintf(fromint,"%d",(int)((float)main_config.labelDensity/1000));
|
|
g_key_file_set_string(gfile,"window","LabelDensity",fromint);
|
|
g_key_file_set_string(gfile,"window","User",login);
|
|
|
|
for (dictionary *dict=widgets->ICSys->first;dict!=NULL;dict=dict->next){
|
|
IVGraphicals *IV=(IVGraphicals*)dict->data;
|
|
g_key_file_set_string(gfile,"sections",IV->sectionName,IV->categories);
|
|
if (main_config.changed==1){
|
|
load_apps_with_clear(IV,widgets->applist,widgets->appssize);
|
|
}
|
|
}
|
|
main_config.changed=0;
|
|
g_key_file_save_to_file(gfile,pth,NULL);
|
|
gtk_widget_hide(widgets->SettingsWindow);
|
|
};
|
|
|
|
void on_paned_move(GtkPaned* self, GtkScrollType* scroll_type, actionWidgets *widgets){
|
|
int position=gtk_paned_get_position(GTK_PANED(widgets->GnomePaned));
|
|
if (position<250) {position=250; gtk_paned_set_position(GTK_PANED(widgets->GnomePaned),250);}
|
|
main_config.iconSegmentSize=position;
|
|
if (position <115) {position=115;}
|
|
double pos=((double)position-(11/(double)position*4)*500)/1.3;
|
|
if (pos<110) pos=110;
|
|
for (dictionary *dict=widgets->ICSys;dict!=NULL;dict=dict->next){
|
|
IVGraphicals *IV=(IVGraphicals*)dict->data;
|
|
gtk_icon_view_set_item_width(GTK_ICON_VIEW(IV->IV),pos);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
int on_settingsOpen(GtkWidget *button, actionWidgets *widgets){
|
|
gtk_window_set_title(GTK_WINDOW(widgets->SettingsWindow),"UBLinux Settings Manager");
|
|
gtk_widget_set_size_request(widgets->SettingsWindow,400,250);
|
|
gtk_window_set_icon_from_file(GTK_WINDOW(widgets->SettingsWindow),AppIconPath,NULL);
|
|
gtk_widget_show_all(widgets->SettingsWindow);
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->settingsThemeChooser),main_config.WindowTheme);
|
|
int sz=1;
|
|
if (*main_config.currentThemeIconSize==64) sz=4;
|
|
if (*main_config.currentThemeIconSize==48) sz=3;
|
|
if (*main_config.currentThemeIconSize==32) sz=2;
|
|
if (*main_config.currentThemeIconSize==24) sz=1;
|
|
gtk_range_set_value(GTK_RANGE(widgets->settingsSizeSlider),sz);
|
|
char *tmp=malloc(6);
|
|
sprintf(tmp,"%dx%d\0",*main_config.currentThemeIconSize,*main_config.currentThemeIconSize);
|
|
gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),tmp);
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale(AppIconPath,*main_config.currentThemeIconSize,*main_config.currentThemeIconSize,1,NULL));
|
|
|
|
gtk_window_present(GTK_WINDOW(widgets->SettingsWindow));
|
|
};
|
|
|
|
int on_settings_icon_size_changed(GtkWidget* self, actionWidgets *widgets){
|
|
int val=(int)gtk_range_get_value(GTK_RANGE(self));
|
|
if ((int)val==1||(int)val==0){
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale(AppIconPath,24,24,1,NULL));
|
|
gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"24x24");
|
|
if (*main_config.currentThemeIconSize!=24)
|
|
main_config.changed=1;
|
|
*main_config.currentThemeIconSize=24;
|
|
}
|
|
if ((int)val==2){
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale(AppIconPath,32,32,1,NULL));
|
|
gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"32x32");
|
|
if (*main_config.currentThemeIconSize!=32)
|
|
main_config.changed=1;
|
|
*main_config.currentThemeIconSize=32;
|
|
}
|
|
if ((int)val==3){
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale(AppIconPath,48,48,1,NULL));
|
|
gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"48x48");
|
|
if (*main_config.currentThemeIconSize!=48)
|
|
main_config.changed=1;
|
|
*main_config.currentThemeIconSize=48;
|
|
}
|
|
if ((int)val==4){
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->settingsIcon),gdk_pixbuf_new_from_file_at_scale(AppIconPath,64,64,1,NULL));
|
|
gtk_label_set_text(GTK_LABEL(widgets->settingsSizeInfoLabel),"64x64");
|
|
if (*main_config.currentThemeIconSize!=64)
|
|
main_config.changed=1;
|
|
*main_config.currentThemeIconSize=64;
|
|
}
|
|
};
|
|
|
|
int on_settings_cancel(GtkWidget *button, actionWidgets *widgets){
|
|
gtk_widget_hide(widgets->SettingsWindow);
|
|
setup_config();
|
|
};
|
|
|
|
void on_caution_understand(GtkWidget *button,actionWidgets *widgets){
|
|
gtk_widget_hide(widgets->CautionWindow);
|
|
}
|
|
|
|
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;
|
|
}
|
|
dict=dict->prev;
|
|
dict->next=NULL;
|
|
}
|
|
gtk_widget_show(widgets->SectionSettingsWindow);
|
|
}
|
|
|
|
void on_sections_edit(GtkWidget *button, actionWidgets *widgets){
|
|
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
|
|
SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
|
|
if (segment!=NULL){
|
|
if (button==segment->ButtonEdit){
|
|
gtk_widget_hide(segment->NameLabel);
|
|
gtk_widget_hide(segment->CategoriesLabel);
|
|
gtk_widget_show(segment->NameEntry);
|
|
gtk_widget_show(segment->CategoriesEntry);
|
|
gtk_widget_show(segment->EditButtonBox);
|
|
gtk_widget_hide(segment->DeleditBox);
|
|
gtk_widget_set_sensitive(segment->DragButtonBox,0);
|
|
|
|
} else {
|
|
gtk_widget_set_sensitive(segment->OptionBox,0);
|
|
gtk_widget_set_sensitive(segment->DragButtonBox,0);
|
|
}
|
|
|
|
}
|
|
}
|
|
};
|
|
|
|
void on_sections_accept(GtkWidget *button, actionWidgets *widgets){
|
|
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
|
|
SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
|
|
if (segment!=NULL){
|
|
if (button==segment->EditButtonAccept){
|
|
gtk_label_set_text(GTK_LABEL(segment->NameLabel),gtk_entry_get_text(GTK_ENTRY(segment->NameEntry)));
|
|
gtk_label_set_text(GTK_LABEL(segment->CategoriesLabel),gtk_entry_get_text(GTK_ENTRY(segment->CategoriesEntry)));
|
|
gtk_widget_show(segment->NameLabel);
|
|
gtk_widget_show(segment->CategoriesLabel);
|
|
gtk_widget_hide(segment->NameEntry);
|
|
gtk_widget_hide(segment->CategoriesEntry);
|
|
gtk_widget_hide(segment->EditButtonBox);
|
|
gtk_widget_show(segment->DeleditBox);
|
|
gtk_widget_set_sensitive(segment->DragButtonBox,1);
|
|
|
|
}else {
|
|
gtk_widget_set_sensitive(segment->OptionBox,1);
|
|
gtk_widget_set_sensitive(segment->DragButtonBox,1);
|
|
}
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
void on_sections_cancel(GtkWidget *button, actionWidgets *widgets){
|
|
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
|
|
SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
|
|
if (segment!=NULL){
|
|
if (button==segment->EditButtonCancel){
|
|
gtk_entry_set_text(GTK_ENTRY(segment->NameEntry),gtk_label_get_text(GTK_LABEL(segment->NameLabel)));
|
|
gtk_entry_set_text(GTK_ENTRY(segment->CategoriesEntry),gtk_label_get_text(GTK_LABEL(segment->CategoriesLabel)));
|
|
gtk_widget_show(segment->NameLabel);
|
|
gtk_widget_show(segment->CategoriesLabel);
|
|
gtk_widget_hide(segment->NameEntry);
|
|
gtk_widget_hide(segment->CategoriesEntry);
|
|
gtk_widget_hide(segment->EditButtonBox);
|
|
gtk_widget_show(segment->ButtonEdit);
|
|
gtk_widget_set_sensitive(segment->DragButtonBox,1);
|
|
|
|
}else {
|
|
gtk_widget_set_sensitive(segment->OptionBox,1);
|
|
gtk_widget_set_sensitive(segment->DragButtonBox,1);
|
|
}
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
void on_sections_move_up(GtkWidget *button, actionWidgets *widgets){
|
|
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
|
|
SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
|
|
if (segment!=NULL){
|
|
if (button==segment->DragUpButton){
|
|
if (dct->prev!=NULL){
|
|
if (dct->prev==dct->first){
|
|
yon_dictionary_make_first(dct);
|
|
dct->next->prev=dct->prev;
|
|
dct->prev->next=dct->next;
|
|
dct->next=dct->prev;
|
|
dct->prev=NULL;
|
|
dct->next->prev=dct;
|
|
} else if (dct->next==NULL){
|
|
dct->next=dct->prev;
|
|
dct->next->next=NULL;
|
|
dct->next->prev->next=dct;
|
|
dct->prev=dct->prev->prev;
|
|
dct->next->prev=dct;
|
|
} else{
|
|
dct->next->prev=dct->prev;
|
|
dct->prev->next=dct->next;
|
|
dct->next=dct->prev;
|
|
dct->prev=dct->prev->prev;
|
|
dct->prev->next=dct;
|
|
dct->next->prev=dct;
|
|
}
|
|
|
|
|
|
yon_segments_hide(widgets);
|
|
yon_segments_show(widgets);
|
|
}
|
|
}
|
|
} else return;
|
|
}
|
|
};
|
|
|
|
void on_sections_move_down(GtkWidget *button, actionWidgets *widgets){
|
|
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
|
|
SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
|
|
if (segment!=NULL){
|
|
if (button==segment->DragDownButton){
|
|
if (dct->next!=NULL){
|
|
if (dct->next->next==NULL){
|
|
dct->next->prev=dct->prev;
|
|
dct->prev->next=dct->next;
|
|
dct->prev=dct->next;
|
|
dct->next=NULL;
|
|
dct->prev->next=dct;
|
|
} else if (dct->prev==NULL){
|
|
yon_dictionary_make_first(dct->next);
|
|
dct->prev=dct->next;
|
|
dct->next=dct->next->next;
|
|
dct->prev->prev=NULL;
|
|
dct->next->prev=dct;
|
|
dct->prev->next=dct;
|
|
|
|
} else{
|
|
dct->next->prev=dct->prev;
|
|
dct->prev->next=dct->next;
|
|
dct->prev=dct->next;
|
|
dct->next=dct->next->next;
|
|
dct->next->prev=dct;
|
|
dct->prev->next=dct;
|
|
}
|
|
|
|
|
|
yon_segments_hide(widgets);
|
|
yon_segments_show(widgets);
|
|
}
|
|
}
|
|
} else return;
|
|
}
|
|
};
|
|
|
|
void on_sections_delete(GtkWidget *button, actionWidgets *widgets){
|
|
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
|
|
SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
|
|
if (segment!=NULL){
|
|
if (button==segment->DragDownButton){
|
|
dct->prev->next=dct->next;
|
|
dct->next->prev=dct->prev;
|
|
|
|
gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),segment->MainFrame);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
void on_sections_add(GtkWidget *button, actionWidgets *widgets){
|
|
dictionary *dict=yon_dictionary_create_empty();
|
|
dictionary *dct=NULL;
|
|
SectionSettingSegment *segment=yon_create_section_setting((char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry)),(char*)gtk_entry_get_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry)));
|
|
for (dct=widgets->SettingsSections->first;dct->next!=NULL;dct=dct->next){}
|
|
dict->data=segment;
|
|
dict->key=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel));
|
|
dct->next=dict;
|
|
dict->prev=dct;
|
|
dict->first=dct->first;
|
|
yon_segments_hide(widgets);
|
|
yon_segments_show(widgets);
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),"");
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),"");
|
|
}
|
|
|
|
void on_sections_new_clear(GtkWidget *button, actionWidgets *widgets){
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),"");
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),"");
|
|
}
|
|
|
|
void on_sections_close(GtkWidget *button, actionWidgets *widgets){
|
|
gtk_widget_hide(widgets->SectionSettingsWindow);
|
|
}
|
|
|
|
void on_sections_save(GtkWidget *button, actionWidgets *widgets){
|
|
GKeyFile *gfile=g_key_file_new();
|
|
g_key_file_load_from_file(gfile,GlobalConfigPath,G_KEY_FILE_NONE,NULL);
|
|
main_config.sections=yon_dictionary_create_empty();
|
|
for (dictionary *dict=widgets->SettingsSections;dict!=NULL;dict=dict->next){
|
|
SectionSettingSegment *segment=(SectionSettingSegment*)dict->data;
|
|
char *nm=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel));
|
|
char *ct=(char*)gtk_label_get_text(GTK_LABEL(segment->CategoriesLabel));
|
|
main_config.sections=yon_section_new(main_config.sections,nm,ct);
|
|
g_key_file_set_string(gfile,"sections",nm,ct);
|
|
for( int i=0;i<removalsize;i++){
|
|
g_key_file_remove_key(gfile,"sections",sectionremoval[i],NULL);
|
|
}
|
|
}
|
|
main_config.sections->next=NULL;
|
|
g_key_file_save_to_file(gfile,GlobalConfigPath,NULL);
|
|
for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){
|
|
IVGraphicals *IV=cur->data;
|
|
gtk_container_remove(GTK_CONTAINER(widgets->icvpack),IV->Box);
|
|
}
|
|
|
|
widgets->ICSys=yon_create_icon_section_list(main_config.sections);
|
|
for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){
|
|
load_apps((IVGraphicals*)cur->data,widgets->applist,widgets->appssize);
|
|
}
|
|
yon_show_icon_views(widgets->ICSys,widgets);
|
|
dictionary *yond=yon_dictionary_create_empty();
|
|
yond->data=widgets;
|
|
hide_if_unfound(yond);
|
|
|
|
}
|
|
|
|
void on_section_delete(GtkWidget *button, actionWidgets *widgets){
|
|
for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){
|
|
SectionSettingSegment *segment=(SectionSettingSegment*)dct->data;
|
|
if (segment!=NULL){
|
|
if (button==segment->ButtonDelete){
|
|
if (dct->prev==NULL&&dct->next==NULL){
|
|
}else if (dct->next==NULL){
|
|
dct->prev->next=NULL;
|
|
}else if (dct->prev==NULL){
|
|
dct->next->prev=NULL;
|
|
} else if (dct->prev==NULL){
|
|
dct->next->prev=NULL;
|
|
}else {
|
|
dct->prev->next=dct->next;
|
|
dct->next->prev=dct->prev;
|
|
}
|
|
if (sectionremoval==NULL){
|
|
removalsize++;
|
|
sectionremoval=malloc(removalsize*sizeof(char**));
|
|
char *nm=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel));
|
|
sectionremoval[0]=malloc(strlen(nm));
|
|
memset(sectionremoval[0],0,strlen(nm));
|
|
sprintf(sectionremoval[0],"%s",nm);
|
|
} else {
|
|
removalsize++;
|
|
sectionremoval=realloc(sectionremoval,removalsize*sizeof(char**));
|
|
char *nm=(char*)gtk_label_get_text(GTK_LABEL(segment->NameLabel));
|
|
sectionremoval[removalsize-1]=malloc(strlen(nm));
|
|
memset(sectionremoval[removalsize-1],0,strlen(nm));
|
|
sprintf(sectionremoval[removalsize-1],"%s",nm);
|
|
}
|
|
gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),segment->MainFrame);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void on_resized (GtkWidget *window, GdkEventConfigure *event, dictionary *widgetsD){
|
|
actionWidgets *widgets=(actionWidgets*)widgetsD->data;
|
|
int x,y;
|
|
|
|
gtk_window_get_size(GTK_WINDOW(window),&main_config.windowWidth,&main_config.windowHeight);
|
|
if (main_config.windowWidth<1240){
|
|
if (stld==0){
|
|
stld=1;
|
|
main_config.WindowTheme=0;
|
|
|
|
gtk_window_set_resizable(GTK_WINDOW(window),0);
|
|
gtk_window_get_position(GTK_WINDOW(window),&main_config.windowPosX,&main_config.windowPosY);
|
|
gtk_window_get_size(GTK_WINDOW(window),&main_config.windowWidth,&main_config.windowHeight);
|
|
yon_switch_theme(&widgetsD,yon_dictionary_find(&widgetsD,"Main"));
|
|
*main_config.currentThemeIconSize=24;
|
|
|
|
for (dictionary *dict=widgets->ICSys->first;dict!=NULL;dict=dict->next){
|
|
IVGraphicals *IV=(IVGraphicals*)dict->data;
|
|
load_apps_with_clear(IV,widgets->applist,widgets->appssize);
|
|
}
|
|
gtk_window_resize(GTK_WINDOW(widgets->window),main_config.windowWidth,main_config.windowHeight);
|
|
gtk_widget_hide(widgets->window);
|
|
}
|
|
}else {
|
|
yon_segments_hide(widgets);
|
|
yon_segments_show(widgets);
|
|
if (stld==1){
|
|
stld=0;
|
|
cmld=0;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void on_resized_done (GtkWidget *window, GdkEvent *event, dictionary *widgetsD){
|
|
actionWidgets *widgets=(actionWidgets*)widgetsD->data;
|
|
if (event->type==GDK_CONFIGURE){
|
|
if (stld==1){
|
|
gtk_window_set_resizable(GTK_WINDOW(window),1);
|
|
}
|
|
}
|
|
}
|
|
|
|
void on_about_system(GtkWidget *button, actionWidgets *widgets){
|
|
char arg[100];
|
|
memset(arg,0,100);
|
|
sprintf(arg,"--socket-id=%d --socket-ext-id=%d",gtk_socket_get_id(GTK_SOCKET(widgets->socket)),gtk_socket_get_id(GTK_SOCKET(widgets->socketbutton)));
|
|
launch_app_with_arguments("ubl-settings-info",arg);
|
|
}
|
|
|
|
void launch(char *command){
|
|
system(command);
|
|
}
|
|
|
|
void launch_app_with_arguments(char *name, char *args){
|
|
char *path=yon_char_get_augumented("/bin/",name);
|
|
path=yon_char_get_augumented(path," ");
|
|
path=yon_char_get_augumented(path,args);
|
|
pthread_t thread_id;
|
|
pthread_create(&thread_id, NULL, (void*)launch, path);
|
|
};
|
|
|
|
void launch_app(char *name){
|
|
char *path=name;
|
|
pthread_t thread_id;
|
|
pthread_create(&thread_id, NULL, (void*)launch, path);
|
|
};
|
|
|
|
void py_launch_app(char *name,char *args){
|
|
char *path=malloc(strlen("python ./")+strlen(name)+6+strlen(args));
|
|
sprintf(path,"python ./%s.py %s &",name,args);
|
|
pthread_t thread_id;
|
|
pthread_create(&thread_id, NULL, (void*)launch, path);
|
|
};
|
|
|
|
apps *get_app_by_name(apps *applist,char *name, int size){
|
|
for (int i=0;i<size;i++){
|
|
if (strcmp(applist[i].Name,name)==0) return &applist[i];
|
|
}
|
|
return NULL;
|
|
};
|
|
|
|
int reload_list(IVGraphicals *section){
|
|
gtk_icon_view_set_model(GTK_ICON_VIEW(section->IV),GTK_TREE_MODEL(section->LV));
|
|
}
|
|
|
|
int load_apps(IVGraphicals *section, apps *applist, int size){
|
|
int catstofind=sizeof(section->categories)/sizeof(char*);
|
|
int i=0,sz=0;
|
|
dictionary *times=yon_dictionary_create_empty();
|
|
for (int i=0;i<size;i++){
|
|
if (check_categories(applist[i],section->categories)==1){
|
|
GError *err=NULL;
|
|
char *path=malloc(strlen(IconPicturesPath)+strlen(applist[i].Icon)+7);
|
|
memset(path,0,strlen(IconPicturesPath)+strlen(applist[i].Icon)+7);
|
|
memcpy(path,IconPicturesPath,strlen(IconPicturesPath));
|
|
path=yon_char_get_augumented(path,applist[i].Icon);
|
|
path=yon_char_get_augumented(path,PictureFormatMain);
|
|
GdkPixbuf *pixbuf;
|
|
pixbuf=gdk_pixbuf_new_from_file_at_size(path,*main_config.currentThemeIconSize,*main_config.currentThemeIconSize,NULL);
|
|
if (!pixbuf) {
|
|
pixbuf=gdk_pixbuf_new_from_file_at_size(ErrIconPicturePath,*main_config.currentThemeIconSize,*main_config.currentThemeIconSize,NULL);
|
|
};
|
|
GtkTreeIter iter;
|
|
gtk_list_store_append(section->LV,&iter);
|
|
GtkTreePath *pth = gtk_tree_model_get_path(GTK_TREE_MODEL(section->LV),&iter);
|
|
gtk_list_store_set(section->LV,&iter,0,pixbuf,1,applist[i].Name,2,0.0,3,0.5,-1);
|
|
yon_time_reg_for_average(times,sz++,clock());
|
|
}
|
|
|
|
}
|
|
printf("среднее время на каждую проверку: %f\n",yon_time_average(times)/1000);
|
|
gtk_icon_view_set_model(GTK_ICON_VIEW(section->IV),GTK_TREE_MODEL(section->LV));
|
|
};
|
|
|
|
int load_apps_with_clear(IVGraphicals *section, apps *applist, int size){
|
|
gtk_list_store_clear(section->LV);
|
|
load_apps(section,applist,size);
|
|
};
|
|
|
|
int hide_if_unfound(dictionary *widgetsD){
|
|
for (dictionary *widgetsDc=widgetsD->first;widgetsDc!=NULL;widgetsDc=widgetsDc->next){
|
|
actionWidgets *widgets=(actionWidgets*)widgetsDc->data;
|
|
for (dictionary *icvd=widgets->ICSys->first;icvd!=NULL;icvd=icvd->next){
|
|
IVGraphicals *icv=icvd->data;
|
|
GtkTreeIter iter;
|
|
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(icv->LV),&iter)==0){
|
|
gtk_widget_hide(icv->Box);
|
|
gtk_widget_hide(GTK_WIDGET(icv->sep));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
GtkWidget *create_socket(actionWidgets *builder){
|
|
GtkWidget *socket;
|
|
socket = gtk_socket_new();
|
|
GtkWidget *socketbutton=gtk_socket_new();
|
|
GtkWidget *ThirdSocket=gtk_socket_new();
|
|
g_signal_connect(G_OBJECT(socket),"plug-added",G_CALLBACK(on_plug_added),builder);
|
|
g_signal_connect(G_OBJECT(socket),"plug-removed",G_CALLBACK(on_plug_removed),builder);
|
|
g_signal_connect(G_OBJECT(socket),"destroy",G_CALLBACK(on_plug_removed),builder);
|
|
gtk_box_pack_start(GTK_BOX(builder->socketplace),socket,true,true,0);
|
|
gtk_box_pack_start(GTK_BOX(builder->socketbuttonplace),socketbutton,1,1,0);
|
|
builder->socketbutton=socketbutton;
|
|
gtk_box_pack_start(GTK_BOX(builder->ThirdSocketPlace),ThirdSocket,1,1,0);
|
|
builder->ThirdSocket=ThirdSocket;
|
|
return socket;
|
|
};
|
|
|
|
void sort_apps(apps *applist,int size){
|
|
apps tmp;
|
|
if (size>2)
|
|
{
|
|
for (int i=1;i<size;i++)
|
|
{
|
|
for (int j=1;j<size;j++)
|
|
{
|
|
if (strcmp(applist[j].Name,applist[j-1].Name)<0){
|
|
tmp=applist[j];
|
|
applist[j]=applist[j-1];
|
|
applist[j-1]=tmp;
|
|
};
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|
|
apps *find_apps(int *sizef){
|
|
int size=0;
|
|
struct apps *applist;
|
|
{
|
|
DIR *directory=opendir(DesktopPath);
|
|
struct dirent *de;
|
|
while ((de = readdir(directory)))
|
|
{
|
|
FILE *file;
|
|
char *path=yon_char_get_augumented(DesktopPath,de->d_name);
|
|
file=fopen(path,"r");
|
|
//printf("%s\n",path);
|
|
if (strlen(de->d_name)>9)
|
|
{
|
|
char *extension=strstr(path,".");
|
|
if (extension!=NULL)
|
|
{
|
|
if (strcmp(extension,".desktop")==0)
|
|
{
|
|
apps tempapp;
|
|
GKeyFile *gfile=g_key_file_new();
|
|
g_key_file_load_from_file(gfile,path,G_KEY_FILE_KEEP_TRANSLATIONS,NULL);
|
|
char *Type=g_key_file_get_string(gfile,"Desktop Entry", "Type",NULL);
|
|
if (strcmp(Type,"Application")==0) tempapp.Type=1; else if (strcmp(Type,"pyApplication")==0) tempapp.Type=2; else continue;
|
|
tempapp.Name=g_key_file_get_locale_string(gfile,"Desktop Entry","Name",setlocale(LC_ALL,NULL),NULL);
|
|
if (tempapp.Name==NULL) continue;
|
|
tempapp.Categories=g_key_file_get_string(gfile,"Desktop Entry", "Categories",NULL);
|
|
if (tempapp.Categories==NULL) continue;
|
|
tempapp.Exec=g_key_file_get_string(gfile,"Desktop Entry", "Exec",NULL);
|
|
if (tempapp.Exec==NULL) continue;
|
|
tempapp.Icon=g_key_file_get_string(gfile,"Desktop Entry", "Icon",NULL);
|
|
if (tempapp.Icon==NULL) continue;
|
|
tempapp.Pluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "Pluggable",NULL);
|
|
if (!tempapp.Pluggable) tempapp.Pluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "X-XfcePluggable",NULL);
|
|
if (tempapp.Pluggable) tempapp.DualPluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "X-UBLPluggable",NULL);
|
|
if (size==0){
|
|
applist=(apps*)malloc(size+1*sizeof(apps));
|
|
applist[0].Name=yon_char_new(tempapp.Name);
|
|
applist[0].Categories=yon_char_new(tempapp.Categories);
|
|
applist[0].Exec=yon_char_new(tempapp.Exec);
|
|
applist[0].Icon=yon_char_new(tempapp.Icon);
|
|
applist[0].Type=tempapp.Type;
|
|
applist[0].Pluggable=tempapp.Pluggable;
|
|
applist[0].DualPluggable=tempapp.DualPluggable;
|
|
size++;
|
|
} else {
|
|
applist=(apps*)realloc(applist,(size+1)*sizeof(apps));
|
|
applist[size].Name=yon_char_new(tempapp.Name);
|
|
applist[size].Categories=yon_char_new(tempapp.Categories);
|
|
applist[size].Exec=yon_char_new(tempapp.Exec);
|
|
applist[size].Icon=yon_char_new(tempapp.Icon);
|
|
applist[size].Pluggable=tempapp.Pluggable;
|
|
applist[size].DualPluggable=tempapp.DualPluggable;
|
|
applist[size].Type=tempapp.Type;
|
|
size++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
*sizef=size;
|
|
return applist;
|
|
};
|
|
|
|
int check_categories(apps app, char *catstocheck){
|
|
if (!catstocheck || strcmp(catstocheck,"")==0||strcmp(catstocheck,";")==0){
|
|
char *found=strstr(app.Categories,"X-UBL-SettingsManager");
|
|
char *perfound=strstr(app.Categories,"X-UBL-PersonalSettings");
|
|
char *harfound=strstr(app.Categories,"X-UBL-HardwareSettings");
|
|
char *sysfound=strstr(app.Categories,"X-UBL-SystemSettings");
|
|
if (found!=NULL&&(perfound==NULL&&harfound==NULL&&sysfound==NULL)) return 1;
|
|
else if (found==NULL)return 0;
|
|
} else
|
|
{
|
|
char *left_cats=catstocheck;
|
|
char *cat=strstr(left_cats,";");
|
|
if (!cat) return 0;
|
|
char *find_it=yon_cut(left_cats,(strlen(left_cats)-strlen(cat)),0);
|
|
char *found=strstr(app.Categories,find_it);
|
|
int to_find=0, n_found=0;
|
|
to_find++;
|
|
if (!found) return 0;
|
|
n_found++;
|
|
while (cat){
|
|
char *fcat=strstr(app.Categories,";");
|
|
cat=strstr(cat+1,";");
|
|
if (!cat) break;
|
|
find_it=yon_cut(left_cats,(strlen(left_cats)-strlen(cat)),0);
|
|
char *found=strstr(app.Categories,find_it);
|
|
to_find++;
|
|
if (!found) break;
|
|
n_found++;
|
|
left_cats=cat+1;
|
|
if (strlen(left_cats)==0 ||strcmp(left_cats,'\0')==0) break;
|
|
}
|
|
if (to_find==n_found) return 1; else return 0;
|
|
}
|
|
};
|
|
|
|
int setup_config(){
|
|
FILE *file;
|
|
GError *err=NULL;
|
|
main_config.sections=malloc(sizeof(dictionary));
|
|
main_config.sections->data=NULL;
|
|
main_config.sections->next=NULL;
|
|
main_config.sections->prev=NULL;
|
|
main_config.sections->first=NULL;
|
|
GKeyFile *configfile = g_key_file_new();
|
|
char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
|
|
sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
|
|
g_key_file_load_from_file(configfile,pth,G_KEY_FILE_KEEP_TRANSLATIONS,&err);
|
|
if (err){
|
|
g_error_free(err);
|
|
err=NULL;
|
|
g_key_file_load_from_file(configfile,GlobalConfigPath,G_KEY_FILE_KEEP_TRANSLATIONS,&err);
|
|
if (err){
|
|
g_error_free(err);
|
|
return 0;
|
|
}
|
|
}
|
|
char *foroutput=NULL;
|
|
char *line=NULL;
|
|
main_config.windowPosX=g_key_file_get_integer(configfile,"window","WindowPosX",NULL);
|
|
main_config.windowPosY=g_key_file_get_integer(configfile,"window","WindowPosY",NULL);
|
|
main_config.windowWidth=g_key_file_get_integer(configfile,"window","WindowWidth",NULL);
|
|
main_config.windowHeight=g_key_file_get_integer(configfile,"window","WindowHeight",NULL);
|
|
main_config.WindowTheme=g_key_file_get_integer(configfile,"window","WindowTheme",NULL);
|
|
main_config.Mainiconsize=g_key_file_get_integer(configfile,"window","MainIconSize",NULL);
|
|
main_config.Gnomeiconsize=g_key_file_get_integer(configfile,"window","GnomeIconSize",NULL);
|
|
main_config.iconSegmentSize=g_key_file_get_integer(configfile,"window","IconSegmentSize",NULL);
|
|
main_config.MainlabelSize=g_key_file_get_integer(configfile,"window","MainLabelSize",NULL);
|
|
main_config.GnomelabelSize=g_key_file_get_integer(configfile,"window","GnomeLabelSize",NULL);
|
|
main_config.labelDensity=g_key_file_get_integer(configfile,"window","LabelDensity",NULL);
|
|
main_config.lastUser=g_key_file_get_string(configfile,"window","User",NULL);
|
|
if (main_config.MainlabelSize==0) main_config.MainlabelSize=12;
|
|
if (main_config.labelDensity==0) main_config.labelDensity=0;
|
|
main_config.MainlabelSize=main_config.MainlabelSize*1000;
|
|
if (main_config.GnomelabelSize==0) main_config.GnomelabelSize=12;
|
|
main_config.GnomelabelSize=main_config.GnomelabelSize*1000;
|
|
|
|
if (main_config.WindowTheme==0){
|
|
main_config.currentThemeLabelSize=&main_config.MainlabelSize;
|
|
main_config.currentThemeIconSize=&main_config.Mainiconsize;
|
|
} else if (main_config.WindowTheme==1){
|
|
main_config.currentThemeLabelSize=&main_config.GnomelabelSize;
|
|
main_config.currentThemeIconSize=&main_config.Gnomeiconsize;
|
|
}
|
|
|
|
yon_icon_size_convert(0);
|
|
gsize length=0;
|
|
char **a=g_key_file_get_keys(configfile,"sections",&length,NULL);
|
|
|
|
if (!a){yon_set_default_sections(&main_config.sections);} else {
|
|
for (int i=0;i<length;i++){
|
|
char *cats=g_key_file_get_string(configfile,"sections",a[i],NULL);
|
|
main_config.sections=yon_section_new(main_config.sections,a[i], cats);
|
|
}
|
|
main_config.sections->next=NULL;
|
|
}
|
|
|
|
if (main_config.windowWidth<1024&&main_config.windowHeight<720){
|
|
main_config.WindowTheme=0;
|
|
}
|
|
return 1;
|
|
};
|
|
|
|
char *yon_cut(char *source, int size, int startpos){
|
|
char *cut=NULL;
|
|
cut=malloc(size+1);
|
|
memset(cut,0,size+1);
|
|
memcpy(cut,source+startpos,size);
|
|
return cut;
|
|
}
|
|
|
|
char *yon_char_divide(char *source, int dividepos){
|
|
char *cut=malloc(dividepos+1);
|
|
memset(cut,0,dividepos+1);
|
|
memcpy(cut,source,dividepos);
|
|
char *left=malloc(strlen(source)-strlen(cut));
|
|
memset(left,0,strlen(source)-strlen(cut));
|
|
memcpy(left,source+dividepos+1,(strlen(source)-dividepos));
|
|
memset(source,0,strlen(source));
|
|
memcpy(source,left,strlen(left));
|
|
return cut;
|
|
}
|
|
|
|
char *yon_char_divide_search(char *source, char* dividepos, int delete_divider){
|
|
char *cut=strstr(source,dividepos);
|
|
int leng=strlen(source)-strlen(cut);
|
|
cut=yon_char_divide(source,leng);
|
|
return cut;
|
|
}
|
|
|
|
void yon_set_default_sections(dictionary **section){
|
|
*section=malloc(sizeof(dictionary));
|
|
IconSection *sec=malloc(sizeof(IconSection));
|
|
sec->section="Personal";
|
|
sec->categories="X-UBL-SettingsManager;X-UBL-PersonalSettings;";
|
|
(*section)->data=sec;
|
|
(*section)->first=*section;
|
|
(*section)->next=malloc(sizeof(dictionary));
|
|
(*section)->next->prev=*section;
|
|
(*section)->next->first=(*section)->first;
|
|
*section=(*section)->next;
|
|
sec=malloc(sizeof(IconSection));
|
|
sec->section="Hardware";
|
|
sec->categories="X-UBL-SettingsManager;X-UBL-HardwareSettings;";
|
|
(*section)->data=sec;
|
|
(*section)->next=malloc(sizeof(dictionary));
|
|
(*section)->next->prev=*section;
|
|
(*section)->next->first=(*section)->first;
|
|
*section=(*section)->next;
|
|
sec=malloc(sizeof(IconSection));
|
|
sec->section="System";
|
|
sec->categories="X-UBL-SettingsManager;X-UBL-SystemSettings;";
|
|
(*section)->data=sec;
|
|
(*section)->next=malloc(sizeof(dictionary));
|
|
(*section)->next->prev=*section;
|
|
(*section)->next->first=(*section)->first;
|
|
*section=(*section)->next;
|
|
sec=malloc(sizeof(IconSection));
|
|
sec->section="Misc";
|
|
sec->categories="X-UBL-SettingsManager;";
|
|
(*section)->data=sec;
|
|
*section=(*section)->first;
|
|
}
|
|
|
|
IVGraphicals *yon_create_single_section_IV(char *name,char *cats){
|
|
IVGraphicals *IVG=malloc(sizeof(IVGraphicals));
|
|
GtkWidget *box=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
|
GtkBuilder *builder=gtk_builder_new_from_file(GladePath);
|
|
GtkWidget *iv=GTK_WIDGET(gtk_builder_get_object(builder,"iconTemplate"));
|
|
GtkWidget *label=gtk_label_new(_(name));
|
|
PangoAttrList *attrs=pango_attr_list_new();
|
|
PangoFontDescription *descr=pango_font_description_new();
|
|
pango_font_description_set_weight(descr,PANGO_WEIGHT_BOLD);
|
|
int stretch = main_config.labelDensity;
|
|
if (stretch>8)
|
|
stretch = 4;
|
|
pango_font_description_set_stretch(descr,main_config.labelDensity);
|
|
pango_attr_list_insert(attrs,pango_attr_size_new(*main_config.currentThemeLabelSize));
|
|
pango_attr_list_insert(attrs, pango_attr_font_desc_new(descr));
|
|
gtk_label_set_attributes(GTK_LABEL(label),attrs);
|
|
gtk_widget_set_margin_end(label,6);
|
|
gtk_widget_set_margin_start(label,6);
|
|
gtk_widget_set_margin_bottom(label,2);
|
|
if (main_config.WindowTheme==1) {
|
|
gtk_icon_view_set_columns(GTK_ICON_VIEW(iv),1);
|
|
gtk_widget_set_name(iv,"GnomeIcon");
|
|
gtk_icon_view_set_activate_on_single_click(GTK_ICON_VIEW(iv),1);
|
|
gtk_icon_view_set_item_orientation(GTK_ICON_VIEW(iv),GTK_ORIENTATION_HORIZONTAL);
|
|
} else {
|
|
gtk_widget_set_name(iv,"Icon");
|
|
gtk_icon_view_set_item_orientation(GTK_ICON_VIEW(iv),GTK_ORIENTATION_HORIZONTAL);
|
|
}
|
|
|
|
GtkWidget *sep=gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
|
|
GtkListStore *lv=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststoreTemplate"));
|
|
gtk_widget_set_halign(box,0);
|
|
gtk_widget_set_valign(box,1);
|
|
gtk_widget_set_margin_end(sep,6);
|
|
gtk_widget_set_margin_start(sep,6);
|
|
gtk_icon_view_set_model(GTK_ICON_VIEW(iv),GTK_TREE_MODEL(lv));
|
|
gtk_label_set_xalign(GTK_LABEL(label),0);
|
|
gtk_box_pack_start(GTK_BOX(box),label,FALSE,FALSE,0);
|
|
gtk_box_pack_start(GTK_BOX(box),sep,FALSE,FALSE,0);
|
|
gtk_box_pack_start(GTK_BOX(box),iv,FALSE,FALSE,0);
|
|
IVG->sectionName=name;
|
|
IVG->categories=cats;
|
|
IVG->LV=lv;
|
|
IVG->Box=box;
|
|
IVG->IV=iv;
|
|
IVG->label=label;
|
|
IVG->sep=sep;
|
|
return IVG;
|
|
}
|
|
|
|
dictionary *yon_create_icon_section_list(dictionary *sections){
|
|
if (!sections)
|
|
return NULL;
|
|
IVGraphicals *IVSections;
|
|
dictionary *IVDict=NULL;
|
|
sections=sections->first;
|
|
while (sections!=NULL){
|
|
IconSection *name=(IconSection*)sections->data;
|
|
IVSections=yon_create_single_section_IV(name->section,name->categories);
|
|
if (!IVDict) {
|
|
IVDict=yon_dictionary_create_empty();
|
|
IVDict->key=name->section;
|
|
IVDict->data=IVSections;
|
|
IVDict->first=IVDict;
|
|
} else {
|
|
IVDict->next=malloc(sizeof(dictionary));
|
|
IVDict->next->prev=IVDict;
|
|
IVDict->next->first=IVDict->first;
|
|
IVDict=IVDict->next;
|
|
IVDict->key=name->section;
|
|
IVDict->data=IVSections;
|
|
}
|
|
sections=sections->next;
|
|
}
|
|
IVDict->next=NULL;
|
|
return IVDict->first;
|
|
}
|
|
|
|
void yon_check_path(char *path){
|
|
FILE *fp;
|
|
char *pth=malloc(255);
|
|
memset(path,0,255);
|
|
fp = popen("screenfetch -n -w -N", "r");
|
|
fgets(pth, 255,fp)!=NULL;
|
|
}
|
|
|
|
dictionary *yon_section_new(dictionary *section, char *section_name, char *categories){
|
|
section->next=NULL;
|
|
IconSection *sct=malloc(sizeof(IconSection));
|
|
dictionary *dict=malloc(sizeof(dictionary));
|
|
sct->section=section_name;
|
|
sct->categories=categories;
|
|
dict->data=sct;
|
|
if (!section->data){
|
|
section->data=dict->data;
|
|
section->first=section;
|
|
section->key=section_name;
|
|
} else {
|
|
dict->first=section->first;
|
|
section->next=dict;
|
|
dict->prev=section;
|
|
dict->key=section_name;
|
|
section=section->next;
|
|
}
|
|
|
|
return section;
|
|
}
|
|
|
|
void yon_icv_resize_item(dictionary *icdict, GtkWidget *paned){
|
|
for (dictionary *dict=icdict->first;dict!=NULL;dict=dict->next){
|
|
IVGraphicals *icv=(IVGraphicals*)dict->data;
|
|
int width=gtk_paned_get_position(GTK_PANED(paned));
|
|
int pos=(int)((double)width-(11/(double)width*4)*500)/1.3;
|
|
if (pos < 115) pos=115;
|
|
|
|
gtk_icon_view_set_item_width(GTK_ICON_VIEW(icv->IV),pos);
|
|
}
|
|
}
|
|
|
|
char *yon_char_get_augumented(char *source, char *append){
|
|
int size=strlen(source)+strlen(append)+1;
|
|
char *final=malloc(size);
|
|
memset(final,0,size);
|
|
sprintf(final,"%s%s",source,append);
|
|
return final;
|
|
}
|
|
|
|
char *yon_char_new(char *chr){
|
|
char *newchar=malloc(strlen(chr)+1);
|
|
memset(newchar,0,strlen(chr)+1);
|
|
memcpy(newchar,chr,strlen(chr));
|
|
return newchar;
|
|
}
|
|
|
|
int yon_show_icon_views(dictionary *IVS,actionWidgets *widgets){
|
|
for (dictionary *dct=IVS->first;dct!=NULL;dct=dct->next){
|
|
IVGraphicals *iv=dct->data;
|
|
gtk_widget_show_all(iv->Box);
|
|
gtk_box_pack_start(GTK_BOX(widgets->icvpack),iv->Box,FALSE,FALSE,0);
|
|
if (main_config.WindowTheme==0)
|
|
g_signal_connect(G_OBJECT(iv->IV),"item-activated",G_CALLBACK(on_Item_activated),widgets);
|
|
else if (main_config.WindowTheme==1)
|
|
g_signal_connect(G_OBJECT(iv->IV),"item-activated",G_CALLBACK(on_gnome_Item_activated),widgets);
|
|
g_signal_connect(G_OBJECT(iv->IV),"selection-changed",G_CALLBACK(on_item_selection_changed),widgets);
|
|
|
|
}
|
|
}
|
|
|
|
dictionary *yon_dictionary_find(dictionary **dict, char *key){
|
|
dictionary *dct=*dict;
|
|
for (dictionary *pointer=dct->first;pointer!=NULL;pointer=pointer->next){
|
|
if (strcmp(pointer->key,key)==0){
|
|
*dict=pointer;
|
|
return pointer;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void yon_switch_theme(dictionary **dict, dictionary *newone){
|
|
dictionary *dct=*dict;
|
|
actionWidgets *widgets=(actionWidgets*)dct->data;
|
|
|
|
gtk_widget_hide(widgets->window);
|
|
*dict=newone;
|
|
dct=*dict;
|
|
widgets=(actionWidgets*)dct->data;
|
|
gtk_window_resize(GTK_WINDOW(widgets->window),main_config.windowWidth,main_config.windowHeight);
|
|
gtk_window_move(GTK_WINDOW(widgets->window),main_config.windowPosX,main_config.windowPosY);
|
|
if (strcmp(dct->key,"Gnome")==0){
|
|
int x,y;
|
|
GdkRectangle workarea;
|
|
gdk_monitor_get_workarea(gdk_display_get_monitor(gdk_screen_get_display(gtk_window_get_screen(GTK_WINDOW(widgets->window))),0),&workarea);
|
|
gtk_window_get_size(GTK_WINDOW(widgets->window),&x, &y);
|
|
if (workarea.width<1240&&workarea.height<720){
|
|
gtk_widget_show(widgets->CautionWindow);
|
|
dictionary *founddict=yon_dictionary_find(dict,"Main");
|
|
dct=yon_dictionary_find(dict,"Gnome");
|
|
yon_switch_theme(&dct,founddict);
|
|
gtk_window_resize(GTK_WINDOW(widgets->window),main_config.windowWidth,main_config.windowHeight);
|
|
gtk_window_move(GTK_WINDOW(widgets->window),main_config.windowPosX,main_config.windowPosY);
|
|
main_config.WindowTheme=0;
|
|
main_config.curThemeName="Main";
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->settingsThemeChooser),0);
|
|
gtk_window_present(GTK_WINDOW(widgets->CautionWindow));
|
|
gtk_widget_show(widgets->MenuItemAboutSystem);
|
|
} else if (x<1240){
|
|
gtk_window_resize(GTK_WINDOW(widgets->window),1245,y);
|
|
main_config.WindowTheme=1;
|
|
main_config.curThemeName="Gnome";
|
|
gtk_widget_show(widgets->window);
|
|
gtk_widget_hide(widgets->MenuItemAboutSystem);
|
|
|
|
}else{
|
|
main_config.WindowTheme=1;
|
|
main_config.curThemeName="Gnome";
|
|
gtk_widget_show(widgets->window);
|
|
gtk_widget_hide(widgets->MenuItemAboutSystem);
|
|
}
|
|
|
|
} else {
|
|
gtk_widget_show(widgets->window);
|
|
main_config.WindowTheme=0;
|
|
main_config.curThemeName="Main";
|
|
gtk_widget_show(widgets->MenuItemAboutSystem);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
void yon_icon_size_convert(int mode){
|
|
if (mode==0){
|
|
if (*main_config.currentThemeIconSize==1) *main_config.currentThemeIconSize=24;
|
|
if (*main_config.currentThemeIconSize==2) *main_config.currentThemeIconSize=32;
|
|
if (*main_config.currentThemeIconSize==3) *main_config.currentThemeIconSize=48;
|
|
if (*main_config.currentThemeIconSize==4) *main_config.currentThemeIconSize=64;
|
|
} else if (mode==1){
|
|
if (*main_config.currentThemeIconSize==24) *main_config.currentThemeIconSize=1;
|
|
if (*main_config.currentThemeIconSize==32) *main_config.currentThemeIconSize=2;
|
|
if (*main_config.currentThemeIconSize==48) *main_config.currentThemeIconSize=3;
|
|
if (*main_config.currentThemeIconSize==64) *main_config.currentThemeIconSize=4;
|
|
}
|
|
}
|
|
|
|
SectionSettingSegment *yon_create_section_setting(char *name, char *categories){
|
|
SectionSettingSegment *segment=malloc(sizeof(SectionSettingSegment));
|
|
segment->MainFrame=gtk_frame_new(NULL);
|
|
gtk_frame_set_shadow_type(GTK_FRAME(segment->MainFrame),GTK_SHADOW_IN);
|
|
segment->MainBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
segment->ElemBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
gtk_widget_set_size_request(segment->ElemBox,0,20);
|
|
segment->DragButtonBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
gtk_widget_set_name(segment->DragButtonBox,"noborders");
|
|
segment->DragUpButton=gtk_button_new_from_icon_name("gtk-goto-top",GTK_ICON_SIZE_BUTTON);
|
|
segment->DragDownButton=gtk_button_new_from_icon_name("gtk-goto-bottom",GTK_ICON_SIZE_BUTTON);
|
|
segment->NameBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
segment->CategoriesBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
segment->OptionBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
segment->NameEntry=gtk_entry_new();
|
|
gtk_entry_set_text(GTK_ENTRY(segment->NameEntry),name);
|
|
segment->NameLabel=gtk_label_new(name);
|
|
segment->CategoriesEntry=gtk_entry_new();
|
|
if (categories[strlen(categories)-1]!=';'){
|
|
char *tmp=malloc(strlen(categories)+1);
|
|
sprintf(tmp,"%s;",categories);
|
|
categories=realloc(tmp,strlen(tmp));
|
|
}
|
|
gtk_entry_set_text(GTK_ENTRY(segment->CategoriesEntry),categories);
|
|
segment->CategoriesLabel=gtk_label_new(categories);
|
|
segment->EditButtonBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
segment->EditButtonAccept=gtk_button_new_from_icon_name("dialog-ok",GTK_ICON_SIZE_BUTTON);
|
|
segment->EditButtonCancel=gtk_button_new_from_icon_name("dialog-no",GTK_ICON_SIZE_BUTTON);
|
|
segment->ButtonEdit=gtk_button_new_from_icon_name("gtk-edit",GTK_ICON_SIZE_BUTTON);
|
|
segment->DeleditBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
segment->ButtonDelete=gtk_button_new_from_icon_name("edit-delete",GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_widget_set_name(segment->NameLabel,"SegName");
|
|
gtk_widget_set_name(segment->CategoriesLabel,"SegCat");
|
|
|
|
gtk_container_add(GTK_CONTAINER(segment->MainFrame),segment->MainBox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->MainBox),segment->DragButtonBox,FALSE,FALSE,0);
|
|
gtk_box_pack_start(GTK_BOX(segment->MainBox),segment->ElemBox,TRUE,TRUE,0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->DragButtonBox),segment->DragUpButton,FALSE,FALSE,0);
|
|
gtk_box_pack_start(GTK_BOX(segment->DragButtonBox),segment->DragDownButton,FALSE,FALSE,0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->ElemBox),segment->NameBox,FALSE,FALSE,0);
|
|
gtk_box_pack_end(GTK_BOX(segment->ElemBox),segment->CategoriesBox,FALSE,FALSE,0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->MainBox),segment->OptionBox,FALSE,FALSE,0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->NameBox),segment->NameEntry,FALSE,FALSE,5);
|
|
gtk_box_pack_start(GTK_BOX(segment->NameBox),segment->NameLabel,FALSE,FALSE,5);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->CategoriesBox),segment->CategoriesEntry,FALSE,FALSE,5);
|
|
gtk_box_pack_start(GTK_BOX(segment->CategoriesBox),segment->CategoriesLabel,FALSE,FALSE,5);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->EditButtonBox),segment->EditButtonAccept,FALSE,FALSE,5);
|
|
gtk_box_pack_start(GTK_BOX(segment->EditButtonBox),segment->EditButtonCancel,FALSE,FALSE,5);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->DeleditBox),segment->ButtonEdit,FALSE,FALSE,5);
|
|
gtk_box_pack_start(GTK_BOX(segment->DeleditBox),segment->ButtonDelete,FALSE,FALSE,5);
|
|
|
|
gtk_box_pack_start(GTK_BOX(segment->OptionBox),segment->DeleditBox,FALSE,FALSE,0);
|
|
gtk_box_pack_start(GTK_BOX(segment->OptionBox),segment->EditButtonBox,FALSE,FALSE,0);
|
|
|
|
gtk_widget_set_size_request(segment->NameLabel,60,10);
|
|
|
|
gtk_widget_set_margin_start(segment->DragButtonBox,5);
|
|
gtk_widget_set_margin_end(segment->OptionBox,5);
|
|
gtk_widget_set_margin_bottom(segment->MainFrame,3);
|
|
gtk_widget_set_margin_bottom(segment->DragButtonBox,3);
|
|
gtk_widget_set_margin_top(segment->DragButtonBox,3);
|
|
gtk_widget_set_margin_end(segment->DragUpButton,3);
|
|
|
|
gtk_widget_set_halign(segment->NameEntry,GTK_ALIGN_START);
|
|
gtk_widget_set_halign(segment->NameLabel,GTK_ALIGN_END);
|
|
|
|
gtk_widget_set_valign(segment->OptionBox,GTK_ALIGN_CENTER);
|
|
gtk_label_set_xalign(GTK_LABEL(segment->NameLabel),0);
|
|
gtk_label_set_xalign(GTK_LABEL(segment->CategoriesLabel),0);
|
|
|
|
gtk_widget_set_vexpand(segment->ElemBox,0);
|
|
gtk_widget_set_vexpand(segment->NameBox,0);
|
|
gtk_widget_set_vexpand(segment->CategoriesBox,0);
|
|
gtk_widget_set_vexpand(segment->NameEntry,0);
|
|
gtk_widget_set_vexpand(segment->NameLabel,0);
|
|
gtk_widget_set_vexpand(segment->CategoriesEntry,0);
|
|
gtk_widget_set_vexpand(segment->CategoriesLabel,0);
|
|
gtk_widget_show_all(segment->MainFrame);
|
|
gtk_widget_hide(segment->NameEntry);
|
|
gtk_widget_hide(segment->CategoriesEntry);
|
|
gtk_widget_hide(segment->EditButtonBox);
|
|
return segment;
|
|
}
|
|
|
|
dictionary *yon_dictionary_create_empty(){
|
|
dictionary *dict=malloc(sizeof(dictionary));
|
|
dict->data=NULL;
|
|
dict->key=NULL;
|
|
dict->next=NULL;
|
|
dict->prev=NULL;
|
|
dict->first=dict;
|
|
return dict;
|
|
}
|
|
|
|
void yon_dictionary_switch_to_last(dictionary **dict){
|
|
if ((*dict)->next!=NULL)
|
|
for ((*dict)=(*dict)->first;(*dict)->next!=NULL;(*dict)=(*dict)->next){}
|
|
}
|
|
|
|
dictionary * yon_dictionary_create_conneced(dictionary *targetdict){
|
|
yon_dictionary_switch_to_last(&targetdict);
|
|
targetdict->next=yon_dictionary_create_empty();
|
|
targetdict->next->prev=targetdict;
|
|
targetdict->next->first=targetdict->first;
|
|
return targetdict->next;
|
|
}
|
|
|
|
void yon_segment_show(actionWidgets *widgets, SectionSettingSegment *sgm){
|
|
gtk_box_pack_start(GTK_BOX(widgets->SectionSettingsPack),sgm->MainFrame,FALSE,FALSE,5);
|
|
g_signal_connect(G_OBJECT(sgm->ButtonEdit),"clicked",G_CALLBACK(on_sections_edit), widgets);
|
|
g_signal_connect(G_OBJECT(sgm->EditButtonAccept),"clicked",G_CALLBACK(on_sections_accept), widgets);
|
|
g_signal_connect(G_OBJECT(sgm->EditButtonCancel),"clicked",G_CALLBACK(on_sections_cancel), widgets);
|
|
g_signal_connect(G_OBJECT(sgm->DragUpButton),"clicked",G_CALLBACK(on_sections_move_up), widgets);
|
|
g_signal_connect(G_OBJECT(sgm->DragDownButton),"clicked",G_CALLBACK(on_sections_move_down), widgets);
|
|
g_signal_connect(G_OBJECT(sgm->ButtonDelete),"clicked",G_CALLBACK(on_section_delete), widgets);
|
|
|
|
}
|
|
|
|
void yon_segments_show(actionWidgets *widgets){
|
|
if(widgets->SettingsSections)
|
|
for (dictionary *dict=widgets->SettingsSections->first;dict!=NULL;dict=dict->next){
|
|
SectionSettingSegment *sgm=(SectionSettingSegment*)dict->data;
|
|
if (sgm!=NULL)
|
|
|
|
gtk_box_pack_start(GTK_BOX(widgets->SectionSettingsPack),sgm->MainFrame,FALSE,FALSE,5);
|
|
else return;
|
|
}
|
|
};
|
|
|
|
void yon_segments_hide(actionWidgets *widgets){
|
|
if(widgets->SettingsSections)
|
|
for (dictionary *dict=widgets->SettingsSections->first;dict!=NULL;dict=dict->next){
|
|
SectionSettingSegment *sgm=(SectionSettingSegment*)dict->data;
|
|
if (sgm!=NULL){
|
|
g_object_ref(G_OBJECT(sgm->MainFrame));
|
|
gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),sgm->MainFrame);
|
|
} else return;
|
|
}
|
|
}
|
|
|
|
void yon_dictionary_make_first(dictionary *dict){
|
|
for (dictionary *dct=dict->first;dct!=NULL;dct=dct->next){
|
|
dct->first=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;
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
void yon_small_window_theme_change(actionWidgets *widgets){
|
|
}
|
|
|
|
dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *theme_id, apps *applist, int appsize){
|
|
|
|
dictionary *widgets=*widgetss;
|
|
actionWidgets *curWidgets=(actionWidgets*)widgets->data;
|
|
if (curWidgets==NULL) {
|
|
curWidgets=malloc(sizeof(actionWidgets));
|
|
widgets->data=curWidgets;
|
|
}
|
|
widgets->key=theme_id;
|
|
curWidgets->builder=builder;
|
|
curWidgets->window=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"Window")));
|
|
curWidgets->DesktopBasic=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"HideWhileLaunch")));
|
|
curWidgets->DesktopSocket=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"socketplace")));
|
|
curWidgets->ButtonBackToMain=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"backToSettingsButton")));
|
|
curWidgets->appSettings=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"appSettings")));
|
|
curWidgets->socketplace=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"socketplace")));
|
|
curWidgets->HideWhileLaunch=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"HideWhileLaunch")));
|
|
curWidgets->workingwindow=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"workingwindow")));
|
|
curWidgets->icvpack=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"icvpack")));
|
|
curWidgets->GnomePaned=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"Paned")));
|
|
curWidgets->GnomeInfoLabel=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"InfoLabel")));
|
|
curWidgets->GnomeInfoDetailsLabel=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"InfoDetailsLabel")));
|
|
curWidgets->socketbuttonplace=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"socketbuttonplace")));
|
|
curWidgets->Overlay=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"Overlay")));
|
|
curWidgets->ThirdSocketPlace=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,yon_char_get_augumented(theme_id,"ThirdSocketPlace")));
|
|
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;
|
|
|
|
gtk_style_context_add_class(gtk_widget_get_style_context(curWidgets->icvpack),"iconview");
|
|
curWidgets->socket=GTK_WIDGET(create_socket(curWidgets));
|
|
g_signal_connect(G_OBJECT(curWidgets->MenuItemAboutSystem), "activate", G_CALLBACK(on_about_system),curWidgets);
|
|
if (curWidgets->ButtonBackToMain!=NULL)
|
|
gtk_button_set_label(GTK_BUTTON(curWidgets->ButtonBackToMain),_("Back to settings"));
|
|
gtk_window_set_title(GTK_WINDOW(curWidgets->window),"UBLinux Settings Manager");
|
|
g_signal_connect(G_OBJECT(curWidgets->window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
|
if (curWidgets->GnomePaned!=NULL){
|
|
gtk_paned_set_position(GTK_PANED(curWidgets->GnomePaned),main_config.iconSegmentSize);
|
|
g_signal_connect(G_OBJECT(curWidgets->GnomePaned), "notify::position", G_CALLBACK(on_paned_move), curWidgets);
|
|
|
|
}
|
|
if (strcmp(theme_id,"Gnome")==0){
|
|
on_about_system(NULL,curWidgets);
|
|
g_signal_connect(G_OBJECT(curWidgets->window), "configure-event", G_CALLBACK(on_resized), widgets);
|
|
g_signal_connect(G_OBJECT(curWidgets->window), "event-after", G_CALLBACK(on_resized_done), widgets);
|
|
|
|
}
|
|
if (curWidgets->ButtonBackToMain!=NULL)
|
|
g_signal_connect(G_OBJECT(curWidgets->ButtonBackToMain), "clicked", G_CALLBACK(on_backToSettingsButton_clicked), curWidgets);
|
|
curWidgets->LabelTitle=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"LabelTitle"));
|
|
gtk_window_set_title(GTK_WINDOW(curWidgets->window),"UBLinux Settings Manager GNOME");
|
|
|
|
// Standard for all themes
|
|
|
|
curWidgets->settingsThemeChooser=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsThemeChooser"));
|
|
curWidgets->SettingsWindow=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SettingsWindow"));
|
|
curWidgets->DialogOpenDocumentation=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"HelpSureWindow"));
|
|
curWidgets->CancelHelpButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"CancelHelpButton"));
|
|
curWidgets->ReadHelpButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"ReadHelpButton"));
|
|
curWidgets->AlwaysOpenDocumentation=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"AlwaysOpenHelpCheckbox"));
|
|
curWidgets->helpHeader=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"helpHeader"));
|
|
curWidgets->helpText=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"helpText"));
|
|
curWidgets->settingsSizeInfoLabel=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSizeInfoLabel"));
|
|
curWidgets->settingsIcon=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsIcon"));
|
|
curWidgets->SectionSettingsWindow=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsWindow"));
|
|
curWidgets->SectionSettingsPack=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsPack"));
|
|
curWidgets->settingsSizeSlider=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSizeSlider"));
|
|
curWidgets->settingsAccept=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsAccept"));
|
|
curWidgets->settingsCancel=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsCancel"));
|
|
curWidgets->settingsSubmenuLabelSize=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSubmenuLabelSize"));
|
|
curWidgets->settingsSubmenuLabelTheme=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"settingsSubmenuLabelTheme"));
|
|
curWidgets->SectionSettingAddButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsAddButton"));
|
|
curWidgets->SectionSettingAddNameEntry=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsAddNameEntry"));
|
|
curWidgets->SectionSettingAddCategoriesEntry=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsAddCategoriesEntry"));
|
|
curWidgets->SectionSettingsClearEntryButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsClearEntryButton"));
|
|
curWidgets->SectionSettingsSaveButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsSaveButton"));
|
|
curWidgets->SectionSettingsCloseButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"SectionSettingsCloseButton"));
|
|
curWidgets->CautionWindow=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"CautionWindow"));
|
|
curWidgets->CautionUnderstandButton=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"CautionUnderstandButton"));
|
|
curWidgets->applist=applist;
|
|
curWidgets->appssize=appsize;
|
|
|
|
gtk_widget_set_size_request(curWidgets->window,800,600);
|
|
gtk_window_resize(GTK_WINDOW(curWidgets->window),main_config.windowWidth,main_config.windowHeight);
|
|
gtk_window_set_icon_from_file(GTK_WINDOW(curWidgets->window),AppIconPath,NULL);
|
|
gtk_window_set_icon_from_file(GTK_WINDOW(curWidgets->SectionSettingsWindow),AppIconPath,NULL);
|
|
g_signal_connect(G_OBJECT(curWidgets->MenuItemDocumentation), "activate", G_CALLBACK(on_ButtonOpenHelp_activated), curWidgets->builder);
|
|
g_signal_connect(G_OBJECT(curWidgets->MenuItemSettings), "activate", G_CALLBACK(on_settingsOpen), curWidgets);
|
|
|
|
if (gnld==0){
|
|
gnld=1;
|
|
|
|
g_signal_connect(G_OBJECT(curWidgets->CancelHelpButton), "clicked", G_CALLBACK(on_CancelHelpButton_activated), curWidgets->builder);
|
|
g_signal_connect(G_OBJECT(curWidgets->ReadHelpButton), "clicked", G_CALLBACK(on_ReadHelpButton_activated), curWidgets->builder);
|
|
|
|
g_signal_connect(G_OBJECT(curWidgets->settingsSizeSlider), "value-changed", G_CALLBACK(on_settings_icon_size_changed), curWidgets);
|
|
g_signal_connect(G_OBJECT(curWidgets->settingsCancel), "clicked", G_CALLBACK(on_settings_cancel), curWidgets);
|
|
g_signal_connect(G_OBJECT(curWidgets->settingsAccept), "clicked", G_CALLBACK(on_settings_accept), widgetss);
|
|
g_signal_connect(G_OBJECT(curWidgets->SectionSettingAddButton), "clicked", G_CALLBACK(on_sections_add), curWidgets);
|
|
g_signal_connect(G_OBJECT(curWidgets->SectionSettingsClearEntryButton), "clicked", G_CALLBACK(on_sections_new_clear), curWidgets);
|
|
g_signal_connect(G_OBJECT(curWidgets->SectionSettingsCloseButton), "clicked", G_CALLBACK(on_sections_close), curWidgets);
|
|
g_signal_connect(G_OBJECT(curWidgets->SectionSettingsSaveButton), "clicked", G_CALLBACK(on_sections_save), curWidgets);
|
|
g_signal_connect(G_OBJECT(curWidgets->CautionUnderstandButton), "clicked", G_CALLBACK(on_caution_understand), curWidgets);
|
|
}
|
|
gtk_label_set_text(GTK_LABEL(curWidgets->LabelTitle),_("UBLinux Settings Manager"));
|
|
gtk_label_set_text(GTK_LABEL(curWidgets->settingsSubmenuLabelSize),_("Icon size"));
|
|
gtk_label_set_text(GTK_LABEL(curWidgets->settingsSubmenuLabelTheme),_("Window theme"));
|
|
gtk_label_set_text(GTK_LABEL(curWidgets->helpHeader),_("Would you like to read documentation in the Web?"));
|
|
gtk_label_set_text(GTK_LABEL(curWidgets->helpText),_("You will be redirected to documentation site, where user help pages are translated and supported by community."));
|
|
gtk_button_set_label(GTK_BUTTON(curWidgets->ReadHelpButton),_("Read online"));
|
|
gtk_button_set_label(GTK_BUTTON(curWidgets->CancelHelpButton),_("Cancel"));
|
|
gtk_button_set_label(GTK_BUTTON(curWidgets->settingsCancel),_("Close"));
|
|
gtk_button_set_label(GTK_BUTTON(curWidgets->settingsAccept),_("Save and apply"));
|
|
gtk_button_set_label(GTK_BUTTON(curWidgets->AlwaysOpenDocumentation),_("Always redirect"));
|
|
gtk_menu_item_set_label(GTK_MENU_ITEM(curWidgets->MenuItemSettings),_("Settings"));
|
|
gtk_menu_item_set_label(GTK_MENU_ITEM(curWidgets->MenuItemDocumentation),_("About..."));
|
|
gtk_menu_item_set_label(GTK_MENU_ITEM(curWidgets->MenuItemAboutSystem),_("About system"));
|
|
gtk_button_set_label(GTK_BUTTON(curWidgets->CautionUnderstandButton),_("Understood"));
|
|
return widgets;
|
|
}
|
|
|
|
int main(int argc, char *argv[]){
|
|
gtk_init(&argc, &argv);
|
|
if (setup_config()==0){
|
|
printf("Ошибка загрузки конфига!\n");
|
|
return -1;
|
|
}
|
|
local=setlocale(LC_ALL, "");
|
|
textdomain (LocaleName);
|
|
actionWidgets *widget=malloc(sizeof(actionWidgets));
|
|
dictionary *widgets=yon_dictionary_create_empty();
|
|
widgets->data=widget;
|
|
int *size=malloc(sizeof(int));
|
|
apps *applist=find_apps(size);
|
|
sort_apps(applist,*size);
|
|
GtkBuilder *builder=gtk_builder_new_from_file(GladePath);
|
|
actionWidgets *widg=(actionWidgets*)widgets->first->data;
|
|
char *theme;
|
|
if (main_config.WindowTheme==1){ theme="Gnome";
|
|
yon_theme_new(&widgets->first, builder,theme,applist,*size);
|
|
widg->applist=applist;
|
|
widg->appssize=*size;
|
|
widg->ICSys=yon_create_icon_section_list(main_config.sections);
|
|
for (dictionary *cur=widg->ICSys->first; cur!=NULL;cur=cur->next){
|
|
load_apps((IVGraphicals*)cur->data,widg->applist,widg->appssize);
|
|
}
|
|
printf("\n\n");
|
|
yon_show_icon_views(widg->ICSys,widg);
|
|
yon_icv_resize_item(widg->ICSys,widg->GnomePaned);
|
|
theme="Main";
|
|
main_config.WindowTheme=0;
|
|
widgets->next=yon_dictionary_create_empty();
|
|
widgets->next->first=widgets;
|
|
widgets->next->prev=widgets;
|
|
yon_theme_new(&widgets->next, builder,theme,applist,*size);
|
|
widg=(actionWidgets*)widgets->next->data;
|
|
widg->applist=applist;
|
|
widg->appssize=*size;
|
|
widg->ICSys=yon_create_icon_section_list(main_config.sections);
|
|
for (dictionary *cur=widg->ICSys->first; cur!=NULL;cur=cur->next){
|
|
load_apps((IVGraphicals*)cur->data,widg->applist,widg->appssize);
|
|
}
|
|
printf("\n\n");
|
|
yon_show_icon_views(widg->ICSys,widg);
|
|
main_config.WindowTheme=1;
|
|
|
|
}
|
|
else {
|
|
theme="Main";
|
|
yon_theme_new(&widgets->first, builder,theme,applist,*size);
|
|
widg->applist=applist;
|
|
widg->appssize=*size;
|
|
widg->ICSys=yon_create_icon_section_list(main_config.sections);
|
|
for (dictionary *cur=widg->ICSys->first; cur!=NULL;cur=cur->next){
|
|
load_apps((IVGraphicals*)cur->data,widg->applist,widg->appssize);
|
|
}
|
|
printf("\n\n");
|
|
yon_show_icon_views(widg->ICSys,widg);
|
|
theme="Gnome";
|
|
main_config.WindowTheme=1;
|
|
widgets->next=yon_dictionary_create_empty();
|
|
widgets->next->first=widgets;
|
|
widgets->next->prev=widgets;
|
|
yon_theme_new(&widgets->next, builder,theme,applist,*size);
|
|
widg=(actionWidgets*)widgets->next->data;
|
|
widg->applist=applist;
|
|
widg->appssize=*size;
|
|
widg->ICSys=yon_create_icon_section_list(main_config.sections);
|
|
for (dictionary *cur=widg->ICSys->first; cur!=NULL;cur=cur->next){
|
|
load_apps((IVGraphicals*)cur->data,widg->applist,widg->appssize);
|
|
}
|
|
printf("\n\n");
|
|
yon_show_icon_views(widg->ICSys,widg);
|
|
main_config.WindowTheme=0;
|
|
yon_icv_resize_item(widg->ICSys,widg->GnomePaned);
|
|
}
|
|
if (geteuid()==0){
|
|
}
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widg->settingsThemeChooser),NULL,_("Standard theme"));
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widg->settingsThemeChooser),NULL,_("GNOME theme"));
|
|
widg=(actionWidgets*)widgets->data;
|
|
gtk_window_maximize(GTK_WINDOW(widg->window));
|
|
gtk_widget_show(widg->window);
|
|
hide_if_unfound(widgets);
|
|
if (main_config.WindowTheme==1)
|
|
gtk_widget_hide(widg->MenuItemAboutSystem);
|
|
GtkWidget *banner = GTK_WIDGET(gtk_builder_get_object(widg->builder,"MainBanner"));
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(banner),gdk_pixbuf_new_from_file(AppBannerPath,NULL));
|
|
banner = GTK_WIDGET(gtk_builder_get_object(widg->builder,"GnomeBanner"));
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(banner),gdk_pixbuf_new_from_file(AppBannerPath,NULL));
|
|
banner = GTK_WIDGET(gtk_builder_get_object(widg->builder,"loaderBanner"));
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(banner),gdk_pixbuf_new_from_file(AppBannerPath,NULL));
|
|
banner = GTK_WIDGET(gtk_builder_get_object(widg->builder,"GnomeInfoLogo"));
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(banner),gdk_pixbuf_new_from_file_at_scale(LogoPath,512,512,1,NULL));
|
|
banner = GTK_WIDGET(gtk_builder_get_object(widg->builder,"settingsIcon"));
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(banner),gdk_pixbuf_new_from_file_at_scale(AppIconPath,*main_config.currentThemeIconSize,*main_config.currentThemeIconSize,1,NULL));
|
|
GtkCssProvider *css=gtk_css_provider_new();
|
|
gtk_css_provider_load_from_path(css,CssPath,NULL);
|
|
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
|
|
GTK_STYLE_PROVIDER(css),
|
|
-1);
|
|
gtk_main();
|
|
|
|
}
|
|
#endif |