diff --git a/.gitignore b/.gitignore index 7eaca04..1ce2845 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ ubl-settings-video.glade~ *ubl-settings-video.glade# compile/ ubl-settings-video_ru.po~ -ubl-settings-video-n.pot \ No newline at end of file +ubl-settings-video-n.pot +vgcore.* \ No newline at end of file diff --git a/Makefile b/Makefile index 42867fb..b83b2ea 100644 --- a/Makefile +++ b/Makefile @@ -87,6 +87,7 @@ uninstall: @$(RM) "${DESTDIR}/etc/xdg/${PKGNAME}/${PKGNAME}.conf" @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop" @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg" + @$(RM) -rd "${DESTDIR}${PREFIX}/share/${PKGNAME}/images" @$(RM) -rd "${DESTDIR}${PREFIX}/share/${PKGNAME}" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ @@ -99,29 +100,31 @@ install: check uninstall @echo "Install ..." @for FILE_PO in $(wildcard *.po); do \ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ - install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \ + install -dm655 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \ FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ echo "$${FILE_PO}"; \ msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \ done @for SIZE in 16 32 48; do \ - install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ + install -dm655 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ done - @install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps" + @install -dm655 "${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 -Dm655 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" + @install -dm655 "${DESTDIR}${PREFIX}/share/applications" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" - @install -dm755 "${DESTDIR}${PREFIX}/share/${PKGNAME}"/{ui,css,images} + @install -dm655 "${DESTDIR}${PREFIX}/share/${PKGNAME}"/{ui,css,images} @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" + @install -dm655 "${DESTDIR}${PREFIX}/share/${PKGNAME}/images" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/images/" "${PKGNAME}-banner.png" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/csv/" "resolutions.csv" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/csv/" "video-drivers.csv" @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/README.md b/README.md index f2222e2..457d749 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ubl-settings-video -# Видеокарта/Экран +# Настройки видеоадаптера и дисплея # Build In order to build ubl-settings-video you will need: diff --git a/resolutions.csv b/resolutions.csv new file mode 100644 index 0000000..bff0b8e --- /dev/null +++ b/resolutions.csv @@ -0,0 +1,27 @@ +640x480 ,4:3,VGA +800x480 ,5:3,WVGA +800x600 ,4:3,SVGA +854x480 ,16:9,FWVGA +960x540 ,19:9,qHD +1024x600,128:75,WSVGA +1024x768,4:3,XGA +1152x864,4:3,XGA+ +1200x600,2:1,WXVGA +1280x720,16:9,HD +1280x768,5:3,WSGA +1280x1024,5:4,SXGA +1440x900,16:10,WXGA+ +1400x1050,4:3,SXGA+ +1440x1080,4:3,HDV 1080 +1536x960,16:10,XJXGA +1536x1024,3:2,WSXGA +1600x900,16:9,HD+ +1600x1024,25:16,WSXGA +1600x1200,4:3,UXGA +1680x1050,16:10,WSXGA+ +1920x1080,16:9,FHD +1920x1200,16:10,WUXGA +2048x1080,19:10,2K DCI +2048x1152,16:9,QWXGA +2560x1080,21:9,UWHD +2560x1440,16:9,QHD diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 0829c09..009e8d4 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -17,9 +17,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin set(SOURCE_FILES ubl-settings-video.c - ubl-settings-video.h ubl-utils.c - ubl-utils.h) +) set(LIBRARIES ${GTK_LIBRARIES} diff --git a/source/ubl-settings-video-strings.h b/source/ubl-settings-video-strings.h new file mode 100644 index 0000000..f15d6ef --- /dev/null +++ b/source/ubl-settings-video-strings.h @@ -0,0 +1,43 @@ +#define PARAMETER_DEFAULT_LABEL _("Default settings") +#define MONITOR_LABEL _("Monitor ") +#define SETTINGS_VIDEO_TITLE_LABEL _("Video adapter and display settings") +#define MONITOR_PORT_LABEL _("Port: ") +#define MONITOR_RESOLUTION_LABEL _("Resolution (px): ") +#define MONITOR_FREQUENCY_LABEL _("Frequency (Hz): ") +#define MONITOR_ROTATION_LABEL _("Rotation: ") +#define MONITOR_POSITION_LABEL _("Position: ") +#define MONITOR_SWITCH_OFF_LABEL _("Do not switch off display") +#define MONITOR_CVT_LABEL _("Create modeline for current resolution with CVT") +#define MONITOR_REDUCED_LABEL _("Use \"CVT Reduced Blanking\"") +#define MONITOR_GTF_LABEL _("Create modeline for current resolution with GTF") +#define MONITOR_MANUALLY_LABEL _("Configure manually through parameter line: ") +#define MONITOR_MAIN_DISPLAY_LABEL _("Main display") +#define MONITOR_UNSUPPORTED_LABEL _("Show unsupported") +#define MONITOR_ENABLED_LABEL _("Enabled") +#define MONITOR_LEFT_LABEL _("Left") +#define MONITOR_RIGHT_LABEL _("Right") +#define MONITOR_INVERTED_LABEL _("Inverted") +#define MONITOR_LEFT_POS_LABEL _("Left of") +#define MONITOR_RIGHT_POS_LABEL _("Right of") +#define MONITOR_ABOVE_POS_LABEL _("Above") +#define MONITOR_BELOW_POS_LABEL _("Below ") +#define MONITOR_NO_ROTATION_LABEL _("No rotation") +#define MONITOR_SAVE_LABEL _("Save") +#define MONITOR_CANCEL_LABEL _("Cancel") +#define MONITOR_CHOOSE_PORT_LABEL _("Choose port to configure") + + +#define MONITOR_POSITION_LEFT_PARAMETER _("lo:") +#define MONITOR_POSITION_RIGHT_PARAMETER _("ro:") +#define MONITOR_POSITION_ABOVE_PARAMETER _("ab:") +#define MONITOR_POSITION_BELOW_PARAMETER _("be:") + + +#define MONITOR_ROTATE_PARAMETER _("rotate:") +#define MONITOR_ROTATE_NORMAL_PARAMETER _("normal") +#define MONITOR_ROTATE_LEFT_PARAMETER _("left") +#define MONITOR_ROTATE_RIGHT_PARAMETER _("right") +#define MONITOR_ROTATE_INVERTED_PARAMETER _("invert") + +#define MONITOR_PORT_ERROR_LABEL _("Error: Port must be chosen to save") +#define MONITOR_PORT_SUCCESS_LABEL _("Monitor configuration succeedeed") \ No newline at end of file diff --git a/source/ubl-settings-video.c b/source/ubl-settings-video.c index 87c8c1a..4161d57 100644 --- a/source/ubl-settings-video.c +++ b/source/ubl-settings-video.c @@ -1,361 +1,1236 @@ #include "ubl-settings-video.h" -#include "ubl-utils.h" - config videoconfig; -void yon_on_plug_added(GtkSocket* self, gpointer user_data){ +void yon_on_plug_added(GtkSocket *self, gpointer user_data) +{ +} +void yon_on_plug_removed(GtkSocket *self, gpointer user_data) +{ } -void yon_on_plug_removed(GtkSocket* self, gpointer user_data){ +void on_subwindow_close(GtkWidget *self) +{ + gtk_widget_destroy(gtk_widget_get_toplevel(self)); +} +void on_monitor_config_save(GtkWidget *self, monitor_edit_window *window){ + monitorconfig *config = yon_dictionary_get_data(window->config,monitorconfig*); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->templateMonitorConfigurationPortCombo))==0){ + _yon_ubl_status_box_render(videoconfig.status_render.box,videoconfig.status_render.icon,videoconfig.status_render.label,MONITOR_PORT_ERROR_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } + config->main=0; + config->enable=0; + config->position=0; + config->rotation=0; + config->dpms=0; + config->cvt=0; + config->reduced=0; + config->position_port=NULL; + config->port=NULL; + config->resolution=NULL; + config->frequency=NULL; + _yon_ubl_status_box_render(videoconfig.status_render.box,videoconfig.status_render.icon,videoconfig.status_render.label,MONITOR_PORT_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + config->port = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationPortCombo)); + window->config->key = yon_char_new(config->port); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationParameterLineCheck))==0){ + config->main = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationMainCheck)); + config->enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationEnableCheck)); + config->dpms = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationModelineCVTCheck)); + config->cvt = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationModelineCVTCheck)); + config->reduced = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationUseCVTReducedCheck)); + config->gtf = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationModelineGTFCheck)); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->templateMonitorConfigurationPositionPosCombo))!=0 + &>k_combo_box_get_active(GTK_COMBO_BOX(window->templateMonitorConfigurationPositionPortCombo))!=0){ + config->position = gtk_combo_box_get_active(GTK_COMBO_BOX(window->templateMonitorConfigurationPositionPosCombo)); + config->position_port = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationPositionPortCombo)); + + } + config->resolution=yon_char_divide_search(gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationResolutionCombo))," ",-1); + int rotation = gtk_combo_box_get_active(GTK_COMBO_BOX(window->templateMonitorConfigurationRotationCombo)); + if (rotation==1) config->rotation=rotation; + else if (rotation==2) config->rotation=rotation; + else if (rotation==3) config->rotation=rotation; + else config->rotation=0; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->templateMonitorConfigurationResolutionCombo))!=0) { + char *resolution = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationResolutionCombo)); + } + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->templateMonitorConfigurationResolutionCombo))!=0) { + char *frequency = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationFrequencyCombo)); + } + yon_monitor_make_string(config); + } else { + char *stringparameters = (char*)gtk_entry_get_text(GTK_ENTRY(window->templateMonitorConfigurationParameterLineEntry)); + } + yon_monitor_view_update(); + on_subwindow_close(self); } -void on_close_subwindow(GtkWidget *self){ - gtk_widget_destroy(gtk_widget_get_toplevel(self)); +// void on_save_window_configuration(GtkWidget *self, MonitorSettings *monitor){ +// char *port=NULL; +// port=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(monitor->templateMonitorConfigurationPortCombo)); +// if (!monitor->curconfig){ +// monitorconfig *confi = new(monitorconfig); +// if (!videoconfig.monitors) videoconfig.monitors=yon_dictionary_create_with_data(port,confi); +// else videoconfig.monitors=yon_dictionary_create_with_data_connected(videoconfig.monitors,port,confi); +// monitor->curconfig=videoconfig.monitors; +// } +// char *freq=NULL; +// char *res=NULL; +// char *rot=NULL; +// char *entr=NULL; +// char *def=NULL; +// def=_("Default settings"); +// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(monitor->templateMonitorConfigurationMainRadio))==1) +// yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->main=1; +// if (strcmp((freq=yon_char_new((char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(monitor->templateMonitorConfigurationFrequencyCombo)))),def)!=0) +// yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->frequency=freq; +// else yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->frequency=NULL; +// if (strcmp((res=yon_char_new((char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(monitor->templateMonitorConfigurationResolutionCombo)))),def)!=0) +// yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->resolution=res; +// else yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->resolution=NULL; +// if (strcmp((rot=yon_char_new((char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(monitor->templateMonitorConfigurationRotationCombo)))),def)!=0) +// yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->rotation=rot; +// else yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->rotation=NULL; +// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(monitor->templateMonitorConfigurationParameterLineCheck))){ +// entr=yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(monitor->templateMonitorConfigurationParameterLineEntry))); +// yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->stringparameters=entr; +// } else { +// char *str=NULL; +// str = ""; +// if (yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->frequency!=NULL) +// str=yon_char_get_augumented(str,yon_char_get_augumented(yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->frequency,",")); +// if (yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->resolution!=NULL) +// str=yon_char_get_augumented(str,yon_char_get_augumented(yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->resolution,",")); +// if (yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->rotation!=NULL) +// if (strcmp(yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->rotation,_("Right"))==0) +// str=yon_char_get_augumented(str,"rotation:right,"); +// else if (strcmp(yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->rotation,_("Left"))==0) +// str=yon_char_get_augumented(str,"rotation:left,"); +// else if (strcmp(yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->rotation,_("Invert"))==0) +// str=yon_char_get_augumented(str,"rotation:invert,"); +// else +// str=yon_char_get_augumented(str,"rotation:normal,"); + +// if (yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->main!=0) +// str=yon_char_get_augumented(str,"primary,"); +// if (strcmp(str,"")!=0) +// yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->stringparameters=str; + +// } +// dictionary *dict=NULL; +// // for_dictionaries (dict,videoconfig.videoconfig){ +// // MonitorSettings *monitorsett=yon_dictionary_get_data(dict,MonitorSettings*); +// // if (monitorsett->curconfig==monitor->curconfig){ +// // yon_parse_monitor(monitorsett->curconfig,yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->stringparameters); +// // gtk_label_set_text(GTK_LABEL(monitorsett->templateMonitorInfoResolutionLabel),yon_dictionary_get_data(monitor->curconfig,monitorconfig*)->resolution); +// // if (yon_dictionary_get_data(monitorsett->curconfig,monitorconfig*)->main==0) +// // gtk_label_set_text(GTK_LABEL(monitorsett->templateMonitorInfoNameLabel), yon_char_get_augumented("Monitor ", ((monitorconfig *)monitorsett->curconfig->data)->port)); +// // if (yon_dictionary_get_data(monitorsett->curconfig,monitorconfig*)->main==1) +// // gtk_label_set_text(GTK_LABEL(monitorsett->templateMonitorInfoNameLabel), yon_char_get_augumented("Monitor ", yon_char_get_augumented(((monitorconfig *)monitorsett->curconfig->data)->port,"*"))); + +// // } +// // } +// on_subwindow_close(self); +// }; + +void on_port_chosen_changed(GtkWidget *self, monitor_edit_window *window){ + monitorconfig* config = yon_dictionary_get_data(window->config,monitorconfig*); + dictionary *dict=NULL; + gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationResolutionCombo)); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationResolutionCombo),PARAMETER_DEFAULT_LABEL); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->templateMonitorConfigurationResolutionCombo),0); + char *combo_text=yon_char_new((char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationPortCombo))); + char *resolution = yon_char_divide_search(combo_text," ",-1); + if (combo_text) + if (strcmp(combo_text,MONITOR_CHOOSE_PORT_LABEL)!=0){ + dict=yon_dictionary_find(&videoconfig.supported_resolutions,resolution); + if (dict){ + resolution_supported *res = yon_dictionary_get_data(dict,resolution_supported*); + int found_size=0; + for (int i=0;isize;i++){ + char *check_line; + for (int j=0;jline[i])){ + found_size++; + if(!config->resolutionCapabilities) config->resolutionCapabilities=new(char*); + else config->resolutionCapabilities=realloc(config->resolutionCapabilities,sizeof(char*)*found_size); + config->resolutionCapabilities[found_size-1]=videoconfig.resolutions[j]; + config->resolution_size=found_size; + } + } + } + yon_gtk_combo_box_fill(window->templateMonitorConfigurationResolutionCombo,config->resolutionCapabilities, config->resolution_size); + } + } } -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"); - GtkWidget *acceptButton=yon_gtk_builder_get_widget(builder,"ProprietaryAcceptButton"); - GtkWidget *columnDriver=yon_gtk_builder_get_widget(builder,"ProprietaryDriverColumn"); - GtkWidget *columnDescription=yon_gtk_builder_get_widget(builder,"ProprietaryDescriptionColumn"); - gtk_button_set_label(GTK_BUTTON(closeButton),_("Cancel")); - gtk_button_set_label(GTK_BUTTON(acceptButton),_("Accept")); - gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(columnDriver),_("Driver")); - gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(columnDescription),_("Description")); - gtk_widget_show(window); - g_signal_connect(G_OBJECT(closeButton), "clicked", G_CALLBACK(on_close_subwindow), NULL); +void on_save_driver_configuration(GtkWidget *self,combo_tree *widgets){ + GtkTreeIter iter; + char *name; + GtkTreeModel *list_s=GTK_TREE_MODEL(videoconfig.list); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->tree)); + gtk_tree_selection_get_selected(selection,&list_s,&iter); + gtk_tree_model_get(list_s,&iter,0,&name,-1); + int ret = yon_gtk_combo_box_text_find(widgets->combo,name); + if (ret!=-1) + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->combo),ret); + on_subwindow_close(self); } -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_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)); - - gtk_widget_set_sensitive(widgets->mainDriverFailsafeNvidiaLabel,!state); - gtk_widget_set_sensitive(widgets->mainDriverProprietaryDriverCombo,!state); - gtk_widget_set_sensitive(widgets->mainDriverProprietaryDriverButton,!state); - gtk_widget_set_sensitive(widgets->mainDriverProprietaryDriverLabel,!state); - gtk_widget_set_sensitive(widgets->mainDriverFailsafeAMDCombo,!state); - gtk_widget_set_sensitive(widgets->mainDriverFailsafeAMDLabel,!state); - gtk_widget_set_sensitive(widgets->mainDriverFailsafeNvidiaCombo,!state); +void on_sensitive_change_reversed(GtkWidget *self, GtkWidget *toggle) +{ + int state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); + + gtk_widget_set_sensitive(toggle, !state); } -void on_closed_configuration(GtkWidget *self, MonitorSettings *monitors){ - gtk_widget_destroy(monitors->templateMonitorConfigurationWindow); +void on_auto_choose_drivers(GtkWidget *self, widgets_dict *widgets) +{ + int state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); + + gtk_widget_set_sensitive(widgets->mainDriverFailsafeNvidiaLabel, !state); + gtk_widget_set_sensitive(widgets->mainDriverFailsafeAMDCombo, !state); + gtk_widget_set_sensitive(widgets->mainDriverFailsafeAMDLabel, !state); + gtk_widget_set_sensitive(widgets->mainDriverFailsafeNvidiaCombo, !state); } -void on_save_configuration_local(GtkWidget *self){ +// void on_closed_configuration(GtkWidget *self, MonitorSettings *monitors) +// { +// gtk_widget_destroy(monitors->templateMonitorConfigurationWindow); +// } +char *yon_configuration_get_save_command(char *command){ + char *str = NULL; + char *dntus = NULL; + dntus=_("Don't use"); + str=yon_char_new(command); + if (videoconfig.autoChooseDrivers==0){ + if (strcmp(videoconfig.failsafenVidia, dntus)!=0) + str = yon_char_get_augumented(str, yon_char_get_augumented(" FAILSAFENVIDIA=", videoconfig.failsafenVidia)); + if (strcmp(videoconfig.failsafeATI, dntus)!=0) + str = yon_char_get_augumented(str, yon_char_get_augumented(" FAILSAFEATI=", videoconfig.failsafeATI)); + } + if (strcmp(videoconfig.optirun, dntus)!=0&&strcmp(videoconfig.optirun, "")!=0) + str = yon_char_get_augumented(str, yon_char_get_augumented(" OPTIRUN=", videoconfig.optirun)); + if (strcmp(videoconfig.primusrun, dntus)!=0&&strcmp(videoconfig.primusrun, "")!=0) + str = yon_char_get_augumented(str, yon_char_get_augumented(" PRIMUSRUN=", videoconfig.primusrun)); + + dictionary *dict=NULL; + for_dictionaries(dict,videoconfig.monitors){ + if (yon_dictionary_get_data(dict,monitorconfig*)->stringparameters){ + + str=yon_char_get_augumented(str, yon_config_make_save_parameter_with_multiple_arguments(yon_dictionary_get_data(dict,monitorconfig*)->stringparameters,XORG_MONITOR(dict->key),",")); + + } + } + + if (strcmp(str,command)!=0) + return str; + else return NULL; } -void on_save_configuration_global(GtkWidget *self){ +void on_resolutions_unsupported_show(GtkWidget *self, monitor_edit_window *window){ + ((monitorconfig*)window->config->data)->show_usupported = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); + gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationResolutionCombo)); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationResolutionCombo),PARAMETER_DEFAULT_LABEL); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->templateMonitorConfigurationResolutionCombo),0); + if (((monitorconfig*)window->config->data)->show_usupported==1){ + yon_gtk_combo_box_fill(window->templateMonitorConfigurationResolutionCombo,videoconfig.resolutions,videoconfig.resolutionssize); + } else { + yon_gtk_combo_box_fill(window->templateMonitorConfigurationResolutionCombo,((monitorconfig*)window->config->data)->resolutionCapabilities,((monitorconfig*)window->config->data)->resolution_size); + + } } -void on_load_configuration_local(GtkWidget *self){ +char *yon_configuration_get_remove_command(char *command){ + char *str = NULL; + char *dntus = NULL; + dntus=_("Don't use"); + str=yon_char_new(command); + str = yon_char_get_augumented(str, " FAILSAFENVIDIA"); + str = yon_char_get_augumented(str, " FAILSAFATI"); + str = yon_char_get_augumented(str, " OPTIRUN"); + str = yon_char_get_augumented(str, " PRIMUSRUN"); + dictionary *dict=NULL; + for_dictionaries(dict,videoconfig.monitors){ + str = yon_char_get_augumented(str, yon_char_get_augumented(" XORG_MONITOR[", yon_char_get_augumented(dict->key, "]"))); + } + if (strcmp(str,command)!=0) + return str; + else return NULL; } -void on_load_configuration_global(GtkWidget *self){ +void on_configuration_save_local(GtkWidget *self, widgets_dict *widgets) +{ + yon_update_config(widgets); + char *str=NULL; + char *delstr=NULL; + str=yon_configuration_get_save_command(save_drivers_local_command); + delstr=yon_configuration_get_remove_command(remove_drivers_local_command); + if (delstr){ + yon_config_save(delstr); + } + if (str){ + printf(str); + yon_config_save(str); + yon_ubl_status_box_render(widgets->mainStatusBox, widgets->mainStatusIcon, widgets->mainStatusLabel, _("Local configuration saving succseeded."), BACKGROUND_IMAGE_SUCCESS_TYPE); + } + // else + // yon_ubl_status_box_render(widgets->mainStatusBox, widgets->mainStatusIcon, widgets->mainStatusLabel, _("Local configuration saving failed."), BACKGROUND_IMAGE_FAIL_TYPE); } -void on_accept_monitor_settings(GtkWidget *self){ +void on_configuration_save_local_global(GtkWidget *self, widgets_dict *widgets) +{ + on_configuration_save_global(self, widgets); + on_configuration_save_local(self, widgets); + yon_ubl_status_box_render(widgets->mainStatusBox, widgets->mainStatusIcon, widgets->mainStatusLabel, _("Local and global configuration saving succseeded."), BACKGROUND_IMAGE_SUCCESS_TYPE); +} +void on_configuration_save_global(GtkWidget *self, widgets_dict *widgets) +{ + yon_ubl_status_box_render(widgets->mainStatusBox, widgets->mainStatusIcon, widgets->mainStatusLabel, _("Global configuration saving succseeded."), BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_update_config(widgets); + char *str = NULL; + if (videoconfig.failsafenVidia) + str = yon_char_get_augumented(save_drivers_global_command, yon_char_get_augumented(" ", videoconfig.failsafenVidia)); + if (videoconfig.failsafeATI) + str = yon_char_get_augumented(str, yon_char_get_augumented(" ", videoconfig.failsafeATI)); + if (videoconfig.optirun) + str = yon_char_get_augumented(str, yon_char_get_augumented(" ", videoconfig.optirun)); + if (videoconfig.primusrun) + str = yon_char_get_augumented(str, yon_char_get_augumented(" ", videoconfig.primusrun)); + printf(str); + yon_config_save(str); } -void on_check_optisun(GtkWidget *self){ +void yon_update_config(widgets_dict *widgets) +{ + videoconfig.optirun = yon_char_new( (char *)gtk_entry_get_text(GTK_ENTRY(widgets->mainExtraLaunchOptirunEntry))); + videoconfig.primusrun = yon_char_new( (char *)gtk_entry_get_text(GTK_ENTRY(widgets->mainExtraLaunchPrismusunEntry))); + videoconfig.failsafenVidia = yon_char_new( gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeNvidiaCombo))); + videoconfig.failsafeATI = yon_char_new( gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeAMDCombo))); } -void on_check_primusrun(GtkWidget *self){ +void on_configuration_load_local(GtkWidget *self, widgets_dict *widgets) +{ + yon_ubl_status_box_render(widgets->mainStatusBox, widgets->mainStatusIcon, widgets->mainStatusLabel, _("Local configuration loading succseeded."), BACKGROUND_IMAGE_SUCCESS_TYPE); + char *command = load_drivers_local_command; + dictionary *dct; + for_dictionaries(dct, videoconfig.monitors) + { + command = yon_char_get_augumented(command, (yon_char_get_augumented(" XORG_MONITOR[", yon_char_get_augumented(((monitorconfig *)dct->data)->port, "]")))); + } + int size = 0; + char **rtn = yon_ubl_load_global_config(command, &size); + char *param = NULL; + // yon_config_init(rtn, size); + on_config_fill_interface(widgets); } -void on_check_discrete_only(GtkWidget *self){ +void on_configuration_load_global(GtkWidget *self, widgets_dict *widgets) +{ + yon_ubl_status_box_render(widgets->mainStatusBox, widgets->mainStatusIcon, widgets->mainStatusLabel, _("Global configuration loading succseeded."), BACKGROUND_IMAGE_SUCCESS_TYPE); + char *command = load_drivers_global_command; + dictionary *dct; + for_dictionaries(dct, videoconfig.monitors) + { + command = yon_char_get_augumented(command, (yon_char_get_augumented(" XORG_MONITOR[", yon_char_get_augumented(((monitorconfig *)dct->data)->port, "]")))); + } + int size = 0; + char **rtn = yon_ubl_load_global_config(command, &size); + char *param = NULL; + // yon_config_init(rtn, size); + on_config_fill_interface(widgets); } -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 on_monitor_delete(GtkWidget *self,monitor_view windowd) + * [EN] +*/ +void on_monitor_delete(GtkWidget *self,monitor_view windowd){ + monitor_window *window = yon_dictionary_get_data(windowd,monitor_window*); + if(window&&window->config){ + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(window->templateMonitorscreenOverlay)),window->templateMonitorscreenOverlay); + yon_dictionary_rip(windowd); + gtk_widget_destroy(window->templateMonitorscreenOverlay); + yon_dictionary_rip(window->config); + free(window); + } +} + +/**void on_monitor_switch(GtkWidget *self,monitor_window *window) + * [EN] +*/ +void on_monitor_switch(GtkWidget *self,monitor_window *window){ + if(window&&window->config){ + int *enable = &yon_dictionary_get_data(window->config,monitorconfig*)->enable; + *enable=!*enable; + gtk_widget_set_sensitive(window->templateMonitorImage,*enable); + } +} +/**void on_monitor_add(GtkWidget *self,monitor_window *window) + * [EN] +*/ +void on_monitor_add(GtkWidget *self,monitor_window *window){ + if(window){ + videoconfig.monitors = yon_monitor_config_new(PARAMETER_DEFAULT_LABEL); + yon_monitor_view_new(videoconfig.monitors); + yon_monitor_view_draw_all(NULL); + } } -void yon_parse_monitor(dictionary *monitor,char *string_of_settings){ - char *result=NULL; - if ((strstr(string_of_settings,","))){ - result=yon_char_divide_search(string_of_settings,",",1); - ((monitorconfig*)monitor->data)->resolution=result; +void on_monitor_configure(GtkWidget *self,monitor_window *window){ + if(window&&window->config){ + monitor_edit_window *monitors = new(monitor_edit_window); + GtkBuilder *builder = gtk_builder_new_from_file(glade_path); + monitors->templateMonitorConfigurationWindow = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationWindow")); + monitors->mainMonitorConfigurationBox = GTK_WIDGET(gtk_builder_get_object(builder, "mainMonitorConfigurationBox")); + monitors->templateMonitorConfigurationBox = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationBox")); + monitors->templateMonitorConfigurationEnableCheck = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationEnableCheck")); + monitors->templateMonitorConfigurationPortLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationPortLabel")); + monitors->templateMonitorConfigurationPortCombo = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationPortCombo")); + monitors->templateMonitorConfigurationMainCheck = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationMainCheck")); + monitors->templateMonitorConfigurationResolutionLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationResolutionLabel")); + monitors->templateMonitorConfigurationResolutionCombo = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationResolutionCombo")); + monitors->templateMonitorConfigurationShowUnsupportedCheck = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationShowUnsupportedCheck")); + monitors->templateMonitorConfigurationFrequencyLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationFrequencyLabel")); + monitors->templateMonitorConfigurationFrequencyCombo = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationFrequencyCombo")); + monitors->templateMonitorConfigurationRotationLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationRotationLabel")); + // monitors->templateMonitorConfigurationDoNotSwitchOffLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationDoNotSwitchOffLabel")); + monitors->templateMonitorConfigurationRotationCombo = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationRotationCombo")); + monitors->templateMonitorConfigurationPositionLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationPositionLabel")); + monitors->templateMonitorConfigurationPositionPosCombo = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationPositionPosCombo")); + monitors->templateMonitorConfigurationPositionPortCombo = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationPositionPortCombo")); + + monitors->templateMonitorConfigurationModelineCVTCheck = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationModelineCVTCheck")); + monitors->templateMonitorConfigurationUseCVTReducedCheck = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationUseCVTReducedCheck")); + monitors->templateMonitorConfigurationModelineGTFCheck = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationModelineGTFCheck")); + monitors->templateMonitorConfigurationParameterLineCheck = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationParameterLineCheck")); + monitors->templateMonitorConfigurationParameterLineEntry = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationParameterLineEntry")); + monitors->templateMonitorConfigurationCancelButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationCancelButton")); + monitors->templateMonitorConfigurationSaveButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationSaveButton")); + monitors->templateMonitorConfigurationDoNotSwitchOffCheck = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorConfigurationDoNotSwitchOffCheck")); + monitors->config=window->config; + + g_signal_connect(G_OBJECT(monitors->templateMonitorConfigurationCancelButton), "clicked", G_CALLBACK(on_subwindow_close), NULL); + g_signal_connect(G_OBJECT(monitors->templateMonitorConfigurationSaveButton), "clicked", G_CALLBACK(on_monitor_config_save), monitors); + g_signal_connect(G_OBJECT(monitors->templateMonitorConfigurationParameterLineCheck), "toggled", G_CALLBACK(on_sensitive_change_reversed), monitors->templateMonitorConfigurationBox); + g_signal_connect(G_OBJECT(monitors->templateMonitorConfigurationParameterLineCheck), "toggled", G_CALLBACK(on_sensitive_change), monitors->templateMonitorConfigurationParameterLineEntry); + g_signal_connect(G_OBJECT(monitors->templateMonitorConfigurationShowUnsupportedCheck), "toggled", G_CALLBACK(on_resolutions_unsupported_show),monitors); + g_signal_connect(G_OBJECT(monitors->templateMonitorConfigurationPortCombo), "changed", G_CALLBACK(on_port_chosen_changed),monitors); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(monitors->templateMonitorConfigurationEnableCheck),yon_dictionary_get_data(monitors->config,monitorconfig*)->enable==1); + + gtk_window_set_title(GTK_WINDOW(monitors->templateMonitorConfigurationWindow),SETTINGS_VIDEO_TITLE_LABEL); + + gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationPortLabel),MONITOR_PORT_LABEL); + gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationResolutionLabel),MONITOR_RESOLUTION_LABEL); + gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationFrequencyLabel),MONITOR_FREQUENCY_LABEL); + gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationRotationLabel),MONITOR_ROTATION_LABEL); + gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationPositionLabel),MONITOR_POSITION_LABEL); + + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationEnableCheck),MONITOR_ENABLED_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationMainCheck),MONITOR_MAIN_DISPLAY_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationShowUnsupportedCheck),MONITOR_UNSUPPORTED_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationDoNotSwitchOffCheck),MONITOR_SWITCH_OFF_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationModelineCVTCheck),MONITOR_CVT_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationUseCVTReducedCheck),MONITOR_REDUCED_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationModelineGTFCheck),MONITOR_GTF_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationParameterLineCheck),MONITOR_MANUALLY_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationCancelButton),MONITOR_CANCEL_LABEL); + gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationSaveButton),MONITOR_SAVE_LABEL); + + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPortCombo),MONITOR_CHOOSE_PORT_LABEL); + dictionary *dict=NULL; + for (int i=0;istringparameters) + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPortCombo),videoconfig.ports[i]); + + } + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationPortCombo),0); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationResolutionCombo),PARAMETER_DEFAULT_LABEL); + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationResolutionCombo),0); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationFrequencyCombo),PARAMETER_DEFAULT_LABEL); + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationFrequencyCombo),0); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationRotationCombo),MONITOR_NO_ROTATION_LABEL); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationRotationCombo),MONITOR_LEFT_LABEL); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationRotationCombo),MONITOR_RIGHT_LABEL); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationRotationCombo),MONITOR_INVERTED_LABEL); + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationRotationCombo),0); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPositionPosCombo),PARAMETER_DEFAULT_LABEL); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPositionPosCombo),MONITOR_LEFT_POS_LABEL); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPositionPosCombo),MONITOR_RIGHT_POS_LABEL); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPositionPosCombo),MONITOR_ABOVE_POS_LABEL); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPositionPosCombo),MONITOR_BELOW_POS_LABEL); + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationPositionPosCombo),0); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPositionPortCombo),PARAMETER_DEFAULT_LABEL); + for (int i=0;itemplateMonitorConfigurationPositionPortCombo),videoconfig.ports[i]); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(monitors->templateMonitorConfigurationPositionPortCombo),0); + + yon_monitor_window_update(monitors); + + gtk_widget_show(monitors->templateMonitorConfigurationWindow); } - char *tmp=NULL; - if (tmp=strstr(string_of_settings,"rotate:")) ((monitorconfig*)monitor->data)->rotation=tmp; - } -void yon_default_configs(){ +/**void on_about() + * [EN] +*/ +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_monitor_window_update(monitor_edit_window *window){ + if (window){ + int found = yon_gtk_combo_box_text_find(window->templateMonitorConfigurationPortCombo, window->config->key); + if (found==-1) + found=0; + gtk_combo_box_set_active(GTK_COMBO_BOX(window->templateMonitorConfigurationPortCombo),found); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->templateMonitorConfigurationResolutionCombo),found); + + found = yon_gtk_combo_box_text_find(window->templateMonitorConfigurationPositionPortCombo, yon_dictionary_get_data(window->config,monitorconfig*)->position_port); + if (found==-1) + found=0; + gtk_combo_box_set_active(GTK_COMBO_BOX(window->templateMonitorConfigurationPositionPortCombo),found); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->templateMonitorConfigurationPositionPosCombo),yon_dictionary_get_data(window->config,monitorconfig*)->position); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->templateMonitorConfigurationRotationCombo),yon_dictionary_get_data(window->config,monitorconfig*)->rotation); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationDoNotSwitchOffCheck),yon_dictionary_get_data(window->config,monitorconfig*)->dpms); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationMainCheck),yon_dictionary_get_data(window->config,monitorconfig*)->main); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationModelineCVTCheck),yon_dictionary_get_data(window->config,monitorconfig*)->cvt); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationUseCVTReducedCheck),yon_dictionary_get_data(window->config,monitorconfig*)->reduced); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationModelineGTFCheck),yon_dictionary_get_data(window->config,monitorconfig*)->gtf); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationEnableCheck),yon_dictionary_get_data(window->config,monitorconfig*)->enable); + if(yon_dictionary_get_data(window->config,monitorconfig*)->stringparameters) + gtk_entry_set_text(GTK_ENTRY(window->templateMonitorConfigurationParameterLineEntry),yon_dictionary_get_data(window->config,monitorconfig*)->stringparameters); + } } -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=NULL; - monitor=malloc(sizeof(monitorconfig)); - monitor->port=yon_char_new(strng); - if (!videoconfig.monitors) { - videoconfig.monitors=yon_dictionary_create_with_data(strng,monitor);} - else { - videoconfig.monitors=yon_dictionary_create_with_data_connected(videoconfig.monitors,strng,monitor); +/**void yon_monitor_view_draw_all(GtkWidget *cnt) + * [EN] +*/ +void yon_monitor_view_draw_all(GtkWidget *cnt){ + monitor_view dict=NULL; + GtkWidget *container=NULL; + if(!container&&cnt) container=cnt; + if(videoconfig.monitor_visuals){ + for_dictionaries(dict,videoconfig.monitor_visuals){ + monitor_window *window = yon_dictionary_get_data(dict,monitor_window*); + if (!container) container = gtk_widget_get_parent(window->templateMonitorscreenOverlay); + if(container){ + g_object_ref(G_OBJECT(window->templateMonitorscreenOverlay)); + gtk_container_remove(GTK_CONTAINER(container),window->templateMonitorscreenOverlay); + } + } + if (container) + for_dictionaries(dict,videoconfig.monitor_visuals){ + monitor_window *window = yon_dictionary_get_data(dict,monitor_window*); + if(dict->first==dict) {} + else gtk_box_pack_start(GTK_BOX(container),window->templateMonitorscreenOverlay,0,0,0); } - memset(str,0,1000); + monitor_window *window = yon_dictionary_get_data(videoconfig.monitor_visuals->first,monitor_window*); + gtk_box_pack_start(GTK_BOX(container),window->templateMonitorscreenOverlay,0,0,0); } - char *command=load_drivers_local_command; - dictionary *dct; - for_dictionaries(dct,videoconfig.monitors){ - command=yon_char_get_augumented(command,(yon_char_get_augumented(" XORG_MONITOR[",yon_char_get_augumented(((monitorconfig*)dct->data)->port,"]")))); - } - FILE *local = popen(command, "r"); - char result[1000]; - 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) - videoconfig.failsafeATI=result; - else videoconfig.failsafeATI=NULL; - memset(result,0,1000); - if (fgets(result,1000,local)&&strcmp(result,"(null)\n")!=0) - videoconfig.optirun=result; - else videoconfig.optirun=NULL; - memset(result,0,1000); - if (fgets(result,1000,local)&&strcmp(result,"(null)\n")!=0) - videoconfig.primusrun=result; - else videoconfig.primusrun=NULL; - for_dictionaries(dct,videoconfig.monitors){ - fgets(result,1000,local); - if (strcmp(result,"(null)\n")!=0||strcmp(result,"")!=0){ - char *curmonitor=strstr(result,"=")+1; - yon_parse_monitor(dct,curmonitor); + yon_monitor_view_update(); +} + +/**void yon_monitor_view_setup(GtkWidget *container) + * [EN] +*/ +void yon_monitor_view_setup(GtkWidget *container){ + if(container){ + monitor_config config=NULL; + yon_monitor_view_new(NULL); + if (videoconfig.monitors){ + for_dictionaries(config,videoconfig.monitors){ + if (yon_dictionary_get_data(config,monitorconfig*)->stringparameters) + yon_monitor_view_new(config); + } } + yon_monitor_view_draw_all(container); } } -void on_apps_chooser_open (GtkWidget *self,widgets_dict *widgets, int mode){ - GtkBuilder *builder=gtk_builder_new_from_file(glade_path);\ - // FILE *output=popen(""); - - printf("not implemented yet\n"); +/**void yon_monitor_view_update() + * [EN] +*/ +void yon_monitor_view_update(){ + monitor_view dict=NULL; + for_dictionaries(dict,videoconfig.monitor_visuals){ + if(dict!=videoconfig.monitor_visuals->first){ + monitor_window *monitor = yon_dictionary_get_data(dict,monitor_window*); + monitorconfig *config = yon_dictionary_get_data(monitor->config,monitorconfig*); + if (strcmp(monitor->config->key,PARAMETER_DEFAULT_LABEL)!=0) + gtk_label_set_text(GTK_LABEL(monitor->templateMonitorInfoNameLabel),yon_char_get_augumented(MONITOR_LABEL,monitor->config->key)); + else + gtk_label_set_text(GTK_LABEL(monitor->templateMonitorInfoNameLabel),yon_char_get_augumented(MONITOR_LABEL,"")); + if (config->resolution) + gtk_label_set_text(GTK_LABEL(monitor->templateMonitorInfoResolutionLabel),config->resolution); + else + gtk_label_set_text(GTK_LABEL(monitor->templateMonitorInfoResolutionLabel),PARAMETER_DEFAULT_LABEL); + } + } } -void yon_fill_ui(widgets_dict *widgets){ - if (!videoconfig.proprietary||strstr(videoconfig.proprietary,"\n")==0) - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->mainDriverProprietaryDriverCombo),0); - - if (!videoconfig.failsafenVidia||strstr(videoconfig.failsafenVidia,"\n")==0) - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->mainDriverFailsafeNvidiaCombo),0); - - if (!videoconfig.failsafeATI||strstr(videoconfig.failsafeATI,"\n")==0) - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->mainDriverFailsafeAMDCombo),0); +/**char *yon_monitor_make_string(monitorconfig* config) + * [EN] +*/ +char *yon_monitor_make_string(monitorconfig* config) +{ + int first=1; + char *main=""; + if (config->main==1){ + main="primary"; + first=0; + } + + char *resolution=""; + if(config->resolution) + if (first==1){ + resolution=config->resolution; + first=0; + }else{ + resolution=yon_char_get_augumented(",",config->resolution); + } + + char *enable=""; + if (config->enable==1) + if (first==1){ + enable="enable"; + first=0; + }else{ + enable=",enable"; + } + else + if (first==1){ + enable="disable"; + first=0; + }else{ + enable=",disable"; + } + + char *position=""; + if (config->position==1) + if (first==1){ + position=yon_char_get_augumented("lo:",config->position_port); + first=0; + }else{ + position=yon_char_get_augumented(",lo:",config->position_port); + } + else if (config->position==2) + if (first==1){ + position=yon_char_get_augumented("ro:",config->position_port); + first=0; + }else{ + position=yon_char_get_augumented(",ro:",config->position_port); + } + else if (config->position==3) + if (first==1){ + position=yon_char_get_augumented("ab:",config->position_port); + first=0; + }else{ + position=yon_char_get_augumented(",ab:",config->position_port); + } + else if (config->position==4) + if (first==1){ + position=yon_char_get_augumented("be:",config->position_port); + first=0; + }else{ + position=yon_char_get_augumented(",be:",config->position_port); + } + + char *rotation=""; + if (config->rotation==0) + if (first==1){ + rotation="rotate:normal"; + first=0; + }else{ + rotation=",rotate:normal"; + } + else if (config->rotation==1) + if (first==1){ + rotation="rotate:left"; + first=0; + }else{ + rotation=",rotate:left"; + } + else if (config->rotation==2) + if (first==1){ + rotation="rotate:right"; + first=0; + }else{ + rotation=",rotate:right"; + } + else if (config->rotation==3) + if (first==1){ + rotation="rotate:invert"; + first=0; + }else{ + rotation=",rotate:invert"; + } + + char *dpms=""; + if (config->dpms==1) + if (first==1){ + dpms="dpms"; + first=0; + }else{ + dpms=",dpms"; + } + + char *cvt=""; + if (config->cvt==1) + if (first==1){ + cvt="cvt"; + first=0; + }else{ + cvt=",cvt"; + } + + char *reduced=""; + if (config->reduced==1) + if (first==1){ + reduced="reduced"; + first=0; + }else{ + reduced=",reduced"; + } + + char *gtf=""; + if (config->gtf==1) + if (first==1){ + gtf="gtf"; + first=0; + }else{ + gtf=",gtf"; + } + + + char *frequency=""; + if (config->frequency) + if (first==1){ + frequency=config->frequency; + first=0; + }else{ + frequency=yon_char_get_augumented(",",config->frequency); + } - if (!videoconfig.optirun||strstr(videoconfig.optirun,"\n")==0) - gtk_entry_set_text(GTK_ENTRY(widgets->mainExtraLaunchOptirunEntry),videoconfig.optirun); + char *stringparameters=yon_char_unite("",main,resolution,frequency,enable,position,rotation,dpms,cvt,reduced,gtf,NULL); + config->stringparameters=yon_char_new(stringparameters); +} + +/**void on_config_fill_interface(widgets_dict *widgets) + * [EN] +*/ +void on_config_fill_interface(widgets_dict *widgets) +{ + gtk_widget_grab_focus(widgets->mainHeaderSettingsButton); + char *str = videoconfig.optirun; + gtk_entry_set_text(GTK_ENTRY(widgets->mainExtraLaunchOptirunEntry), ""); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->mainExtraLaunchOptirunCheck), 0); + if (str) + { + yon_char_divide_search((str = yon_char_new(videoconfig.optirun)), "=", -1); + gtk_entry_set_text(GTK_ENTRY(widgets->mainExtraLaunchOptirunEntry), str); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->mainExtraLaunchOptirunCheck), 1); + } + str = videoconfig.primusrun; + gtk_entry_set_text(GTK_ENTRY(widgets->mainExtraLaunchPrismusunEntry), ""); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->mainExtraLaunchPrismusunCheck), 0); + if (str) + { + yon_char_divide_search((str = yon_char_new(videoconfig.primusrun)), "=", 1); + gtk_entry_set_text(GTK_ENTRY(widgets->mainExtraLaunchPrismusunEntry), str); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->mainExtraLaunchPrismusunCheck), 1); + } + - if (!videoconfig.primusrun||strstr(videoconfig.primusrun,"\n")==0) - gtk_entry_set_text(GTK_ENTRY(widgets->mainExtraLaunchPrismusunEntry),videoconfig.primusrun); + gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeNvidiaCombo)); + + str = videoconfig.failsafenVidia; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeNvidiaCombo), _("Don't use")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeNvidiaCombo), _("fbdev")); + if (str) + { + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->mainDriverFailsafeNvidiaCombo), 1); + } + else + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->mainDriverFailsafeNvidiaCombo), 0); + gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeAMDCombo)); + + str = videoconfig.failsafeATI; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeAMDCombo), _("Don't use")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverFailsafeAMDCombo), _("fbdev")); + if (str) + { + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->mainDriverFailsafeAMDCombo), 1); + } + else + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->mainDriverFailsafeAMDCombo), 0); + dictionary *dict = NULL; +} + +/**dictionary *yon_proprieary_get() + * [EN] +*/ +dictionary *yon_proprieary_get(){ + int size=0; + char **rtn = yon_config_load(get_proprietary_drivers_command,&size); + + for (int i=0;idata,&size,":"); + gtk_list_store_append(list,&iter); + gtk_list_store_set(list,&iter,1,str[1],2,str[2],3,str[3],4,str[4],-1); + } +} + +/**void yon_setup_config(char *configcommand) + * [EN] +*/ +void yon_setup_config(char *configcommand) +{ + videoconfig.portssize=0; + videoconfig.ports=yon_config_load(get_ports_command,&videoconfig.portssize); + + int size = 0; + + char *command = configcommand; + dictionary *dct; + for(int i=0; iwindow = yon_gtk_builder_get_widget(builder, "ProprietaryDriverChooseWindow"); + + widgets->propriearyTreeView = yon_gtk_builder_get_widget(builder, "propriearyTreeView"); + widgets->ProprietaryDriverColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder, "ProprietaryDriverColumn")); + widgets->ProprietaryDescriptionColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder, "ProprietaryDescriptionColumn")); + + widgets->ProprietaryCloseButton = yon_gtk_builder_get_widget(builder, "ProprietaryCloseButton"); + widgets->ProprietaryAcceptButton = yon_gtk_builder_get_widget(builder, "ProprietaryAcceptButton"); + if(!videoconfig.list) + videoconfig.list = GTK_LIST_STORE(gtk_builder_get_object(builder, "liststore6")); + gtk_list_store_clear(videoconfig.list); + yon_gtk_list_store_fill_with_proprietaries(videoconfig.list); + gtk_button_set_label(GTK_BUTTON(widgets->ProprietaryCloseButton), _("Cancel")); + gtk_button_set_label(GTK_BUTTON(widgets->ProprietaryAcceptButton), _("Accept")); + gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->propriearyTreeView),GTK_TREE_MODEL(videoconfig.list)); + gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(widgets->ProprietaryDriverColumn), _("Installed")); + gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(widgets->ProprietaryDriverColumn), _("Package")); + gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(widgets->ProprietaryDriverColumn), _("Supported Devices")); + gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(widgets->ProprietaryDriverColumn), _("Driver")); + gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(widgets->ProprietaryDescriptionColumn), _("Description")); + gtk_widget_show(widgets->window); + g_signal_connect(G_OBJECT(widgets->ProprietaryCloseButton), "clicked", G_CALLBACK(on_subwindow_close), NULL); + combo_tree *trcm=NULL; + trcm=malloc(sizeof(combo_tree)); + trcm->combo=comboe; + trcm->tree=widgets->propriearyTreeView; + g_signal_connect(G_OBJECT(widgets->ProprietaryAcceptButton), "clicked", G_CALLBACK(on_save_driver_configuration), trcm); +} + +/** monitor_config yon_monitor_config_new(char *port) + * [EN] +*/ +monitor_config yon_monitor_config_new(char *port){ + if (port){ + monitorconfig *monitor=new(monitorconfig); + monitor->main=0; + monitor->enable=0; + monitor->position=0; + monitor->port=NULL; + monitor->position_port=NULL; + monitor->resolution=NULL; + monitor->resolutionCapabilities=NULL; + monitor->frequency=NULL; + monitor->rotation=0; + monitor->stringparameters=NULL; + monitor->dpms=0; + monitor->resolution_size=0; + monitor->cvt=0; + monitor->reduced=0; + monitor->gtf=0; + if (videoconfig.monitors) + videoconfig.monitors=yon_dictionary_create_with_data_connected(videoconfig.monitors,port,monitor); + else + videoconfig.monitors=yon_dictionary_create_with_data(port,monitor); + return videoconfig.monitors; + } +} + +/**void yon_monitor_config_update(monitorconfig* monitor, char *port, char *config_string) + * [EN] +*/ +void yon_monitor_config_update(monitorconfig* monitor, char *port, char *config_string){ + if (port&&config_string){ + monitor->stringparameters=yon_char_new(config_string); + int size=0; + config_str cnf = yon_char_parse(config_string,&size,","); + if (yon_char_parsed_check_exist(cnf,size,"primary")!=-1) + monitor->main=1; + if (yon_char_parsed_check_exist(cnf,size,"enable")!=-1) + monitor->enable=1; + if (yon_char_parsed_check_exist(cnf,size,"disable")!=-1) + monitor->enable=0; + // if (yon_char_parsed_check_exist(cnf,size,"ignore")==1) + // monitor->enable=0; + if (yon_char_parsed_check_exist(cnf,size,"LeftOf:")!=-1) + monitor->position=1; + if (yon_char_parsed_check_exist(cnf,size,"lo:")!=-1) + monitor->position=1; + if (yon_char_parsed_check_exist(cnf,size,"RightOf:")!=-1) + monitor->position=2; + if (yon_char_parsed_check_exist(cnf,size,"ro:")!=-1) + monitor->position=2; + if (yon_char_parsed_check_exist(cnf,size,"Below:")!=-1) + monitor->position=4; + if (yon_char_parsed_check_exist(cnf,size,"be:")!=-1) + monitor->position=4; + if (yon_char_parsed_check_exist(cnf,size,"Above:")!=-1) + monitor->position=3; + if (yon_char_parsed_check_exist(cnf,size,"ab:")!=-1) + monitor->position=3; + if (yon_char_parsed_check_exist(cnf,size,"rotate:")!=-1) + monitor->rotation=0; + if (yon_char_parsed_check_exist(cnf,size,"dpms")!=-1) + monitor->dpms=1; + if (yon_char_parsed_check_exist(cnf,size,"nodpms")!=-1) + monitor->dpms=0; + if (yon_char_parsed_check_exist(cnf,size,"cvt")!=-1) + monitor->cvt=1; + if (yon_char_parsed_check_exist(cnf,size,"reduced")!=-1) + monitor->reduced=1; + if (yon_char_parsed_check_exist(cnf,size,"r")!=-1) + monitor->reduced=1; + if (yon_char_parsed_check_exist(cnf,size,"gtf")!=-1) + monitor->gtf=1; + } +} + +// MonitorSettings *yon_setup_monitor_settings() +// { +// int monitors_n = videoconfig.portssize; +// MonitorSettings *monitors = NULL; +// monitors = malloc(sizeof(MonitorSettings) * (monitors_n+1)); +// // videoconfig.videoconfig=videoconfig.videoconfig->first; +// int i=0; +// if (videoconfig.monitors){ +// for (i = 0; i < monitors_n; i++) +// { +// GtkBuilder *builder = gtk_builder_new_from_file(glade_path); +// monitors[i].templateMonitorscreenOverlay = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorscreenOverlay")); +// monitors[i].templateMonitorInfoBox = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoBox")); +// monitors[i].templateMonitorInfoNameLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoNameLabel")); +// monitors[i].templateMonitorImage = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorImage")); +// monitors[i].templateMonitorInfoResolutionLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoResolutionLabel")); +// monitors[i].templateMonitorInfoConfigureButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoConfigureButton")); +// monitors[i].templateMonitorDeleteButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorDeleteButton")); +// monitors[i].templateMonitorSwitchButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorSwitchButton")); +// monitors[i].curconfig = yon_dictionary_get_nth(videoconfig.monitors, i); +// printf("%d\n", i); +// if (yon_dictionary_get_data(monitors[i].curconfig,monitorconfig*)->main==0) +// gtk_label_set_text(GTK_LABEL(monitors[i].templateMonitorInfoNameLabel), yon_char_get_augumented("Monitor ", ((monitorconfig *)monitors[i].curconfig->data)->port)); +// if (yon_dictionary_get_data(monitors[i].curconfig,monitorconfig*)->main==1) +// gtk_label_set_text(GTK_LABEL(monitors[i].templateMonitorInfoNameLabel), yon_char_get_augumented("Monitor ", yon_char_get_augumented(((monitorconfig *)monitors[i].curconfig->data)->port,"*"))); +// char *res = yon_char_get_augumented(((monitorconfig *)monitors[i].curconfig->data)->resolution, ""); +// if (yon_dictionary_get_data(monitors[i].curconfig,monitorconfig*)->enable==1) +// gtk_widget_set_sensitive(monitors[i].templateMonitorImage,1); +// if (!res) +// res = _("Default settings"); +// gtk_label_set_text(GTK_LABEL(monitors[i].templateMonitorInfoResolutionLabel), res); +// gtk_overlay_add_overlay(GTK_OVERLAY(monitors[i].templateMonitorscreenOverlay), monitors[i].templateMonitorInfoBox); +// g_signal_connect(G_OBJECT(monitors[i].templateMonitorInfoConfigureButton), "clicked", G_CALLBACK(on_confugure_monitor_settings), &monitors[i]); +// g_signal_connect(G_OBJECT(monitors[i].templateMonitorDeleteButton), "clicked", G_CALLBACK(on_confugure_monitor_settings), &monitors[i]); +// g_signal_connect(G_OBJECT(monitors[i].templateMonitorSwitchButton), "clicked", G_CALLBACK(on_confugure_monitor_settings), &monitors[i]); +// if (i==0) +// videoconfig.videoconfig = yon_dictionary_create_with_data(((monitorconfig *)monitors[i].curconfig->data)->port,&monitors[i]); +// else +// videoconfig.videoconfig = yon_dictionary_create_with_data_connected(videoconfig.videoconfig,((monitorconfig *)monitors[i].curconfig->data)->port,&monitors[i]); +// if (videoconfig.monitors->next) +// videoconfig.monitors = videoconfig.monitors->next; +// } +// } +// GtkBuilder *builder = gtk_builder_new_from_file(glade_path); +// monitors[i].templateMonitorscreenOverlay = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorscreenOverlay")); +// monitors[i].templateMonitorInfoBox = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoBox")); +// monitors[i].templateMonitorInfoNameLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoNameLabel")); +// monitors[i].templateMonitorImage = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorImage")); +// monitors[i].templateMonitorInfoResolutionLabel = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoResolutionLabel")); +// monitors[i].templateMonitorInfoConfigureButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoConfigureButton")); +// monitors[i].templateMonitorDeleteButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorDeleteButton")); +// monitors[i].templateMonitorSwitchButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorSwitchButton")); +// monitors[i].templateMonitorInfoAddButton = GTK_WIDGET(gtk_builder_get_object(builder, "templateMonitorInfoAddButton")); +// gtk_widget_show(monitors[i].templateMonitorInfoAddButton); +// gtk_widget_hide(monitors[i].templateMonitorSwitchButton); +// gtk_widget_hide(monitors[i].templateMonitorDeleteButton); +// gtk_widget_hide(monitors[i].templateMonitorInfoConfigureButton); +// monitors[i].curconfig = NULL; +// gtk_label_set_text(GTK_LABEL(monitors[i].templateMonitorInfoNameLabel), ""); +// gtk_widget_set_sensitive(monitors[i].templateMonitorImage,0); +// gtk_label_set_text(GTK_LABEL(monitors[i].templateMonitorInfoResolutionLabel), ""); +// gtk_overlay_add_overlay(GTK_OVERLAY(monitors[i].templateMonitorscreenOverlay), monitors[i].templateMonitorInfoBox); +// g_signal_connect(G_OBJECT(monitors[i].templateMonitorInfoAddButton), "clicked", G_CALLBACK(on_confugure_monitor_settings), &monitors[i]); +// if (i==0) +// videoconfig.videoconfig = yon_dictionary_create_with_data("TEMPLATE",&monitors[i]); +// else +// videoconfig.videoconfig = yon_dictionary_create_with_data_connected(videoconfig.videoconfig,"TEMPLATE",&monitors[i]); +// return monitors; +// } + +int yon_char_get_if_resolution(char *parsed_string){ + char *left=NULL, *right=NULL; + right=yon_char_new(parsed_string); + left=yon_char_divide_search(right,"x",1); + if (left&&right) + if (atoi(left)&&atoi(right)) + return 1; + return 0; +} + +void yon_monitor_view_new(monitor_config monitor){ + GtkBuilder *builder = gtk_builder_new_from_file(glade_path); + monitor_window *window = new(monitor_window); + window->templateMonitorscreenOverlay=yon_gtk_builder_get_widget(builder,"templateMonitorscreenOverlay"); + window->templateMonitorImage=yon_gtk_builder_get_widget(builder,"templateMonitorImage"); + window->templateMonitorInfoBox=yon_gtk_builder_get_widget(builder,"templateMonitorInfoBox"); + window->templateMonitorInfoNameLabel=yon_gtk_builder_get_widget(builder,"templateMonitorInfoNameLabel"); + window->templateMonitorInfoResolutionLabel=yon_gtk_builder_get_widget(builder,"templateMonitorInfoResolutionLabel"); + window->templateMonitorDeleteButton=yon_gtk_builder_get_widget(builder,"templateMonitorDeleteButton"); + window->templateMonitorSwitchButton=yon_gtk_builder_get_widget(builder,"templateMonitorSwitchButton"); + window->templateMonitorInfoConfigureButton=yon_gtk_builder_get_widget(builder,"templateMonitorInfoConfigureButton"); + window->templateMonitorInfoAddButton=yon_gtk_builder_get_widget(builder,"templateMonitorInfoAddButton"); + window->config=NULL; + gtk_overlay_add_overlay(GTK_OVERLAY(window->templateMonitorscreenOverlay),window->templateMonitorInfoBox); + if (monitor){ + window->config=monitor; + gtk_widget_hide(window->templateMonitorInfoAddButton); + g_signal_connect(G_OBJECT(window->templateMonitorInfoConfigureButton), "clicked", G_CALLBACK(on_monitor_configure), window); + if (videoconfig.monitor_visuals) videoconfig.monitor_visuals = yon_dictionary_create_with_data_connected(videoconfig.monitor_visuals, window->config->key,window); + else videoconfig.monitor_visuals = yon_dictionary_create_with_data(window->config->key,window); + + g_signal_connect(G_OBJECT(window->templateMonitorDeleteButton), "clicked", G_CALLBACK(on_monitor_delete), videoconfig.monitor_visuals); + g_signal_connect(G_OBJECT(window->templateMonitorSwitchButton), "clicked", G_CALLBACK(on_monitor_switch), window); + } else { + gtk_widget_show(window->templateMonitorInfoAddButton); + gtk_widget_hide(window->templateMonitorDeleteButton); + gtk_widget_hide(window->templateMonitorSwitchButton); + gtk_widget_hide(window->templateMonitorInfoConfigureButton); + g_signal_connect(G_OBJECT(window->templateMonitorInfoAddButton), "clicked", G_CALLBACK(on_monitor_add), window); + if (videoconfig.monitor_visuals) videoconfig.monitor_visuals = yon_dictionary_create_with_data_connected(videoconfig.monitor_visuals, "GENERIC",window); + else videoconfig.monitor_visuals = yon_dictionary_create_with_data("GENERIC",window); + } +} + +void yon_monitor_set_resolutions(){ + dictionary *dact=NULL; + int size_connected=0; + config_str connected_ports = yon_config_load(get_resolution_ports_command,&size_connected); + int resolutions_size=0; + config_str resolutions = yon_config_load(get_resolutions_command,&resolutions_size); + for (int i=0;iline=resol; + supported->size=0; + yon_dictionary_add_or_create_if_exists_with_data(videoconfig.supported_resolutions,connected_ports[i],supported); + } + config_str final=NULL; + for(int i=0;idata)){ + equals=1; + port_for_res=NULL; + } + if (cur_pos>*((int*)dct->data)&&equals==0) + port_for_res=yon_char_new(dct->key); + } + if(port_for_res){ + dct=yon_dictionary_find(&videoconfig.supported_resolutions,port_for_res); + resolution_supported *sup=yon_dictionary_get_data(dct,resolution_supported*); + sup->size++; + sup->line=realloc(sup->line,sizeof(char*)*sup->size); + sup->line[sup->size-1]=yon_char_new(yon_char_divide_search(resolutions[i],"\n",-1)); + } + } } -void on_confugure_monitor_settings(GtkWidget *self, MonitorSettings *settings){ - int monitors_n=yon_check_for_monitors(); - MonitorSettings *monitors = NULL; - monitors=malloc(sizeof(MonitorSettings)); - GtkBuilder *builder=gtk_builder_new_from_file(glade_path); - monitors->templateMonitorConfigurationWindow=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationWindow")); - monitors->templateMonitorConfigurationBox=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationBox")); - monitors->templateMonitorConfigurationMonitorLabel=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationMonitorLabel")); - monitors->templateMonitorConfigurationResolutionLabel=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationResolutionLabel")); - monitors->templateMonitorConfigurationResolutionCombo=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationResolutionCombo")); - monitors->templateMonitorConfigurationFrequencyLabel=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationFrequencyLabel")); - monitors->templateMonitorConfigurationFrequencyCombo=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationFrequencyCombo")); - monitors->templateMonitorConfigurationRotationCombo=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationRotationCombo")); - monitors->templateMonitorConfigurationRotationLabel=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationRotationLabel")); - monitors->templateMonitorConfigurationMainRadio=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationMainRadio")); - monitors->templateMonitorConfigurationParameterLineCheck=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationParameterLineCheck")); - monitors->templateMonitorConfigurationParameterLineEntry=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationParameterLineEntry")); - monitors->templateMonitorConfigurationDoNotSwitchOffLabel=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationDoNotSwitchOffLabel")); - monitors->templateMonitorConfigurationDoNotSwitchOffCheck=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationDoNotSwitchOffCheck")); - monitors->templateMonitorConfigurationCancelButton=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationCancelButton")); - monitors->templateMonitorConfigurationSaveButton=GTK_WIDGET(gtk_builder_get_object(builder,"templateMonitorConfigurationSaveButton")); - - g_signal_connect(G_OBJECT(monitors->templateMonitorConfigurationCancelButton), "clicked", G_CALLBACK(on_closed_configuration), monitors); - // g_signal_connect(G_OBJECT(monitors->templateMonitorConfigurationSaveButton), "clicked", G_CALLBACK(on_save_configuration), monitors); - // if (i!=0) - // gtk_radio_button_join_group(GTK_RADIO_BUTTON(monitors[i].templateMonitorConfigurationMainRadio),GTK_RADIO_BUTTON(monitors[i-1].templateMonitorConfigurationMainRadio)); - - gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationMonitorLabel),_("Monitor: ")); - gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationResolutionLabel),_("Resolution (px): ")); - gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationFrequencyLabel),_("Frequency (Hz): ")); - gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationRotationLabel),_("Rotation: ")); - // gtk_label_set_text(GTK_LABEL(monitors->templateMonitorConfigurationDoNotSwitchOffLabel),_("Do not switch display off")); - gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationMainRadio),_("Main monitor")); - gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationParameterLineCheck),_("through parameter line:")); - // gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationDoNotSwitchOffCheck),_("DPMS off")); - gtk_button_set_label(GTK_BUTTON(monitors->templateMonitorConfigurationCancelButton),_("Cancel")); - gtk_widget_show(monitors->templateMonitorConfigurationWindow); - char *addln=NULL; - 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_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(){ - int monitors_n=yon_check_for_monitors(); - MonitorSettings *monitors = NULL; - monitors=malloc(sizeof(MonitorSettings)*monitors_n); - // videoconfig.videoconfig=videoconfig.videoconfig->first; - for (int i=0;idata)->port)); - char *res=yon_char_get_augumented(((monitorconfig*)monitors[i].curconfig->data)->resolution,""); - if (!res) res=_("Default settings"); - gtk_label_set_text(GTK_LABEL(monitors[i].templateMonitorInfoResolutionLabel),res); - gtk_overlay_add_overlay(GTK_OVERLAY(monitors[i].templateMonitorscreenOverlay),monitors[i].templateMonitorInfoBox); - g_signal_connect(G_OBJECT(monitors[i].templateMonitorInfoConfigureButton), "clicked", G_CALLBACK(on_confugure_monitor_settings), &monitors[i]); - - if(videoconfig.monitors->next) - videoconfig.monitors=videoconfig.monitors->next; - } - return monitors; -} - -int yon_check_for_monitors(){ - GdkScreen *screen=gdk_screen_get_default(); - int monitors=gdk_display_get_n_monitors(gdk_screen_get_display(screen)); - return monitors; -} - -dictionary *yon_dictionary_pack_monitors(MonitorSettings *monitors, int size){ - dictionary *dict=yon_dictionary_create_with_data("0",monitors[0].templateMonitorConfigurationBox); - for (int i=1;ibuilder=gtk_builder_new_from_file(glade_path); - widgets->appsPackWindow=yon_gtk_builder_get_widget(widgets->builder,"appsPackWindow"); - widgets->appsPackBox=yon_gtk_builder_get_widget(widgets->builder,"appsPackBox"); - widgets->MainWindow=yon_gtk_builder_get_widget(widgets->builder,"MainWindow"); - widgets->headBox=yon_gtk_builder_get_widget(widgets->builder,"headBox"); - widgets->headInfoLabel=yon_gtk_builder_get_widget(widgets->builder,"headInfoLabel"); - widgets->mainPlugBox=yon_gtk_builder_get_widget(widgets->builder,"mainPlugBox"); - widgets->mainErrorBox=yon_gtk_builder_get_widget(widgets->builder,"mainErrorBox"); - widgets->mainHeadOverlay=yon_gtk_builder_get_widget(widgets->builder,"mainHeadOverlay"); - widgets->extraOptirunChooseAppsButton=yon_gtk_builder_get_widget(widgets->builder,"extraOptirunChooseAppsButton"); - widgets->extraPrimusunChooseAppsButton=yon_gtk_builder_get_widget(widgets->builder,"extraPrimusunChooseAppsButton"); - widgets->mainHeadBackgroundImage=yon_gtk_builder_get_widget(widgets->builder,"mainHeadBackgroundImage"); - widgets->mainDriverAutomaticallyChooseCheck=yon_gtk_builder_get_widget(widgets->builder,"mainDriverAutomaticallyChooseCheck"); - widgets->mainDriverProprietaryDriverLabel=yon_gtk_builder_get_widget(widgets->builder,"mainDriverProprietaryDriverLabel"); - widgets->mainDriverFailsafeNvidiaLabel=yon_gtk_builder_get_widget(widgets->builder,"mainDriverFailsafeNvidiaLabel"); - widgets->mainDriverFailsafeAMDLabel=yon_gtk_builder_get_widget(widgets->builder,"mainDriverFailsafeAMDLabel"); - widgets->mainDriverProprietaryDriverCombo=yon_gtk_builder_get_widget(widgets->builder,"mainDriverProprietaryDriverCombo"); - widgets->mainExtraFixGapCombo=yon_gtk_builder_get_widget(widgets->builder,"mainExtraFixGapCombo"); - widgets->mainDriverProprietaryDriverButton=yon_gtk_builder_get_widget(widgets->builder,"mainDriverProprietaryDriverButton"); - widgets->mainDriverFailsafeNvidiaCombo=yon_gtk_builder_get_widget(widgets->builder,"mainDriverFailsafeNvidiaCombo"); - widgets->mainDriverFailsafeAMDCombo=yon_gtk_builder_get_widget(widgets->builder,"mainDriverFailsafeAMDCombo"); - widgets->mainDriverFrameLabel=yon_gtk_builder_get_widget(widgets->builder,"mainDriverFrameLabel"); - widgets->monitorConfigurationMethodLabel=yon_gtk_builder_get_widget(widgets->builder,"monitorConfigurationMethodLabel"); - widgets->monitorConfigurationMethodCombo=yon_gtk_builder_get_widget(widgets->builder,"monitorConfigurationMethodCombo"); - widgets->mainMonitorVisualConfigurationBox=yon_gtk_builder_get_widget(widgets->builder,"mainMonitorVisualConfigurationBox"); - widgets->mainMonitorConfigurationBox=yon_gtk_builder_get_widget(widgets->builder,"mainMonitorConfigurationBox"); - widgets->mainMonitorConfigurationFrameLabel=yon_gtk_builder_get_widget(widgets->builder,"mainMonitorConfigurationFrameLabel"); - widgets->mainHybridGraphicsDiscreteLabel=yon_gtk_builder_get_widget(widgets->builder,"mainHybridGraphicsDiscreteLabel"); - widgets->mainHybridGraphicsDiscreteCheck=yon_gtk_builder_get_widget(widgets->builder,"mainHybridGraphicsDiscreteCheck"); - widgets->mainHybridGraphicsFrameLabel=yon_gtk_builder_get_widget(widgets->builder,"mainHybridGraphicsFrameLabel"); - widgets->mainExtraLaunchOptirunCheck=yon_gtk_builder_get_widget(widgets->builder,"mainExtraLaunchOptirunCheck"); - widgets->mainExtraLaunchPrismusunCheck=yon_gtk_builder_get_widget(widgets->builder,"mainExtraLaunchPrismusunCheck"); - widgets->mainExtraFixGapLabel=yon_gtk_builder_get_widget(widgets->builder,"mainExtraFixGapLabel"); - widgets->mainExtraLaunchOptirunEntry=yon_gtk_builder_get_widget(widgets->builder,"mainExtraLaunchOptirunEntry"); - widgets->mainExtraLaunchPrismusunEntry=yon_gtk_builder_get_widget(widgets->builder,"mainExtraLaunchPrismusunEntry"); - widgets->mainExtraFixGapLabelCombo=yon_gtk_builder_get_widget(widgets->builder,"mainExtraFixGapLabelCombo"); - widgets->mainExtraLaunchThroughButton=yon_gtk_builder_get_widget(widgets->builder,"mainExtraLaunchThroughButton"); - widgets->mainExtraFrameLabel=yon_gtk_builder_get_widget(widgets->builder,"mainExtraFrameLabel"); - widgets->mainHeaderTitleLabel=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderTitleLabel"); - widgets->mainHeaderLoadButton=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderLoadButton"); - widgets->mainHeaderConfigLoadLabel=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderConfigLoadLabel"); - widgets->mainHeaderSaveConfigurationLabel=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderSaveConfigurationLabel"); - widgets->mainHeaderSaveButton=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderSaveButton"); - widgets->mainHeaderSettingsButton=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderSettingsButton"); - widgets->mainHeaderLoadGlobalMenuItem=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderLoadGlobalMenuItem"); - widgets->mainHeaderLoadLocalMenuItem=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderLoadLocalMenuItem"); - widgets->mainHeaderSaveGlobalLocalMenuItem=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderSaveGlobalLocalMenuItem"); - widgets->mainHeaderSaveGlobalMenuItem=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderSaveGlobalMenuItem"); - widgets->mainHeaderSaveLocalMenuItem=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderSaveLocalMenuItem"); - widgets->mainHeaderSettingsDocumentationMenuItem=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderSettingsDocumentationMenuItem"); - widgets->mainHeaderSettingsAboutMenuItem=yon_gtk_builder_get_widget(widgets->builder,"mainHeaderSettingsAboutMenuItem"); - widgets->mainStatusBox=yon_gtk_builder_get_widget(widgets->builder,"mainStatusBox"); - widgets->mainStatusIcon=yon_gtk_builder_get_widget(widgets->builder,"mainStatusIcon"); - widgets->mainStatusLabel=yon_gtk_builder_get_widget(widgets->builder,"mainStatusLabel"); - widgets->templateMonitorConfigurationBox=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationBox"); - widgets->templateMonitorConfigurationMonitorLabel=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationMonitorLabel"); - widgets->templateMonitorConfigurationResolutionLabel=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationResolutionLabel"); - widgets->templateMonitorConfigurationResolutionCombo=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationResolutionCombo"); - widgets->templateMonitorConfigurationFrequencyLabel=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationFrequencyLabel"); - widgets->templateMonitorConfigurationFrequencyCombo=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationFrequencyCombo"); - widgets->templateMonitorConfigurationRotationLabel=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationRotationLabel"); - widgets->templateMonitorConfigurationRotationCombo=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationRotationCombo"); - widgets->templateMonitorConfigurationMainRadio=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationMainRadio"); - widgets->templateMonitorConfigurationParameterLineCheck=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationParameterLineCheck"); - widgets->templateMonitorConfigurationParameterLineEntry=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationParameterLineEntry"); - widgets->templateMonitorConfigurationDoNotSwitchOffLabel=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationDoNotSwitchOffLabel"); - widgets->templateMonitorConfigurationDoNotSwitchOffCheck=yon_gtk_builder_get_widget(widgets->builder,"templateMonitorConfigurationDoNotSwitchOffCheck"); +/** void yon_setup_widgets(widgets_dict *widgets) + * [EN] + * Sets up every element on main window + * [RU] + * + * */ +void yon_setup_widgets(widgets_dict *widgets) +{ + widgets->builder = gtk_builder_new_from_file(glade_path); + widgets->appsPackWindow = yon_gtk_builder_get_widget(widgets->builder, "appsPackWindow"); + widgets->appsPackBox = yon_gtk_builder_get_widget(widgets->builder, "appsPackBox"); + widgets->MainWindow = yon_gtk_builder_get_widget(widgets->builder, "MainWindow"); + widgets->headBox = yon_gtk_builder_get_widget(widgets->builder, "headBox"); + widgets->headInfoLabel = yon_gtk_builder_get_widget(widgets->builder, "headInfoLabel"); + widgets->mainPlugBox = yon_gtk_builder_get_widget(widgets->builder, "mainPlugBox"); + widgets->mainErrorBox = yon_gtk_builder_get_widget(widgets->builder, "mainErrorBox"); + widgets->mainHeadOverlay = yon_gtk_builder_get_widget(widgets->builder, "mainHeadOverlay"); + widgets->extraOptirunChooseAppsButton = yon_gtk_builder_get_widget(widgets->builder, "extraOptirunChooseAppsButton"); + widgets->extraPrimusunChooseAppsButton = yon_gtk_builder_get_widget(widgets->builder, "extraPrimusunChooseAppsButton"); + widgets->mainHeadBackgroundImage = yon_gtk_builder_get_widget(widgets->builder, "mainHeadBackgroundImage"); + widgets->mainDriverAutomaticallyChooseCheck = yon_gtk_builder_get_widget(widgets->builder, "mainDriverAutomaticallyChooseCheck"); + widgets->mainDriverFailsafeNvidiaLabel = yon_gtk_builder_get_widget(widgets->builder, "mainDriverFailsafeNvidiaLabel"); + widgets->mainDriverFailsafeAMDLabel = yon_gtk_builder_get_widget(widgets->builder, "mainDriverFailsafeAMDLabel"); + widgets->mainExtraFixGapCombo = yon_gtk_builder_get_widget(widgets->builder, "mainExtraFixGapCombo"); + widgets->mainDriverFailsafeNvidiaCombo = yon_gtk_builder_get_widget(widgets->builder, "mainDriverFailsafeNvidiaCombo"); + widgets->mainDriverFailsafeAMDCombo = yon_gtk_builder_get_widget(widgets->builder, "mainDriverFailsafeAMDCombo"); + widgets->mainDriverFrameLabel = yon_gtk_builder_get_widget(widgets->builder, "mainDriverFrameLabel"); + widgets->monitorConfigurationMethodLabel = yon_gtk_builder_get_widget(widgets->builder, "monitorConfigurationMethodLabel"); + widgets->monitorConfigurationMethodCombo = yon_gtk_builder_get_widget(widgets->builder, "monitorConfigurationMethodCombo"); + widgets->mainMonitorVisualConfigurationBox = yon_gtk_builder_get_widget(widgets->builder, "mainMonitorVisualConfigurationBox"); + widgets->mainMonitorConfigurationBox = yon_gtk_builder_get_widget(widgets->builder, "mainMonitorConfigurationBox"); + widgets->mainMonitorConfigurationFrameLabel = yon_gtk_builder_get_widget(widgets->builder, "mainMonitorConfigurationFrameLabel"); + widgets->mainHybridGraphicsDiscreteLabel = yon_gtk_builder_get_widget(widgets->builder, "mainHybridGraphicsDiscreteLabel"); + widgets->mainHybridGraphicsDiscreteCheck = yon_gtk_builder_get_widget(widgets->builder, "mainHybridGraphicsDiscreteCheck"); + widgets->mainHybridGraphicsFrameLabel = yon_gtk_builder_get_widget(widgets->builder, "mainHybridGraphicsFrameLabel"); + widgets->mainExtraLaunchOptirunCheck = yon_gtk_builder_get_widget(widgets->builder, "mainExtraLaunchOptirunCheck"); + widgets->mainExtraLaunchPrismusunCheck = yon_gtk_builder_get_widget(widgets->builder, "mainExtraLaunchPrismusunCheck"); + widgets->mainExtraFixGapLabel = yon_gtk_builder_get_widget(widgets->builder, "mainExtraFixGapLabel"); + widgets->mainExtraLaunchOptirunEntry = yon_gtk_builder_get_widget(widgets->builder, "mainExtraLaunchOptirunEntry"); + widgets->mainExtraLaunchPrismusunEntry = yon_gtk_builder_get_widget(widgets->builder, "mainExtraLaunchPrismusunEntry"); + widgets->mainExtraFixGapLabelCombo = yon_gtk_builder_get_widget(widgets->builder, "mainExtraFixGapLabelCombo"); + widgets->mainExtraLaunchThroughButton = yon_gtk_builder_get_widget(widgets->builder, "mainExtraLaunchThroughButton"); + widgets->mainExtraFrameLabel = yon_gtk_builder_get_widget(widgets->builder, "mainExtraFrameLabel"); + widgets->mainHeaderTitleLabel = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderTitleLabel"); + widgets->mainHeaderLoadButton = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderLoadButton"); + widgets->mainHeaderConfigLoadLabel = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderConfigLoadLabel"); + widgets->mainHeaderSaveConfigurationLabel = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderSaveConfigurationLabel"); + widgets->mainHeaderSaveButton = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderSaveButton"); + widgets->mainHeaderSettingsButton = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderSettingsButton"); + widgets->mainHeaderLoadGlobalMenuItem = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderLoadGlobalMenuItem"); + widgets->mainHeaderLoadLocalMenuItem = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderLoadLocalMenuItem"); + widgets->mainHeaderSaveGlobalLocalMenuItem = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderSaveGlobalLocalMenuItem"); + widgets->mainHeaderSaveGlobalMenuItem = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderSaveGlobalMenuItem"); + widgets->mainHeaderSaveLocalMenuItem = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderSaveLocalMenuItem"); + widgets->mainHeaderSettingsDocumentationMenuItem = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderSettingsDocumentationMenuItem"); + widgets->mainHeaderSettingsAboutMenuItem = yon_gtk_builder_get_widget(widgets->builder, "mainHeaderSettingsAboutMenuItem"); + widgets->mainStatusBox = yon_gtk_builder_get_widget(widgets->builder, "mainStatusBox"); + widgets->mainStatusIcon = yon_gtk_builder_get_widget(widgets->builder, "mainStatusIcon"); + widgets->mainStatusLabel = yon_gtk_builder_get_widget(widgets->builder, "mainStatusLabel"); + widgets->templateMonitorConfigurationBox = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationBox"); + widgets->templateMonitorConfigurationMonitorLabel = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationMonitorLabel"); + widgets->templateMonitorConfigurationResolutionLabel = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationResolutionLabel"); + widgets->templateMonitorConfigurationResolutionCombo = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationResolutionCombo"); + widgets->templateMonitorConfigurationFrequencyLabel = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationFrequencyLabel"); + widgets->templateMonitorConfigurationFrequencyCombo = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationFrequencyCombo"); + widgets->templateMonitorConfigurationRotationLabel = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationRotationLabel"); + widgets->templateMonitorConfigurationRotationCombo = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationRotationCombo"); + widgets->templateMonitorConfigurationMainRadio = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationMainRadio"); + widgets->templateMonitorConfigurationParameterLineCheck = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationParameterLineCheck"); + widgets->templateMonitorConfigurationParameterLineEntry = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationParameterLineEntry"); + widgets->templateMonitorConfigurationDoNotSwitchOffLabel = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationDoNotSwitchOffLabel"); + widgets->templateMonitorConfigurationDoNotSwitchOffCheck = yon_gtk_builder_get_widget(widgets->builder, "templateMonitorConfigurationDoNotSwitchOffCheck"); + + videoconfig.list = GTK_LIST_STORE(gtk_builder_get_object(widgets-> builder, "liststore6")); 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); @@ -365,82 +1240,91 @@ void yon_setup_widgets(widgets_dict *widgets){ 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->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); + g_signal_connect(G_OBJECT(widgets->mainHeaderSettingsDocumentationMenuItem), "activate", G_CALLBACK(on_about), NULL); + + g_signal_connect(G_OBJECT(widgets->mainHeaderLoadGlobalMenuItem), "activate", G_CALLBACK(on_configuration_load_global), widgets); + g_signal_connect(G_OBJECT(widgets->mainHeaderLoadLocalMenuItem), "activate", G_CALLBACK(on_configuration_load_local), widgets); - 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: ")); - gtk_label_set_text(GTK_LABEL(widgets->mainDriverFailsafeAMDLabel),_("Failsafe driver AMD/ATI: ")); - gtk_label_set_text(GTK_LABEL(widgets->mainDriverFrameLabel),_("Driver")); + g_signal_connect(G_OBJECT(widgets->mainHeaderSaveGlobalLocalMenuItem), "activate", G_CALLBACK(on_configuration_save_local_global), widgets); + g_signal_connect(G_OBJECT(widgets->mainHeaderSaveGlobalMenuItem), "activate", G_CALLBACK(on_configuration_save_global), widgets); + g_signal_connect(G_OBJECT(widgets->mainHeaderSaveLocalMenuItem), "activate", G_CALLBACK(on_configuration_save_local), widgets); + + 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->mainDriverFailsafeNvidiaLabel), _("Failsafe driver nVidia: ")); + gtk_label_set_text(GTK_LABEL(widgets->mainDriverFailsafeAMDLabel), _("Failsafe driver AMD/ATI: ")); + gtk_label_set_text(GTK_LABEL(widgets->mainDriverFrameLabel), _("Driver")); // gtk_label_set_text(GTK_LABEL(widgets->monitorConfigurationMethodLabel),_("Configuration method")); - gtk_label_set_text(GTK_LABEL(widgets->mainMonitorConfigurationFrameLabel),_("Monitor configuration")); - gtk_label_set_text(GTK_LABEL(widgets->mainHybridGraphicsFrameLabel),_("Hybrid graphics")); - gtk_label_set_text(GTK_LABEL(widgets->mainExtraFixGapLabel),_("Fix frame gap (nVidia)")); - gtk_label_set_text(GTK_LABEL(widgets->mainExtraFrameLabel),_("Extra")); - gtk_label_set_text(GTK_LABEL(widgets->mainHeaderTitleLabel),_("UBlinux Video Configuration")); - gtk_label_set_text(GTK_LABEL(widgets->mainHeaderConfigLoadLabel),_("Load")); - gtk_label_set_text(GTK_LABEL(widgets->mainHeaderSaveConfigurationLabel),_("Save")); - - gtk_button_set_label(GTK_BUTTON(widgets->mainHybridGraphicsDiscreteCheck),_("On")); - gtk_button_set_label(GTK_BUTTON(widgets->mainDriverAutomaticallyChooseCheck),_("Automatically choose and use driver")); - gtk_button_set_label(GTK_BUTTON(widgets->mainExtraLaunchOptirunCheck),_("Launch programms through optirun (nVidia): ")); - gtk_button_set_label(GTK_BUTTON(widgets->mainExtraLaunchPrismusunCheck),_("Launch programs through primusun (nVidia): ")); - gtk_button_set_label(GTK_BUTTON(widgets->mainHybridGraphicsDiscreteCheck),_("discrete video only (AMD/ATI)")); - - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderLoadGlobalMenuItem),_("Load from global configuration")); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderLoadLocalMenuItem),_("Load from local configuration")); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSaveGlobalLocalMenuItem),_("Save to global an local configuration")); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSaveGlobalMenuItem),_("Save to global configuration")); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSaveLocalMenuItem),_("Save to local configuration")); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSettingsDocumentationMenuItem),_("Documentation")); - gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSettingsAboutMenuItem),_("About")); + gtk_label_set_text(GTK_LABEL(widgets->mainMonitorConfigurationFrameLabel), _("Monitor configuration")); + gtk_label_set_text(GTK_LABEL(widgets->mainHybridGraphicsFrameLabel), _("Hybrid graphics")); + gtk_label_set_text(GTK_LABEL(widgets->mainExtraFixGapLabel), _("Fix frame gap (nVidia)")); + gtk_label_set_text(GTK_LABEL(widgets->mainExtraFrameLabel), _("Extra")); + gtk_label_set_text(GTK_LABEL(widgets->mainHeaderTitleLabel), _("UBlinux Video Configuration")); + gtk_label_set_text(GTK_LABEL(widgets->mainHeaderConfigLoadLabel), _("Load")); + gtk_label_set_text(GTK_LABEL(widgets->mainHeaderSaveConfigurationLabel), _("Save")); + gtk_button_set_label(GTK_BUTTON(widgets->mainHybridGraphicsDiscreteCheck), _("On")); + gtk_button_set_label(GTK_BUTTON(widgets->mainDriverAutomaticallyChooseCheck), _("Automatically choose and use driver")); + gtk_button_set_label(GTK_BUTTON(widgets->mainExtraLaunchOptirunCheck), _("Launch programms through optirun (nVidia): ")); + gtk_button_set_label(GTK_BUTTON(widgets->mainExtraLaunchPrismusunCheck), _("Launch programs through primusun (nVidia): ")); + gtk_button_set_label(GTK_BUTTON(widgets->mainHybridGraphicsDiscreteCheck), _("discrete video only (AMD/ATI)")); + + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderLoadGlobalMenuItem), _("Load from global configuration")); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderLoadLocalMenuItem), _("Load from local configuration")); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSaveGlobalLocalMenuItem), _("Save to global an local configuration")); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSaveGlobalMenuItem), _("Save to global configuration")); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSaveLocalMenuItem), _("Save to local configuration")); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSettingsDocumentationMenuItem), _("Documentation")); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->mainHeaderSettingsAboutMenuItem), _("About")); // gtk_button_set_label(GTK_BUTTON(widgets->mainExtraLaunchThroughButton),_("Change")); - yon_ubl_header_setup(widgets->mainHeadOverlay,widgets->headBox,widgets->mainHeadBackgroundImage, banner_path); + yon_ubl_header_setup(widgets->mainHeadOverlay, widgets->headBox, widgets->mainHeadBackgroundImage, banner_path); // gtk_overlay_add_overlay(GTK_OVERLAY(widgets->mainHeadOverlay),widgets->headBox); + yon_monitor_view_setup(widgets->mainMonitorVisualConfigurationBox); + yon_monitor_view_update(); + videoconfig.status_render.icon=widgets->mainStatusIcon; + videoconfig.status_render.label=widgets->mainStatusLabel; + videoconfig.status_render.box=widgets->mainStatusBox; // gtk_image_set_from_file(GTK_IMAGE(widgets->mainHeadBackgroundImage),banner_path); - MonitorSettings *monitors = yon_setup_monitor_settings(); - videoconfig.monitors=yon_dictionary_pack_monitors(monitors,yon_check_for_monitors()); - widgets->overlays=yon_dictionary_pack_overlays(monitors,yon_check_for_monitors()); - yon_dictionary_gtk_pack_start_multiple_widgets(widgets->overlays,widgets->mainMonitorVisualConfigurationBox,0,0,0); + // MonitorSettings *monitors = yon_setup_monitor_settings(); + // videoconfig.monitors=yon_dictionary_pack_monitors(monitors,yon_check_for_monitors()); + // widgets->overlays = yon_dictionary_pack_overlays(monitors); + // yon_dictionary_gtk_pack_start_multiple_widgets(widgets->overlays, widgets->mainMonitorVisualConfigurationBox, 0, 0, 0); // yon_dictionary_gtk_pack_start_multiple_widgets(widgets->monitors,widgets->mainMonitorConfigurationBox,0,0,0); - } -int main(int argc, char *argv[]){ +int main(int argc, char *argv[]) +{ - local=setlocale(LC_ALL, ""); - textdomain (LocaleName); + local = setlocale(LC_ALL, ""); + textdomain(LocaleName); gtk_init(&argc, &argv); GError error; - // xfconf_init (&error); - // display_channel = xfconf_channel_new ("displays"); - videoconfig.applist=yon_apps_scan_and_parse_desktops(&videoconfig.appsize); - yon_setup_config(); + yon_setup_config(load_drivers_local_command); widgets_dict widgets; yon_setup_widgets(&widgets); + yon_gtk_list_store_fill_with_proprietaries(videoconfig.list); 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); - GtkCssProvider *css=gtk_css_provider_new(); - gtk_css_provider_load_from_path(css,CssPath,NULL); + // yon_fill_ui(&widgets); + yon_ubl_status_box_render(widgets.mainStatusBox, widgets.mainStatusIcon, widgets.mainStatusLabel, _("Configuration has been loaded"), BACKGROUND_IMAGE_SUCCESS_TYPE); + on_config_fill_interface(&widgets); + yon_monitor_set_resolutions(); + 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_STYLE_PROVIDER(css), + -1); gtk_main(); return 0; } \ No newline at end of file diff --git a/source/ubl-settings-video.h b/source/ubl-settings-video.h index 3f34972..f286018 100644 --- a/source/ubl-settings-video.h +++ b/source/ubl-settings-video.h @@ -8,15 +8,16 @@ #include #include #include "ubl-utils.h" +#include "ubl-settings-video-strings.h" #ifndef UBL_SETINGS_VIDEO_H #define UBL_SETINGS_VIDEO_H #define icon_name "com.ublinux.ubl-settings-video" -#define banner_path "/usr/share/ubl-settings-video/ui/ubl-settings-video-banner.png" +#define banner_path "/usr/share/ubl-settings-video/images/ubl-settings-video-banner.png" #define glade_path "/usr/share/ubl-settings-video/ui/ubl-settings-video.glade" -#define LocalePath "/usr/share/locale" +#define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-video" #define CssPath "/usr/share/ubl-settings-video/css/ubl-settings-video.css" #define StatusLoadGlobalFailed _("Failed to load global configuration") @@ -25,54 +26,112 @@ #define StatusSaveGlobalFailed _("Saving to global configuration Succeeded") #define StatusSaveLocalFailed _("Saving to local configuration Succeeded") -#define get_ports_command "xrandr |grep -E \"^[A-Z0-9]* connected\" |cut -d' ' -f1" +#define get_ports_command "xrandr |grep -E \"*connected\" |cut -d' ' -f1" + +#define get_resolutions_command "xrandr |grep -noP \"\\d+x+\\d+\"" +#define get_resolution_ports_command "xrandr |grep -nwP \"connected\" |grep -oE \"[0-9a-zA-Z:]{1,10} connected\" |grep -oE \"[0-9a-zA-Z:]{1,10} \"" + +#define get_proprietary_drivers_command "cut -d, -f1- /usr/share/ubl-settings-video/csv/video-drivers.csv | grep -E \"-\"" + +#define get_resolutions_supportable_command "cut -d, -f1- /usr/share/ubl-settings-video/csv/resolutions.csv |sed 's/,/ /g'" + +#define get_frequences_command "xrandr |grep -v -n \"[a-z][a-z]\" |sed 's/ * / /g' |cut -d' ' -f1,3-" #define load_drivers_command "/usr/bin/ubconfig --default --source " #define load_drivers_global_command "/usr/bin/ubconfig --default --source global get video FAILSAFENVIDIA FAILSAFEATI OPTIRUN PRIMUSRUN " -#define save_drivers_global_command "/usr/bin/ubconfig --target global set video FAILSAFENVIDIA=%s FAILSAFEATI=%s OPTIRUN=%s PRIMUSRUN=%s " +#define save_drivers_global_command "/usr/bin/ubconfig --target global set video " #define load_drivers_local_command "/usr/bin/ubconfig --default --source system get video FAILSAFENVIDIA FAILSAFEATI OPTIRUN PRIMUSRUN " -#define save_drivers_local_command "/usr/bin/ubconfig --target system set video FAILSAFENVIDIA=%s FAILSAFEATI=%s OPTIRUN=%s PRIMUSRUN=%s " +#define save_drivers_local_command "pkexec /usr/bin/ubconfig --target system set video " + +#define remove_drivers_global_command "/usr/bin/ubconfig --target system remove video " + +#define remove_drivers_local_command "/usr/bin/ubconfig --target global remove video " + +#define install_proprietary_command "pkexec pacman -Sy --noconfirm " + +#define delete_proprietary_command "pkexec pacman -R --noconfirm " + +#define get_info_proprietary_command "pamac-manager --details=" + +#define get_version_proprietary_command "grep \"VERSION_ID=\" /etc/os-release | cut -d= -f2" + +#define XORG_MONITOR(port) yon_char_get_augumented(" XORG_MONITOR[",yon_char_get_augumented(port,"] ")) + char *local; -typedef char* string; +typedef char *string; string version_application = "1.0"; +#define _(String) gettext(String) + +typedef dictionary* monitor_config; +typedef dictionary* proprietary_config; +typedef dictionary* monitor_view; + -#define _(String) gettext(String) typedef struct { + config_str line; + int size; +} resolution_supported; + +typedef struct +{ + config_str loaded_config; + int configsize; int autoChooseDrivers; - dictionary *videoconfig; - dictionary *monitors; - char *proprietary; + monitor_view monitor_visuals; + monitor_config monitors; + proprietary_config proprietary; + dictionary *supported_resolutions; + GtkListStore *list; char *failsafenVidia; char *failsafeATI; int descreteOnly; char *optirun; char *primusrun; int gapfix; - int optiorprimus; - apps *applist; - int appsize; + config_str ports; + int portssize; + config_str resolutions; + int resolutionssize; + render_data status_render; } config; -typedef struct { + +typedef struct +{ int main; + int enable; + int position; + char *position_port; char *port; char *resolution; - char *resolutionCapabilities; + config_str resolutionCapabilities; char *frequency; - char *rotation; + int rotation; char *stringparameters; + int dpms; + int resolution_size; + int cvt; + int reduced; + int gtf; + int show_usupported; } monitorconfig; typedef struct { + GtkWidget *combo; + GtkWidget *tree; +} combo_tree; + +typedef struct +{ dictionary *monitors; dictionary *overlays; GtkBuilder *builder; @@ -143,42 +202,110 @@ typedef struct { GtkWidget *templateMonitorConfigurationParameterLineEntry; GtkWidget *templateMonitorConfigurationDoNotSwitchOffLabel; GtkWidget *templateMonitorConfigurationDoNotSwitchOffCheck; + + GtkWidget *proprietaryTreeView; + GtkWidget *proprietaryInfoButton; + GtkWidget *proprietaryDeleteButton; + GtkWidget *proprietaryInstallButton; + GtkTreeSelection *proprietaryTreeSelection; + GtkWidget *driversTreeView; + GtkWidget *driversInfoButton; + GtkWidget *driversDeleteButton; + GtkWidget *driversInstallButton; + GtkTreeSelection *driversTreeSelection; + + GtkTreeViewColumn *proprietartInstalledColumn; + GtkTreeViewColumn *ProprietaryPackageColumn; + GtkTreeViewColumn *ProprietaryDriverColumn; + GtkTreeViewColumn *ProprietaryDescriptionColumn; + GtkTreeViewColumn *ProprietarySupportedColumn; + + GtkTreeViewColumn *driverInstalledColumn; + GtkTreeViewColumn *driverPackageColumn; + GtkTreeViewColumn *driverDriverColumn; + GtkTreeViewColumn *driverDescriptionColumn; + GtkTreeViewColumn *driverSupportedColumn; } widgets_dict; -typedef struct { +typedef struct +{ GtkWidget *templateMonitorConfigurationWindow; + GtkWidget *mainMonitorConfigurationBox; GtkWidget *templateMonitorConfigurationBox; - GtkWidget *templateMonitorConfigurationMonitorLabel; + GtkWidget *templateMonitorConfigurationEnableCheck; + GtkWidget *templateMonitorConfigurationPortLabel; + GtkWidget *templateMonitorConfigurationPortCombo; + GtkWidget *templateMonitorConfigurationMainCheck; GtkWidget *templateMonitorConfigurationResolutionLabel; GtkWidget *templateMonitorConfigurationResolutionCombo; + GtkWidget *templateMonitorConfigurationShowUnsupportedCheck; GtkWidget *templateMonitorConfigurationFrequencyLabel; GtkWidget *templateMonitorConfigurationFrequencyCombo; - GtkWidget *templateMonitorConfigurationRotationCombo; GtkWidget *templateMonitorConfigurationRotationLabel; - GtkWidget *templateMonitorConfigurationMainRadio; + GtkWidget *templateMonitorConfigurationRotationCombo; + GtkWidget *templateMonitorConfigurationPositionLabel; + GtkWidget *templateMonitorConfigurationPositionPosCombo; + GtkWidget *templateMonitorConfigurationPositionPortCombo; + GtkWidget *templateMonitorConfigurationDoNotSwitchOffCheck; + GtkWidget *templateMonitorConfigurationModelineCVTCheck; + GtkWidget *templateMonitorConfigurationUseCVTReducedCheck; + GtkWidget *templateMonitorConfigurationModelineGTFCheck; GtkWidget *templateMonitorConfigurationParameterLineCheck; GtkWidget *templateMonitorConfigurationParameterLineEntry; - GtkWidget *templateMonitorConfigurationDoNotSwitchOffLabel; - GtkWidget *templateMonitorConfigurationDoNotSwitchOffCheck; GtkWidget *templateMonitorConfigurationCancelButton; GtkWidget *templateMonitorConfigurationSaveButton; + + dictionary *config; +} monitor_edit_window; +typedef struct { GtkWidget *templateMonitorscreenOverlay; + GtkWidget *templateMonitorImage; GtkWidget *templateMonitorInfoBox; GtkWidget *templateMonitorInfoNameLabel; GtkWidget *templateMonitorInfoResolutionLabel; + GtkWidget *templateMonitorDeleteButton; + GtkWidget *templateMonitorSwitchButton; GtkWidget *templateMonitorInfoConfigureButton; - dictionary *curconfig; -} MonitorSettings; + GtkWidget *templateMonitorInfoAddButton; + monitor_config config; +} monitor_window; +typedef struct +{ + GtkWidget *window; + GtkWidget *propriearyTreeView; + GtkTreeViewColumn *ProprietaryDriverColumn; + GtkTreeViewColumn *ProprietaryDescriptionColumn; + GtkListStore *list; + GtkWidget *ProprietaryCloseButton; + GtkWidget *ProprietaryAcceptButton; +} driver_window; -int yon_check_for_monitors(); -MonitorSettings *yon_setup_monitor_settings(); -dictionary *yon_dictionary_pack_monitors(MonitorSettings *monitors, int size); -dictionary *yon_dictionary_pack_overlays(MonitorSettings *monitors, int size); -void on_closed_configuration(GtkWidget *self, MonitorSettings *monitors); -void on_save_configuration(GtkWidget self, MonitorSettings *monitors); +// void on_closed_configuration(GtkWidget *self, MonitorSettings *monitors); +// void on_save_configuration(GtkWidget self, MonitorSettings *monitors); +void yon_parse_monitor(); +void on_config_fill_interface(widgets_dict *widgets); +void yon_update_config(widgets_dict *widgets); +void on_configuration_save_global(GtkWidget *self, widgets_dict *widgets); +void on_configuration_save__local_global(GtkWidget *self, widgets_dict *widgets); +void on_configuration_save__local(GtkWidget *self, widgets_dict *widgets); +void yon_config_monitor_string_parse(char *parameters, int *size); +int yon_char_get_if_resolution(char *parsed_string); +void yon_monitor_set_resolutions(); +monitor_config yon_monitor_config_new(char *port); +void yon_monitor_config_update(monitorconfig* monitor, char *port, char *config_string); +void yon_monitor_view_new(monitor_config monitor); +// void on_confugure_monitor_settings(GtkWidget *self, MonitorSettings *settings); +void yon_monitor_view_draw_all(GtkWidget *cnt); +void on_monitor_configure(GtkWidget *self,monitor_window *window); +void on_monitor_add(GtkWidget *self,monitor_window *window); +void on_monitor_switch(GtkWidget *self,monitor_window *window); +void on_monitor_delete(GtkWidget *self,monitor_view windowd); +void yon_monitor_view_update(); +void yon_monitor_window_update(monitor_edit_window *window); +char *yon_monitor_make_string(monitorconfig* config); #endif \ No newline at end of file diff --git a/source/ubl-utils.c b/source/ubl-utils.c index d2088df..fd78093 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1,14 +1,16 @@ #include "ubl-utils.h" #ifndef UBL_UTILS -typedef enum { +typedef enum +{ DICTIONARY_ACTION_WIDGETS_TYPE, DICTIONARY_IVGRAPHICALS_TYPE, DICTIONARY_OTHER_TYPE } DICT_TYPE; -typedef struct dictionary { +typedef struct dictionary +{ char *key; void *data; struct dictionary *next; @@ -17,23 +19,26 @@ typedef struct dictionary { DICT_TYPE data_type; } dictionary; -typedef struct apps{ - char *Name; - int Type; - char *Categories; - char *Exec; - char *Icon; - int Pluggable; - int DualPluggable; - } apps; - -typedef struct { +typedef struct apps +{ + char *Name; + int Type; + char *Categories; + char *Exec; + char *Icon; + int Pluggable; + int DualPluggable; +} apps; + +typedef struct +{ char *command; int *exitcode; } thread_output; #ifdef __GTK_H__ -typedef struct IVGrapgicals{ +typedef struct IVGrapgicals +{ char *sectionName; char *categories; GtkListStore *LV; @@ -46,354 +51,543 @@ typedef struct IVGrapgicals{ #endif #endif - -//dictionary functions - -/** - * yon_dictionary_create_empty: - * Creates and returns empty dictionary -*/ -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; - dict->data_type=DICTIONARY_OTHER_TYPE; +// dictionary functions + +/**[EN] + * yon_dictionary_create_empty(): + * Creates and returns empty dictionary + */ +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; + dict->data_type = DICTIONARY_OTHER_TYPE; return dict; } -void yon_dictionary_switch_to_last(dictionary **dict){ - if ((*dict)->next!=NULL) - for ((*dict)=(*dict)->first;(*dict)->next!=NULL;(*dict)=(*dict)->next){} +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){ - targetdict=yon_dictionary_get_last(targetdict); - targetdict->next=yon_dictionary_create_empty(); - targetdict->next->prev=targetdict; - targetdict->next->first=targetdict->first; - targetdict->next->data_type=DICTIONARY_OTHER_TYPE; +dictionary *yon_dictionary_create_conneced(dictionary *targetdict) +{ + targetdict = yon_dictionary_get_last(targetdict); + targetdict->next = yon_dictionary_create_empty(); + targetdict->next->prev = targetdict; + targetdict->next->first = targetdict->first; + targetdict->next->data_type = DICTIONARY_OTHER_TYPE; return targetdict->next; } -dictionary *yon_dictionary_get_last(dictionary *dict){ - dictionary *dct=NULL; - for (dct=dict->first;dct->next!=NULL;dct=dct->next){} +dictionary *yon_dictionary_get_last(dictionary *dict) +{ + dictionary *dct = NULL; + for (dct = dict->first; dct->next != NULL; dct = dct->next) + { + } return dct; } -dictionary *yon_dictionary_switch_places(dictionary *dict,int aim){ - if (aim<0){ - if (dict->prev){ - if (dict->prev->prev){ - dictionary *next = dict->next,*prev=dict->prev,*preprev=prev->prev; - if (next){ - preprev->next=dict; - dict->prev=preprev; - dict->next=prev; - prev->prev=dict; - prev->next=next; - next->prev=prev; - } else { - preprev->next=dict; - dict->prev=preprev; - dict->next=prev; - prev->prev=dict; - prev->next=NULL; +dictionary *yon_dictionary_switch_places(dictionary *dict, int aim) +{ + if (aim < 0) + { + if (dict->prev) + { + if (dict->prev->prev) + { + dictionary *next = dict->next, *prev = dict->prev, *preprev = prev->prev; + if (next) + { + preprev->next = dict; + dict->prev = preprev; + dict->next = prev; + prev->prev = dict; + prev->next = next; + next->prev = prev; + } + else + { + preprev->next = dict; + dict->prev = preprev; + dict->next = prev; + prev->prev = dict; + prev->next = NULL; } return prev; - } else { - dictionary *next = dict->next,*prev=dict->prev; - if (next){ - yon_dictionary_make_first(dict); - dict->prev=NULL; - dict->next=prev; - prev->prev=dict; - prev->next=next; - next->prev=prev; - } else { - dict->prev=NULL; - dict->next=prev; - prev->prev=dict; - prev->next=NULL; } - return prev; + else + { + dictionary *next = dict->next, *prev = dict->prev; + if (next) + { + yon_dictionary_make_first(dict); + dict->prev = NULL; + dict->next = prev; + prev->prev = dict; + prev->next = next; + next->prev = prev; + } + else + { + dict->prev = NULL; + dict->next = prev; + prev->prev = dict; + prev->next = NULL; + } + return prev; } } - } else if (aim>0){ - if (dict->next){ - if (dict->next->next){ - dictionary *next = dict->next,*prev=dict->prev,*afnext=next->next; - if (prev){ - prev->next=next; - next->prev=prev; - next->next=dict; - dict->prev=next; - dict->next=afnext; - afnext->prev=dict; - } else { + } + else if (aim > 0) + { + if (dict->next) + { + if (dict->next->next) + { + dictionary *next = dict->next, *prev = dict->prev, *afnext = next->next; + if (prev) + { + prev->next = next; + next->prev = prev; + next->next = dict; + dict->prev = next; + dict->next = afnext; + afnext->prev = dict; + } + else + { yon_dictionary_make_first(next); - next->prev=NULL; - next->next=dict; - dict->prev=next; - dict->next=afnext; - afnext->prev=dict; + next->prev = NULL; + next->next = dict; + dict->prev = next; + dict->next = afnext; + afnext->prev = dict; } return next; - } else { - dictionary *next = dict->next,*prev=dict->prev; - if (prev){ - prev->next=next; - next->prev=prev; - next->next=dict; - dict->prev=next; - dict->next=NULL; - } else { - next->prev=NULL; - next->next=dict; - dict->prev=next; - dict->next=NULL; + } + else + { + dictionary *next = dict->next, *prev = dict->prev; + if (prev) + { + prev->next = next; + next->prev = prev; + next->next = dict; + dict->prev = next; + dict->next = NULL; + } + else + { + next->prev = NULL; + next->next = dict; + dict->prev = next; + dict->next = NULL; } } } } } -void yon_dictionary_make_first(dictionary *dict){ - for (dictionary *dct=dict->first;dct!=NULL;dct=dct->next){ - dct->first=dict; +void yon_dictionary_make_first(dictionary *dict) +{ + for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) + { + dct->first = dict; } } -void yon_dictionary_make_nth(dictionary *dict, int nth){ - dictionary *dct=dict->first; - for (int i=0;inext;} +void yon_dictionary_make_nth(dictionary *dict, int nth) +{ + dictionary *dct = dict->first; + for (int i = 0; i < nth; i++) + { + if (dct == NULL) + return; + else + dct = dct->next; + } yon_dictionary_rip(dict); - dictionary *prev=dct->prev; - prev->next=dict; - dict->prev=prev; - dict->next=dct; - dct->prev=dict; -} - -dictionary *yon_dictionary_create_with_data(char *key, void *data){ - dictionary *dct=yon_dictionary_create_empty(); - dct->key=yon_char_new(key); - dct->data=data; - dct->data_type=DICTIONARY_OTHER_TYPE; + dictionary *prev = dct->prev; + prev->next = dict; + dict->prev = prev; + dict->next = dct; + dct->prev = dict; +} + +dictionary *yon_dictionary_create_with_data(char *key, void *data) +{ + dictionary *dct = yon_dictionary_create_empty(); + dct->key = yon_char_new(key); + dct->data = data; + dct->data_type = DICTIONARY_OTHER_TYPE; return dct; } -dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data){ - dictionary *dct=yon_dictionary_create_conneced(dict); - dct->key=yon_char_new(key); - dct->data=data; - dct->data_type=DICTIONARY_OTHER_TYPE; +dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) +{ + dictionary *dct = yon_dictionary_create_conneced(dict); + dct->key = yon_char_new(key); + dct->data = data; + dct->data_type = DICTIONARY_OTHER_TYPE; return dct; } -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect){ - dictionary *dict=yon_dictionary_get_last(old); - dict->next=toconnect; - toconnect->prev=dict; - toconnect->first=dict->first; +dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) +{ + dictionary *dict = yon_dictionary_get_last(old); + dict->next = toconnect; + toconnect->prev = dict; + toconnect->first = dict->first; return toconnect; } -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; +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; } - -dictionary *yon_dictionary_rip(dictionary *dict){ - if (!dict->next){ - dictionary *prev=dict->prev; - if (prev){ - prev->next=NULL; - return prev; - } else return dict; +dictionary *yon_dictionary_rip(dictionary *dict) +{ + if (!dict->next) + { + dictionary *prev = dict->prev; + if (prev) + { + prev->next = NULL; + return prev; + } + else + return dict; } - else if (!dict->prev){ - dictionary *next=dict->next; - if (next){ + else if (!dict->prev) + { + dictionary *next = dict->next; + if (next) + { yon_dictionary_make_first(next); - next->prev=NULL; + next->prev = NULL; return next; } - else return dict; + else + return dict; } - else { - dictionary *next=dict->next, *prev=dict->prev; - next->prev=prev; - prev->next=next; + else + { + dictionary *next = dict->next, *prev = dict->prev; + next->prev = prev; + prev->next = next; return next; } } -dictionary *yon_dictionary_get_nth(dictionary *dict, int place){ - dict=dict->first; - int i=0; - for (i=0;inext) - dict=dict->next; - else break; - if (i==place) return dict; - else return NULL; +dictionary *yon_dictionary_get_nth(dictionary *dict, int place) +{ + if (dict){ + dict = dict->first; + int i = 0; + for (i = 0; i < place; i++) + if (dict->next) + dict = dict->next; + else + break; + if (i == place) + return dict; + else + return NULL; + } else return NULL; } -//char functions +// char functions -/** +/**[EN] + * * creates new char string by combining two char strings. -*/ -char *yon_char_get_augumented(char *source, char *append){ - if (source&&append){ - int size=strlen(source)+strlen(append)+1; - char *final=malloc(size); - memset(final,0,size); - if (strstr(source,"%%")) - sprintf(final,source,append); + */ +char *yon_char_get_augumented(char *source, char *append) +{ + if (source && append) + { + int size = strlen(source) + strlen(append) + 1; + char *final = malloc(size); + memset(final, 0, size); + if (strstr(source, "%%")) + sprintf(final, source, append); + else + sprintf(final, "%s%s", source, append); + return final; + } else - sprintf(final,"%s%s",source,append); - return final; - } else return NULL; } -/** +/**[EN] + * * creates new char string by copying another char. -*/ -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; + */ +char *yon_char_new(char *chr) +{ + if (chr){ + char *newchar = malloc(strlen(chr) + 1); + memset(newchar, 0, strlen(chr) + 1); + memcpy(newchar, chr, strlen(chr)); + return newchar; + } else + return NULL; } -/** +// char *yon_char_unite(char *source, ...) + +char *yon_char_unite(char *source, ...){ + va_list arglist; + char *new_char=NULL; + char *unite_char=NULL; + new_char=yon_char_new(source); + va_start(arglist,source); + unite_char = va_arg(arglist,char*); + while(unite_char){ + new_char = yon_char_get_augumented(new_char,unite_char); + unite_char = va_arg(arglist,char*); + } + va_end(arglist); + return new_char; +} + +/**[EN] + * * cuts source string by size length from startpos position. -*/ -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); + */ +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; } -/** +/**[EN] + * * divides source string in dividepos position, * returning left part of divided string and * inserting right part to source string. -*/ -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)); + */ +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; } -/** - * searches string dividepos in source string and divides it, +/**[EN] + * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) + * searches string [dividepos] in [source] string and divides it, * returning left part of divided string and - * inserting right part to source string. - * if delete_divider is 0, left part will contain delete_divider substring, else - * it will stay in right part. -*/ -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; + * inserting right part to [source] string. + * if [delete_divider] is 0, left part will contain [delete_divider] substring, else + * if [delete_divider] is 1 it will stay in right part, else + * if [delete_divider] is -1 it will be deleted from string. + * + * [RU] + * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) + * Ищет строку [dividepos] в строке [source] и делит её в этом месте, + * возвращая левую часть разделённой строки и устанавливает в [source] правую часть. + * Если [delete_divider] равен 0, [dividepos] останется в левой строке, иначе + * если [delete_divider] равен 1, [dividepos] останется в правой строке, иначе + * если [delete_divider] равен -1, [dividepos] удаляется из строки. + */ +char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) +{ + if (source&÷pos){ + char *cut = strstr(source, dividepos); + if (cut) + { + int leng = strlen(source) - strlen(cut); + cut = yon_char_divide(source, leng); + return cut; + } + else + return source; + } } -/** - * converts int to char. +/**[EN] + * char *yon_char_from_int(int int_to_convert) + * converts int to char*. + * + * [RU] + * char *yon_char_from_int(int int_to_convert) + * Конвертирует int в char* + */ +char *yon_char_from_int(int int_to_convert) +{ + int i = 1; + float convert_check = (float)int_to_convert; + for (i = 1; convert_check > 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = malloc(i * sizeof(char) + 1); + sprintf(ch, "%d", int_to_convert); + return ch; +} + +/**[EN] + * char **yon_char_parse(char *parameters, int *size, char *divider) + * Parses string [parameters], divided by [divider], + * then returns parsed string array and sets [size] to + * size of returned array */ -char *yon_char_from_int(int int_to_convert){ +char **yon_char_parse(char *parameters, int *size, char *divider){ + char **string=NULL; int i=1; - float convert_check=(float)int_to_convert; - for (i=1;convert_check>10;i++){ - convert_check=convert_check/10; + string=malloc(sizeof(char*)); + char *paramline=yon_char_new(parameters); + char *param; + while ((param=yon_char_divide_search(paramline,divider,1))){ + string=realloc(string,sizeof(char*)*i); + string[i-1]=yon_char_new(param); + i++; + if (strcmp(param,paramline)==0) break; } - char *ch=malloc(i*sizeof(char)+1); - sprintf(ch,"%d",int_to_convert); - return ch; + string=realloc(string,sizeof(char*)*i); + string[i-1]=yon_char_new(paramline); + i++; + printf("%d\n",i); + *size=i-1; + return string; + } +char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete){ + char **new_char_parsed=NULL; + new_char_parsed=malloc(sizeof(char*)*(*size)-2); + int sz=0; + for (int i=0;i<*size-2;i++){ + if (i!=item_to_delete){ + new_char_parsed[i]=yon_char_new(char_string[i]); + sz++; + } + + } + *size=sz; + return new_char_parsed; +} + +/**[EN] + * + * Checks if [parameters] string array of length [size] + * has [param] element; +*/ +int yon_char_parsed_check_exist(char **parameters, int size, char *param){ + + for (int i=0;id_name); - file=fopen(path,"r"); - if (strlen(de->d_name)>9) + char *path = yon_char_get_augumented(DesktopPath, de->d_name); + file = fopen(path, "r"); + if (strlen(de->d_name) > 9) { - char *extension=strstr(path,"."); - if (extension!=NULL) + char *extension = strstr(path, "."); + if (extension != NULL) { - if (strcmp(extension,".desktop")==0) + if (strcmp(extension, ".desktop") == 0) { apps tempapp; - GKeyFile *gfile=g_key_file_new(); - GError *err=NULL; - 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",&err); - if (err){ - printf("%s\n",err->message); + GKeyFile *gfile = g_key_file_new(); + GError *err = NULL; + 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", &err); + if (err) + { + printf("%s\n", err->message); } - 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 (g_key_file_get_boolean(gfile,"Desktop Entry", "X-UBL-SettingsManager-Hidden",NULL)==0) - 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; + 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 (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) + 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; + } + 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++; } } @@ -401,94 +595,175 @@ apps *yon_apps_scan_and_parse_desktops(int *sizef){ } } } - *sizef=size; + *sizef = size; return applist; }; - -void yon_apps_sort(apps *applist,int size){ +void yon_apps_sort(apps *applist, int size) +{ apps tmp; - if (size>2) + if (size > 2) { - for (int i=1;i0){ + *str_len = i; + return output_strings; + } else{ + *str_len=-1; + return NULL; } } -int yon_config_save(char *command){ - FILE *output=popen(command,"r"); + +/**[EN] + * int yon_config_save(char *command) + * Saves config with [command] + * [RU] +*/ +int yon_config_save(char *command) +{ + FILE *output = popen(command, "r"); return 1; } -//terminal-using functions +/**[EN] + * char *yon_config_get_parameter(config parameters, int size, char *param) + * Gets parameter from parameter list; + * + * [RU] +*/ +char *yon_config_get_parameter(config_str parameters, int size, char *param) +{ + if (param[0]==' ') + yon_char_divide_search(param," ",-1); + param=yon_char_divide_search(yon_char_new(param)," ",-1); + + char *str = NULL; + for (int j = 0; j < size; j++) + { + char *name = yon_char_divide_search(yon_char_new(parameters[j]), "=", 1); + if (name) + { + if (strcmp(name, param) == 0) + { + str = yon_char_divide_search(yon_char_new(parameters[j]), "\n", 1); + if (strcmp(str, "") != 0 && strcmp(str, "(null)") != 0) + return str; + else + return NULL; + } + } + } + return NULL; +} +/**[EN] + * Parses, modifies and connects string to use it as one of arguments, + * sended to ubconfig. + * + * [RU] + */ +char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider){ + char *final=""; + int done=0; + char *cur=yon_char_new(parameter_string); + yon_char_divide_search(cur,"=",1); + char *cur_param=NULL; + while (cur_param=yon_char_divide_search(cur,",",1)){ + if (done==0){ + final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"="), yon_char_get_augumented(cur_param,", "))); + done=1; + } else { + final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"+="), yon_char_get_augumented(cur_param,", "))); + } + } + if (cur&&strcmp(cur,"")!=0) + if (done==0) + final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"="), yon_char_get_augumented(cur,", "))); + else + final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"+="), yon_char_get_augumented(cur,", "))); + return final; +} +// terminal-using functions -int yon_launch_app(char *name){ - char *path=name; - thread_output *thread=malloc(sizeof(thread_output)); - thread->command=path; - thread->exitcode=malloc(sizeof(int)); +int yon_launch_app(char *name) +{ + char *path = name; + thread_output *thread = malloc(sizeof(thread_output)); + thread->command = path; + thread->exitcode = malloc(sizeof(int)); pthread_t thread_id; - pthread_create(&thread_id, NULL, (void*)yon_launch, thread); + pthread_create(&thread_id, NULL, (void *)yon_launch, thread); return *thread->exitcode; }; - -int yon_launch_app_with_arguments(char *name, char *args){ - char *path=yon_char_get_augumented("/usr/bin/",name); - path=yon_char_get_augumented(path," "); - path=yon_char_get_augumented(path,args); +int yon_launch_app_with_arguments(char *name, char *args) +{ + char *path = yon_char_get_augumented("/usr/bin/", name); + path = yon_char_get_augumented(path, " "); + path = yon_char_get_augumented(path, args); pthread_t thread_id; - thread_output *thread=malloc(sizeof(thread_output)); - thread->command=path; - thread->exitcode=malloc(sizeof(int)); - pthread_create(&thread_id, NULL, (void*)yon_launch, thread); + thread_output *thread = malloc(sizeof(thread_output)); + thread->command = path; + thread->exitcode = malloc(sizeof(int)); + pthread_create(&thread_id, NULL, (void *)yon_launch, thread); return *thread->exitcode; }; - -int yon_launch(thread_output *thread){ - int a=0; - a=system(thread->command); - *thread->exitcode=a; +int yon_launch(thread_output *thread) +{ + int a = 0; + a = system(thread->command); + *thread->exitcode = a; return *thread->exitcode; } - -//Gtk functions +// Gtk functions #ifdef __GTK_H__ @@ -500,7 +775,7 @@ int yon_launch(thread_output *thread){ // GtkWidget *PackBox=gtk_box_new(GTK_ORIENTATION_VERTICAL,5); // GtkWidget *ButtonsBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); // GtkWidget *ButtonsPlaceBox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - + // GtkWidget *CancelButton=gtk_button_new_with_label("Cancel"); // GtkWidget *AcceptButton=gtk_button_new_with_label("Accept"); // gtk_container_add(GTK_CONTAINER(chooserWindow),Box); @@ -525,7 +800,7 @@ int yon_launch(thread_output *thread){ * - templateAppsPack - setted up container for every template widget; * - templateAppsImage - image for rendering section image; * - templateAppsLabel - label for rendering section name; -*/ + */ // dictionary *yon_iv_segment_create(dictionary *connect_to, char *name, char *categories, char *segment_icon_name){ // IVSegment *segment=malloc(sizeof(IVSegment)); // segment->name=name; @@ -570,7 +845,7 @@ int yon_launch(thread_output *thread){ // gtk_box_pack_start(GTK_BOX(Box),((IVSegment*)nd->data)->Expander,0,0,0); // } // return Box; - + // } // GtkWidget *yon_gtk_socket_create_new_with_connect(GtkWidget *container, gpointer data){ @@ -583,38 +858,76 @@ int yon_launch(thread_output *thread){ // return socket; // }; -int yon_dictionary_gtk_pack_start_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding){ - for (dictionary *dct=dict->first; dct!=NULL;dct=dct->next){ - gtk_box_pack_start(GTK_BOX(destination),(GtkWidget*)dct->data,expand,fill,padding); - } +int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ + if (combo&¶meters){ + for (int i=0;ifirst; dct != NULL; dct = dct->next) + { + gtk_box_pack_start(GTK_BOX(destination), (GtkWidget *)dct->data, expand, fill, padding); + } return 1; + }else return 0; } -int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding){ - for (dictionary *dct=dict->first; dct!=NULL;dct=dct->next){ - gtk_box_pack_end(GTK_BOX(destination),(GtkWidget*)dct->data,expand,fill,padding); +int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding) +{ + for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) + { + gtk_box_pack_end(GTK_BOX(destination), (GtkWidget *)dct->data, expand, fill, padding); } return 1; } -void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path){ - gtk_overlay_add_overlay(GTK_OVERLAY(Overlay),Head); - gtk_image_set_from_file(GTK_IMAGE(Image),image_path); +void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) +{ + gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); + gtk_image_set_from_file(GTK_IMAGE(Image), image_path); } -void _yon_ubl_status_box_render(GtkWidget *StatusBox, GtkWidget *StatusIcon, GtkWidget *StatusLabel, char *IconName, char* StatusText, BACKGROUND_IMAGE_TYPE BackgroundClass){ - GtkIconTheme *ictheme=gtk_icon_theme_get_default(); - GError *err=NULL; - gtk_image_set_from_pixbuf(GTK_IMAGE(StatusIcon),gtk_icon_theme_load_icon_for_scale(ictheme,IconName,25,1,GTK_ICON_LOOKUP_FORCE_SIZE,&err)); - if (err){ - printf("%s\n",err->message); +void _yon_ubl_status_box_render(GtkWidget *StatusBox, GtkWidget *StatusIcon, GtkWidget *StatusLabel, char *StatusText, BACKGROUND_IMAGE_TYPE BackgroundClass) +{ + GtkIconTheme *ictheme = gtk_icon_theme_get_default(); + GError *err = NULL; + if (err) + { + printf("%s\n", err->message); g_error_free(err); } - gtk_label_set_text(GTK_LABEL(StatusLabel),StatusText); - if (BackgroundClass==BACKGROUND_IMAGE_SUCCESS_TYPE){ - gtk_style_context_add_class(gtk_widget_get_style_context(StatusBox),"boxInfoMessOK"); - } else if (BackgroundClass==BACKGROUND_IMAGE_FAIL_TYPE){ - gtk_style_context_add_class(gtk_widget_get_style_context(StatusBox),"boxInfoMessError"); + gtk_label_set_text(GTK_LABEL(StatusLabel), StatusText); + if (BackgroundClass == BACKGROUND_IMAGE_SUCCESS_TYPE) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(StatusBox), "boxInfoMessError"); + gtk_style_context_add_class(gtk_widget_get_style_context(StatusBox), "boxInfoMessOK"); + gtk_image_set_from_pixbuf(GTK_IMAGE(StatusIcon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); + } + else if (BackgroundClass == BACKGROUND_IMAGE_FAIL_TYPE) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(StatusBox), "boxInfoMessOK"); + gtk_style_context_add_class(gtk_widget_get_style_context(StatusBox), "boxInfoMessError"); + gtk_image_set_from_pixbuf(GTK_IMAGE(StatusIcon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); } } #endif \ No newline at end of file diff --git a/source/ubl-utils.h b/source/ubl-utils.h index d0c1049..eea989e 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -12,43 +13,35 @@ #define DesktopPath "/usr/share/applications/" -#define for_dictionaries(obj,obj1) for(obj=obj1->first;obj!=NULL;obj=obj->next) +#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 new(type) malloc(sizeof(type)) +#define new_arr(type,size) malloc(sizeof(type)*size) -#define yon_ubl_set_config_save_data_pointer(command) config_commands.config_save_data=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) +#define yon_ubl_load_global_config(command, size_pointer) yon_config_load(command, size_pointer) +#define yon_ubl_load_local_config(command, size_pointer) yon_config_load(command, size_pointer) +#define yon_ubl_save_global_config(command) yon_config_save(command) +#define yon_ubl_save_local_config(command) yon_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, +typedef enum +{ + #ifdef __GTK_H__ + DICTIONARY_GTK_WIDGETS_TYPE, + #endif DICTIONARY_OTHER_TYPE } DICT_TYPE; - -typedef struct { +typedef struct +{ char *command; int *exitcode; } thread_output; -typedef struct dictionary { +typedef struct dictionary +{ char *key; void *data; struct dictionary *next; @@ -57,26 +50,32 @@ typedef struct dictionary { DICT_TYPE data_type; } dictionary; -typedef struct apps{ - char *Name; - int Type; - char *Categories; - char *Exec; - char *Icon; - int Pluggable; - int DualPluggable; - } apps; +typedef struct apps +{ + char *Name; + int Type; + char *Categories; + char *Exec; + char *Icon; + int Pluggable; + int DualPluggable; +} apps; + +typedef char** config_str; +// dictionary functions -//dictionary functions +#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) +#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) if (!dict) dict=yon_dictionary_create_with_data(key,data); \ + else dict=yon_dictionary_create_with_data_connected(dict,key,data); dictionary *yon_dictionary_create_empty(); -dictionary * yon_dictionary_create_conneced(dictionary *targetdict); +dictionary *yon_dictionary_create_conneced(dictionary *targetdict); dictionary *yon_dictionary_get_last(dictionary *dict); -dictionary *yon_dictionary_switch_places(dictionary *dict,int aim); +dictionary *yon_dictionary_switch_places(dictionary *dict, int aim); void yon_dictionary_make_first(dictionary *dict); @@ -94,69 +93,78 @@ dictionary *yon_dictionary_rip(dictionary *dict); dictionary *yon_dictionary_get_nth(dictionary *dict, int place); -//char functions +// char functions char *yon_char_get_augumented(char *source, char *append); char *yon_char_new(char *chr); +char *yon_char_unite(char *source, ...); + char *yon_cut(char *source, int size, int startpos); char *yon_char_divide(char *source, int dividepos); -char *yon_char_divide_search(char *source, char* dividepos, int delete_divider); +char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); char *yon_char_from_int(int int_to_convert); +char **yon_char_parse(char *parameters, int *size, char *divider); +char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete); -//parsing functions +int yon_char_parsed_check_exist(char **parameters, int size, char *param); -apps *yon_apps_scan_and_parse_desktops(int *sizef); -void yon_apps_sort(apps *applist,int size); +// parsing functions + +apps *yon_apps_scan_and_parse_desktops(int *sizef); +void yon_apps_sort(apps *applist, int size); -apps *yon_apps_get_by_name(apps *applist,char *name, int size); +apps *yon_apps_get_by_name(apps *applist, char *name, int size); -char *yon_config_load(char *command); +config_str yon_config_load(char *command, int *str_len); int yon_config_save(char *command); -//terminal-using functions +char *yon_config_get_parameter(config_str parameters, int size, char *param); +char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider); +// terminal-using functions int yon_launch_app(char *name); - int yon_launch_app_with_arguments(char *name, char *args); - int yon_launch(thread_output *thread); -//Gtk functions +// Gtk functions #ifdef __GTK_H__ -#define yon_gtk_builder_get_widget(obj,obj2) GTK_WIDGET(gtk_builder_get_object(obj,obj2)) +#define yon_gtk_builder_get_widget(obj, obj2) GTK_WIDGET(gtk_builder_get_object(obj, obj2)) - -typedef struct { +typedef struct +{ GtkWidget *Icon; GtkWidget *Label; GtkWidget *IconView; GtkListStore *List; } expander_icon_view; - // GtkWidget *yon_gtk_app_chooser_apps_create(); // dictionary *yon_gtk_app_chooser_create(); // expander_icon_view yon_gtk_icon_view_expander_create(GtkWidget *pack, ...); +int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); + +int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); + GtkWidget *yon_gtk_socket_create_new_with_connect(GtkWidget *container, gpointer data); int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); @@ -164,25 +172,26 @@ int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); int yon_dictionary_gtk_pack_start_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding); int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding); -//uninitialised +// uninitialised -void yon_on_plug_added(GtkSocket* self, gpointer user_data); -void yon_on_plug_removed(GtkSocket* self, gpointer user_data); +void yon_on_plug_added(GtkSocket *self, gpointer user_data); +void yon_on_plug_removed(GtkSocket *self, gpointer user_data); -#endif -typedef enum { +typedef enum +{ BACKGROUND_IMAGE_SUCCESS_TYPE, BACKGROUND_IMAGE_FAIL_TYPE } BACKGROUND_IMAGE_TYPE; #ifdef __cplusplus -#define yon_ubl_header_setup(overlay,head,image,imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay.gobj()),GTK_WIDGET(head.gobj()),GTK_WIDGET(image.gobj()),(char*)imag_path) -#define yon_ubl_status_box_render(statusbox, statusicon, statuslabel, iconname, statustext, backgroundclass) _yon_ubl_status_box_render(GTK_WIDGET(statusbox.gobj()), GTK_WIDGET(statusicon.gobj()), GTK_WIDGET(statuslabel.gobj()), (char*)iconname, (char*)statustext, backgroundclass) +#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay.gobj()), GTK_WIDGET(head.gobj()), GTK_WIDGET(image.gobj()), (char *)imag_path) +#define yon_ubl_status_box_render(statusbox, statusicon, statuslabel, iconname, statustext, backgroundclass) _yon_ubl_status_box_render(GTK_WIDGET(statusbox.gobj()), GTK_WIDGET(statusicon.gobj()), GTK_WIDGET(statuslabel.gobj()), (char *)iconname, (char *)statustext, backgroundclass) #else -#define yon_ubl_header_setup(overlay,head,image,imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay),GTK_WIDGET(head),GTK_WIDGET(image), (char*)imag_path) -#define yon_ubl_status_box_render(statusbox, statusicon, statuslabel, iconname, statustext, backgroundclass) _yon_ubl_status_box_render(statusbox, statusicon, statuslabel, iconname, statustext, backgroundclass) +#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) +#define yon_ubl_status_box_render(statusbox, statusicon, statuslabel, statustext, backgroundclass) _yon_ubl_status_box_render(statusbox, statusicon, statuslabel, statustext, backgroundclass) #endif void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); -void _yon_ubl_status_box_render(GtkWidget *StatusBox, GtkWidget *StatusIcon, GtkWidget *StatusLabel, char *IconName, char* StatusText, BACKGROUND_IMAGE_TYPE BackgroundClass); +void _yon_ubl_status_box_render(GtkWidget *StatusBox, GtkWidget *StatusIcon, GtkWidget *StatusLabel, char *StatusText, BACKGROUND_IMAGE_TYPE BackgroundClass); +#endif #endif \ No newline at end of file diff --git a/ubl-settings-video.desktop b/ubl-settings-video.desktop index b2b9897..f12dc01 100644 --- a/ubl-settings-video.desktop +++ b/ubl-settings-video.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Encoding=UTF-8 Name=ubl-settings-video -Name[ru]=Настройки Видеоадаптера и дисплея +Name[ru]=Настройки видеоадаптера и дисплея GenericName=ubl-settings-video GenericName[ru]=Настройки Видеоадаптера и дисплея Comment=Application for managing video adapter and display settings diff --git a/ubl-settings-video.glade b/ubl-settings-video.glade index 2ee72e6..dcdaae5 100644 --- a/ubl-settings-video.glade +++ b/ubl-settings-video.glade @@ -3,7 +3,9 @@ + + True False @@ -144,111 +146,6 @@ - - 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 @@ -342,6 +239,35 @@ False document-edit-symbolic + + True + False + dialog-information-symbolic + + + True + False + user-trash-symbolic + + + True + False + dialog-information-symbolic + + + True + False + system-shutdown-symbolic + + + True + False + user-trash-symbolic + + + False + value-increase-symbolic + True False @@ -360,17 +286,16 @@ True False - center - center + start 3 3 + 10 20 vertical True False - Monitor True @@ -391,7 +316,6 @@ False 5 5 - 1920x1200:60Hz @@ -406,17 +330,84 @@ - + True - True - True - end - image3 - + False + 15 + + + True + True + True + image14 + + + + False + True + 0 + + + + + True + True + True + image13 + + + + False + True + 1 + + + + + True + True + True + end + image3 + + + + False + True + end + 2 + + + + + True + True + True + image15 + + + + False + True + 3 + + False @@ -435,54 +426,36 @@ False emblem-ok-symbolic - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - - True - False - system-run-symbolic - - - 800 - 600 + False - 800 - 600 + True com.ublinux.ubl-settings-video - + True False - True vertical True False + 5 + 5 + 5 + 5 vertical - + True False + 5 - + + Enabled True - False - 5 - 5 - 5 - 5 - 6 - 6 - 25 + True + False + True False @@ -490,33 +463,11 @@ 0 - - - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - - - - - - - True - True - 1 - - False True - 0 + 1 @@ -525,18 +476,40 @@ False vertical - - 81 + True False + end + 5 + True - + + Save True - False - start + True + True + image5 - -1 + False + True + end + 0 + + + + + Cancel + True + True + True + image4 + + + False + True + end + 1 @@ -550,217 +523,31 @@ False True - 1 + end + 2 - - 165 + True - True - 5 - 5 - 5 - 5 - external + False + vertical - + True False + vertical + 5 True False - 5 - 5 - 5 - 5 - 5 - vertical + 5 - + True False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 12 - 5 - - - True - False - vertical - - - Automatically choose and use driver - True - True - False - start - True - - - False - True - 0 - - - - - True - False - 5 - - - True - False - vertical - 5 - - - True - False - start - Proprietary driver: - 0 - - - False - True - 0 - - - - - True - False - start - Failsafe driver nVidia: - 0 - - - False - True - 1 - - - - - True - False - start - Failsafe driver AMD/ATI: - 0 - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - 0 - - - True - True - 0 - - - - - True - True - True - image8 - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - True - False - - - False - True - 2 - - - - - True - True - 1 - - - - - False - True - 1 - - - - - - - - - True - False - Driver - - + Port False @@ -769,58 +556,10 @@ - + True False - vertical - - - True - False - 0.019999999552965164 - in - - - True - False - vertical - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - 10 - - - - - - False - True - 0 - - - - - - - True - False - Monitor configuration - - - - - True - True - 0 - - + 0 True @@ -829,51 +568,62 @@ - + + Main display + True + True + False + True + + + False + True + 2 + + + + + False + True + 1 + + + + + True + False + 5 + + True False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 12 - 5 - - - True - False - - - discrete video only (AMD/ATI) - True - True - False - 5 - 5 - True - - - False - True - 1 - - - - - - - - - True - False - 0 - Hybrid graphics - - + Resolution (px): + + + False + True + 0 + + + + + True + False + 0 + + + True + True + 1 + + + + + Show unsupported + True + True + False + True False @@ -881,447 +631,294 @@ 2 + + + False + True + 2 + + + + + True + False + 5 - + True False - 5 - 0.019999999552965164 - in - - - True - False - 5 - 5 - 12 - 5 - - - True - False - vertical - - - True - False - 5 - - - True - False - vertical - 5 - - - Launch programms through optirun (nVidia): - True - True - False - True - - - False - True - 0 - - - - - Launch programs through primusun (nVidia): - True - True - False - True - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - 5 - - - True - False - True - steam - - - True - True - 0 - - - - - True - False - True - steam - - - True - True - 1 - - - - - True - True - 1 - - - - - True - False - vertical - 5 - - - True - False - True - True - image1 - - - False - True - 0 - - - - - True - False - True - True - image2 - - - False - True - 1 - - - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - 5 - 5 - - - True - False - Fix frame gap (nVidia): - 0 - - - False - True - 0 - - - - - True - False - - - True - True - 1 - - - - - False - True - 1 - - - - - - - - - True - False - Extra - - + Frequency (Hz): False True - 3 + 0 + + + + + True + False + 0 + + + True + True + 1 - - - - - - - True - True - 2 - - - - - True - True - 0 - - - - - - - True - False - True - - - True - False - start - 5 - 5 - 5 - 5 - False - UBlinux Video Configuration - - - - - - - - True - False - 5 - 5 - 5 - 5 - 32 - com.ublinux.ubl-settings-video - - - - - True - False - - - True - True - False - True - LoadConfigurationMenu - none - - - True - False - - - True - False - 5 - 5 - 5 - 5 - Load False True - 0 + 3 - + True False - pan-down-symbolic + 5 + + + True + False + Rotation: + + + False + True + 0 + + + + + True + False + 0 + + + True + True + 1 + + False True - 1 + 4 - - - - - False - True - 0 - - - - - 1 - - - - - True - False - - - True - True - False - True - True - SaveConfigurationMenu - none - - - True - False - + True False - 5 - 5 - 5 - 5 - Save - + 5 + + + True + False + Position: + + + False + True + 0 + + + + + True + False + 5 + True + + + True + False + 0 + + + True + True + 0 + + + + + True + False + 0 + + + True + True + 1 + + + + + True + True + 1 + + False True - 0 + 5 - + + Do not switch off display + True + True + False + True + + + False + True + 6 + + + + + Create modeline for current resolution with CVT + True + True + False + True + + + False + True + 7 + + + + + Use "CVT Reduced Blanking"gshgrbehr + True + True + False + True + + + False + True + 8 + + + + + Create modeline for current resolution with GTF + True + True + False + True + + + False + True + 9 + + + + True False - pan-down-symbolic False True - 1 + 10 + + False + True + 0 + - - - False - True - 0 - - - - - True - True - False - True - True - SettingsMenu - none - + + True + False + 5 + 5 + vertical + 5 + + + Configure manually through parameter line: + True + True + False + True + + + False + True + 0 + + + + + True + False + True + center + 1920x1080 + + + True + True + 1 + + + + + False + True + 1 + False True - 1 + 3 - end - 3 + True + True + 0 - - vertical - - - - - - - - - - - - - - - - - - - + + True + False + go-bottom-symbolic - - - - - - - - - - - - - - - + + True + False + user-trash-symbolic + + + True + False + go-bottom-symbolic @@ -1336,343 +933,1145 @@ - - - g89 - Settings - Settings - - - - - True - True - - - True - False - vertical - - - True - True - 15 - 15 - 6 - multiple - horizontal - liststore5 - 1 - True - - - - 0 - - - - - 0 - True - word - - - 1 - - - - - True - True - 0 - - - - - - - True - False - 5 - - - True - False - 25 - applications-system - - - False - True - 0 - - - - - True - False - Settings - - - False - True - 1 - - - - - - + + + - + + + - + - - 450 - 300 + + 800 + 600 False + 800 + 600 com.ublinux.ubl-settings-video - + True False - 5 - 5 - 5 - 5 + True vertical - 5 - + True - True - liststore6 - True - 2 - - - + False + vertical - - Driver + + True + False - - - 0 - + + True + False + 5 + 5 + 5 + 5 + 6 + 6 + 25 + + + False + True + 0 + + + + + True + False + start + 5 + 5 + 5 + 5 + 6 + 6 + + + + + + + True + True + 1 + + + False + True + 0 + - - Description + + True + False + vertical - - - 1 - + + 81 + True + False + + + True + False + start + + + -1 + + + + + False + True + 0 + - - - - True - True - 0 - - - - - True - False - 5 - - + + False + True + 1 + - + True - False - 5 - True + True + 5 - - Cancel + + 165 True True - True - image6 + 5 + 5 + 5 + 5 + external + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + vertical + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 12 + 5 + + + True + False + vertical + + + Automatically choose and use driver + True + True + False + start + True + + + False + True + 0 + + + + + True + False + 5 + + + True + False + vertical + 5 + + + True + False + start + Failsafe driver nVidia: + 0 + + + False + True + 1 + + + + + True + False + start + Failsafe driver AMD/ATI: + 0 + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + vertical + 5 + + + True + False + + + False + True + 1 + + + + + True + False + + + False + True + 2 + + + + + True + True + 1 + + + + + False + True + 1 + + + + + + + + + True + False + Driver + + + + + False + True + 0 + + + + + True + False + vertical + + + True + False + 0.019999999552965164 + in + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 10 + + + + + + False + True + 0 + + + + + + + True + False + Monitor configuration + + + + + True + True + 0 + + + + + True + True + 1 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 12 + 5 + + + True + False + + + discrete video only (AMD/ATI) + True + True + False + 5 + 5 + True + + + False + True + 1 + + + + + + + + + True + False + 0 + Hybrid graphics + + + + + False + True + 2 + + + + + True + False + 5 + 0.019999999552965164 + in + + + True + False + 5 + 5 + 12 + 5 + + + True + False + vertical + + + True + False + 5 + + + True + False + vertical + 5 + + + Launch programms through optirun (nVidia): + True + True + False + True + + + False + True + 0 + + + + + Launch programs through primusun (nVidia): + True + True + False + True + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + vertical + 5 + + + True + False + True + steam + + + True + True + 0 + + + + + True + False + True + steam + + + True + True + 1 + + + + + True + True + 1 + + + + + True + False + vertical + 5 + + + True + False + True + True + image1 + + + False + True + 0 + + + + + True + False + True + True + image2 + + + False + True + 1 + + + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + 5 + 5 + + + True + False + Fix frame gap (nVidia): + 0 + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 1 + + + + + + + + + True + False + Extra + + + + + False + True + 3 + + + + + + + + + + + True + False + Main Settings + + + False + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + 5 + 5 + 5 + 5 + 5 + vertical + 5 + + + True + True + + + True + True + 5 + liststore6 + 1 + True + + + + + + Installed + + + + 0 + + + + + + + Package + + + + 1 + + + + + + + Driver + + + + 2 + + + + + + + Description + + + + 3 + + + + + + + Supported Devices + + + + 4 + + + + + + + + + True + True + 0 + + + + + True + False + center + 5 + + + Установить + True + True + True + image9 + + + False + True + end + 0 + + + + + Удалить + True + True + True + image11 + + + False + True + end + 1 + + + + + Подробнее + True + True + True + image10 + + + False + True + end + 2 + + + + + False + True + 1 + + + + + + + True + False + Driver Modules + + + False + + + + + True + False + 5 + 5 + 5 + 5 + 5 + vertical + 5 + + + True + True + + + True + True + 5 + liststore6 + 0 + True + 2 + + + + + + Installed + + + + 0 + + + + + + + Package + + + + 1 + + + + + + + Driver + + + + 2 + + + + + + + Description + + + + 3 + + + + + + + Supported Devices + + + + 4 + + + + + + + + + True + True + 0 + + + + + True + False + center + 5 + + + Установить + True + True + True + image6 + + + False + True + end + 0 + + + + + Удалить + True + True + True + image7 + + + False + True + end + 1 + + + + + Подробнее + True + True + True + image12 + + + False + True + end + 2 + + + + + False + True + 1 + + + + + 1 + + + + + True + False + Drivers + + + 1 + False + + + + + + + + - False - True - 0 + 1 - - - Accept + + True - True - True - image7 + False + Drivers - False - True 1 + False - - - False - True - end - 1 - - - - - False - True - 1 - - - - - - - radiobutton - True - True - False - True - True - - - False - True - com.ublinux.ubl-settings-video - - - True - False - vertical - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - vertical - 5 - - - True - False - 5 - + True False - start - Monitor: + 5 + 5 + 5 + 5 + 5 + 5 + 0 + none + + + True + False + 12 + + + True + False + + + True + False + start + 75 + appointment-new-symbolic + + + False + True + 0 + + + + + True + False + start + start + 10 + 5 + 10 + 5 + 10 + 10 + label + + + False + True + 1 + + + + + + + + + True + False + 5 + 5 + Devices and Drivers + + - False - True - 0 + 2 - + True False - 0 - - - False - True - 1 - - - - - Main monitor - True - True - False - 15 - 15 - True - radioMainMonitor + Information - False - True 2 + False - False + True True - 0 + 2 + + + True + True + 0 + + + + + + + True + False + True + + + True + False + start + 5 + 5 + 5 + 5 + False + UBlinux Video Configuration + + + + + + + + True + False + 5 + 5 + 5 + 5 + 32 + com.ublinux.ubl-settings-video + + + + + True + False - + True - False - 5 - - - True - False - Resolution (px): - 0 - - - False - True - 0 - - - - - True - False - center - 0 - - - True - True - 1 - - + True + False + True + LoadConfigurationMenu + none - + True False - 5 - + True False - Frequency (Hz) + 5 + 5 + 5 + 5 + Load False @@ -1681,10 +2080,10 @@ - + True False - center + pan-down-symbolic False @@ -1693,205 +2092,133 @@ - - False - True - 2 - - - - - False - True - 1 - - - - - True - False - 5 - - - True - False - Rotation - 0 - - - False - True - 0 - - - - - True - False - - - True - True - 1 - - - - - True - False - - - - - - False - True - 2 - - - - - False - True - 2 - - - - - True - False - 5 - 5 - - - through parameter line: - True - True - False - True - - - False - True - 0 - - - - - True - False - True - center - - - True - True - 1 - False True - 3 - - - - - True - False - - - False - True - 5 + 0 + + + 1 + + + + + True + False - + True - False - vertical + True + False + True + True + SaveConfigurationMenu + none True False - end - 5 - True - - Save + True - True - True - image5 + False + 5 + 5 + 5 + 5 + Save + False True - end 0 - - Cancel + True - True - True - image4 + False + pan-down-symbolic False True - end 1 - - False - True - 0 - False True - end - 6 + 0 + + + + + True + True + False + True + True + SettingsMenu + none + + + + + + False + True + 1 - True - True - 0 + end + 3 - + + vertical - - + + + + + + + + + - + - - + + + + True False - + True + False False 128 com.ublinux.ubl-settings-video.display diff --git a/ubl-settings-video.pot b/ubl-settings-video.pot index 369eeae..3bc82af 100644 --- a/ubl-settings-video.pot +++ b/ubl-settings-video.pot @@ -1,170 +1,204 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. +# Language translations for ubl-settings-manager package. +# Copyright (C) 2022, UBTech LLC +# This file is distributed under the same license as the ubl-settings-manager package. +# UBLinux Team , 2022 # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-04-04 17:42+0000\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" +"Project-Id-Version: ubl-settings-manager 1.0\n" +"Report-Msgid-Bugs-To: info@ublinux.com\n" +"POT-Creation-Date: 2023-04-21 12:33+0000\n" +"PO-Revision-Date: 2023-01-01 00:00+0600\n" +"Last-Translator: UBLinux Team \n" +"Language-Team: Russian - UBLinux Team \n" +"Language: Russian\n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: source/ubl-settings-video.c:151 -msgid "About" +#: source/ubl-settings-video.c:26 source/ubl-settings-video.c:223 +msgid "Cancel" msgstr "" -#: source/ubl-settings-video.c:143 -msgid "Automatically choose and use driver" +#: source/ubl-settings-video.c:27 +msgid "Accept" msgstr "" -#: source/ubl-settings-video.c:153 -msgid "Change" +#: source/ubl-settings-video.c:28 source/ubl-settings-video.c:386 +msgid "Driver" msgstr "" -#: source/ubl-settings-video.c:131 -msgid "Configuration method" +#: source/ubl-settings-video.c:29 +msgid "Description" msgstr "" -#: source/ubl-settings-video.c:41 -msgid "DPMS off" +#: source/ubl-settings-video.c:87 source/ubl-settings-video.c:392 +msgid "UBlinux Video Configuration" msgstr "" -#: source/ubl-settings-video.c:37 -msgid "Do not switch display off" +#: source/ubl-settings-video.c:89 +msgid "Progect Home Page" msgstr "" -#: source/ubl-settings-video.c:150 -msgid "Documentation" +#: source/ubl-settings-video.c:90 +msgid "Videocard and monitor configuration manager" msgstr "" -#: source/ubl-settings-video.c:130 -msgid "Driver" +#: source/ubl-settings-video.c:215 +msgid "Monitor: " msgstr "" -#: source/ubl-settings-video.c:136 -msgid "Extra" +#: source/ubl-settings-video.c:216 +msgid "Resolution (px): " msgstr "" -#: source/ubl-settings-video.h:16 -msgid "Failed to load global configuration" +#: source/ubl-settings-video.c:217 +msgid "Frequency (Hz): " msgstr "" -#: source/ubl-settings-video.h:17 -msgid "Failed to load local configuration" +#: source/ubl-settings-video.c:218 +msgid "Rotation: " msgstr "" -#: source/ubl-settings-video.c:129 -msgid "Failsafe driver AMD/ATI: " +#: source/ubl-settings-video.c:220 +msgid "Main monitor" msgstr "" -#: source/ubl-settings-video.c:128 -msgid "Failsafe driver nVidia: " +#: source/ubl-settings-video.c:221 +msgid "through parameter line:" msgstr "" -#: source/ubl-settings-video.c:135 -msgid "Fix frame gap (nVidia)" +#: source/ubl-settings-video.c:226 source/ubl-settings-video.c:231 +#: source/ubl-settings-video.c:233 source/ubl-settings-video.c:236 +#: source/ubl-settings-video.c:238 source/ubl-settings-video.c:258 +msgid "Default settings" msgstr "" -#: source/ubl-settings-video.c:35 -msgid "Frequency (Hz): " +#: source/ubl-settings-video.c:374 +msgid "Don't use" msgstr "" -#: source/ubl-settings-video.c:134 -msgid "Hybrid graphics" +#: source/ubl-settings-video.c:375 source/ubl-settings-video.c:377 +msgid "Off" msgstr "" -#: source/ubl-settings-video.c:125 -msgid "Launch programms through (nVidia)" +#: source/ubl-settings-video.c:376 source/ubl-settings-video.c:378 +msgid "fbdev" msgstr "" -#: source/ubl-settings-video.c:138 -msgid "Load" +#: source/ubl-settings-video.c:380 +msgid "1st variant. May cause perfomance drops in video games" msgstr "" -#: source/ubl-settings-video.c:145 -msgid "Load from global configuration" +#: source/ubl-settings-video.c:381 +msgid "2nd variant. May not work on specific video cards" msgstr "" -#: source/ubl-settings-video.c:146 -msgid "Load from local configuration" +#: source/ubl-settings-video.c:382 +msgid "Video output configuration" msgstr "" -#: source/ubl-settings-video.c:39 -msgid "Main monitor" +#: source/ubl-settings-video.c:383 +msgid "Proprietary driver: " msgstr "" -#: source/ubl-settings-video.c:141 -msgid "Manual configuration" +#: source/ubl-settings-video.c:384 +msgid "Failsafe driver nVidia: " msgstr "" -#: source/ubl-settings-video.c:132 +#: source/ubl-settings-video.c:385 +msgid "Failsafe driver AMD/ATI: " +msgstr "" + +#: source/ubl-settings-video.c:388 msgid "Monitor configuration" msgstr "" -#: source/ubl-settings-video.c:33 -msgid "Monitor: " +#: source/ubl-settings-video.c:389 +msgid "Hybrid graphics" +msgstr "" + +#: source/ubl-settings-video.c:390 +msgid "Fix frame gap (nVidia)" msgstr "" -#: source/ubl-settings-video.c:142 +#: source/ubl-settings-video.c:391 +msgid "Extra" +msgstr "" + +#: source/ubl-settings-video.c:393 +msgid "Load" +msgstr "" + +#: source/ubl-settings-video.c:394 +msgid "Save" +msgstr "" + +#: source/ubl-settings-video.c:396 msgid "On" msgstr "" -#: source/ubl-settings-video.c:127 -msgid "Proprietary driver: " +#: source/ubl-settings-video.c:397 +msgid "Automatically choose and use driver" msgstr "" -#: source/ubl-settings-video.c:34 -msgid "Resolution (px): " +#: source/ubl-settings-video.c:398 +msgid "Launch programms through optirun (nVidia): " msgstr "" -#: source/ubl-settings-video.c:36 -msgid "Rotation: " +#: source/ubl-settings-video.c:399 +msgid "Launch programs through primusun (nVidia): " msgstr "" -#: source/ubl-settings-video.c:139 -msgid "Save" +#: source/ubl-settings-video.c:400 +msgid "discrete video only (AMD/ATI)" +msgstr "" + +#: source/ubl-settings-video.c:402 +msgid "Load from global configuration" msgstr "" -#: source/ubl-settings-video.c:147 +#: source/ubl-settings-video.c:403 +msgid "Load from local configuration" +msgstr "" + +#: source/ubl-settings-video.c:404 msgid "Save to global an local configuration" msgstr "" -#: source/ubl-settings-video.c:148 +#: source/ubl-settings-video.c:405 msgid "Save to global configuration" msgstr "" -#: source/ubl-settings-video.c:149 +#: source/ubl-settings-video.c:406 msgid "Save to local configuration" msgstr "" -#: source/ubl-settings-video.h:19 -msgid "Saving to global configuration Succeeded" +#: source/ubl-settings-video.c:407 +msgid "Documentation" msgstr "" -#: source/ubl-settings-video.h:20 -msgid "Saving to local configuration Succeeded" +#: source/ubl-settings-video.c:408 +msgid "About" msgstr "" -#: source/ubl-settings-video.c:137 -msgid "UBlinux Video Configuration" +#: source/ubl-settings-video.c:438 +msgid "Configuration has been loaded" msgstr "" -#: source/ubl-settings-video.c:126 -msgid "Video output configuration" +#: source/ubl-settings-video.h:22 +msgid "Failed to load global configuration" msgstr "" -#: source/ubl-settings-video.c:133 -msgid "discrete video only (AMD/ATI)" +#: source/ubl-settings-video.h:23 +msgid "Failed to load local configuration" msgstr "" -#: source/ubl-settings-video.c:40 -msgid "through parameter line:" +#: source/ubl-settings-video.h:25 +msgid "Saving to global configuration Succeeded" +msgstr "" + +#: source/ubl-settings-video.h:26 +msgid "Saving to local configuration Succeeded" msgstr "" diff --git a/ubl-settings-video_ru.po b/ubl-settings-video_ru.po index fc99cdd..c4ea148 100644 --- a/ubl-settings-video_ru.po +++ b/ubl-settings-video_ru.po @@ -1,4 +1,4 @@ -# Language translations for ubl-settings-manager package. +# Russian translations for ubl-settings-manager package. # Copyright (C) 2022, UBTech LLC # This file is distributed under the same license as the ubl-settings-manager package. # UBLinux Team , 2022 @@ -7,12 +7,12 @@ msgid "" msgstr "" "Project-Id-Version: ubl-settings-manager 1.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-04-05 10:05+0000\n" +"Report-Msgid-Bugs-To: info@ublinux.com\n" +"POT-Creation-Date: 2023-04-21 12:33+0000\n" "PO-Revision-Date: 2023-01-01 00:00+0600\n" "Last-Translator: UBLinux Team \n" -"Language-Team: UBLinux Team \n" -"Language: \n" +"Language-Team: Russian - UBLinux Team \n" +"Language: Russian\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/video-drivers.csv b/video-drivers.csv new file mode 100644 index 0000000..e79c785 --- /dev/null +++ b/video-drivers.csv @@ -0,0 +1,8 @@ +VERSION_ID:DRV_PAСKAGE:DRV_NAME:DRV_DESCRIPTION:DRV_SUPPORT +:ubm-nvidia-340:nvidia-340:Пакет с модулем драйвера и утилиты NVIDIA 340xx:Драйвер видеокарт nVidia серий 8XXX, 9XXX, 1XX, 2XX, 3XX, 4XX, 5XX, 6XX, 7XX +:ubm-nvidia-390:nvidia-390:Пакет с модулем драйвера и утилиты NVIDIA 390xx:Драйвер видеокарт nVidia серий 4XX, 5XX, 6XX, 7XX, 9XX, 10XX +:ubm-nvidia-430:nvidia-430:Пакет с модулем включает в себя драйвер NVIDIA 430xx и утилиты:Драйвер видеокарт nVidia серий 6XX, 7XX, 9XX, 10XX, 16XX +:ubm-nvidia-470:nvidia-470:Пакет с модулем драйвера и утилиты NVIDIA 470xx:Драйвер видеокарт nVidia серий NVS, Quadro Sync, Quadro NVS, Quadro Blade/Embedded, Quadro, Quadro RTX, NVIDIA RTX +:ubm-nvidia-510:nvidia-510:Пакет с модулем драйвера и утилиты NVIDIA 510xx:Драйвер видеокарт nVidia серий NVS, Quadro Sync, Quadro NVS, Quadro Blade/Embedded, Quadro, Quadro RTX, NVIDIA RTX +:ubm-nvidia-515:nvidia-515:Пакет с модулем драйвера и утилиты NVIDIA 515xx:Драйвер видеокарт nVidia серий NVS, Quadro Sync, Quadro NVS, Quadro Blade/Embedded, Quadro, Quadro RTX, NVIDIA RTX +:ubm-nvidia-optimus:nvidia-optimus:Пакет с модулем включает в себя NVIDIA Optimus: