@ -2,102 +2,27 @@
config main_config ;
//signal emmit handlers - no header initialization
/**on_close_subwindow(GtkWidget *self)
* [ EN ]
* Closes window in which [ self ] is contained .
* [ RU ]
* З а к р ы в а е т о к н о , в к о т о р о м р а с п о л о ж е н в и д ж е т [ self ] .
*/
void on_close_subwindow ( GtkWidget * self ) {
gtk_widget_destroy ( gtk_widget_get_toplevel ( self ) ) ;
}
/**yon_open_browser(GtkWidget *self, char *link)
* [ EN ]
* Opens browser with [ link ] link .
* [ RU ]
* О т к р ы в а е т б р а у з е р с [ link ] с с ы л к о й .
*/
void yon_open_browser ( GtkWidget * self , char * link ) {
yon_ubl_browser_window_open ( link , TITLE_LABEL ) ;
}
/**on_open_documentation_confirmation(GtkWidget *self, char *link)
* [ EN ]
* Opens confirmation window for [ link ] link .
* [ RU ]
* О т к р ы в а е т о к н о п о д т в е р ж д е н и е п е р е х о д а п о с с ы л к е [ link ] .
*/
void on_open_documentation_confirmation ( GtkWidget * self , char * link ) {
if ( main_config . always_open_documentation = = 0 ) {
GtkBuilder * builder = gtk_builder_new_from_resource ( glade_path ) ;
documentation_confirmation_window * widgets = malloc ( sizeof ( documentation_confirmation_window ) ) ;
widgets - > Window = yon_gtk_builder_get_widget ( builder , " helpConfirmationWindow " ) ;
widgets - > AcceptButton = yon_gtk_builder_get_widget ( builder , " ReadHelpButton " ) ;
widgets - > CloseButton = yon_gtk_builder_get_widget ( builder , " CancelHelpButton " ) ;
widgets - > HatText = yon_gtk_builder_get_widget ( builder , " webHeaderNameLabel " ) ;
widgets - > HeaderText = yon_gtk_builder_get_widget ( builder , " helpHeader " ) ;
widgets - > InfoText = yon_gtk_builder_get_widget ( builder , " helpText " ) ;
widgets - > AlwaysOpenCheck = yon_gtk_builder_get_widget ( builder , " AlwaysOpenDocumentationCheckbox " ) ;
gtk_label_set_text ( GTK_LABEL ( widgets - > HatText ) , TITLE_LABEL ) ;
gtk_label_set_text ( GTK_LABEL ( widgets - > HeaderText ) , HELP_TITLE_LABEL ) ;
gtk_label_set_text ( GTK_LABEL ( widgets - > InfoText ) , HELP_INFO_LABEL ) ;
gtk_button_set_label ( GTK_BUTTON ( widgets - > AcceptButton ) , OPEN_HELP_LABEL ) ;
gtk_button_set_label ( GTK_BUTTON ( widgets - > AlwaysOpenCheck ) , HELP_ALWAYS_OPEN_LABEL ) ;
gtk_button_set_label ( GTK_BUTTON ( widgets - > CloseButton ) , CANCEL_LABEL ) ;
gtk_widget_show_all ( widgets - > Window ) ;
g_signal_connect ( G_OBJECT ( widgets - > CloseButton ) , " clicked " , G_CALLBACK ( on_close_subwindow ) , NULL ) ;
g_signal_connect ( G_OBJECT ( widgets - > AcceptButton ) , " clicked " , G_CALLBACK ( yon_open_browser ) , yon_char_new ( link ) ) ;
g_signal_connect ( G_OBJECT ( widgets - > AcceptButton ) , " clicked " , G_CALLBACK ( on_close_subwindow ) , NULL ) ;
} else {
yon_open_browser ( self , link ) ;
}
}
/**on_link(GtkWidget *self, char* uri, gpointer user_data)
* [ EN ]
* Signal for hadnling AboutDialog links .
* Connect to " activate-link " signal .
* [ self ] is AboutDialog window ;
* [ uri ] is activated link ;
* [ user_data ] is pointer for user data , hasn ' t used in standard handler ;
* [ RU ]
* Ф у н к ц и я д л я о б р а б о т к и с и г н а л а н а ж а т и я н а с с ы л к у о к н а AboutDialog .
* П р и с о е д и н я т ь к с и г н а л у " activate-link " .
* [ self ] - о к н о AboutDialog ;
* [ uri ] - с с ы л к а , п о к о т о р о й с о в е р ш а е т с я п е р е х о д ;
* [ user_data ] - у к а з а т е л ь н а л ю б ы е д р у г и е д а н н ы е , н е и с п о л ь з у е т с я в с т а н д а р т н о м о б р а б о т ч и к е ;
*/
void on_link ( GtkWidget * self , char * uri , gpointer user_data ) {
gtk_widget_destroy ( self ) ;
on_open_documentation_confirmation ( self , uri ) ;
}
/**on_about()
* [ EN ]
* Function for setting up and showing AboutDialog .
* Connect it to " activate " signal of Documentation MenuItem .
* [ RU ]
* Ф у н к и ц я д л я н а с т р о й к и и п о к а з а о к н а AboutDialog .
* П р и с о е д и н я т ь к с и г н а л у " activate " к н о п к и с п р а в к и т и п а MenuItem .
*/
void on_about ( ) {
GtkBuilder * builder = gtk_builder_new_from_resource ( glade_path ) ;
GtkWidget * window = yon_gtk_builder_get_widget ( builder , " AboutWindow " ) ;
GtkWidget * title = yon_gtk_builder_get_widget ( builder , " headerAboutTopic " ) ;
GtkWidget * hideButtonBox = yon_gtk_builder_get_widget ( builder , " buttonBoxHide " ) ;
gtk_about_dialog_set_version ( GTK_ABOUT_DIALOG ( window ) , version_application ) ;
gtk_about_dialog_set_website_label ( GTK_ABOUT_DIALOG ( window ) , PROJECT_HOME_LABEL ) ;
gtk_about_dialog_set_comments ( GTK_ABOUT_DIALOG ( window ) , TITLE_LABEL ) ;
gtk_label_set_text ( GTK_LABEL ( title ) , TITLE_LABEL ) ;
g_signal_connect ( G_OBJECT ( window ) , " activate-link " , G_CALLBACK ( on_link ) , NULL ) ;
gtk_widget_set_visible ( hideButtonBox , 0 ) ;
gtk_widget_destroy ( hideButtonBox ) ;
gtk_widget_show ( window ) ;
void on_save_done ( main_window * , config_str output , int size ) {
char * final_output = yon_char_parsed_to_string ( output , size , " " ) ;
if ( final_output ) {
printf ( " %s \n " , final_output ) ;
free ( final_output ) ;
}
yon_char_parsed_free ( output , size ) ;
textdomain ( template_ui_LocaleName ) ;
switch ( main_config . save_config ) {
case 0 :
yon_ubl_status_box_render ( GLOBAL_SAVE_SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
break ;
case 1 :
yon_ubl_status_box_render ( LOCAL_SAVE_SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
break ;
case 2 :
yon_ubl_status_box_render ( GLOBAL_LOCAL_SAVE_SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
break ;
}
textdomain ( LocaleName ) ;
}
//functions
@ -117,7 +42,7 @@ char *get_size_mod(GtkComboBox *combo){
return size_modifier ;
}
void on_device_limits_update ( GtkWidget * self , quota_window * window ) {
void on_device_limits_update ( GtkWidget * , quota_window * window ) {
if ( window - > devices - > data ) {
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitReadCheck ) ) )
yon_dictionary_get_data ( window - > devices , device_limits * ) - > read = yon_char_append ( yon_char_from_long ( gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitReadSpin ) ) ) , get_size_mod ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) ) ) ;
@ -130,19 +55,27 @@ void on_device_limits_update(GtkWidget *self, quota_window *window){
void on_quota_configuration_update ( GtkWidget * self , quota_window * window ) {
char * output_line = NULL ;
char * size_modifier = NULL ;
on_device_limits_update ( self , window ) ;
char * soft_limit = yon_char_unite ( " MemoryHigh= " , yon_char_from_long ( ( long ) gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > SoftRestrictionSpin ) ) ) , get_size_mod ( GTK_COMBO_BOX ( window - > SoftRestrictionCombo ) ) , NULL ) ;
char * hard_limit = yon_char_unite ( " MemoryMax= " , yon_char_from_long ( ( long ) gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > HardRestrictionSpin ) ) ) , get_size_mod ( GTK_COMBO_BOX ( window - > HardRestrictionCombo ) ) , NULL ) ;
char * paging_limit = yon_char_unite ( " MemorySwapMax= " , yon_char_from_long ( ( long ) gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > PagingLimitSpin ) ) ) , get_size_mod ( GTK_COMBO_BOX ( window - > PagingLimitCombo ) ) , NULL ) ;
char * cpu_limit = yon_char_unite ( " CPUQuota= " , yon_char_from_long ( ( long ) gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > CpuLimitSpin ) ) ) , " % " , NULL ) ;
long sft = ( long ) gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > SoftRestrictionSpin ) ) ;
long hrd = ( long ) gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > HardRestrictionSpin ) ) ;
long pgl = ( long ) gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > PagingLimitSpin ) ) ;
long cpu = ( long ) gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > CpuLimitSpin ) ) ;
char * soft_limit = " " ;
char * hard_limit = " " ;
char * paging_limit = " " ;
char * cpu_limit = " " ;
if ( sft ) soft_limit = yon_char_unite ( " MemoryHigh= " , yon_char_from_long ( sft ) , get_size_mod ( GTK_COMBO_BOX ( window - > SoftRestrictionCombo ) ) , NULL ) ;
if ( hrd ) hard_limit = yon_char_unite ( " MemoryMax= " , yon_char_from_long ( hrd ) , get_size_mod ( GTK_COMBO_BOX ( window - > HardRestrictionCombo ) ) , NULL ) ;
if ( pgl ) paging_limit = yon_char_unite ( " MemorySwapMax= " , yon_char_from_long ( pgl ) , get_size_mod ( GTK_COMBO_BOX ( window - > PagingLimitCombo ) ) , NULL ) ;
if ( cpu ) cpu_limit = yon_char_unite ( " CPUQuota= " , yon_char_from_long ( cpu ) , " % " , NULL ) ;
char * read_limit = " " ;
char * read_devices = " " ;
dictionary * dict ;
for_dictionaries ( dict , window - > devices ) {
if ( dict - > data & & yon_dictionary_get_data ( dict , device_limits * ) - > read )
read_devices = yon_char_unite ( read_devices , " IOReadBandwidthMax= " , yon_char_divide_search ( yon_char_new ( dict - > key ) , " " , - 1 ) , " " , yon_dictionary_get_data ( dict , device_limits * ) - > read , " , " , NULL ) ;
if ( ! strstr ( yon_dictionary_get_data ( dict , device_limits * ) - > read , " 0 " ) )
read_devices = yon_char_unite ( read_devices , " IOReadBandwidthMax= " , yon_char_divide_search ( yon_char_new ( dict - > key ) , " " , - 1 ) , " " , yon_dictionary_get_data ( dict , device_limits * ) - > read , " , " , NULL ) ;
}
if ( read_devices [ strlen ( read_devices ) - 1 ] = = ' , ' ) read_devices [ strlen ( read_devices ) - 1 ] = ' \0 ' ;
read_limit = yon_char_unite ( read_limit , read_devices , NULL ) ;
@ -152,7 +85,8 @@ void on_quota_configuration_update(GtkWidget *self, quota_window *window){
char * write_devices = " " ;
for_dictionaries ( dict , window - > devices ) {
if ( dict - > data & & yon_dictionary_get_data ( dict , device_limits * ) - > write )
write_devices = yon_char_unite ( write_devices , " IOWriteBandwidthMax= " , yon_char_divide_search ( yon_char_new ( dict - > key ) , " " , - 1 ) , " " , yon_dictionary_get_data ( dict , device_limits * ) - > write , " , " , NULL ) ;
if ( ! strstr ( yon_dictionary_get_data ( dict , device_limits * ) - > write , " 0 " ) )
write_devices = yon_char_unite ( write_devices , " IOWriteBandwidthMax= " , yon_char_divide_search ( yon_char_new ( dict - > key ) , " " , - 1 ) , " " , yon_dictionary_get_data ( dict , device_limits * ) - > write , " , " , NULL ) ;
}
if ( write_devices [ strlen ( write_devices ) - 1 ] = = ' , ' ) write_devices [ strlen ( write_devices ) - 1 ] = ' \0 ' ;
write_limit = yon_char_unite ( write_limit , write_devices , NULL ) ;
@ -167,7 +101,7 @@ void on_quota_configuration_update(GtkWidget *self, quota_window *window){
gtk_entry_set_text ( GTK_ENTRY ( window - > ManualInputEntry ) , output_line ) ;
}
void on_limit_manual_input ( GtkWidget * self , double * new_value , quota_window * window ) {
void on_limit_manual_input ( GtkWidget * self , double * , quota_window * window ) {
on_quota_configuration_update ( self , window ) ;
}
@ -281,78 +215,86 @@ void on_target_check_chosen(GtkWidget *self, quota_window *window){
void yon_get_devices ( quota_window * window ) {
int size = 0 ;
config_str devices_parsed = yon_config_load ( get_devices_command , & size ) ;
yon_char_parsed_remove_newline_symbols ( devices_parsed , & size ) ;
for ( int i = 0 ; i < size ; i + + ) {
yon_char_remove_last_symbol ( devices_parsed [ i ] , ' \n ' ) ;
yon_dictionary_add_or_create_if_exists_with_data ( window - > devices , devices_parsed [ i ] , NULL ) ;
}
}
void on_device_current_changed ( GtkWidget * self , quota_window * window ) {
void on_device_current_changed ( GtkWidget * , quota_window * window ) {
char * chosen = ( char * ) gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( window - > DeviceLimitCombo ) ) ;
if ( ! window - > devices - > data ) {
printf ( " %s \n " , gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( window - > DeviceLimitCombo ) ) ) ;
yon_dictionary_get ( & window - > devices , chosen ) ;
if ( ! window - > devices - > data )
if ( ! window - > devices - > data ) {
window - > devices - > data = g_malloc0 ( sizeof ( device_limits ) ) ;
( ( device_limits * ) window - > devices - > data ) - > write = NULL ;
( ( device_limits * ) window - > devices - > data ) - > read = NULL ;
}
( ( device_limits * ) window - > devices - > data ) - > write = NULL ;
( ( device_limits * ) window - > devices - > data ) - > read = NULL ;
} else {
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitReadCheck ) ) )
yon_dictionary_get_data ( window - > devices , device_limits * ) - > read = yon_char_append ( yon_char_from_long ( gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitReadSpin ) ) ) , get_size_mod ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) ) ) ;
else yon_dictionary_get_data ( window - > devices , device_limits * ) - > read = NULL ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitWriteCheck ) ) )
yon_dictionary_get_data ( window - > devices , device_limits * ) - > write = yon_char_append ( yon_char_from_long ( gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitWriteSpin ) ) ) , get_size_mod ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) ) ) ;
else yon_dictionary_get_data ( window - > devices , device_limits * ) - > write = NULL ;
long read_lim = gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitReadSpin ) ) ;
long write_lim = gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitWriteSpin ) ) ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitReadCheck ) ) ) {
if ( read_lim ) yon_dictionary_get_data ( window - > devices , device_limits * ) - > read = yon_char_append ( yon_char_from_long ( read_lim ) , get_size_mod ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) ) ) ;
} else yon_dictionary_get_data ( window - > devices , device_limits * ) - > read = NULL ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitWriteCheck ) ) ) {
if ( write_lim ) yon_dictionary_get_data ( window - > devices , device_limits * ) - > write = yon_char_append ( yon_char_from_long ( write_lim ) , get_size_mod ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) ) ) ;
} else yon_dictionary_get_data ( window - > devices , device_limits * ) - > write = NULL ;
yon_dictionary_get ( & window - > devices , chosen ) ;
if ( ! window - > devices - > data )
if ( ! window - > devices - > data ) {
window - > devices - > data = g_malloc0 ( sizeof ( device_limits ) ) ;
( ( device_limits * ) window - > devices - > data ) - > write = NULL ;
( ( device_limits * ) window - > devices - > data ) - > read = NULL ;
char * read = yon_dictionary_get_data ( window - > devices , device_limits * ) - > read ;
char * write = yon_dictionary_get_data ( window - > devices , device_limits * ) - > write ;
if ( read ) {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitReadSpin ) , atoi ( read ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitReadCheck ) , 1 ) ;
switch ( read [ strlen ( read ) - 1 ] ) {
case ' K ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 0 ) ;
break ;
case ' M ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 1 ) ;
break ;
case ' G ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 2 ) ;
break ;
case ' T ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 3 ) ;
break ;
}
} else {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitReadSpin ) , 0 ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitReadCheck ) , 0 ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 0 ) ;
}
( ( device_limits * ) window - > devices - > data ) - > write = NULL ;
( ( device_limits * ) window - > devices - > data ) - > read = NULL ;
char * read = yon_dictionary_get_data ( window - > devices , device_limits * ) - > read ;
char * write = yon_dictionary_get_data ( window - > devices , device_limits * ) - > write ;
if ( read ) {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitReadSpin ) , atoi ( read ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitReadCheck ) , 1 ) ;
switch ( read [ strlen ( read ) - 1 ] ) {
case ' K ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 0 ) ;
break ;
case ' M ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 1 ) ;
break ;
case ' G ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 2 ) ;
break ;
case ' T ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 3 ) ;
break ;
}
if ( write ) {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( window - > DeviceLimit WriteSpin) , atoi ( write ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimit WriteCheck) , 1 ) ;
switch ( write [ strlen ( write ) - 1 ] ) {
case ' K ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 0 ) ;
break ;
case ' M ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 1 ) ;
break ;
case ' G ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 2 ) ;
break ;
case ' T ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 3 ) ;
break ;
}
} else {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitWriteSpin ) , 0 ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitWriteCheck ) , 0 ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 0 ) ;
} else {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitReadSpin ) , 0 ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitReadCheck ) , 0 ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitReadCombo ) , 0 ) ;
}
if ( write ) {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitWriteSpin ) , atoi ( write ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitWriteCheck ) , 1 ) ;
switch ( write [ strlen ( write ) - 1 ] ) {
case ' K ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 0 ) ;
break ;
case ' M ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 1 ) ;
break ;
case ' G ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 2 ) ;
break ;
case ' T ' : gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 3 ) ;
break ;
}
} else {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( window - > DeviceLimitWriteSpin ) , 0 ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > DeviceLimitWriteCheck ) , 0 ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > DeviceLimitWriteCombo ) , 0 ) ;
}
}
}
void on_quotas_save ( GtkWidget * self , dictionary * windows ) {
quota_window * window = yon_dictionary_get_data ( windows - > first , quota_window * ) ;
main_window * widgets = yon_dictionary_get_data ( windows - > first - > next , main_window * ) ;
// main_window *widgets = yon_dictionary_get_data(windows->first->next,main_window*);
GtkTreeIter iter ;
if ( ! strcmp ( gtk_entry_get_text ( GTK_ENTRY ( window - > ManualInputEntry ) ) , " " ) ) {
yon_ubl_status_box_render ( OPERATION_FAILED_EMPTY_LABEL , BACKGROUND_IMAGE_FAIL_TYPE ) ;
return ;
}
const char * string = gtk_entry_get_text ( GTK_ENTRY ( window - > ManualInputEntry ) ) ;
const char * type = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( window - > TargetTypeCombo ) ) ;
const char * target = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( window - > TargetCombo ) ) ;
@ -381,8 +323,8 @@ void on_quotas_save(GtkWidget *self, dictionary *windows){
write_limit = yon_char_unite ( write_limit , write_devices , NULL ) ;
gtk_list_store_append ( main_config . list , & iter ) ;
gtk_list_store_set ( main_config . list , & iter , 0 , type , 1 , target , 2 , soft , 3 , hard , 4 , paging , 5 , cpu , 6 , read_limit , 7 , write_limit , 8 , string , - 1 ) ;
yon_config_register ( CGROUP_QUOTA ( ( char * ) target ) , yon_char_new( ( char * ) string ) ) ;
on_ close_ subwindow( self ) ;
yon_config_register ( CGROUP_QUOTA ( ( char * ) target ) , CGROUP_QUOTA_comd( ( char * ) target ) , yon_char_new( ( char * ) string ) ) ;
on_ subwindow_close ( self ) ;
yon_ubl_status_box_render ( SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
}
@ -401,12 +343,12 @@ int yon_get_size_request_from_letter(char size){
}
}
void yon_ load_proceed( char * command ) {
void yon_ interface_update( main_window * ) {
gtk_list_store_clear ( main_config . list ) ;
if ( yon_config_load_register ( command ) ) {
config_str rtn = yon_config_get_all ( ) ;
int parameters_size ;
config_str rtn = yon_config_get_all ( & parameters_size ) ;
char * quota = NULL ;
for ( int i = 0 ; rtn[ i ] ; i + + ) {
for ( int i = 0 ; i< parameters_size ; i + + ) {
quota = yon_char_new ( rtn [ i ] ) ;
char * name = yon_char_divide_search ( quota , " = " , - 1 ) ;
if ( quota [ 0 ] = = ' \" ' ) yon_char_divide ( quota , 0 ) ;
@ -461,48 +403,94 @@ void yon_load_proceed(char *command){
gtk_list_store_append ( main_config . list , & iter ) ;
gtk_list_store_set ( main_config . list , & iter , 0 , type , 1 , name , 2 , high , 3 , max , 4 , swap , 5 , cpu , 6 , read , 7 , write , 8 , quota , - 1 ) ;
}
}
}
void on_config_ load_global( ) {
yon_load_proceed ( load_global_command ) ;
yon_ubl_status_box_render ( GLOBAL_LOAD_SUCCESS , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
void on_config_ global_local_save( GtkWidget * , main_window * ) {
main_config . save_config = 3 ;
yon_save_proceed ( NULL , YON_CONFIG_BOTH , config_get_global_command , NULL ) ;
}
void on_config_lo ad_lo cal( ) {
yon_load_proceed ( load_local_command ) ;
yon_ubl_status_box_render ( LOCAL_LOAD_SUCCESS , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
void on_config_lo cal_save ( GtkWidget * , main_window * ) {
main_config . save_config = 1 ;
yon_save_proceed ( " system " , YON_CONFIG_LOCAL , config_get_local_command , NULL ) ;
}
void yon_save_proceed ( char * path , char * section ) {
yon_config_save_registered ( path , section ) ;
void on_config_global_save ( GtkWidget * , main_window * ) {
main_config . save_config = 0 ;
yon_save_proceed ( " global " , YON_CONFIG_GLOBAL , config_get_global_command , NULL ) ;
}
void on_config_save ( ) {
yon_save_proceed ( NULL , " security " ) ;
yon_ubl_status_box_render ( GLOBAL_LOCAL_SAVE_SUCCESS , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
void on_config_custom_save ( GtkWidget * , main_window * ) {
main_config . save_config = 1 ;
template_saving_window * window = yon_save_proceed ( NULL , YON_CONFIG_CUSTOM , yon_config_get_custom_command ( " system " ) , NULL ) ;
if ( window ) { } ;
}
void on_config_save_global ( ) {
yon_save_proceed ( " global " , " security " ) ;
yon_ubl_status_box_render ( GLOBAL_SAVE_SUCCESS , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
void on_config_local_load ( GtkWidget * , main_window * widgets ) {
yon_load_proceed ( YON_CONFIG_LOCAL ) ;
yon_interface_update ( widgets ) ;
main_config . load_mode = 1 ;
}
void on_config_global_load ( GtkWidget * , main_window * widgets ) {
yon_load_proceed ( YON_CONFIG_GLOBAL ) ;
yon_interface_update ( widgets ) ;
main_config . load_mode = 0 ;
}
void on_config_save_local ( ) {
yon_save_proceed ( " system " , " security " ) ;
yon_ubl_status_box_render ( LOCAL_SAVE_SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
void on_config_custom_load ( GtkWidget * , main_window * widgets ) {
yon_load_proceed ( YON_CONFIG_CUSTOM ) ;
textdomain ( template_ui_LocaleName ) ;
yon_ubl_status_box_render ( GLOBAL_LOAD_SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
textdomain ( LocaleName ) ;
main_config . load_mode = 3 ;
yon_interface_update ( widgets ) ;
}
void yon_load_proceed ( YON_CONFIG_TYPE type ) {
yon_config_clean ( ) ;
if ( ! yon_char_is_empty ( config_get_default_command ) )
yon_config_load_config ( YON_CONFIG_DEFAULT , config_get_default_command , NULL ) ;
if ( type = = YON_CONFIG_GLOBAL ) {
yon_config_load_config ( type , config_get_global_command , NULL ) ;
} else if ( type = = YON_CONFIG_LOCAL ) {
yon_config_load_config ( type , config_get_local_command , NULL ) ;
} else if ( type = = YON_CONFIG_CUSTOM ) {
char * path = " " ;
textdomain ( template_ui_LocaleName ) ;
GtkWidget * dialog = gtk_file_chooser_dialog_new ( template_app_information . app_title , NULL , GTK_FILE_CHOOSER_ACTION_SAVE , CANCEL_LABEL , GTK_RESPONSE_CANCEL , OPEN_LABEL , GTK_RESPONSE_ACCEPT , NULL ) ;
textdomain ( LocaleName ) ;
gtk_window_set_icon_name ( GTK_WINDOW ( dialog ) , " com.ublinux.ubl-settings-services " ) ;
gtk_window_set_title ( GTK_WINDOW ( dialog ) , TITLE_LABEL ) ;
GtkFileFilter * filter = gtk_file_filter_new ( ) ;
gtk_file_filter_add_pattern ( filter , " *.ini " ) ;
gtk_file_filter_set_name ( filter , " *.ini " ) ;
gtk_file_chooser_add_filter ( GTK_FILE_CHOOSER ( dialog ) , filter ) ;
gtk_widget_show ( dialog ) ;
int response = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
if ( response = = GTK_RESPONSE_ACCEPT ) {
char * file = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER ( dialog ) ) ;
if ( ! yon_char_is_empty ( file ) ) {
path = file ;
}
gtk_widget_destroy ( dialog ) ;
} else {
gtk_widget_destroy ( dialog ) ;
}
char * command = yon_config_get_custom_command ( path ) ;
yon_config_load_config ( type , command , NULL ) ;
}
}
void on_apply_filters ( GtkWidget * self , dictionary * dict ) {
GList * columns = yon_dictionary_get_data ( dict - > first , GList * ) ;
GList * checks = yon_dictionary_get_data ( dict - > first - > next , GList * ) ;
if ( g_list_length ( columns ) = = g_list_length ( checks ) ) {
for ( int i = 0 ; i < g_list_length ( columns ) ; i + + ) {
for ( gu int i = 0 ; i < g_list_length ( columns ) ; i + + ) {
if ( gtk_toggle_button_get_active ( ( GtkToggleButton * ) g_list_nth_data ( checks , i ) ) )
gtk_tree_view_column_set_visible ( ( GtkTreeViewColumn * ) g_list_nth_data ( columns , i ) , 1 ) ;
else {
@ -512,7 +500,7 @@ void on_apply_filters(GtkWidget *self, dictionary *dict){
} else {
printf ( " Error! Unequal quantity of filters and tree columns! " ) ;
}
on_ close_ subwindow( self ) ;
on_ subwindow_close ( self ) ;
}
void on_quota_manual_input ( GtkWidget * self , quota_window * window ) {
@ -633,34 +621,13 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){
} else return ;
}
}
// g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitCombo),G_CALLBACK(on_device_current_changed),window);
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitCombo),0);
// g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitCombo),G_CALLBACK(on_device_current_changed),window);
// if (window->devices->data){
// if (((device_limits*)window->devices->data)->read&&strcmp(((device_limits*)window->devices->data)->read,"")!=0){
// char *rd = ((device_limits*)window->devices->data)->read;
// g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_quota_configuration_update),window);
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
// g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_quota_configuration_update),window);
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),yon_get_size_request_from_letter(rd[strlen(rd)-1]));
// rd[strlen(rd)-1]='\0';
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),strtol(((device_limits*)window->devices->data)->read,NULL,10));
// }
// else ((device_limits*)window->devices->data)->read=NULL;
// if (((device_limits*)window->devices->data)->write&&strcmp(((device_limits*)window->devices->data)->write,"")!=0){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1);
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),yon_get_size_request_from_letter(((device_limits*)window->devices->data)->write[strlen(((device_limits*)window->devices->data)->write)-1]));
// ((device_limits*)window->devices->data)->write[strlen(((device_limits*)window->devices->data)->write)-1]='\0';
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),strtol(((device_limits*)window->devices->data)->write,NULL,10));
// } else ((device_limits*)window->devices->data)->write=NULL;
// }
}
void on_quota_manual_input_focus ( GtkWidget * self , GdkEventFocus * event , quota_window * window ) {
void on_quota_manual_input_focus ( GtkWidget * self , GdkEventFocus * , quota_window * window ) {
on_quota_manual_input ( self , window ) ;
}
void on_filters_opened ( GtkWidget * self , main_window * widgets ) {
void on_filters_opened ( GtkWidget * , main_window * widgets ) {
GtkBuilder * builder = gtk_builder_new_from_resource ( glade_filters_path ) ;
filters_window * window = g_malloc0 ( sizeof ( filters_window ) ) ;
@ -680,7 +647,7 @@ void on_filters_opened(GtkWidget *self, main_window *widgets) {
GList * columns = gtk_tree_view_get_columns ( GTK_TREE_VIEW ( widgets - > MainTree ) ) ;
GList * checks = gtk_container_get_children ( GTK_CONTAINER ( gtk_widget_get_parent ( window - > QuotaTypeCheck ) ) ) ;
if ( g_list_length ( columns ) = = g_list_length ( checks ) ) {
for ( int i = 0 ; i < g_list_length ( columns ) ; i + + ) {
for ( gu int i = 0 ; i < g_list_length ( columns ) ; i + + ) {
if ( gtk_tree_view_column_get_visible ( ( GtkTreeViewColumn * ) g_list_nth_data ( columns , i ) ) )
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( ( GtkToggleButton * ) g_list_nth_data ( checks , i ) ) , 1 ) ;
}
@ -692,14 +659,14 @@ void on_filters_opened(GtkWidget *self, main_window *widgets) {
yon_dictionary_add_or_create_if_exists_with_data ( dict , " columns " , columns ) ;
yon_dictionary_add_or_create_if_exists_with_data ( dict , " checks " , checks ) ;
g_signal_connect ( G_OBJECT ( window - > CancelButton ) , " clicked " , G_CALLBACK ( on_ close_ subwindow) , NULL ) ;
g_signal_connect ( G_OBJECT ( window - > CancelButton ) , " clicked " , G_CALLBACK ( on_ subwindow_close ) , NULL ) ;
g_signal_connect ( G_OBJECT ( window - > AcceptButton ) , " clicked " , G_CALLBACK ( on_apply_filters ) , dict ) ;
gtk_window_set_title ( GTK_WINDOW ( window - > Window ) , TITLE_LABEL ) ;
gtk_widget_show ( window - > Window ) ;
}
void on_add_open ( GtkWidget * self , main_window * widgets ) {
void on_add_open ( GtkWidget * , main_window * widgets ) {
GtkBuilder * builder = gtk_builder_new_from_resource ( glade_quota_path ) ;
quota_window * window = g_malloc0 ( sizeof ( quota_window ) ) ;
@ -755,7 +722,7 @@ void on_add_open(GtkWidget *self, main_window *widgets){
dictionary * windows = NULL ;
yon_dictionary_add_or_create_if_exists_with_data ( windows , " window " , window ) ;
yon_dictionary_add_or_create_if_exists_with_data ( windows , " widgets " , widgets ) ;
g_signal_connect ( G_OBJECT ( window - > CancelButton ) , " clicked " , G_CALLBACK ( on_ close_ subwindow) , NULL ) ;
g_signal_connect ( G_OBJECT ( window - > CancelButton ) , " clicked " , G_CALLBACK ( on_ subwindow_close ) , NULL ) ;
g_signal_connect ( G_OBJECT ( window - > SaveButton ) , " clicked " , G_CALLBACK ( on_quotas_save ) , windows ) ;
g_signal_connect ( G_OBJECT ( window - > TargetTypeCombo ) , " changed " , G_CALLBACK ( on_quota_target_type_changed ) , window ) ;
@ -822,8 +789,8 @@ void on_add_open(GtkWidget *self, main_window *widgets){
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( window - > DeviceLimitCombo ) , dict - > key ) ;
}
main_config . users = yon_ubl_get_all_users ( & main_config . users_size ) ;
main_config . processes = yon_ ubl_get_all_processes( & main_config . processes_size ) ;
main_config . slices = yon_ ubl_get_all_slices( & main_config . slices_size ) ;
main_config . processes = yon_ config_load( get_processes_command , & main_config . processes_size ) ;
main_config . slices = yon_ config_load( get_slices_command , & main_config . slices_size ) ;
for ( int i = 0 ; i < main_config . users_size ; i + + ) {
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( window - > TargetCombo ) , main_config . users [ i ] ) ;
}
@ -835,11 +802,12 @@ void on_information_chosen_changed(GtkWidget *self, main_window *widgets){
if ( chosen ) {
char * command = yon_char_unite ( get_information_command , ( char * ) chosen , " --no-pager " , NULL ) ;
main_config . last_info = yon_char_new ( ( char * ) chosen ) ;
yon_terminal_integrated_start ( widgets - > InformationTerminal , command , NULL , NULL ) ;
vte_terminal_reset ( VTE_TERMINAL ( widgets - > InformationTerminal ) , 1 , 1 ) ;
yon_terminal_integrated_start ( widgets - > InformationTerminal , command ) ;
}
}
void on_information ( GtkWidget * self , main_window * widgets ) {
void on_information ( GtkWidget * , main_window * widgets ) {
GtkTreeModel * model = GTK_TREE_MODEL ( main_config . list ) ;
GtkTreeIter iter ;
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > MainTree ) ) , & model , & iter ) ) {
@ -857,19 +825,21 @@ void on_information(GtkWidget *self, main_window *widgets){
g_signal_handlers_unblock_by_func ( G_OBJECT ( widgets - > TargetCombo ) , on_information_chosen_changed , widgets ) ;
char * command = yon_char_unite ( get_information_command , ( char * ) name , " --no-pager " , NULL ) ;
main_config . last_info = yon_char_new ( ( char * ) name ) ;
yon_terminal_integrated_start ( widgets - > InformationTerminal , command , NULL , NULL ) ;
vte_terminal_reset ( VTE_TERMINAL ( widgets - > InformationTerminal ) , 1 , 1 ) ;
yon_terminal_integrated_start ( widgets - > InformationTerminal , command ) ;
gtk_notebook_set_current_page ( GTK_NOTEBOOK ( widgets - > MainNotebook ) , 3 ) ;
yon_ubl_status_box_render ( SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
}
else yon_ubl_status_box_render ( NOTHING_CHOSEN_LABEL , BACKGROUND_IMAGE_FAIL_TYPE ) ;
}
void on_information_update ( GtkWidget * self , main_window * widgets ) {
void on_information_update ( GtkWidget * , main_window * widgets ) {
char * command = yon_char_unite ( get_information_command , main_config . last_info , " --no-pager " , NULL ) ;
yon_terminal_integrated_start ( widgets - > InformationTerminal , command , NULL , NULL ) ;
vte_terminal_reset ( VTE_TERMINAL ( widgets - > InformationTerminal ) , 1 , 1 ) ;
yon_terminal_integrated_start ( widgets - > InformationTerminal , command ) ;
}
void on_remove ( GtkWidget * self , main_window * widgets ) {
void on_remove ( GtkWidget * , main_window * widgets ) {
GtkTreeModel * model = GTK_TREE_MODEL ( main_config . list ) ;
GtkTreeIter iter ;
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > MainTree ) ) , & model , & iter ) ) {
@ -888,6 +858,10 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){
quota_window * window = yon_dictionary_get_data ( windows - > first , quota_window * ) ;
main_window * widgets = yon_dictionary_get_data ( windows - > first - > next , main_window * ) ;
GtkTreeIter iter ;
if ( ! strcmp ( gtk_entry_get_text ( GTK_ENTRY ( window - > ManualInputEntry ) ) , " " ) ) {
yon_ubl_status_box_render ( OPERATION_FAILED_EMPTY_LABEL , BACKGROUND_IMAGE_FAIL_TYPE ) ;
return ;
}
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > MainTree ) ) , & model , & iter ) ) {
const char * string = gtk_entry_get_text ( GTK_ENTRY ( window - > ManualInputEntry ) ) ;
const char * target = gtk_label_get_text ( GTK_LABEL ( window - > TargetLabel ) ) ;
@ -916,13 +890,13 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){
write_limit = yon_char_unite ( write_limit , write_devices , NULL ) ;
gtk_list_store_set ( main_config . list , & iter , 1 , target , 2 , soft , 3 , hard , 4 , paging , 5 , cpu , 6 , read_limit , 7 , write_limit , 8 , string , - 1 ) ;
yon_config_set ( CGROUP_QUOTA ( target ) , ( void * ) yon_char_new ( ( char * ) string ) ) ;
on_ close_ subwindow( self ) ;
on_ subwindow_close ( self ) ;
yon_ubl_status_box_render ( SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
}
else yon_ubl_status_box_render ( NOTHING_CHOSEN_LABEL , BACKGROUND_IMAGE_FAIL_TYPE ) ;
}
void on_edit_open ( GtkWidget * self , main_window * widgets ) {
void on_edit_open ( GtkWidget * , main_window * widgets ) {
GtkTreeModel * model = GTK_TREE_MODEL ( main_config . list ) ;
GtkTreeIter iter ;
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > MainTree ) ) , & model , & iter ) ) {
@ -1008,7 +982,7 @@ void on_edit_open(GtkWidget *self, main_window *widgets){
dictionary * windows = NULL ;
yon_dictionary_add_or_create_if_exists_with_data ( windows , " window " , window ) ;
yon_dictionary_add_or_create_if_exists_with_data ( windows , " widgets " , widgets ) ;
g_signal_connect ( G_OBJECT ( window - > CancelButton ) , " clicked " , G_CALLBACK ( on_ close_ subwindow) , NULL ) ;
g_signal_connect ( G_OBJECT ( window - > CancelButton ) , " clicked " , G_CALLBACK ( on_ subwindow_close ) , NULL ) ;
g_signal_connect ( G_OBJECT ( window - > SaveButton ) , " clicked " , G_CALLBACK ( on_quotas_edit ) , windows ) ;
g_signal_connect ( G_OBJECT ( window - > TargetTypeCombo ) , " changed " , G_CALLBACK ( on_quota_target_type_changed ) , window ) ;
@ -1181,13 +1155,13 @@ void on_edit_open(GtkWidget *self, main_window *widgets){
}
}
void on_dispatcher_update ( GtkWidget * self , main_window * widgets ) {
void on_dispatcher_update ( GtkWidget * , main_window * widgets ) {
int interval = gtk_spin_button_get_value ( GTK_SPIN_BUTTON ( widgets - > DispatcherUpdateSpin ) ) ;
if ( interval > 0 ) {
char * str_second = yon_char_from_int ( interval ) ;
char * command = yon_char_unite ( get_dispatcher_command , " -d " , str_second , NULL ) ;
if ( ! gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widgets - > DispatcherUpdateCheck ) ) ) command = yon_char_append ( command , " -n 1 " ) ;
yon_terminal_integrated_start ( widgets - > DispatcherTerminal , command , NULL , NULL ) ;
yon_terminal_integrated_start _shell ( widgets - > DispatcherTerminal , command , NULL , NULL ) ;
free ( str_second ) ;
GValue * val = g_malloc0 ( sizeof ( GValue ) ) ;
g_object_get_property ( G_OBJECT ( widgets - > DispatcherUpdateSpin ) , " has-focus " , val ) ;
@ -1197,16 +1171,16 @@ void on_dispatcher_update(GtkWidget *self,main_window *widgets){
}
}
void on_processes_update ( GtkWidget * self , main_window * widgets ) {
void on_processes_update ( GtkWidget * , main_window * widgets ) {
int show_all = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widgets - > ShowAllCheck ) ) ;
int show_core = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widgets - > ShowCoreCheck ) ) ;
char * command = get_processes_tree_command ;
if ( show_all ) yon_char_append ( command , " -k " ) ;
if ( show_core ) yon_char_append ( command , " -l " ) ;
yon_terminal_integrated_start ( widgets - > ProcessesTerminal , command , NULL , NULL ) ;
yon_terminal_integrated_start _shell ( widgets - > ProcessesTerminal , command , NULL , NULL ) ;
}
void on_tab_changed ( GtkWidget * self , GtkWidget * page , int page_num , main_window * widgets ) {
void on_tab_changed ( GtkWidget * , GtkWidget * , int , main_window * ) {
}
@ -1236,51 +1210,22 @@ void on_info_target_type_switched(GtkWidget *self, main_window *widgets){
// standard functions
void config_init ( ) {
main_config . always_open_documentation = 0 ;
main_config . win_height = 0 ;
main_config . win_width = 0 ;
main_config . win_pos_x = 0 ;
main_config . win_pos_y = 0 ;
main_config . socket_id = - 1 ;
main_config . save_socket_id = - 1 ;
main_config . load_socket_id = - 1 ;
main_config . lock_help = 0 ;
main_config . lock_help = 0 ;
main_config . lock_load_global = 0 ;
main_config . lock_save_global = 0 ;
main_config . lock_save_local = 0 ;
main_config . avaliable_ram = 0 ;
}
main_window * setup_window ( ) {
/* Widgets getting | Получение виджетов */
main_window * widgets = malloc ( sizeof ( main_window ) ) ;
GtkBuilder * builder = gtk_builder_new_from_resource ( glade_path ) ;
widgets - > Window = yon_gtk_builder_get_widget ( builder , " MainWindow " ) ;
widgets - > HatLabel = yon_gtk_builder_get_widget ( builder , " headerTopic " ) ;
widgets - > PlugBox = yon_gtk_builder_get_widget ( builder , " plugBox " ) ;
widgets - > HeadOverlay = yon_gtk_builder_get_widget ( builder , " HeadOverlay " ) ;
widgets - > HeadImage = yon_gtk_builder_get_widget ( builder , " HeadBackgroundImage " ) ;
widgets - > HeadBox = yon_gtk_builder_get_widget ( builder , " HeaderBox " ) ;
widgets - > HeadTitleLabel = yon_gtk_builder_get_widget ( builder , " HeaderTitleLabel " ) ;
widgets - > HeadInfoLabel = yon_gtk_builder_get_widget ( builder , " HeaderInfoLabel " ) ;
widgets - > StatusBox = yon_gtk_builder_get_widget ( builder , " mainStatusBox " ) ;
widgets - > StatusIcon = yon_gtk_builder_get_widget ( builder , " mainStatusIcon " ) ;
widgets - > StatusLabel = yon_gtk_builder_get_widget ( builder , " mainStatusLabel " ) ;
widgets - > SaveLabel = yon_gtk_builder_get_widget ( builder , " headerSaveConfigLabel " ) ;
widgets - > SaveMenuItem = yon_gtk_builder_get_widget ( builder , " SaveGlobalLocalConfigurationMenuItem " ) ;
widgets - > SaveGlobalMenuItem = yon_gtk_builder_get_widget ( builder , " SaveGlobalConfigurationMenuItem " ) ;
widgets - > SaveLocalMenuItem = yon_gtk_builder_get_widget ( builder , " SaveLocalConfigurationMenuItem " ) ;
widgets - > RightBox = yon_gtk_builder_get_widget ( builder , " HeaderRightBox " ) ;
widgets - > LoadLabel = yon_gtk_builder_get_widget ( builder , " headerLoadConfigLabel " ) ;
widgets - > LoadGlobalMenuItem = yon_gtk_builder_get_widget ( builder , " LoadGlobalConfigurationMenuItem " ) ;
widgets - > LoadLocalMenuItem = yon_gtk_builder_get_widget ( builder , " LoadLocalConfigurationMenuItem " ) ;
widgets - > LeftBox = yon_gtk_builder_get_widget ( builder , " HeaderLeftBox " ) ;
// void config_init(){
// main_config.avaliable_ram=0;
// }
/**yon_main_window_complete(main_window *widgets)
* [ EN ]
*
* [ RU ]
* Ф у н к ц и я н а с т р о й к и о с н о в н о г о о к н а п р и л о ж е н и я . [ widgets ] - с т р у к т у р а с о с т а н д а р т н ы м и н т е р ф е й с о м .
*/
void yon_main_window_complete ( main_window * widgets ) {
widgets = yon_remalloc ( widgets , sizeof ( main_window ) ) ;
GtkBuilder * builder = gtk_builder_new_from_resource ( glade_path ) ;
gtk_box_pack_start ( GTK_BOX ( widgets - > InterfaceBox ) , yon_gtk_builder_get_widget ( builder , " BoxMain " ) , 1 , 1 , 0 ) ;
// Custom widgets configuration
{
widgets - > FiltersButton = yon_gtk_builder_get_widget ( builder , " FiltersButton " ) ;
widgets - > InformationButton = yon_gtk_builder_get_widget ( builder , " InformationButton " ) ;
@ -1307,28 +1252,7 @@ main_window *setup_window(){
widgets - > InformationTerminal = yon_gtk_builder_get_widget ( builder , " InformationTerminal " ) ;
main_config . list = GTK_LIST_STORE ( gtk_builder_get_object ( builder , " liststore " ) ) ;
widgets - > DocumentationMenuItem = yon_ubl_menu_item_documentation_new ( DOCUMENTATION_LABEL ) ;
widgets - > AboutMenuItem = yon_ubl_menu_item_about_new ( ABOUT_LABEL ) ;
gtk_window_set_title ( GTK_WINDOW ( widgets - > Window ) , TITLE_LABEL ) ;
GtkWidget * menu = yon_gtk_builder_get_widget ( builder , " menu2 " ) ;
gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ) , widgets - > DocumentationMenuItem ) ;
gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ) , widgets - > AboutMenuItem ) ;
if ( main_config . lock_load_global = = 1 ) {
gtk_widget_set_sensitive ( widgets - > LoadGlobalMenuItem , 0 ) ;
}
if ( main_config . lock_save_global = = 1 ) {
gtk_widget_set_sensitive ( widgets - > SaveGlobalMenuItem , 0 ) ;
gtk_widget_set_sensitive ( widgets - > SaveMenuItem , 0 ) ;
}
if ( main_config . lock_save_local = = 1 ) {
gtk_widget_set_sensitive ( widgets - > SaveLocalMenuItem , 0 ) ;
gtk_widget_set_sensitive ( widgets - > SaveMenuItem , 0 ) ;
}
/* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */
// yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING);
@ -1353,131 +1277,62 @@ main_window *setup_window(){
g_signal_connect ( G_OBJECT ( widgets - > ProcessesUpdateButton ) , " clicked " , G_CALLBACK ( on_processes_update ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > InformationUpdateButton ) , " clicked " , G_CALLBACK ( on_information_update ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveMenuItem ) , " activate " , G_CALLBACK ( on_config_save ) , NULL ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveGlobalMenuItem ) , " activate " , G_CALLBACK ( on_config_save_global ) , NULL ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveLocalMenuItem ) , " activate " , G_CALLBACK ( on_config_save_local ) , NULL ) ;
g_signal_connect ( G_OBJECT ( widgets - > LoadGlobalMenuItem ) , " activate " , G_CALLBACK ( on_config_load_global ) , NULL ) ;
g_signal_connect ( G_OBJECT ( widgets - > LoadLocalMenuItem ) , " activate " , G_CALLBACK ( on_config_load_local ) , NULL ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveMenuItem ) , " activate " , G_CALLBACK ( on_config_global_local_save ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveGlobalMenuItem ) , " activate " , G_CALLBACK ( on_config_global_save ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveLocalMenuItem ) , " activate " , G_CALLBACK ( on_config_local_save ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveCustomMenuItem ) , " activate " , G_CALLBACK ( on_config_custom_save ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > LoadGlobalMenuItem ) , " activate " , G_CALLBACK ( on_config_global_load ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > LoadLocalMenuItem ) , " activate " , G_CALLBACK ( on_config_local_load ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > LoadCustomMenuItem ) , " activate " , G_CALLBACK ( on_config_custom_load ) , widgets ) ;
on_dispatcher_update ( NULL , widgets ) ;
on_processes_update ( NULL , widgets ) ;
yon_window_config_add_listener ( widgets - > DispatcherUpdateCheck , " DispatcherAutoupdate " , " active " , YON_TYPE_BOOLEAN ) ;
yon_window_config_add_listener ( widgets - > ShowAllCheck , " ProcessShowAll " , " active " , YON_TYPE_BOOLEAN ) ;
yon_window_config_add_listener ( widgets - > ShowCoreCheck , " ProcessShowCore " , " active " , YON_TYPE_BOOLEAN ) ;
yon_ window_config_add_listener( widgets - > DispatcherUpdateSpin , " DispatcherUpdateDelay " , " value " , YON_TYPE_DOUBLE ) ;
yon_ gtk_tree_view_minimal_fixed_size_set_full( GTK_TREE_VIEW ( widgets - > MainTree ) ) ;
GList * list = gtk_tree_view_get_columns ( GTK_TREE_VIEW ( widgets - > MainTree ) ) ;
for ( int i = 0 ; i < g_list_length ( list ) ; i + + ) {
for ( gu int i = 0 ; i < g_list_length ( list ) ; i + + ) {
yon_window_config_add_listener ( ( GtkWidget * ) g_list_nth_data ( list , i ) , yon_char_append ( " column " , yon_char_from_int ( i ) ) , " fixed-width " , YON_TYPE_INT ) ;
}
main_config . users = yon_ubl_get_all_users ( & main_config . users_size ) ;
main_config . processes = yon_ ubl_get_all_processes( & main_config . processes_size ) ;
main_config . slices = yon_ ubl_get_all_slices( & main_config . slices_size ) ;
main_config . processes = yon_ config_load( get_processes_command , & main_config . processes_size ) ;
main_config . slices = yon_ config_load( get_slices_command , & main_config . slices_size ) ;
on_info_target_type_switched ( widgets - > TargetTypeCombo , widgets ) ;
gtk_widget_show ( widgets - > Window ) ;
return widgets ;
}
yon_root_button_setup ( ( template_main_window * ) widgets , main_config . launch_arguments , main_config . launch_size ) ;
yon_save_window_set_postsave_function ( on_save_done , widgets ) ;
}
int main ( int argc , char * argv [ ] ) {
local = setlocale ( LC_ALL , " " ) ;
setlocale ( LC_ALL , " " ) ;
textdomain ( LocaleName ) ;
config_init ( ) ;
int option_index = 0 ;
int show_help = 0 ;
int debug_mode = 0 ;
{
struct option long_options [ ] = {
{ " help " , 0 , 0 , ' h ' } ,
{ " version " , 0 , 0 , ' V ' } ,
{ " lock-help " , 0 , 0 , 1 } ,
{ " lock-save " , 0 , 0 , 2 } ,
{ " lock-save-local " , 0 , 0 , 3 } ,
{ " lock-save-global " , 0 , 0 , 4 } ,
{ " lock-load-global " , 0 , 0 , 5 } ,
{ " socket-id " , 1 , 0 , ' s ' } ,
{ " socket-ext-id " , 1 , 0 , ' e ' } ,
{ " socket-trd-id " , 1 , 0 , ' t ' } ,
{ " debug " , 0 , 0 , ' d ' } ,
{ " clean-config " , 0 , 0 , ' c ' } ,
{ NULL , 0 , NULL , 0 }
} ;
for ( int i = 0 ; i < argc ; i + + ) {
int argument = getopt_long ( argc , argv , " hVvs:e:t:dc " , long_options , & option_index ) ;
switch ( argument ) {
case ' h ' :
show_help = 1 ;
break ;
case ' v ' :
case ' V ' :
printf ( " %s \n " , VERSION_LABEL ) ;
exit ( 0 ) ;
break ;
case ' s ' :
if ( optarg )
main_config . socket_id = atoi ( optarg ) ;
break ;
case ' e ' :
if ( optarg )
main_config . save_socket_id = atoi ( optarg ) ;
break ;
case ' t ' :
if ( optarg )
main_config . load_socket_id = atoi ( optarg ) ;
break ;
case ' c ' : rmdir ( yon_char_unite ( yon_ubl_user_get_home_directory ( ) , " / " , LocaleName , " / " , LocaleName , " .conf " , NULL ) ) ;
break ;
case 1 :
main_config . lock_help = 1 ;
break ;
case 2 :
main_config . lock_save_local = 1 ;
main_config . lock_save_global = 1 ;
break ;
case 3 :
main_config . lock_save_local = 1 ;
break ;
case 4 :
main_config . lock_save_global = 1 ;
break ;
case 5 :
main_config . lock_load_global = 1 ;
break ;
}
}
if ( show_help = = 1 & & main_config . lock_help ! = 1 ) {
printf ( " %s \n " , HELP_LABEL ) ;
exit ( 0 ) ;
}
}
if ( getuid ( ) ! = 0 ) {
main_config . lock_load_global = 1 ;
main_config . lock_save_global = 1 ;
main_config . lock_save_local = 1 ;
}
gtk_init ( & argc , & argv ) ;
yon_ubl_connect_config ( ( _template_config * ) & main_config ) ;
yon_ubl_window_init ( TITLE_LABEL , TITLE_INFO_LABEL , LocaleName , CssPath , LocaleName , version_application , WIKI_LINK ) ;
config_str unfound = NULL ;
int size = 0 ;
yon_ubl_setup_arguments ( argc , argv , & unfound , & size , NULL ) ;
gtk_init ( & argc , & argv ) ;
template_main_window * widgets = yon_ubl_window_setup ( ) ;
main_window * widgets = setup_window ( ) ;
yon_ubl_header_setup_resource ( widgets - > HeadOverlay , widgets - > HeadBox , widgets - > HeadImage , banner_path ) ;
yon_ubl_status_box_setup ( widgets - > StatusIcon , widgets - > StatusBox , widgets - > StatusLabel ) ;
yon_ubl_setup_sockets ( widgets - > PlugBox , widgets - > LeftBox , widgets - > RightBox , main_config . socket_id , main_config . load_socket_id , main_config . save_socket_id ) ;
yon_window_config_setup ( GTK_WINDOW ( widgets - > Window ) ) ;
yon_window_config_load ( config_path ) ;
on_config_load_local ( ) ;
GList * list = gtk_tree_view_get_columns ( GTK_TREE_VIEW ( widgets - > MainTree ) ) ;
for ( int i = 0 ; i < g_list_length ( list ) ; i + + ) {
yon_gtk_column_minimal_fixed_size_set ( ( GtkTreeViewColumn * ) g_list_nth_data ( list , i ) ) ;
}
g_list_free ( list ) ;
//turn off if custom presented
// yon_ubl_settings_window_set_standard_callbacks(widgets,config_get_global_command,config_get_local_command,yon_config_get_custom_command("./"),config_get_default_command,config_get_global_only_parameters,config_get_local_only_parameters);
if ( getuid ( ) ! = 0 )
yon_main_window_complete ( ( main_window * ) widgets ) ;
char * path = yon_char_unite ( yon_ubl_user_get_home_directory ( ) , " /.config/ " , LocaleName , " / " , LocaleName , " .conf " , NULL ) ;
yon_window_config_load ( path ) ;
main_config . launch_arguments = yon_char_parsed_copy ( argv , argc ) ;
main_config . launch_size = argc ;
if ( getuid ( ) ! = 0 ) {
textdomain ( template_ui_LocaleName ) ;
yon_ubl_status_box_render ( ROOT_WARNING_LABEL , BACKGROUND_IMAGE_FAIL_TYPE ) ;
else
yon_ubl_status_box_render ( LOCAL_LOAD_SUCCESS , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
GtkCssProvider * css = gtk_css_provider_new ( ) ;
gtk_css_provider_load_from_resource ( css , CssPath ) ;
gtk_style_context_add_provider_for_screen ( gdk_screen_get_default ( ) ,
GTK_STYLE_PROVIDER ( css ) ,
- 1 ) ;
textdomain ( LocaleName ) ;
}
gtk_main ( ) ;
return 0 ;
}