Monitor configuration design changes are completed

pull/6/head^2
parent 8382fb0914
commit ac2fa32f55

@ -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;i<res->size;i++){
char *check_line;
for (int j=0;j<videoconfig.resolutionssize;j++){
check_line=yon_char_new(videoconfig.resolutions[j]);
check_line=yon_char_divide_search(check_line," ",-1);
if (strstr(videoconfig.resolutions[j],res->line[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){
@ -673,15 +730,6 @@ char *yon_monitor_make_string(monitorconfig* config)
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="";
if (config->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;i<videoconfig.resolutionssize;i++){
videoconfig.resolutions[i]=yon_char_divide_search(videoconfig.resolutions[i],"\n",-1);
}
yon_proprieary_get();
}
@ -891,7 +942,6 @@ monitor_config yon_monitor_config_new(char *port){
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
@ -1063,29 +1113,50 @@ 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;i<size_connected;i++){
int a=atoi(yon_char_divide_search(connected_ports[i],":",-1));
int *cur_pos=new(int);
memcpy(cur_pos,&a,sizeof(int));
connected_ports[i]=yon_char_divide_search(connected_ports[i],"\n",-1);
connected_ports[i]=yon_char_divide_search(connected_ports[i]," ",-1);
yon_dictionary_add_or_create_if_exists_with_data(dact,connected_ports[i],cur_pos);
config_str resol=new(char*);
resolution_supported *supported=new(resolution_supported);
supported->line=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;i<resolutions_size;i++){
int cur_pos=atoi(yon_char_divide_search(resolutions[i],":",-1));
dictionary *dct=NULL;
char *port_for_res=NULL;
int equals=0;
for_dictionaries (dct,dact){
if (cur_pos==*((int*)dct->data)){
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)
* [EN]
* Sets up every element on main window
@ -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(),

@ -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);

@ -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&&parameters){
for (int i=0;i<size;i++){
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),parameters[i]);
}
return 1;
} else
return 0;
}
int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find){
if (combo_box&&text_to_find){

@ -66,6 +66,8 @@ typedef char** config_str;
#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();
@ -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);

@ -904,9 +904,6 @@
</child>
</object>
</child>
<child type="titlebar">
<placeholder/>
</child>
</object>
<object class="GtkImage" id="image6">
<property name="visible">True</property>
@ -937,87 +934,6 @@
<column type="gchararray"/>
</columns>
</object>
<object class="GtkExpander" id="templateAppsPack">
<property name="visible">True</property>
<property name="can-focus">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkIconView" id="templateAppsIconView">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-left">15</property>
<property name="margin-start">15</property>
<property name="margin">6</property>
<property name="selection-mode">multiple</property>
<property name="item-orientation">horizontal</property>
<property name="model">liststore5</property>
<property name="columns">1</property>
<property name="activate-on-single-click">True</property>
<child>
<object class="GtkCellRendererPixbuf"/>
<attributes>
<attribute name="pixbuf">0</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText">
<property name="xalign">0</property>
<property name="single-paragraph-mode">True</property>
<property name="wrap-mode">word</property>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="templateAppsImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">25</property>
<property name="icon-name">applications-system</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="templateAppsLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Settings</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<style>
<class name="workingbg"/>
</style>
</object>
<object class="GtkListStore" id="liststore6">
<columns>
<!-- column-name is_installed -->
@ -2296,14 +2212,6 @@
<widget name="mainExtraLaunchOptirunCheck"/>
</widgets>
</object>
<object class="GtkRadioButton" id="radioMainMonitor">
<property name="label" translatable="yes">radiobutton</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<object class="GtkOverlay" id="templateMonitorscreenOverlay">
<property name="visible">True</property>
<property name="can-focus">False</property>

Loading…
Cancel
Save