From 4e47dac2eb56004fab643a61b8c6872c474ac860 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 26 Jul 2024 16:39:09 +0600 Subject: [PATCH] Test changes for parameter toggles selection sensitivity --- source/ubinstall-gtk.c | 44 +++++++++++++++++++++++++++++++++---- source/ubinstall-gtk.h | 8 ++++++- ubinstall-gtk.glade | 50 ++++++++++++++++-------------------------- 3 files changed, 66 insertions(+), 36 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index f06b2bc..f1a3cdf 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -4,6 +4,37 @@ config main_config; //functions +void on_toggle_button_switch_on(GtkWidget *, GtkToggleButton *toggle){ + gtk_toggle_button_set_active(toggle,1); +} + +void on_autohostname_check(GtkWidget *, main_window *widgets){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),1); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck))){ + gtk_widget_set_sensitive(widgets->HotnameEntry,0); + }else{ + gtk_widget_set_sensitive(widgets->HotnameEntry,1); + } +} + +void on_autohostname_sensitiveness_check(GtkWidget *, main_window *widgets){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck))){ + gtk_widget_set_sensitive(widgets->AutoHostnameCheck,1); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck))){ + gtk_widget_set_sensitive(widgets->HotnameEntry,0); + } else + gtk_widget_set_sensitive(widgets->HotnameEntry,1); + } else { + gtk_widget_set_sensitive(widgets->HotnameEntry,0); + gtk_widget_set_sensitive(widgets->AutoHostnameCheck,0); + } +} + +void on_hostname_entry_changed (GtkWidget *, main_window *widgets){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),1); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),0); +} + void _yon_saving_threaded(char *final_command); void _yon_saving_threaded(char *final_command){ FILE *file = popen(final_command,"r"); @@ -144,6 +175,7 @@ void yon_interface_update(main_window *widgets){ } if (format&&!strcmp(format,"yes")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),1); else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),main_config.format_default); + if (!yon_char_is_empty(fs_type)) gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->NextInstallationFilesystemTypeCombo),fs_type); gtk_entry_set_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry),device_label); @@ -151,7 +183,8 @@ void yon_interface_update(main_window *widgets){ case YON_PAGE_INSTALL_SAME_PARTITION:{ device_tree = widgets->SamePlaceDeviceTree; part_tree = widgets->SamePlacePartTree; - gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->SameInstallationFilesystemTypeCombo),fs_type); + if (!yon_char_is_empty(fs_type)) + gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->SameInstallationFilesystemTypeCombo),fs_type); if (format&&!strcmp(format,"yes")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),1); else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),main_config.format_default); if (device_label) @@ -353,7 +386,9 @@ void yon_interface_update(main_window *widgets){ } } else { gtk_entry_set_text(GTK_ENTRY(widgets->HotnameEntry),""); + g_signal_handlers_block_by_func(G_OBJECT(widgets->AutoHostnameCheck),on_autohostname_check,widgets); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),1); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->AutoHostnameCheck),on_autohostname_check,widgets); } // if (fs_type) free(fs_type); @@ -1876,9 +1911,7 @@ main_window *yon_main_window_complete(){ widgets = yon_remalloc(widgets,sizeof(main_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); gtk_builder_add_callback_symbol(builder,"yon_gtk_widget_set_sensitive_from_toggle_button",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button)); - gtk_builder_add_callback_symbol(builder,"yon_gtk_toggle_button_set_inactive_from_toggle",G_CALLBACK(yon_gtk_toggle_button_set_inactive_from_toggle)); - gtk_builder_add_callback_symbol(builder,"yon_gtk_toggle_button_set_inactive_from_entry",G_CALLBACK(yon_gtk_toggle_button_set_inactive_from_entry)); - gtk_builder_add_callback_symbol(builder,"yon_gtk_toggle_button_set_inactive_from_combo_box",G_CALLBACK(yon_gtk_toggle_button_set_inactive_from_combo_box)); + gtk_builder_add_callback_symbol(builder,"on_toggle_button_switch_on",G_CALLBACK(on_toggle_button_switch_on)); // Custom widgets configuration widgets->builder = builder; @@ -2096,6 +2129,9 @@ main_window *yon_main_window_complete(){ g_signal_connect(G_OBJECT(widgets->NextInstallationFormatCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->NextInstallationFilesystemTypeCombo); g_signal_connect(G_OBJECT(widgets->SameInstallationFormatCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->SameInstallationFilesystemTypeCombo); + g_signal_connect(G_OBJECT(widgets->HostnameSensitiveCheck),"toggled",G_CALLBACK(on_autohostname_sensitiveness_check),widgets); + g_signal_connect(G_OBJECT(widgets->AutoHostnameCheck),"toggled",G_CALLBACK(on_autohostname_check),widgets); + g_signal_connect(G_OBJECT(widgets->HotnameEntry),"changed",G_CALLBACK(on_hostname_entry_changed),widgets); // g_signal_connect(G_OBJECT(widgets->InstallationToggle),"toggled",G_CALLBACK(on_toggle_block),widgets); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 608bd39..ac1f11e 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -446,4 +446,10 @@ char *yon_save_command_prepare(char *command, char *target); void yon_interface_update(main_window *widgets); void on_summary_log_view(GtkWidget *); -void on_near_installation_device_changed(GtkWidget *self, main_window *widgets); \ No newline at end of file +void on_near_installation_device_changed(GtkWidget *self, main_window *widgets); + +void on_toggle_button_switch_on(GtkWidget *, GtkToggleButton *toggle); + +void on_autohostname_sensitiveness_check(GtkWidget *, main_window *widgets); +void on_autohostname_check(GtkWidget *, main_window *widgets); +void on_hostname_entry_changed (GtkWidget *, main_window *widgets); \ No newline at end of file diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 7cec106..1f241e3 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -564,7 +564,6 @@ agreement 5 5 left - False True @@ -1638,7 +1637,7 @@ and help you install UBLinux on your computer True False False - + False @@ -1676,7 +1675,7 @@ and help you install UBLinux on your computer True False False - + False @@ -1968,7 +1967,7 @@ and help you install UBLinux on your computer Default (Regular 105-key) - + True @@ -2050,7 +2049,7 @@ and help you install UBLinux on your computer Scroll Lock Left Ctrl+Left Win - + True @@ -2119,7 +2118,7 @@ and help you install UBLinux on your computer False True True - + False @@ -2136,7 +2135,7 @@ and help you install UBLinux on your computer False True DefaultLayoutRadio - + False @@ -2368,7 +2367,7 @@ and help you install UBLinux on your computer False True Super Admin - + True @@ -2424,7 +2423,7 @@ and help you install UBLinux on your computer False True superadmin - + True @@ -2451,7 +2450,6 @@ and help you install UBLinux on your computer False True - @@ -2485,7 +2483,7 @@ and help you install UBLinux on your computer Default Set a password - + False @@ -2502,7 +2500,6 @@ and help you install UBLinux on your computer ****** password - True @@ -2574,7 +2571,6 @@ and help you install UBLinux on your computer False True - @@ -2608,7 +2604,7 @@ and help you install UBLinux on your computer Default Set a password - + False @@ -2625,7 +2621,6 @@ and help you install UBLinux on your computer ****** password - True @@ -2662,8 +2657,6 @@ and help you install UBLinux on your computer False False True - - @@ -2693,7 +2686,6 @@ and help you install UBLinux on your computer False True ubstation - True @@ -2709,7 +2701,6 @@ and help you install UBLinux on your computer True False True - False @@ -3207,7 +3198,7 @@ or continue working in the UBLinux Live environment. xfs zfs - + True @@ -3261,7 +3252,7 @@ or continue working in the UBLinux Live environment. True False True - + True @@ -3722,6 +3713,7 @@ installed. 0,0 adjustment1 1 + False @@ -3740,7 +3732,7 @@ installed. Gb Tb - + False @@ -3773,7 +3765,6 @@ installed. False False True - @@ -3814,7 +3805,7 @@ installed. xfs zfs - + True @@ -3829,7 +3820,6 @@ installed. False True False - True True @@ -3885,7 +3875,7 @@ installed. True False True - + True @@ -4309,7 +4299,6 @@ installed. False False True - @@ -4350,7 +4339,7 @@ installed. xfs zfs - + True @@ -4365,9 +4354,8 @@ installed. False True False - True True - + False @@ -4421,7 +4409,7 @@ installed. True False True - + True