diff --git a/source/ubl-settings-video.c b/source/ubl-settings-video.c index 406d051..4161d57 100644 --- a/source/ubl-settings-video.c +++ b/source/ubl-settings-video.c @@ -48,6 +48,7 @@ void on_monitor_config_save(GtkWidget *self, monitor_edit_window *window){ 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; @@ -135,6 +136,39 @@ void on_monitor_config_save(GtkWidget *self, monitor_edit_window *window){ // 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_save_driver_configuration(GtkWidget *self,combo_tree *widgets){ GtkTreeIter iter; char *name; @@ -208,6 +242,19 @@ char *yon_configuration_get_save_command(char *command){ else return NULL; } +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); + + } +} + char *yon_configuration_get_remove_command(char *command){ char *str = NULL; char *dntus = NULL; @@ -382,11 +429,11 @@ void on_monitor_configure(GtkWidget *self,monitor_window *window){ 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); @@ -464,6 +511,7 @@ void yon_monitor_window_update(monitor_edit_window *window){ 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) @@ -561,6 +609,15 @@ char *yon_monitor_make_string(monitorconfig* config) 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){ @@ -672,15 +729,6 @@ char *yon_monitor_make_string(monitorconfig* config) }else{ gtf=",gtf"; } - - char *resolution=""; - if(config->resolution) - if (first==1){ - resolution=config->resolution; - first=0; - }else{ - resolution=yon_char_get_augumented(",",config->resolution); - } char *frequency=""; @@ -833,6 +881,9 @@ void yon_setup_config(char *configcommand) } videoconfig.resolutions=yon_config_load(get_resolutions_supportable_command,&videoconfig.resolutionssize); + for (int i=0;icvt=0; monitor->reduced=0; monitor->gtf=0; - if (videoconfig.monitors) videoconfig.monitors=yon_dictionary_create_with_data_connected(videoconfig.monitors,port,monitor); else @@ -1063,27 +1113,48 @@ void yon_monitor_view_new(monitor_config monitor){ } } -void yon_monitor_set_resolutions(dictionary *dict){ - yon_dictionary_get_data(dict,monitorconfig*)->resolutionCapabilities=malloc(0); - FILE *resolutions = popen(get_resolutions_command, "r"); - char res[1000]; - memset(res,0,1000); - int size=0; - int last_string=0; - while (fgets(res,1000,resolutions)){ - - int string_n = atoi(yon_char_divide_search(res,":",1)); - if (last_string==0) last_string=string_n-1; - if (last_string==string_n-1){ - yon_dictionary_get_data(dict,monitorconfig*)->resolutionCapabilities=realloc(yon_dictionary_get_data(dict,monitorconfig*)->resolutionCapabilities,(sizeof(char*))*(size+2)); - yon_dictionary_get_data(dict,monitorconfig*)->resolutionCapabilities[size]=yon_char_divide_search(yon_char_new(res),"\n",1); - size++; - last_string=string_n; - } else { - yon_dictionary_get_data(dict,monitorconfig*)->resolution_size=size; - break; +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 yon_setup_widgets(widgets_dict *widgets) @@ -1248,6 +1319,7 @@ int main(int argc, char *argv[]) // 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(), diff --git a/source/ubl-settings-video.h b/source/ubl-settings-video.h index dccebb3..a02998b 100644 --- a/source/ubl-settings-video.h +++ b/source/ubl-settings-video.h @@ -29,10 +29,11 @@ #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/,/\t/g'" +#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-" @@ -72,6 +73,11 @@ typedef struct { GtkWidget *label; } render_data; +typedef struct { + config_str line; + int size; +} resolution_supported; + typedef struct { config_str loaded_config; @@ -80,6 +86,7 @@ typedef struct monitor_view monitor_visuals; monitor_config monitors; proprietary_config proprietary; + dictionary *supported_resolutions; GtkListStore *list; char *failsafenVidia; char *failsafeATI; @@ -111,6 +118,7 @@ typedef struct int cvt; int reduced; int gtf; + int show_usupported; } monitorconfig; typedef struct { @@ -260,7 +268,7 @@ 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(dictionary *dict); +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); diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 2870909..fd78093 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -858,6 +858,15 @@ int yon_launch(thread_output *thread) // return socket; // }; +int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ + if (combo&¶meters){ + for (int i=0;idata) +#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(); @@ -159,6 +161,8 @@ typedef struct // 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); diff --git a/ubl-settings-video.glade b/ubl-settings-video.glade index d69248f..dcdaae5 100644 --- a/ubl-settings-video.glade +++ b/ubl-settings-video.glade @@ -904,9 +904,6 @@ - - - True @@ -937,87 +934,6 @@ - - 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 - - - - - - @@ -2296,14 +2212,6 @@ - - radiobutton - True - True - False - True - True - True False