From 0239b8f8cbd8b3fd61fcdf914fd875bfe5e59c6e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 18 Jan 2024 12:35:37 +0600 Subject: [PATCH] Added new window --- Makefile | 1 + gresource.xml | 1 + ....ubl-settings-usergroups.save-symbolic.svg | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-usergroups.c | 41 ++++- source/ubl-settings-usergroups.h | 11 +- source/ubl-strings.h | 7 +- ubl-settings-usergroups-savesettings.glade | 144 ++++++++++++++++++ ubl-settings-usergroups.glade | 22 +++ ubl-settings-usergroups.pot | 14 ++ ubl-settings-usergroups_ru.po | 16 ++ 11 files changed, 255 insertions(+), 4 deletions(-) create mode 100644 icons/com.ublinux.ubl-settings-usergroups.save-symbolic.svg create mode 100644 ubl-settings-usergroups-savesettings.glade diff --git a/Makefile b/Makefile index 7f11cb6..82e76b9 100644 --- a/Makefile +++ b/Makefile @@ -139,6 +139,7 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.accept-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.cancel-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.profile-settings-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.save-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/${PKGNAME}/csv" "csv/hash_list.csv" @install -Dm644 -t "${DESTDIR}/usr/share/${PKGNAME}/csv" "csv/shell_list.csv" @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy" diff --git a/gresource.xml b/gresource.xml index 081a63f..08c8d12 100644 --- a/gresource.xml +++ b/gresource.xml @@ -8,6 +8,7 @@ ubl-settings-usergroups-group.glade ubl-settings-usergroups-user.glade ubl-settings-usergroups-system.glade + ubl-settings-usergroups-savesettings.glade ubl-settings-usergroups.css diff --git a/icons/com.ublinux.ubl-settings-usergroups.save-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.save-symbolic.svg new file mode 100644 index 0000000..d383f09 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.save-symbolic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 518b1ed..b5fd2fb 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -31,6 +31,7 @@ set(DEPENDFILES ../ubl-settings-usergroups-system.glade ../ubl-settings-usergroups-user.glade ../ubl-settings-usergroups-group.glade + ../ubl-settings-usergroups-savesettings.glade ../gresource.xml ../ubl-settings-usergroups-banner.png ../ubl-settings-usergroups.css diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 7713a24..2d13f9c 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -5,8 +5,8 @@ config main_config; //functions int yon_load_proceed(YON_CONFIG_TYPE type){ - yon_config_load_register(YON_CONFIG_DEFAULT,"users","DEFAULTPASSWD DEFAULTROOTPASSWD USERGROUPS DEFAULTUSER HASHPASSWD ADDADM",NULL); - if (yon_config_load_register_no_cleaning(type,"users","DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERSHADOW[*] GROUPADD[*]",NULL)){ + yon_config_load_register(YON_CONFIG_DEFAULT,"[users]","DEFAULTPASSWD DEFAULTROOTPASSWD USERGROUPS DEFAULTUSER HASHPASSWD ADDADM",NULL); + if (yon_config_load_register_no_cleaning(type,"[users]","DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERSHADOW[*] GROUPADD[*]","[system]","SYSTEMBOOT_STATEMODE","[save]","SAVE_ROOTCOPY_CHANGES",NULL)){ return 1; } return 0; @@ -109,6 +109,41 @@ void on_config_local_save(){ yon_save_proceed("system",YON_CONFIG_LOCAL,"users", "DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERSHADOW[*] GROUPADD[*]",NULL); } +void on_saving_settings_save(GtkWidget *self, yon_savasettings_window *window){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->SambaCheck))){ + if (!yon_config_append("SAVE_ROOTCOPY_CHANGES","/var/lib/samba",",")){ + yon_config_register("SAVE_ROOTCOPY_CHANGES","[save]","/var/lib/samba"); + } + } else { + yon_config_remove_element("SAVE_ROOTCOPY_CHANGES","/var/lib/samba",","); + } + on_subwindow_close(self); +} + +yon_savasettings_window *yon_saving_settings_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_savesettings); + yon_savasettings_window *window = malloc(sizeof(yon_savasettings_window)); + window->Window = yon_gtk_builder_get_widget(builder,"Window"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->SambaCheck = yon_gtk_builder_get_widget(builder,"SambaSaveCheck"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + gtk_widget_show(window->Window); + char *string = yon_config_get_by_key("SAVE_ROOTCOPY_CHANGES"); + if (!yon_char_is_empty(string)&&strstr(string,"/var/lib/samba")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SambaCheck),1); + } + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),SYSTEM_SAVEMODE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + return window; +} + +void on_saving_settings_open(GtkWidget *self, main_window *widgets){ + yon_savasettings_window *window = yon_saving_settings_new(); + gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window)); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_saving_settings_save),window); +} + void on_password_combo_changed(GtkComboBox *self, GtkWidget *target){ gtk_widget_set_sensitive(target,gtk_combo_box_get_active(self)>1); } @@ -1585,6 +1620,7 @@ main_window *yon_main_window_complete(main_window *widgets){ widgets->UsersTree=yon_gtk_builder_get_widget(builder,"UsersTree"); widgets->GroupsTree=yon_gtk_builder_get_widget(builder,"GroupsTree"); widgets->MainNotebook=yon_gtk_builder_get_widget(builder,"MainNotebook"); + widgets->SavingSettingsButton=yon_gtk_builder_get_widget(builder,"SavingSettingsButton"); gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddlemargin"); @@ -1610,6 +1646,7 @@ main_window *yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->button2),"clicked",G_CALLBACK(on_ubl_settings_usergroups_additional_settings_open),widgets); g_signal_connect(G_OBJECT(widgets->button1),"clicked",G_CALLBACK(on_settings_usergroups_system_open),widgets); g_signal_connect(G_OBJECT(widgets->UpdateButton),"clicked",G_CALLBACK(on_config_update),widgets); + g_signal_connect(G_OBJECT(widgets->SavingSettingsButton),"clicked",G_CALLBACK(on_saving_settings_open),widgets); g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_config_save),widgets); g_signal_connect(G_OBJECT(widgets->UsersTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->GroupsTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index 30b7fea..ff40b73 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -26,6 +26,7 @@ #define glade_path_ubl_settings_usergroups_password "/com/ublinux/ui/ubl-settings-usergroups-password.glade" #define glade_path_ubl_settings_usergroups_system "/com/ublinux/ui/ubl-settings-usergroups-system.glade" #define glade_path_ubl_settings_usergroups_user "/com/ublinux/ui/ubl-settings-usergroups-user.glade" +#define glade_path_ubl_settings_usergroups_savesettings "/com/ublinux/ui/ubl-settings-usergroups-savesettings.glade" #define banner_path "/com/ublinux/images/ubl-settings-usergroups-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-usergroups.css" @@ -137,6 +138,7 @@ typedef struct { GtkWidget *UsersTree; GtkWidget *GroupsTree; GtkWidget *MainNotebook; + GtkWidget *SavingSettingsButton; } main_window; @@ -266,7 +268,14 @@ typedef struct{ char *old_password; } ubl_settings_usergroups_user_window; - + typedef struct { + GtkWidget *Window; + GtkWidget *StatusBox; + GtkWidget *CancelButton; + GtkWidget *AcceptButton; + GtkWidget *SambaCheck; + } yon_savasettings_window; + ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new(); void on_ubl_settings_usergroups_additional_settings_open(GtkWidget *self, main_window *widgets); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 4bb04e3..09e660d 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -155,4 +155,9 @@ //ubl-settings-usergroups-password.glade #define PASSWORD_REPEAT_LABEL _("Repeat password:") -#define PASSWORD_HASH_LABEL _("Password hash:") \ No newline at end of file +#define PASSWORD_HASH_LABEL _("Password hash:") + +//ubl-settings-usergroups-savesettings.glade +#define SAVESETTINGS_TITLE_LABEL _("Additional configuration of service parameter saving") +#define SAMBA_ROOTCOPY_LABEL _("At every system shutdown save changes of /var/lib/samba\ninto /ublinux-data/rootcopy") +#define SYSTEM_SAVEMODE_LABEL _("For system save mode \"Sandbox\"") \ No newline at end of file diff --git a/ubl-settings-usergroups-savesettings.glade b/ubl-settings-usergroups-savesettings.glade new file mode 100644 index 0000000..c10feb7 --- /dev/null +++ b/ubl-settings-usergroups-savesettings.glade @@ -0,0 +1,144 @@ + + + + + + False + False + True + 450 + com.ublinux.ubl-settings-usergroups + + + True + False + vertical + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + vertical + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + At every system shutdown save changes of /var/lib/samba +into /ublinux-data/rootcopy + True + True + False + True + + + + + + + True + False + Samba + + + + + False + True + 0 + + + + + True + True + 1 + + + + + + + True + False + + + True + False + Additional configuration of service parameter saving + + + + + + + + Cancel + True + True + True + image4 + + + + + + Accept + True + True + True + image5 + + + + end + 1 + + + + + + + True + False + com.ublinux.ubl-settings-usergroups.cancel-symbolic + + + True + False + com.ublinux.ubl-settings-usergroups.accept-symbolic + + diff --git a/ubl-settings-usergroups.glade b/ubl-settings-usergroups.glade index 8061413..b490cce 100644 --- a/ubl-settings-usergroups.glade +++ b/ubl-settings-usergroups.glade @@ -256,6 +256,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 8 + + + True + True + True + Update users and groups + image4 + + + + False + True + 9 + + False @@ -560,4 +577,9 @@ status + + True + False + com.ublinux.ubl-settings-usergroups.save-symbolic + diff --git a/ubl-settings-usergroups.pot b/ubl-settings-usergroups.pot index 46ff057..f8ab6dd 100644 --- a/ubl-settings-usergroups.pot +++ b/ubl-settings-usergroups.pot @@ -579,3 +579,17 @@ msgstr "" #: source/ubl-strings.h:158 msgid "Password hash:" msgstr "" + +#: source/ubl-strings.h:161 +msgid "Additional configuration of service parameter saving" +msgstr "" + +#: source/ubl-strings.h:162 +msgid "" +"At every system shutdown save changes of /var/lib/samba\n" +"into /ublinux-data/rootcopy" +msgstr "" + +#: source/ubl-strings.h:163 +msgid "For system save mode \"Sandbox\"" +msgstr "" diff --git a/ubl-settings-usergroups_ru.po b/ubl-settings-usergroups_ru.po index 5bc48a9..8c044f3 100644 --- a/ubl-settings-usergroups_ru.po +++ b/ubl-settings-usergroups_ru.po @@ -614,3 +614,19 @@ msgstr "Подтверждение пароля:" #: source/ubl-strings.h:158 msgid "Password hash:" msgstr "Хэш пароля:" + +#: source/ubl-strings.h:161 +msgid "Additional configuration of service parameter saving" +msgstr "Дополнительные настройки сохранения параметров сервисов" + +#: source/ubl-strings.h:162 +msgid "" +"At every system shutdown save changes of /var/lib/samba\n" +"into /ublinux-data/rootcopy" +msgstr "" +"При каждом завершении работы ОС сохранять изменения /var/lib/samba\n" +"в /ublinux-data/rootcopy/" + +#: source/ubl-strings.h:163 +msgid "For system save mode \"Sandbox\"" +msgstr "Для режима сохранения системы \"Песочница\""