From 03857aa110521fd5bb8dc3cbee70988675fb586c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Sep 2024 11:07:49 +0600 Subject: [PATCH] Fixed device and partitions lables --- source/ubinstall-gtk.c | 66 +++++++++++++++++++++++++++++++------ source/ubinstall-gtk.h | 14 +++++--- source/ubl-strings.h | 6 ++-- ubinstall-gtk-warning.glade | 4 +-- ubinstall-gtk.glade | 23 +++++++++---- ubinstall-gtk.pot | 2 +- ubinstall-gtk_ru.po | 2 +- 7 files changed, 89 insertions(+), 28 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index c8d05a7..640df44 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -1788,8 +1788,17 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ case YON_PAGE_INSTALL_ERROR: case YON_PAGE_COMPLETION: - if (!system("reboot")) - return; + confirmation_window *window = yon_confirmation_window_new(); + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_reboot_accepted),dict); + gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow)); + gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); + gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_path); + gtk_label_set_text(GTK_LABEL(window->TextLabel),WARNING_TEXT_LABEL); + gtk_label_set_text(GTK_LABEL(window->TitleLabel),WARNING_TITLE_LABEL); + gtk_widget_show(window->Window); break; case YON_PAGE_INSTALL_OPTIONS: { @@ -2121,7 +2130,7 @@ void on_near_installation_device_changed(GtkWidget *self, main_window *widgets){ json_object_object_get_ex(root, "blockdevices", &blockdevices); for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { struct json_object *device = json_object_array_get_idx(blockdevices, i); - struct json_object *type, *path, *size, *model, *fstype, *fsused; + struct json_object *type, *path, *size, *model, *fstype, *fsused, *label; json_object_object_get_ex(device, "type", &type); if (strcmp("part",json_object_get_string(type))) @@ -2132,6 +2141,7 @@ void on_near_installation_device_changed(GtkWidget *self, main_window *widgets){ } json_object_object_get_ex(device, "size", &size); json_object_object_get_ex(device, "model", &model); + json_object_object_get_ex(device, "label", &label); json_object_object_get_ex(device, "fstype", &fstype); json_object_object_get_ex(device, "fsused", &fsused); @@ -2165,7 +2175,7 @@ void on_near_installation_device_changed(GtkWidget *self, main_window *widgets){ // gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),0.0); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin)),0.0); gtk_list_store_append(widgets->PartitionsList,&iter); - gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(size),2,free_space_string,3,json_object_get_string(fstype),-1); + gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(size),2,free_space_string,3,json_object_get_string(fstype),4,json_object_get_string(label),-1); } yon_char_parsed_free(parsed,size); } @@ -2217,6 +2227,22 @@ void on_gparted_open(){ gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets); +void on_reboot_accepted(GtkWidget *,dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + confirmation_window *window = yon_dictionary_get_data(dict->first->next,confirmation_window*); + g_mutex_lock(&main_config.install_mutex); + if (main_config.install_thread){ + pthread_cancel((pthread_t)main_config.install_thread); + g_mutex_unlock(&main_config.install_mutex); + } + main_config.exit_accepted=1; + g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event"); + free(window); + yon_dictionary_free_all(dict,NULL); + free(dict); + if (system("reboot")){}; +} + void on_exit_accepted(GtkWidget *,dictionary *dict); void on_exit_accepted(GtkWidget *,dictionary *dict){ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); @@ -2234,23 +2260,31 @@ void on_exit_accepted(GtkWidget *,dictionary *dict){ gtk_widget_destroy(widgets->MainWindow); } -gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ - if (!main_config.exit_accepted){ - if (widgets){}; - confirmation_window *window = malloc(sizeof(confirmation_window)); +confirmation_window *yon_confirmation_window_new(){ + confirmation_window *window = malloc(sizeof(confirmation_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_confirmation); window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->TitleLabel = yon_gtk_builder_get_widget(builder,"TitleLabel"); + window->TextLabel = yon_gtk_builder_get_widget(builder,"TextLabel"); window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + return window; +} + +gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ + if (!main_config.exit_accepted){ + if (widgets){}; + confirmation_window *window = yon_confirmation_window_new(); dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),dict); - g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow)); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_path); + gtk_label_set_text(GTK_LABEL(window->TextLabel),WARNING_TEXT_LABEL); + gtk_label_set_text(GTK_LABEL(window->TitleLabel),WARNING_TITLE_LABEL); gtk_widget_show(window->Window); @@ -2498,6 +2532,18 @@ main_window *yon_main_window_complete(){ g_signal_connect(G_OBJECT(widgets->RootPasswordSensitiveCheck),"toggled",G_CALLBACK(yon_password_set_sensitive_from_toggle),widgets); g_signal_connect(G_OBJECT(widgets->PasswordSensitiveCheck),"toggled",G_CALLBACK(yon_password_set_sensitive_from_toggle),widgets); + if (main_config.lock_load_global == 1){ + gtk_widget_set_sensitive(widgets->LoadGlobalConfigurationMenuItem,0); + } + if (main_config.lock_save_global == 1){ + gtk_widget_set_sensitive(widgets->SaveGlobalConfigurationMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveGlobalLocalConfigurationMenuItem,0); + } + if (main_config.lock_save_local == 1){ + gtk_widget_set_sensitive(widgets->SaveLocalConfigurationMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveGlobalLocalConfigurationMenuItem,0); + } + gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter),0); gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 454face..519c4cd 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -35,9 +35,9 @@ #define LocalePath "/usr/share/locale" #define LocaleName "ubinstall-gtk" -#define clear_config_both_command "ubconfig remove TEMP_SECTION TEMP_PATAMETER" -#define clear_config_global_command "ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER" -#define clear_config_local_command "ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER" +#define clear_config_both_command "pkexec bash -c 'ubconfig remove TEMP_SECTION TEMP_PATAMETER '" +#define clear_config_global_command "pkexec bash -c 'ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER '" +#define clear_config_local_command "pkexec bash -c 'ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER '" #define regions_path "/com/ublinux/images/map-time-zone.png" #define keyboard_path "/com/ublinux/images/keyboard.png" @@ -441,6 +441,8 @@ typedef struct { typedef struct { GtkWidget *Window; + GtkWidget *TitleLabel; + GtkWidget *TextLabel; GtkWidget *AcceptButton; GtkWidget *CancelButton; } confirmation_window; @@ -470,4 +472,8 @@ void on_hostname_entry_changed (GtkWidget *, main_window *widgets); gboolean on_install_success(main_window *widgets); -void *on_install_error(main_window *widgets); \ No newline at end of file +void *on_install_error(main_window *widgets); + +confirmation_window *yon_confirmation_window_new(); + +void on_reboot_accepted(GtkWidget *,dictionary *dict); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index c25745b..c43b7bd 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -9,7 +9,7 @@ #define OPEN_LABEL _("Open") #define KEYBOARD_TITLE_LABEL _("Keyboard layout") - #define CUSTOM_CONFIG_CREATION_ERROR_LABEL _("New configuration file creation failed") +#define CUSTOM_CONFIG_CREATION_ERROR_LABEL _("New configuration file creation failed") #define CANCEL_LABEL _("Cancel") #define BACK_LABEL _("Back") @@ -59,7 +59,7 @@ #define CHOOSE_SECTION_LABEL _("Choose a section:") #define ATTENSION_LABEL _("Attention! The selected partition will be modified: the size will be reduced. In the resulting free space, a partition will be created into which the UBLinux OS will be\ninstalled.") #define DEVICE_LABEL _("Device") -#define MARK_LABEL _("Mark") +#define MARK_LABEL _("Label") #define SIZE_LABEL _("Size") #define FREE_LABEL _("Free") #define SPECIFY_LABEL _("Specify the size of the new partition for UBLinux OS:") @@ -173,8 +173,6 @@ #define ACCEPT_LABEL _("Accept") #define GPARTED_LABEL _("Start GParted") -#define EXIT_WARNING_LABEL _("Are you sure want to exit and interrupt installation process?") - #define PROGRESS_LOG_LABEL _("Progress log") #define INSTALL_LOG_LABEL _("Installation log") diff --git a/ubinstall-gtk-warning.glade b/ubinstall-gtk-warning.glade index cf113d5..6dfe131 100644 --- a/ubinstall-gtk-warning.glade +++ b/ubinstall-gtk-warning.glade @@ -60,7 +60,7 @@ vertical 5 - + True False center @@ -105,7 +105,7 @@ interrupt installation process? True False - + True False Warning diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 0edbb2c..52126c7 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -3049,7 +3049,7 @@ or continue working in the UBLinux Live environment. - Mark + Label @@ -3071,7 +3071,7 @@ or continue working in the UBLinux Live environment. - Free + Serial @@ -3456,7 +3456,7 @@ installed. - Mark + Label @@ -4046,7 +4046,7 @@ installed. - Mark + Description @@ -4057,7 +4057,7 @@ installed. - Capacity + Label @@ -4068,7 +4068,7 @@ installed. - Location + Size @@ -4077,6 +4077,17 @@ installed. + + + Serial + + + + 4 + + + + diff --git a/ubinstall-gtk.pot b/ubinstall-gtk.pot index 98031f6..e3ef875 100644 --- a/ubinstall-gtk.pot +++ b/ubinstall-gtk.pot @@ -272,7 +272,7 @@ msgid "Device" msgstr "" #: source/ubl-strings.h:58 -msgid "Mark" +msgid "Label" msgstr "" #: source/ubl-strings.h:59 diff --git a/ubinstall-gtk_ru.po b/ubinstall-gtk_ru.po index e687ffe..83736f7 100644 --- a/ubinstall-gtk_ru.po +++ b/ubinstall-gtk_ru.po @@ -286,7 +286,7 @@ msgid "Device" msgstr "Устройство" #: source/ubl-strings.h:58 -msgid "Mark" +msgid "Label" msgstr "Метка" #: source/ubl-strings.h:59