@ -11,6 +11,14 @@ bool flag_load_global = false;
bool flag_lock_help = false ;
string version_application = " 1.0 " ;
MainWindow * obj_main ;
void wrapper_help_show ( GtkWidget * self , char * link , gpointer user_data ) {
if ( self & & user_data ) { }
obj_main - > global_lick_doc = link ;
obj_main - > aboutWindows - > hide ( ) ;
obj_main - > temp_help_show ( ) ;
}
CmdArgParser : : CmdArgParser ( const string & p_name , const string & p_description , const string & p_help )
: Glib : : OptionGroup { p_name , p_description , p_help } {
Glib : : OptionEntry socketIDArg ;
@ -62,6 +70,7 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
}
void MainWindow : : settings ( ) {
obj_main = this ;
map_cmd_error [ " " ] = " " ;
vec_param_names . push_back ( " GRUB_TIMEOUT " ) ;
vec_param_names . push_back ( " GRUB_CMDLINE_LINUX " ) ;
@ -182,7 +191,7 @@ void MainWindow::flag_block_gui() {
btnSaveLocalGlob - > set_sensitive ( false ) ;
}
if ( flag_lock_help = = true ) {
btn Synopsis - > set_sensitive ( false ) ;
btn Help - > set_sensitive ( false ) ;
}
}
@ -223,10 +232,8 @@ void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::Tr
treeViewMelody - > get_selection ( ) - > unselect_all ( ) ;
if ( flag_blocked_tree_view = = false ) {
string str_flags = template_item_selected ( size_kernel , list_store_kernel , " GRUB_CMDLINE_LINUX " ) ;
Utils : : str_replace_all ( str_flags , " \" " , " \" " ) ;
Utils : : str_replace_all ( str_flags , " \" " , " " ) ;
map_cmd_selection [ " GRUB_CMDLINE_LINUX " ] = str_flags ;
Utils : : str_replace_all ( str_flags , " " , " , " ) ;
// Utils::str_replace_all(str_flags, " ", ", ");
entryKernel - > set_text ( str_flags ) ;
}
}
@ -238,10 +245,8 @@ void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeM
treeViewMelody - > get_selection ( ) - > unselect_all ( ) ;
if ( flag_blocked_tree_view = = false ) {
string str_flags = template_item_selected ( size_OTT , list_store_OTT , " GRUB_TERMINAL_OUTPUT " ) ;
Utils : : str_replace_all ( str_flags , " \" " , " \" " ) ;
Utils : : str_replace_all ( str_flags , " \" " , " " ) ;
map_cmd_selection [ " GRUB_TERMINAL_OUTPUT " ] = str_flags ;
Utils : : str_replace_all ( str_flags , " " , " , " ) ;
// Utils::str_replace_all(str_flags, " ", ", ");
entryOTT - > set_text ( str_flags ) ;
}
}
@ -253,10 +258,8 @@ void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path&, const Gtk::TreeM
treeViewMelody - > get_selection ( ) - > unselect_all ( ) ;
if ( flag_blocked_tree_view = = false ) {
string str_flags = template_item_selected ( size_IPT , list_store_IPT , " GRUB_TERMINAL_INPUT " ) ;
Utils : : str_replace_all ( str_flags , " \" " , " \" " ) ;
Utils : : str_replace_all ( str_flags , " \" " , " " ) ;
map_cmd_selection [ " GRUB_TERMINAL_INPUT " ] = str_flags ;
Utils : : str_replace_all ( str_flags , " " , " , " ) ;
// Utils::str_replace_all(str_flags, " ", ", ");
entryIPT - > set_text ( str_flags ) ;
}
}
@ -315,27 +318,32 @@ void MainWindow::set_download_mode() {
}
string MainWindow : : template_item_selected ( int size , Glib : : RefPtr < Gtk : : ListStore > & list_store , string key ) {
string cmds = map_cmd_selection [ key ] ;
Utils : : str_replace_all ( cmds , " \" " , " " ) ;
string cmds_old = map_cmd_selection [ key ] ;
string cmds = " " ;
string param = " " ;
vector < string > vec_param = Utils : : split ( cmds_old , ' ' ) ;
for ( int index = 0 ; index < size ; index + + ) {
Gtk : : TreeModel : : Row row = list_store - > children ( ) [ index ] ;
if ( row ) {
string param = row [ m_columns . name ] + " " ;
if ( row [ m_columns . check_button ] = = true & & cmds . find ( param ) = = string : : npos ) {
cmds + = " " + param + " " ;
param = row [ m_columns . name ] + " " ;
if ( row [ m_columns . check_button ] = = true ) {
cmds + = param + " " ;
}
for ( size_t i = 0 ; i < vec_param . size ( ) ; i + + ) {
if ( param = = vec_param [ i ] ) {
vec_param . erase ( vec_param . begin ( ) + i ) ;
}
if ( row [ m_columns . check_button ] = = false & & cmds . find ( param ) ! = string : : npos ) {
Utils : : str_remove ( cmds , param ) ;
}
}
}
Utils : : str_replace_all ( cmds , " " , " " ) ;
if ( cmds . length ( ) > 0 ) {
if ( cmds [ 0 ] = = ' ' ) {
cmds = cmds . substr ( 1 , cmds . length ( ) - 1 ) ;
for ( size_t i = 0 ; i < vec_param . size ( ) ; i + + ) {
cmds + = vec_param [ i ] + " " ;
}
if ( cmds . length ( ) > 1 ) {
if ( cmds [ cmds . length ( ) - 1 ] = = ' ' ) {
cmds = cmds . substr ( 0 , cmds . length ( ) - 1 ) ;
}
}
cmds = " \" " + cmds + " \" " ;
return cmds ;
}
@ -386,7 +394,7 @@ void MainWindow::get_builder() {
builder - > get_widget ( " boxColor " , boxColor ) ;
builder - > get_widget ( " boxWidgetAll " , boxWidgetAll ) ;
builder - > get_widget ( " aboutWindows " , aboutWindows ) ;
builder - > get_widget ( " btn Synopsis" , btnSynopsis ) ;
builder - > get_widget ( " btn Help" , btnHelp ) ;
builder - > get_widget ( " btnAbout " , btnAbout ) ;
builder - > get_widget ( " btnLoadLocal " , btnLoadLocal ) ;
builder - > get_widget ( " btnLoadGlob " , btnLoadGlob ) ;
@ -459,7 +467,7 @@ void MainWindow::localization() {
lblInfoInputTerminal - > set_text ( terminal_for_input ) ;
lblInfoOutputTerminal - > set_text ( terminal_for_output ) ;
chbLoadVariantSelectionTimer - > set_label ( boot_selection_menu_timer ) ;
btn Synopsis - > set_label ( str_help ) ;
btn Help - > set_label ( str_help ) ;
btnAbout - > set_label ( str_about_1 ) ;
lblHeadeWndWeb - > set_text ( name_app ) ;
btnSaveLocalGlob - > set_label ( save_all ) ;
@ -533,23 +541,20 @@ void MainWindow::set_entry_to_tree_view(Glib::RefPtr<Gtk::ListStore> &list_store
flag_blocked_tree_view = true ;
vector < string > vec_params ;
std : : string text = entry . get_text ( ) ;
Utils : : str_replace_all ( text , " " , " " ) ;
vec_params = Utils : : split ( text , ' , ' ) ;
// Utils::str_replace_all(text, " ", "");
vec_params = Utils : : split ( text , ' ' ) ;
for ( auto & name : vec_Option ) {
this - > set_row ( list_store , size , name , false ) ;
}
for ( auto & name : vec_params ) {
this - > set_row ( list_store , size , name , true ) ;
}
Utils : : str_replace_all ( text , " , " , " " ) ;
// Utils::str_replace_all(text, ",", " ");
if ( text . length ( ) > 0 ) {
if ( text [ 0 ] = = ' ' ) {
text = text . substr ( 1 , text . length ( ) - 1 ) ;
}
}
if ( text . find ( " \" " ) = = string : : npos & & text . length ( ) ! = 0 ) {
text = " \" " + text + " \" " ;
}
map_cmd_selection [ key ] = text ;
}
@ -592,6 +597,7 @@ void MainWindow::cmd_entry_all(Gtk::Entry &entry, string cmd_settings, string cm
}
void MainWindow : : event ( ) {
g_signal_connect ( G_OBJECT ( aboutWindows - > gobj ( ) ) , " activate-link " , G_CALLBACK ( wrapper_help_show ) , NULL ) ;
btnRemoveUser - > signal_clicked ( ) . connect ( [ & ] ( ) { remove_user ( ) ; } ) ;
btnRemoveMusic - > signal_clicked ( ) . connect ( [ & ] ( ) { remove_melody ( ) ; } ) ;
btnAddUser - > signal_clicked ( ) . connect ( [ & ] ( ) { string name = " " , passwd = " " ;
@ -602,7 +608,7 @@ void MainWindow::event() {
btnCancelHelp - > signal_clicked ( ) . connect ( [ & ] ( ) { wndShowWeb - > hide ( ) ; } ) ;
chkAlwaysOpenHelp - > signal_toggled ( ) . connect ( [ & ] ( ) { flag_open_browser = true ; } ) ;
btnReadHelp - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : open_browser ) ) ;
btn Synopsis - > signal_activate ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : synopsis_show ) ) ;
btn Help - > signal_activate ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : open_help ) ) ;
btnAbout - > signal_activate ( ) . connect ( [ & ] ( ) { aboutWindows - > show ( ) ; } ) ;
btnLoadLocal - > signal_activate ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : download_local_cfg ) ) ;
btnLoadGlob - > signal_activate ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : download_globl_cfg ) ) ;
@ -696,7 +702,7 @@ void MainWindow::set_init_data_user(std::map<string, string> &map_temp) {
}
}
Glib : : RefPtr < Gtk : : TreeModel > treeViewUserModel = treeViewUser - > get_model ( ) ;
treeViewUserModel - > signal_row_changed ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : remove _line_user) ) ;
treeViewUserModel - > signal_row_changed ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : select _line_user) ) ;
this - > view_add_colums_user ( * treeViewUser ) ;
}
@ -758,6 +764,7 @@ void MainWindow::set_add_data_user(Gtk::TreeModel::Row &row, bool flag, string &
row [ m_columns_user . check_button ] = flag ;
row [ m_columns_user . name ] = name ;
row [ m_columns_user . password ] = password ;
len_old_user + = 1 ;
}
void MainWindow : : set_init_data_melody ( std : : map < string , string > & map_temp ) {
@ -776,7 +783,7 @@ void MainWindow::set_init_data_melody(std::map<string, string> &map_temp) {
this - > set_add_data_melody ( row_melody , flag , name , code ) ;
}
Glib : : RefPtr < Gtk : : TreeModel > treeViewMelodyModel = treeViewMelody - > get_model ( ) ;
treeViewMelodyModel - > signal_row_changed ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : remove _line_melody) ) ;
treeViewMelodyModel - > signal_row_changed ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : select _line_melody) ) ;
this - > view_add_colums_melody ( * treeViewMelody ) ;
}
@ -785,6 +792,7 @@ void MainWindow::set_add_data_melody(Gtk::TreeModel::Row &row, bool flag, string
row [ m_columns_melody . check_button ] = flag ;
row [ m_columns_melody . title ] = name ;
row [ m_columns_melody . melody_code ] = code ;
len_old_melody + = 1 ;
}
void MainWindow : : remove_user ( ) {
@ -799,7 +807,7 @@ void MainWindow::remove_user() {
flag_validate_del_user = false ;
info_status_app ( info_box_ok_css ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( " " ) ;
lblWarning - > set_text ( str_del_user ) ;
}
flag_validate_del_user = false ;
}
@ -810,12 +818,12 @@ void MainWindow::remove_melody() {
flag_validate_del_melody = false ;
info_status_app ( info_box_ok_css ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( " " ) ;
lblWarning - > set_text ( str_del_melody ) ;
}
flag_validate_del_melody = false ;
}
void MainWindow : : remove _line_user( const Gtk : : TreeModel : : Path & , const Gtk : : TreeModel : : iterator & iter ) {
void MainWindow : : select _line_user( const Gtk : : TreeModel : : Path & , const Gtk : : TreeModel : : iterator & iter ) {
treeViewKernel - > get_selection ( ) - > unselect_all ( ) ;
treeViewOTT - > get_selection ( ) - > unselect_all ( ) ;
treeViewIPT - > get_selection ( ) - > unselect_all ( ) ;
@ -825,15 +833,17 @@ void MainWindow::remove_line_user(const Gtk::TreeModel::Path&, const Gtk::TreeMo
bool flag_error = false ;
string name = " " ;
string password = " " ;
size_t len_new_user = 0 ;
Glib : : RefPtr < Gtk : : TreeModel > treeViewUser_model = treeViewUser - > get_model ( ) ;
Gtk : : TreeModel : : Children children = treeViewUser_model - > children ( ) ;
for ( Gtk : : TreeModel : : iterator iter = children . begin ( ) ; iter ! = children . end ( ) ; + + iter ) {
Gtk : : TreeModel : : Row row = * iter ;
name = row [ m_columns_user . name ] + " " ;
password = row [ m_columns_user . password ] + " " ;
len_new_user + = 1 ;
if ( name . length ( ) = = 0 | | password . length ( ) = = 0 ) {
flag_error = true ;
break ;
}
}
if ( flag_error = = true ) {
@ -842,13 +852,16 @@ void MainWindow::remove_line_user(const Gtk::TreeModel::Path&, const Gtk::TreeMo
lblWarning - > set_text ( str_null_username ) ;
}
else {
if ( ( len_old_user - 1 ) ! = len_new_user ) {
info_status_app ( info_box_ok_css ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( " " ) ;
lblWarning - > set_text ( str_add_user ) ;
}
}
len_old_user = len_new_user ;
}
void MainWindow : : remove _line_melody( const Gtk : : TreeModel : : Path & , const Gtk : : TreeModel : : iterator & iter ) {
void MainWindow : : select _line_melody( const Gtk : : TreeModel : : Path & , const Gtk : : TreeModel : : iterator & iter ) {
treeViewKernel - > get_selection ( ) - > unselect_all ( ) ;
treeViewOTT - > get_selection ( ) - > unselect_all ( ) ;
treeViewIPT - > get_selection ( ) - > unselect_all ( ) ;
@ -857,6 +870,7 @@ void MainWindow::remove_line_melody(const Gtk::TreeModel::Path&, const Gtk::Tree
flag_validate_del_melody = true ;
string code_melodyes = " " ;
string melody_title = " " ;
size_t len_new_melody = 0 ;
bool flag_error = false ;
Glib : : RefPtr < Gtk : : TreeModel > treeViewMelody_model = treeViewMelody - > get_model ( ) ;
Gtk : : TreeModel : : Children children = treeViewMelody_model - > children ( ) ;
@ -864,9 +878,9 @@ void MainWindow::remove_line_melody(const Gtk::TreeModel::Path&, const Gtk::Tree
Gtk : : TreeModel : : Row row = * iter ;
code_melodyes = row [ m_columns_melody . melody_code ] + " " ;
melody_title = row [ m_columns_melody . title ] + " " ;
len_new_melody + = 1 ;
if ( code_melodyes . length ( ) = = 0 | | melody_title . length ( ) = = 0 ) {
flag_error = true ;
break ;
}
}
if ( flag_error = = true ) {
@ -875,12 +889,14 @@ void MainWindow::remove_line_melody(const Gtk::TreeModel::Path&, const Gtk::Tree
lblWarning - > set_text ( str_null_melody_name ) ;
}
else {
if ( ( len_old_melody - 1 ) ! = len_new_melody ) {
info_status_app ( info_box_ok_css ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( " " ) ;
lblWarning - > set_text ( str_add_melody ) ;
}
}
this - > validate_melody ( ) ;
len_old_melody = len_new_melody ;
}
void MainWindow : : validate_melody ( ) {
@ -1003,15 +1019,15 @@ void MainWindow::wrapper_save_local_cfg() {
void MainWindow : : set_data_cfg ( ) {
string str_flags = entryKernel - > get_text ( ) ;
Utils : : str_remove ( str_flags , " , " ) ;
// Utils::str_remove(str_flags, ",");
Utils : : str_replace_all ( str_flags , " \" " , " \" " ) ;
map_cmd_selection [ " GRUB_CMDLINE_LINUX " ] = str_flags ;
str_flags = entryIPT - > get_text ( ) ;
Utils : : str_remove ( str_flags , " , " ) ;
// Utils::str_remove(str_flags, ",");
Utils : : str_replace_all ( str_flags , " \" " , " \" " ) ;
map_cmd_selection [ " GRUB_TERMINAL_INPUT " ] = str_flags ;
str_flags = entryOTT - > get_text ( ) ;
Utils : : str_remove ( str_flags , " , " ) ;
// Utils::str_remove(str_flags, ",");
Utils : : str_replace_all ( str_flags , " \" " , " \" " ) ;
map_cmd_selection [ " GRUB_TERMINAL_OUTPUT " ] = str_flags ;
if ( chbLoadVariantSelectionTimer - > get_active ( ) ) {
@ -1087,7 +1103,7 @@ void MainWindow::set_entry(Gtk::Entry* entry, std::map<string, string> &map_temp
if ( map_temp . find ( key ) ! = map_temp . end ( ) ) {
string value = map_temp [ key ] ;
Utils : : str_replace_all ( value , " \" " , " " ) ;
Utils : : str_replace_all ( value , " " , " , " ) ;
// Utils::str_replace_all(value, " ", ", ");
entry - > set_text ( value ) ;
}
else {
@ -1138,7 +1154,7 @@ void MainWindow::set_row(Glib::RefPtr<Gtk::ListStore> &list_store, int size, str
}
}
void MainWindow : : synopsis _show( ) {
void MainWindow : : temp_help _show( ) {
if ( flag_open_browser = = true ) {
this - > open_browser ( ) ;
}
@ -1148,17 +1164,23 @@ void MainWindow::synopsis_show() {
}
void MainWindow : : open_help ( ) {
global_lick_doc = const_link_doc ;
temp_help_show ( ) ;
}
void MainWindow : : open_browser ( ) {
# ifdef WEBKIT_FOUND
webkit_web_view_load_uri ( one , link_doc ) ;
webkit_web_view_load_uri ( one , _( global_lick_doc . c_str ( ) ) ) ;
wndWeb - > show_all ( ) ;
# else
this - > template_open_browser ( ) ;
this - > template_open_browser ( global_lick_doc ) ;
# endif
wndShowWeb - > hide ( ) ;
}
void MainWindow : : template_open_browser ( ) {
string cmd = cmd_xdg + string ( _ ( link_doc )) + " & " ;
void MainWindow : : template_open_browser ( string link_doc ) {
string cmd = cmd_xdg + string ( _ ( link_doc .c_str ( ) )) + " & " ;
string buf = " " ;
if ( geteuid ( ) = = 0 ) {
string response_user = getlogin ( ) ;
@ -1240,7 +1262,6 @@ void MainWindow::add_CSS() {
Glib : : RefPtr < Gtk : : StyleContext > styleContext = Gtk : : StyleContext : : create ( ) ;
Glib : : RefPtr < Gdk : : Screen > screen = Gdk : : Screen : : get_default ( ) ; //get default screen
styleContext - > add_provider_for_screen ( screen , cssProvider , GTK_STYLE_PROVIDER_PRIORITY_APPLICATION ) ; //add provider for screen in all application
Glib : : RefPtr < Gtk : : StyleContext > lblInfoHead_css = lblInfoHead - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > boxButton_css = boxButton - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > boxSave_css = boxSave - > get_style_context ( ) ;
boxInfo = boxInfoError - > get_style_context ( ) ;
@ -1249,7 +1270,6 @@ void MainWindow::add_CSS() {
boxButton_css - > add_class ( " bkim_no_plug " ) ;
boxSave_css - > add_class ( " bkim_no_plug " ) ;
}
lblInfoHead_css - > add_class ( " textHead " ) ;
}
void help ( ) {