@ -1,44 +1,110 @@
# 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_close_subwindow ( GtkWidget * self ) {
void on_close_subwindow ( GtkWidget * self )
{
gtk_widget_destroy ( gtk_widget_get_toplevel ( self ) ) ;
}
void on_proprietary_driver_window_open ( GtkWidget * self ) {
GtkBuilder * builder = gtk_builder_new_from_file ( glade_path ) ;
GtkWidget * window = yon_gtk_builder_get_widget ( builder , " ProprietaryDriverChooseWindow " ) ;
GtkWidget * closeButton = yon_gtk_builder_get_widget ( builder , " ProprietaryCloseButton " ) ;
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_window_configuration ( GtkWidget * self , MonitorSettings * monitor ) {
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_close_subwindow ( self ) ;
} ;
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_close_subwindow ( 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 ) {
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 ) ;
gtk_widget_set_sensitive ( toggle , ! state ) ;
}
void on_auto_choose_drivers ( GtkWidget * self , widgets_dict * widgets ) {
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 ) ;
@ -50,37 +116,188 @@ void on_auto_choose_drivers(GtkWidget *self, widgets_dict *widgets){
gtk_widget_set_sensitive ( widgets - > mainDriverFailsafeNvidiaCombo , ! state ) ;
}
void on_closed_configuration ( GtkWidget * self , MonitorSettings * monitors ) {
void on_closed_configuration ( GtkWidget * self , MonitorSettings * monitors )
{
gtk_widget_destroy ( monitors - > templateMonitorConfigurationWindow ) ;
}
void on_save_configuration_local ( GtkWidget * self ) {
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 , yon_char_get_augumented ( yon_char_get_augumented ( " XORG_MONITOR[ " , dict - > key ) , " ] " ) , " , " ) ) ;
}
}
if ( strcmp ( str , command ) ! = 0 )
return str ;
else return NULL ;
}
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_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_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 yon_update_config ( widgets_dict * widgets )
{
videoconfig . optirun = yon_char_get_augumented ( " " , ( char * ) gtk_entry_get_text ( GTK_ENTRY ( widgets - > mainExtraLaunchOptirunEntry ) ) ) ;
videoconfig . primusrun = yon_char_get_augumented ( " " , ( char * ) gtk_entry_get_text ( GTK_ENTRY ( widgets - > mainExtraLaunchPrismusunEntry ) ) ) ;
// videoconfig.proprietary = yon_char_get_augumented("", gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->mainDriverProprietaryDriverCombo)));
videoconfig . failsafenVidia = yon_char_get_augumented ( " " , gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( widgets - > mainDriverFailsafeNvidiaCombo ) ) ) ;
videoconfig . failsafeATI = yon_char_get_augumented ( " " , gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( widgets - > mainDriverFailsafeAMDCombo ) ) ) ;
}
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 , " ] " ) ) ) ) ;
}
void on_save_configuration_global ( GtkWidget * self ) {
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_load_configuration_local ( 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 , " ] " ) ) ) ) ;
}
void on_load_configuration_global ( GtkWidget * self ) {
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 ) ;
}
int yon_config_init ( char * * parameters , int size )
{
char * param = NULL ;
dictionary * dct = NULL ;
videoconfig . failsafenVidia = yon_config_get_parameter ( parameters , size , " FAILSAFENVIDIA " ) ;
videoconfig . failsafeATI = yon_config_get_parameter ( parameters , size , " FAILSAFEATI " ) ;
// videoconfig.proprietary = yon_config_get_parameter(parameters, size, "FAILSAFENVIDIA");
videoconfig . optirun = yon_config_get_parameter ( parameters , size , " OPTIRUN " ) ;
videoconfig . primusrun = yon_config_get_parameter ( parameters , size , " PRIMUSRUN " ) ;
for_dictionaries ( dct , videoconfig . monitors )
{
char * prm = yon_char_get_augumented ( yon_char_get_augumented ( " XORG_MONITOR[ " , dct - > key ) , " ] " ) ;
param = yon_config_get_parameter ( parameters , size , prm ) ;
if ( param )
{
yon_parse_monitor ( dct , param ) ;
}
void on_accept_monitor_settings ( GtkWidget * self ) {
else {
yon_dictionary_get_data ( dct , monitorconfig * ) - > frequency = NULL ;
yon_dictionary_get_data ( dct , monitorconfig * ) - > resolution = NULL ;
yon_dictionary_get_data ( dct , monitorconfig * ) - > main = 0 ;
yon_dictionary_get_data ( dct , monitorconfig * ) - > rotation = NULL ;
yon_dictionary_get_data ( dct , monitorconfig * ) - > stringparameters = NULL ;
}
void on_check_optisun ( GtkWidget * self ) {
yon_monitor_set_resolutions ( dct ) ;
}
void on_check_primusrun ( GtkWidget * self ) {
if ( videoconfig . videoconfig )
for_dictionaries ( dct , videoconfig . videoconfig ) {
MonitorSettings * settings = yon_dictionary_get_data ( dct , MonitorSettings * ) ;
if ( ( ( monitorconfig * ) settings - > curconfig - > data ) - > port ) {
if ( yon_dictionary_get_data ( settings - > curconfig , monitorconfig * ) - > main = = 0 )
gtk_label_set_text ( GTK_LABEL ( settings - > templateMonitorInfoNameLabel ) , yon_char_get_augumented ( " Monitor " , ( ( monitorconfig * ) settings - > curconfig - > data ) - > port ) ) ;
if ( yon_dictionary_get_data ( settings - > curconfig , monitorconfig * ) - > main = = 1 )
gtk_label_set_text ( GTK_LABEL ( settings - > templateMonitorInfoNameLabel ) , yon_char_get_augumented ( " Monitor " , yon_char_get_augumented ( ( ( monitorconfig * ) settings - > curconfig - > data ) - > port , " * " ) ) ) ;
}
void on_check_discrete_only ( GtkWidget * self ) {
if ( ( ( monitorconfig * ) settings - > curconfig - > data ) - > resolution )
gtk_label_set_text ( GTK_LABEL ( settings - > templateMonitorInfoResolutionLabel ) , ( ( monitorconfig * ) settings - > curconfig - > data ) - > resolution ) ;
else
gtk_label_set_text ( GTK_LABEL ( settings - > templateMonitorInfoResolutionLabel ) , _ ( " Default settings " ) ) ;
}
}
void on_about ( ) {
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 " ) ;
@ -90,102 +307,227 @@ void on_about(){
gtk_about_dialog_set_comments ( GTK_ABOUT_DIALOG ( window ) , _ ( " Videocard and monitor configuration manager " ) ) ;
gtk_widget_set_visible ( hideButtonBox , 0 ) ;
gtk_widget_show ( window ) ;
}
void yon_parse_monitor ( dictionary * monitor , char * string_of_settings )
{
int size = 0 ;
yon_dictionary_get_data ( monitor , monitorconfig * ) - > stringparameters = string_of_settings ;
char * param_string = yon_char_new ( string_of_settings ) ;
yon_char_divide_search ( param_string , " = " , 1 ) ;
char * * rtn = yon_char_parse ( param_string , & size , " , " ) ;
int check_code = - 1 ;
if ( ( check_code = yon_char_parsed_check_exist ( rtn , size , " primary " ) ) ! = - 1 ) {
yon_dictionary_get_data ( monitor , monitorconfig * ) - > main = 1 ;
rtn = yon_char_parsed_shrink ( rtn , & size , check_code ) ;
}
else
yon_dictionary_get_data ( monitor , monitorconfig * ) - > main = 0 ;
if ( ( check_code = yon_char_parsed_check_exist ( rtn , size , " rotation " ) ) ! = - 1 ) {
yon_dictionary_get_data ( monitor , monitorconfig * ) - > rotation = rtn [ check_code ] ;
rtn = yon_char_parsed_shrink ( rtn , & size , check_code ) ;
}
else
yon_dictionary_get_data ( monitor , monitorconfig * ) - > rotation = 0 ;
for ( int i = 0 ; i < size ; i + + ) {
if ( yon_char_get_if_resolution ( rtn [ i ] ) = = 1 )
yon_dictionary_get_data ( monitor , monitorconfig * ) - > resolution = yon_char_new ( rtn [ i ] ) ;
}
}
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 ) ;
}
gtk_combo_box_text_remove_all ( GTK_COMBO_BOX_TEXT ( widgets - > mainDriverProprietaryDriverCombo ) ) ;
// str = videoconfig.proprietary->key;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( widgets - > mainDriverProprietaryDriverCombo ) , _ ( " Don't use " ) ) ;
int size = 0 ;
char * * rtn = yon_config_load ( get_proprietary_drivers_command , & size ) ;
for ( int driv = 0 ; driv < size ; driv + + ) {
char * drivr = yon_char_divide_search ( rtn [ driv ] , " \n " , - 1 ) ;
printf ( " %s \n " , drivr ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( widgets - > mainDriverProprietaryDriverCombo ) , drivr ) ;
}
gtk_combo_box_set_active ( GTK_COMBO_BOX ( widgets - > mainDriverProprietaryDriverCombo ) , 0 ) ;
gtk_combo_box_text_remove_all ( GTK_COMBO_BOX_TEXT ( widgets - > mainDriverFailsafeNvidiaCombo ) ) ;
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 ;
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 ) ;
}
char * tmp = NULL ;
if ( tmp = strstr ( string_of_settings , " rotate: " ) ) ( ( monitorconfig * ) monitor - > data ) - > rotation = tmp ;
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 ;
}
void yon_default_configs ( ) {
dictionary * yon_proprieary_get ( ) {
int size = 0 ;
char * * rtn = yon_config_load ( get_proprietary_drivers_command , & size ) ;
for ( int i = 0 ; i < size ; i + + ) {
rtn [ i ] = yon_char_divide_search ( rtn [ i ] , " \n " , - 1 ) ;
if ( i = = 0 ) videoconfig . proprietary = yon_dictionary_create_with_data ( rtn [ i ] , rtn [ i ] ) ;
else videoconfig . proprietary = yon_dictionary_create_with_data_connected ( videoconfig . proprietary , rtn [ i ] , rtn [ i ] ) ;
}
}
void yon_gtk_list_store_fill_with_proprietaries ( GtkListStore * list ) {
dictionary * dict = NULL ;
for_dictionaries ( dict , videoconfig . proprietary ) {
GtkTreeIter iter ;
gtk_list_store_append ( list , & iter ) ;
gtk_list_store_set ( list , & iter , 0 , dict - > key , 1 , ( char * ) dict - > data , - 1 ) ;
}
}
void yon_setup_config ( ) {
void yon_setup_config ( )
{
FILE * videoports = popen ( get_ports_command , " r " ) ;
char str [ 1000 ] ;
while ( fgets ( str , 1000 , videoports ) ) {
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 {
monitor - > frequency = NULL ;
monitor - > frequency = NULL ;
monitor - > main = 0 ;
monitor - > resolution = NULL ;
monitor - > rotation = NULL ;
monitor - > stringparameters = NULL ;
monitor - > resolutionCapabilities = NULL ;
videoconfig . list = NULL ;
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 ) ;
}
memset ( str , 0 , 1000 ) ;
}
int size = 0 ;
char * command = load_drivers_local_command ;
dictionary * dct ;
for_dictionaries ( dct , videoconfig . monitors ) {
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 ) ;
}
}
}
void on_apps_chooser_open ( GtkWidget * self , widgets_dict * widgets , int mode ) {
GtkBuilder * builder = gtk_builder_new_from_file ( glade_path ) ; \
// FILE *output=popen("");
char * * rtn = yon_ubl_load_global_config ( command , & size ) ;
char * param = NULL ;
yon_config_init ( rtn , size ) ;
// on_config_fill_interface(widgets);
// (param=yon_config_get_parameter(rtn,size,"OPTIRUN"))
if ( ( param = yon_config_get_parameter ( rtn , size , " FAILSAFENVIDIA " ) ) )
videoconfig . failsafenVidia = yon_char_new ( param ) ;
else
videoconfig . failsafenVidia = NULL ;
if ( ( param = yon_config_get_parameter ( rtn , size , " FAILSAFEATI " ) ) )
videoconfig . failsafeATI = yon_char_new ( param ) ;
else
videoconfig . failsafeATI = NULL ;
if ( ( param = yon_config_get_parameter ( rtn , size , " OPTIRUN " ) ) )
videoconfig . optirun = yon_char_new ( param ) ;
else
videoconfig . optirun = NULL ;
if ( ( param = yon_config_get_parameter ( rtn , size , " PRIMUSRUN " ) ) )
videoconfig . primusrun = yon_char_new ( param ) ;
else
videoconfig . primusrun = NULL ;
for_dictionaries ( dct , videoconfig . monitors )
{
char * prm = yon_char_get_augumented ( yon_char_get_augumented ( " XORG_MONITOR[ " , dct - > key ) , " ] " ) ;
param = yon_config_get_parameter ( rtn , size , prm ) ;
if ( param )
{
yon_parse_monitor ( dct , param ) ;
}
}
yon_proprieary_get ( ) ;
}
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_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 ) ;
if ( ! videoconfig . optirun | | strstr ( videoconfig . optirun , " \n " ) = = 0 )
gtk_entry_set_text ( GTK_ENTRY ( widgets - > mainExtraLaunchOptirunEntry ) , videoconfig . optirun ) ;
if ( ! videoconfig . primusrun | | strstr ( videoconfig . primusrun , " \n " ) = = 0 )
gtk_entry_set_text ( GTK_ENTRY ( widgets - > mainExtraLaunchPrismusunEntry ) , videoconfig . primusrun ) ;
if ( videoconfig . gapfix = = 0 )
gtk_combo_box_set_active ( GTK_COMBO_BOX ( widgets - > mainExtraFixGapCombo ) , 0 ) ;
}
void on_confugure_monitor_settings ( GtkWidget * self , MonitorSettings * settings ) {
driver_window * on_driver_window_open ( GtkWidget * self , GtkWidget * comboe )
{
GtkBuilder * builder = gtk_builder_new_from_file ( glade_path ) ;
driver_window * widgets = NULL ;
widgets = malloc ( sizeof ( driver_window ) ) ;
widgets - > window = 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 ) , _ ( " 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_close_subwindow ) , 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 ) ;
}
void on_confugure_monitor_settings ( GtkWidget * self , MonitorSettings * settings )
{
int monitors_n = yon_check_for_monitors ( ) ;
MonitorSettings * monitors = NULL ;
monitors = malloc ( sizeof ( MonitorSettings ) ) ;
@ -206,11 +548,13 @@ void on_confugure_monitor_settings(GtkWidget *self, MonitorSettings *settings){
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 " ) ) ;
monitors - > curconfig = settings - > curconfig ;
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 - > 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));
g_signal_connect ( G_OBJECT ( monitors - > templateMonitorConfigurationSaveButton ) , " clicked " , G_CALLBACK ( on_save_window_configuration ) , monitors ) ;
gtk_label_set_text ( GTK_LABEL ( monitors - > templateMonitorConfigurationMonitorLabel ) , _ ( " Monitor: " ) ) ;
gtk_label_set_text ( GTK_LABEL ( monitors - > templateMonitorConfigurationResolutionLabel ) , _ ( " Resolution (px): " ) ) ;
@ -219,32 +563,51 @@ void on_confugure_monitor_settings(GtkWidget *self, MonitorSettings *settings){
// 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_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( monitors - > templateMonitorConfigurationMainRadio ) , ( ( monitorconfig * ) settings - > curconfig - > data ) - > main ) ;
addln = _ ( " Default settings " ) ;
int chosen = - 1 ;
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 ;
addln = _ ( " Default settings " ) ;
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 ;
addln = _ ( " Default settings " ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( monitors - > templateMonitorConfigurationRotationCombo ) , _ ( " Default settings " ) ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( monitors - > templateMonitorConfigurationRotationCombo ) , _ ( " Left " ) ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( monitors - > templateMonitorConfigurationRotationCombo ) , _ ( " Right " ) ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( monitors - > templateMonitorConfigurationRotationCombo ) , _ ( " Invert " ) ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( monitors - > templateMonitorConfigurationRotationCombo ) , 0 ) ;
if ( yon_dictionary_get_data ( settings - > curconfig , monitorconfig * ) - > resolutionCapabilities )
for ( int res = 0 ; res < yon_dictionary_get_data ( settings - > curconfig , monitorconfig * ) - > resolution_size ; res + + ) {
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( monitors - > templateMonitorConfigurationResolutionCombo ) , yon_dictionary_get_data ( settings - > curconfig , monitorconfig * ) - > resolutionCapabilities [ res ] ) ;
}
if ( yon_dictionary_get_data ( settings - > curconfig , monitorconfig * ) - > stringparameters ) {
char * entry_text = yon_char_new ( yon_dictionary_get_data ( settings - > curconfig , monitorconfig * ) - > stringparameters ) ;
yon_char_divide_search ( entry_text , " = " , 1 ) ;
gtk_entry_set_text ( GTK_ENTRY ( monitors - > templateMonitorConfigurationParameterLineEntry ) , entry_text ) ;
}
if ( ( ( monitorconfig * ) settings - > curconfig - > data ) - > resolution )
if ( ( chosen = yon_gtk_combo_box_text_find ( monitors - > templateMonitorConfigurationResolutionCombo , ( ( monitorconfig * ) settings - > curconfig - > data ) - > resolution ) ) ! = - 1 )
gtk_combo_box_set_active ( GTK_COMBO_BOX ( monitors - > templateMonitorConfigurationResolutionCombo ) , chosen ) ;
}
MonitorSettings * yon_setup_monitor_settings ( ) {
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 ; i < monitors_n ; i + + ) {
for ( int 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 " ) ) ;
@ -253,42 +616,88 @@ MonitorSettings *yon_setup_monitor_settings(){
monitors [ i ] . templateMonitorInfoConfigureButton = GTK_WIDGET ( gtk_builder_get_object ( builder , " templateMonitorInfoConfigureButton " ) ) ;
monitors [ i ] . curconfig = yon_dictionary_get_nth ( videoconfig . monitors , i ) ;
printf ( " %d \n " , i ) ;
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 ( ! res ) res = _ ( " Default settings " ) ;
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 ( 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 ;
}
return monitors ;
}
int yon_check_for_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 ;
}
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 * yon_dictionary_pack_monitors ( MonitorSettings * monitors , int size )
{
dictionary * dict = yon_dictionary_create_with_data ( " 0 " , monitors [ 0 ] . templateMonitorConfigurationBox ) ;
for ( int i = 1 ; i < size ; i + + ) {
for ( int i = 1 ; i < size ; i + + )
{
dict = yon_dictionary_create_with_data_connected ( dict , yon_char_from_int ( i ) , monitors [ i ] . templateMonitorConfigurationBox ) ;
}
return dict ;
}
dictionary * yon_dictionary_pack_overlays ( MonitorSettings * monitors , int size ) {
dictionary * yon_dictionary_pack_overlays ( MonitorSettings * monitors , int size )
{
dictionary * dict = yon_dictionary_create_with_data ( " 0 " , monitors [ 0 ] . templateMonitorscreenOverlay ) ;
for ( int i = 1 ; i < size ; i + + ) {
for ( int i = 1 ; i < size ; i + + )
{
dict = yon_dictionary_create_with_data_connected ( dict , yon_char_from_int ( i ) , monitors [ i ] . templateMonitorscreenOverlay ) ;
}
return dict ;
}
void yon_setup_widgets ( widgets_dict * widgets ) {
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_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 " ) ;
@ -365,11 +774,19 @@ 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 - > mainDriverProprietaryDriverButton ) , " clicked " , G_CALLBACK ( on_ driver_window_open) , widgets - > mainDriverProprietaryDriverCombo ) ;
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 ) ;
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 - > mainDriverProprietaryDriverCombo ) , _ ( " Don't use " ) ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( widgets - > mainDriverFailsafeNvidiaCombo ) , _ ( " Off " ) ) ;
@ -406,21 +823,20 @@ void yon_setup_widgets(widgets_dict *widgets){
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 ) ;
// gtk_overlay_add_overlay(GTK_OVERLAY(widgets->mainHeadOverlay),widgets->headBox);
// 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 ( ) ) ;
// 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 ) ;
// 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 ) ;
@ -429,13 +845,13 @@ int main(int argc, char *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 ( ) ;
widgets_dict widgets ;
yon_setup_widgets ( & widgets ) ;
gtk_widget_show ( widgets . MainWindow ) ;
yon_fill_ui ( & widgets ) ;
yon_ubl_status_box_render ( widgets . mainStatusBox , widgets . mainStatusIcon , widgets . mainStatusLabel , " com.ublinux.ubl-settings-video.checked " , _ ( " Configuration has been loaded " ) , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
// yon_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 ) ;
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 ( ) ,