From 609da7ed75381e766f031680a2db073a44699305 Mon Sep 17 00:00:00 2001 From: YanTheKaller Date: Thu, 26 Jan 2023 04:43:57 +0000 Subject: [PATCH] Added localisation for PC characteristics on Gnome theme --- ubl-settings-manager.c | 72 ++++++++++++++++++++++------------- ubl-settings-manager.h | 2 +- ui/ubl-settings-manager.glade | 51 ++++++++++++++++++++----- 3 files changed, 89 insertions(+), 36 deletions(-) diff --git a/ubl-settings-manager.c b/ubl-settings-manager.c index b4903ba..7add2dc 100644 --- a/ubl-settings-manager.c +++ b/ubl-settings-manager.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "ubl-settings-manager.h" @@ -48,10 +49,7 @@ void on_plug_added(GtkSocket* self, actionWidgets *builder){ } void on_plug_removed(GtkSocket* self, actionWidgets *widgets){ - - //gtk_box_pack_start(GTK_BOX(widgets->workingwindow),widgets->HideWhileLaunch,TRUE,TRUE,10); gtk_widget_show(widgets->HideWhileLaunch); - //gtk_widget_hide(widgets->socketplace); gtk_widget_set_vexpand(widgets->socketplace,0); gtk_widget_set_vexpand(widgets->HideWhileLaunch,1); //printf("Plug has been removed!\n\n\n"); @@ -414,7 +412,7 @@ void on_sections_move_up(GtkWidget *button, actionWidgets *widgets){ }; void on_sections_move_down(GtkWidget *button, actionWidgets *widgets){ -for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ + for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ SectionSettingSegment *segment=(SectionSettingSegment*)dct->data; if (segment!=NULL){ if (button==segment->DragDownButton){ @@ -453,7 +451,7 @@ for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ }; void on_sections_delete(GtkWidget *button, actionWidgets *widgets){ -for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ + for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ SectionSettingSegment *segment=(SectionSettingSegment*)dct->data; if (segment!=NULL){ if (button==segment->DragDownButton){ @@ -463,7 +461,7 @@ for (dictionary *dct=widgets->SettingsSections->first;dct!=NULL;dct=dct->next){ gtk_container_remove(GTK_CONTAINER(widgets->SectionSettingsPack),segment->MainFrame); } } -} + } }; void on_sections_add(GtkWidget *button, actionWidgets *widgets){ dictionary *dict=yon_dictionary_create_empty(); @@ -1274,7 +1272,6 @@ void yon_dictionary_make_first(dictionary *dict){ } - dictionary *yon_theme_new(dictionary *widgets, GtkBuilder *builder, char *theme_id, apps *applist, int appsize){ actionWidgets *curWidgets=(actionWidgets*)widgets->data; if (!curWidgets) { @@ -1294,28 +1291,51 @@ dictionary *yon_theme_new(dictionary *widgets, GtkBuilder *builder, char *theme_ 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->SettingsSections=NULL; gtk_style_context_add_class(gtk_widget_get_style_context(curWidgets->icvpack),"iconview"); - if (curWidgets->GnomeInfoLabel!=NULL){ - struct utsname sysinfos; - uname(&sysinfos); - printf("System Name = %s\n", sysinfos.sysname); - printf("Node Name = %s\n", sysinfos.nodename); - printf("Version = %s\n", sysinfos.version); - printf("Release = %s\n", sysinfos.release); - printf("Machine = %s\n", sysinfos.machine); - struct sysinfo info; - sysinfo(&info); - char lbl[2000]; - memset(lbl,0,2000); - double mind=(double)info.uptime/60; - while(mind>60) mind-=60; - int minutes=mind; - sprintf(lbl,"Система: UBLinux\nЯдро: %s %s %s\nВремя работы: %d ч. %d мин. \n\nОперативная память: %d MiB/%d MiB\nЗапущенные процессы: %d\nСредняя загруженность процессора за 15 минут: %d%%\n",sysinfos.machine,sysinfos.sysname,sysinfos.release,info.uptime/60/60,minutes,info.freeram/1024/1024,info.totalram/1024/1024,info.procs,info.loads[2]/1000); - gtk_label_set_text(GTK_LABEL(curWidgets->GnomeInfoLabel),lbl); - //printf("\n\n%d\n\n",info.totalram/1024/1024); - //printf("\n\n%d\n\n",info.freeram/1024/1024); + + if (curWidgets->GnomeInfoLabel!=NULL&&curWidgets->GnomeInfoDetailsLabel!=NULL){ + FILE *fp; + char path[1035]; + char *loc=setlocale(LC_ALL,NULL); + if (strcmp(loc,"ru_RU.UTF-8")==0) + fp = popen("screenfetch -N -n | sed 's/OS:/Система:/' | sed 's/Kernel:/Ядро:/g' | sed 's/Uptime:/Время работы:/g' | \ + sed 's/Packages:/Установлено пакетов:/g' | sed 's/Shell:/Оболочка:/g' | sed 's/Resolution:/Разрешение:/g' | sed 's/DE:/Среда рабочего стола:/g' | \ + sed 's/WM:/Оконный менеджер:/g' | sed 's/WM Theme:/Тема оконного менеджера:/g' | sed 's/GTK Theme:/Тема GTK:/g' | sed 's/Icon Theme:/Тема значков:/g' | sed 's/Font:/Шрифт:/g' | \ + sed 's/Disk:/Диск:/g' | sed 's/RAM:/Оперативная память:/g'", "r"); + else fp = popen("screenfetch -n -w -N", "r"); + if (fp == NULL) { + printf("Failed to run command\n" ); + exit(1); + } + char *line=NULL; + line=""; + char *prevline=NULL; + char *pth; + char *preph=""; + line=""; + while (fgets(path, sizeof(path),fp)!=NULL){ + preph=pth; + prevline=line; + line=strstr(path,": "); + if (line!=NULL){ + int size=strlen(path)-strlen(line); + pth=yon_cut(path,size,0); + // pth=_(pth);;;; + pth=yon_char_get_augumented(preph,pth); + pth=yon_char_get_augumented(pth,"\n"); + } else { + line=path; + pth="\n"; + } + line=yon_char_get_augumented(prevline,line); + }; + prevline=line; + gtk_label_set_text(GTK_LABEL(curWidgets->GnomeInfoDetailsLabel),prevline); + gtk_label_set_text(GTK_LABEL(curWidgets->GnomeInfoLabel),pth); + } if (curWidgets->ButtonBackToMain!=NULL) diff --git a/ubl-settings-manager.h b/ubl-settings-manager.h index fb15281..3897726 100644 --- a/ubl-settings-manager.h +++ b/ubl-settings-manager.h @@ -126,7 +126,7 @@ typedef struct { GtkWidget *SectionSettingsClearEntryButton; GtkWidget *SectionSettingsSaveButton; GtkWidget *SectionSettingsCloseButton; - + GtkWidget *GnomeInfoDetailsLabel; int appssize; apps *applist; GtkWidget *icvpack; diff --git a/ui/ubl-settings-manager.glade b/ui/ubl-settings-manager.glade index be387c2..9ab54e6 100644 --- a/ui/ubl-settings-manager.glade +++ b/ui/ubl-settings-manager.glade @@ -935,7 +935,6 @@ True False 3 - 3 3 3 3 @@ -988,7 +987,9 @@ True False - 50 + end + 100 + 50 ../../../../../../../usr/share/icons/ubmanager-cockpit.svg @@ -998,17 +999,49 @@ - - iconlabel + True False - fsdfhsdftj - True - 0.15000000596046448 - 0.5 + + + True + False + center + label: + right + 1 + 0 + + + + + + + False + True + 0 + + + + + True + False + center + label + 0 + + + + + + False + True + 1 + + - True + False True 1