diff --git a/.gitignore b/.gitignore index 041dc72..7eaca04 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ ubl-settings-video ubl-settings-video.glade~ *ubl-settings-video.glade# -compile/ \ No newline at end of file +compile/ +ubl-settings-video_ru.po~ +ubl-settings-video-n.pot \ No newline at end of file diff --git a/Makefile b/Makefile index 9b33e6e..42867fb 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ all: init build init: @echo "Initialize ..."; \ sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2)\";/" -i source/ubl-settings-video.h; \ - gcc source/ubl-settings-video.c source/ubl-utils.c -o ubl-settings-video `pkg-config --cflags --libs gtk+-3.0` -g; \ echo "-- Build path: ${CMAKE_BUILD_DIR}" depend: @@ -113,6 +112,8 @@ install: check uninstall @install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/devices/" "com.ublinux.${PKGNAME}.display.svg" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" @install -dm755 "${DESTDIR}${PREFIX}/share/applications" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" @@ -120,6 +121,7 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}.glade" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/css/" "${PKGNAME}.css" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}-banner.png" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}-banner.png" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ diff --git a/source/ubl-settings-video.c b/source/ubl-settings-video.c index 54d83f8..724558e 100644 --- a/source/ubl-settings-video.c +++ b/source/ubl-settings-video.c @@ -12,6 +12,25 @@ void yon_on_plug_removed(GtkSocket* self, gpointer user_data){ } +void on_close_subwindow(GtkWidget *self){ + gtk_widget_destroy(gtk_widget_get_toplevel(self)); +} + +void on_proprietary_driver_window_open(GtkWidget *self){ + GtkBuilder *builder=gtk_builder_new_from_file(glade_path); + GtkWidget *window=yon_gtk_builder_get_widget(builder,"ProprietaryDriverChooseWindow"); + GtkWidget *closeButton=yon_gtk_builder_get_widget(builder,"ProprietaryCloseButton"); + gtk_widget_show(window); + g_signal_connect(G_OBJECT(closeButton), "clicked", G_CALLBACK(on_close_subwindow), NULL); + +} + +void on_sensitive_change(GtkWidget *self, GtkWidget *toggle){ + int state=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); + + gtk_widget_set_sensitive(toggle,state); +} + void on_auto_choose_drivers(GtkWidget *self, widgets_dict *widgets){ int state=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); @@ -54,6 +73,19 @@ void on_check_discrete_only(GtkWidget *self){ } +void on_about(){ + GtkBuilder *builder=gtk_builder_new_from_file(glade_path); + GtkWidget *window=yon_gtk_builder_get_widget(builder,"aboutWindow"); + GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); + gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(window),_("UBlinux Video Configuration")); + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); + gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(window),_("Progect Home Page")); + gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),_("Videocard and monitor configuration manager")); + gtk_widget_set_visible(hideButtonBox,0); + gtk_widget_show(window); + +} + void yon_parse_monitor(dictionary *monitor,char *string_of_settings){ char *result=NULL; if ((strstr(string_of_settings,","))){ @@ -65,13 +97,18 @@ void yon_parse_monitor(dictionary *monitor,char *string_of_settings){ } +void yon_default_configs(){ + +} + void yon_setup_config(){ FILE *videoports = popen(get_ports_command, "r"); char str[1000]; while (fgets(str,1000,videoports)){ printf("%s\n",str); char *strng=yon_char_divide_search(str,"\n",0); - monitorconfig *monitor=malloc(sizeof(monitorconfig)); + monitorconfig *monitor=NULL; + monitor=malloc(sizeof(monitorconfig)); monitor->port=yon_char_new(strng); if (!videoconfig.monitors) { videoconfig.monitors=yon_dictionary_create_with_data(strng,monitor);} @@ -90,6 +127,7 @@ void yon_setup_config(){ memset(result,0,1000); if (fgets(result,1000,local)&&strcmp(result,"(null)\n")!=0) videoconfig.failsafenVidia=result; + else if (strcmp(result,"")==0) { yon_default_configs(); return; } else videoconfig.failsafenVidia=NULL; memset(result,0,1000); if (fgets(result,1000,local)&&strcmp(result,"(null)\n")!=0) @@ -105,7 +143,7 @@ void yon_setup_config(){ else videoconfig.primusrun=NULL; for_dictionaries(dct,videoconfig.monitors){ fgets(result,1000,local); - if (strcmp(result,"(null)\n")!=0){ + if (strcmp(result,"(null)\n")!=0||strcmp(result,"")!=0){ char *curmonitor=strstr(result,"=")+1; yon_parse_monitor(dct,curmonitor); } @@ -177,11 +215,20 @@ void on_confugure_monitor_settings(GtkWidget *self, MonitorSettings *settings){ gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationDoNotSwitchOffCheck),_("DPMS off")); gtk_widget_show(monitors->templateMonitorConfigurationWindow); char *addln=NULL; - if (!monitors->curconfig||!((monitorconfig*)monitors->curconfig->data)->resolution) addln=_("Default Settings"); - else addln=((monitorconfig*)monitors->curconfig->data)->resolution; + if (!settings->curconfig||!((monitorconfig*)settings->curconfig->data)->resolution) addln=_("Default settings"); + else addln=((monitorconfig*)settings->curconfig->data)->resolution; gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationResolutionCombo),addln); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationFrequencyCombo),_("Default Settings")); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationRotationCombo),_("Default Settings")); + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationResolutionCombo),0); + + if (!settings->curconfig||!((monitorconfig*)settings->curconfig->data)->frequency) addln=_("Default settings"); + else addln=((monitorconfig*)settings->curconfig->data)->frequency; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationFrequencyCombo),_("Default settings")); + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationFrequencyCombo),0); + + if (!settings->curconfig||!((monitorconfig*)settings->curconfig->data)->rotation) addln=_("Default settings"); + else addln=((monitorconfig*)settings->curconfig->data)->rotation; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationRotationCombo),_("Default settings")); + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationRotationCombo),0); } MonitorSettings *yon_setup_monitor_settings(){ @@ -197,6 +244,7 @@ MonitorSettings *yon_setup_monitor_settings(){ monitors[i].templateMonitorInfoResolutionLabel=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorInfoResolutionLabel")); monitors[i].templateMonitorInfoConfigureButton=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorInfoConfigureButton")); monitors[i].curconfig=yon_dictionary_get_nth(videoconfig.monitors,i); + printf("%d\n",i); gtk_label_set_text(GTK_LABEL(monitors[i].templateMonitorInfoNameLabel),yon_char_get_augumented("Monitor ",((monitorconfig*)monitors[i].curconfig->data)->port)); char *res=yon_char_get_augumented(((monitorconfig*)monitors[i].curconfig->data)->resolution,""); if (!res) res=_("Default settings"); @@ -302,11 +350,27 @@ void yon_setup_widgets(widgets_dict *widgets){ widgets->templateMonitorConfigurationDoNotSwitchOffCheck=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationDoNotSwitchOffCheck"); g_signal_connect(G_OBJECT(widgets->mainDriverAutomaticallyChooseCheck), "toggled", G_CALLBACK(on_auto_choose_drivers), widgets); + // g_signal_connect(G_OBJECT(widgets->mainHybridGraphicsDiscreteCheck), "toggled", G_CALLBACK(on_sensitive_change), widgets); + g_signal_connect(G_OBJECT(widgets->mainExtraLaunchOptirunCheck), "toggled", G_CALLBACK(on_sensitive_change), widgets->mainExtraLaunchOptirunEntry); + g_signal_connect(G_OBJECT(widgets->mainExtraLaunchPrismusunCheck), "toggled", G_CALLBACK(on_sensitive_change), widgets->mainExtraLaunchPrismusunEntry); + g_signal_connect(G_OBJECT(widgets->mainExtraLaunchOptirunCheck), "toggled", G_CALLBACK(on_sensitive_change), widgets->extraOptirunChooseAppsButton); + g_signal_connect(G_OBJECT(widgets->mainExtraLaunchPrismusunCheck), "toggled", G_CALLBACK(on_sensitive_change), widgets->extraPrimusunChooseAppsButton); g_signal_connect(G_OBJECT(widgets->MainWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL); + g_signal_connect(G_OBJECT(widgets->mainDriverProprietaryDriverButton), "clicked", G_CALLBACK(on_proprietary_driver_window_open), NULL); g_signal_connect(G_OBJECT(widgets->extraOptirunChooseAppsButton), "clicked", G_CALLBACK(on_apps_chooser_open), widgets); g_signal_connect(G_OBJECT(widgets->extraPrimusunChooseAppsButton), "clicked", G_CALLBACK(on_apps_chooser_open), widgets); - + + g_signal_connect(G_OBJECT(widgets->mainHeaderSettingsAboutMenuItem), "activate", G_CALLBACK(on_about), NULL); + + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverProprietaryDriverCombo),_("Don't use")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeNvidiaCombo),_("Off")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeNvidiaCombo),_("fbdev")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeAMDCombo),_("Off")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeAMDCombo),_("fbdev")); + + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainExtraFixGapCombo),_("1st variant. May cause perfomance drops in video games")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainExtraFixGapCombo),_("2nd variant. May not work on specific video cards")); gtk_label_set_text(GTK_LABEL(widgets->headInfoLabel),_("Video output configuration")); gtk_label_set_text(GTK_LABEL(widgets->mainDriverProprietaryDriverLabel),_("Proprietary driver: ")); gtk_label_set_text(GTK_LABEL(widgets->mainDriverFailsafeNvidiaLabel),_("Failsafe driver nVidia: ")); @@ -363,7 +427,7 @@ int main(int argc, char *argv[]){ yon_setup_widgets(&widgets); gtk_widget_show(widgets.MainWindow); yon_fill_ui(&widgets); - yon_ubl_status_box_render(widgets.mainStatusBox,widgets.mainStatusIcon,widgets.mainStatusLabel,"com.ublinux.ubl-settings-video.checked","Configuration has been loaded",BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(widgets.mainStatusBox,widgets.mainStatusIcon,widgets.mainStatusLabel,"com.ublinux.ubl-settings-video.checked",_("Configuration has been loaded"),BACKGROUND_IMAGE_SUCCESS_TYPE); 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(), diff --git a/source/ubl-settings-video.h b/source/ubl-settings-video.h index 2af67ef..56b9fc6 100644 --- a/source/ubl-settings-video.h +++ b/source/ubl-settings-video.h @@ -41,7 +41,7 @@ char *local; typedef char* string; -string version_application = ""; +string version_application = "1.0"; diff --git a/source/ubl-utils.c b/source/ubl-utils.c index ed01b97..d2088df 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -241,10 +241,12 @@ dictionary *yon_dictionary_rip(dictionary *dict){ dictionary *yon_dictionary_get_nth(dictionary *dict, int place){ dict=dict->first; - for (int i=0;inext) dict=dict->next; - if (dict) return dict; + else break; + if (i==place) return dict; else return NULL; } @@ -430,6 +432,25 @@ apps *yon_apps_get_by_name(apps *applist,char *name, int size){ return NULL; }; +char *yon_config_load(char *command){ + FILE *output=popen(command,"r"); + char **output_strings=NULL; + output_strings=malloc(sizeof(char)); + int i=0; + char str[1000]; + memset(str,0,1000); + while (fgets(str,1000,output)){ + output_strings=realloc(output_strings,sizeof(char*)*(i+1)); + output_strings[i]=yon_char_new(str); + memset(str,0,1000); + i++; + } +} + +int yon_config_save(char *command){ + FILE *output=popen(command,"r"); + return 1; +} //terminal-using functions diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 444fd93..d0c1049 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -14,6 +14,27 @@ #define for_dictionaries(obj,obj1) for(obj=obj1->first;obj!=NULL;obj=obj->next) +#define yon_ubl_set_global_config_load_command(command) config_commands.global_config_load_command=command +#define yon_ubl_set_global_config_save_command(command) config_commands.global_config_save_command=command +#define yon_ubl_set_local_config_load_command(command) config_commands.local_config_load_command=command +#define yon_ubl_set_local_config_save_command(command) config_commands.local_config_save_command=command + +#define yon_ubl_set_config_save_data_pointer(command) config_commands.config_save_data=command + +#define yon_ubl_load_global_config() yon_config_load(config_commands.global_config_load_command) +#define yon_ubl_load_local_config() yon_config_load(config_commands.local_config_load_command) +#define yon_ubl_save_global_config() yon_config_save(config_commands.global_config_save_command) +#define yon_ubl_save_local_config() yon_config_save(config_commands.local_config_save_command) + + +struct config_commands{ +char *global_config_load_command; +char *global_config_save_command; +char *local_config_load_command; +char *local_config_save_command; +char **config_save_data; +}; + typedef enum { DICTIONARY_ACTION_WIDGETS_TYPE, DICTIONARY_IVGRAPHICALS_TYPE, @@ -99,6 +120,9 @@ void yon_apps_sort(apps *applist,int size); apps *yon_apps_get_by_name(apps *applist,char *name, int size); +char *yon_config_load(char *command); + +int yon_config_save(char *command); //terminal-using functions diff --git a/ubl-settings-video.glade b/ubl-settings-video.glade index f6ac563..5be249b 100644 --- a/ubl-settings-video.glade +++ b/ubl-settings-video.glade @@ -97,6 +97,359 @@ + + + False + О Программе + False + True + center + com.ublinux.ubl-settings-video + dialog + True + ubl-settings-video + 1.2 + Copyright © 2023 - UBSoft Software LLC + Settings for video output + https://ublinux.ru/ + Project Home Page + Это приложение распространяется без каких-либо гарантий. +Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. + UBGroup + UBGroup + com.ublinux.ubl-settings-video + True + gpl-2-0 + + + False + vertical + 2 + + + False + False + top + spread + + + False + False + 0 + + + + + + + + + + False + ubl-settings-video + 800 + 558 + com.ublinux.ubl-settings-video + + + True + False + 5 + 5 + 5 + 5 + vertical + + + True + True + external + in + + + True + False + + + True + False + vertical + + + + + + + + + + + True + True + 0 + + + + + True + False + + + + + + True + False + 5 + 5 + True + + + Cancel + True + True + True + + + False + True + 0 + + + + + OK + True + True + True + + + False + True + 1 + + + + + False + True + end + 1 + + + + + False + True + 1 + + + + + + + True + False + + + 90 + True + False + 5 + 5 + 5 + 5 + 6 + 6 + 69 + com.ublinux.ubl-settings-video + + + False + True + 0 + + + + + True + False + + + True + False + + + True + False + vertical + + + 255 + True + False + Video output configuration + + + + + + + + + True + True + 0 + + + + + False + True + 0 + + + + + True + True + 0 + + + + + True + False + + + False + True + 1 + + + + + True + True + 1 + + + + + True + False + document-edit-symbolic + + + True + False + document-edit-symbolic + + + True + False + open-menu-symbolic + + + + True + False + center + center + 3 + 3 + 20 + vertical + + + True + False + Monitor + True + + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 1920x1200:60Hz + + + + + + + False + True + 1 + + + + + True + True + True + end + image3 + + + + False + True + 2 + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + + True + False + system-run-symbolic + 800 600 @@ -333,14 +686,7 @@ True False - - ubm-nvidia-340 - ubm-nvidia-390 - ubm-nvidia-470 - ubm-nvidia-510 - ubm-nvidia-515 - ubm-nvidia-optimus - + 0 True @@ -372,10 +718,6 @@ True False - - Off - fbdev - False @@ -387,10 +729,6 @@ True False - - Off - fbdev - False @@ -719,9 +1057,6 @@ True False - - 1st variant - True @@ -909,437 +1244,84 @@ False - True - 1 - - - - - - - False - True - 0 - - - - - True - True - False - True - True - SettingsMenu - none - - - - - - False - True - 1 - - - - - end - 3 - - - - - - - vertical - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - False - О Программе - False - True - center - com.ublinux.ubl-settings-video - dialog - True - ubl-settings-video - 1.2 - Copyright © 2023 - UBSoft Software LLC - Settings for video output - https://ublinux.ru/ - Project Home Page - Это приложение распространяется без каких-либо гарантий. -Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. - UBGroup - UBGroup - com.ublinux.ubl-settings-video - True - gpl-2-0 - - - False - vertical - 2 - - - False - False - top - spread - - - False - False - 0 - - - - - - - - - - False - ubl-settings-video - 800 - 558 - com.ublinux.ubl-settings-video - - - True - False - 5 - 5 - 5 - 5 - vertical - - - True - True - external - in - - - True - False - - - True - False - vertical - - - - - - - - - - - True - True - 0 - - - - - True - False - - - - - - True - False - 5 - 5 - True - - - Cancel - True - True - True - - - False - True - 0 - - - - - OK - True - True - True + True + 1 + + - - False - True - 1 - False True - end - 1 + 0 - - - False - True - 1 - - - - - - - True - False - - - 90 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 69 - com.ublinux.ubl-settings-video - - - False - True - 0 - - - - - True - False - - - True - False - + True - False - vertical + True + False + True + True + SettingsMenu + none - - 255 - True - False - Video output configuration - - - - - - - - - True - True - 0 - + False True - 0 + 1 - True - True - 0 - - - - - True - False - - - False - True - 1 + end + 3 - - True - True - 1 - - - - - True - False - document-edit-symbolic - - - True - False - document-edit-symbolic - - - True - False - open-menu-symbolic - - - - True - False - center - center - 3 - 3 - 20 - vertical - - - True - False - Monitor - True - - - - - - - False - True - 0 - - - - - True - False - 5 - 5 - 1920x1200:60Hz - - - - - - - False - True - 1 - - - - - True - True - True - end - image3 - - - - False - True - 2 - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic + + vertical + + + + + + + + + + + + + + + + + + + - - True - False - system-run-symbolic + + + + + + + + + + + + + + + @@ -1452,15 +1434,8 @@ - - - argadrh - ssfasfasf - khjgkj - - - + 450 300 False @@ -1529,7 +1504,7 @@ 5 True - + Cancel True True