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