From f842f66db188a29bad957120fe09690a57e15364 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 17 Jan 2025 18:01:21 +0600 Subject: [PATCH] Sync menu WIP --- source/ubl-settings-usergroups-settings.c | 62 +++-- source/ubl-settings-usergroups.h | 13 +- source/ubl-strings.h | 6 +- ...tings-usergroups-additional-settings.glade | 251 ++++++++++++++++-- 4 files changed, 284 insertions(+), 48 deletions(-) diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index a090bfe..dad7996 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -19,8 +19,8 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add } else if (self == window->UsersBootCheck){ window->user_boot = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsersBootCheck)); - } else if (self == window->UsersShutdownCheck){ - window->user_shutdown = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsersShutdownCheck)); + // } else if (self == window->UsersShutdownCheck){ + // window->user_shutdown = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsersShutdownCheck)); } } @@ -67,24 +67,24 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add if (window->password_hash) yon_config_remove_by_key(HASHPASSWD_parameter); } - char *sync = ""; - int boot_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsersBootCheck)); - int shutdown_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsersShutdownCheck)); - if (!boot_active&&!shutdown_active){ - if (window->user_boot>-1||window->user_boot>-1) - yon_config_remove_by_key(USERADD_SYNC_parameter); - } else { - if (boot_active){ - if (window->user_boot>-1) - sync = "boot"; - } - if (shutdown_active){ - if (window->user_shutdown>-1) - sync = yon_char_unite(sync,yon_char_is_empty(sync)?"":",","shutdown",NULL); - } - if (window->user_boot>-1||window->user_boot>-1) - yon_config_register(USERADD_SYNC_parameter,USERADD_SYNC_parameter_command,sync); - } + // char *sync = ""; + // int boot_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsersBootCheck)); + // int shutdown_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UsersShutdownCheck)); + // if (!boot_active&&!shutdown_active){ + // if (window->user_boot>-1||window->user_boot>-1) + // yon_config_remove_by_key(USERADD_SYNC_parameter); + // } else { + // if (boot_active){ + // if (window->user_boot>-1) + // sync = "boot"; + // } + // if (shutdown_active){ + // if (window->user_shutdown>-1) + // sync = yon_char_unite(sync,yon_char_is_empty(sync)?"":",","shutdown",NULL); + // } + // if (window->user_boot>-1||window->user_boot>-1) + // yon_config_register(USERADD_SYNC_parameter,USERADD_SYNC_parameter_command,sync); + // } } ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new(){ @@ -105,7 +105,17 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); window->AcceptButton=yon_gtk_builder_get_widget(builder,"AcceptButton"); window->UsersBootCheck=yon_gtk_builder_get_widget(builder,"UsersBootCheck"); - window->UsersShutdownCheck=yon_gtk_builder_get_widget(builder,"UsersShutdownCheck"); + window->UsersShutdownSwitch=yon_gtk_builder_get_widget(builder,"UsersShutdownSwitch"); + window->UserShutdownRevealer=yon_gtk_builder_get_widget(builder,"UserShutdownRevealer"); + window->UsersTree=yon_gtk_builder_get_widget(builder,"UsersTree"); + window->UserAddButton=yon_gtk_builder_get_widget(builder,"UserAddButton"); + window->UserRemoveButton=yon_gtk_builder_get_widget(builder,"UserRemoveButton"); + window->GroupsBootCheck=yon_gtk_builder_get_widget(builder,"GroupsBootCheck"); + window->GroupsShutdownSwitch=yon_gtk_builder_get_widget(builder,"GroupsShutdownSwitch"); + window->GroupShutdownRevealer=yon_gtk_builder_get_widget(builder,"GroupShutdownRevealer"); + window->GroupsTree=yon_gtk_builder_get_widget(builder,"GroupsTree"); + window->GroupAddButton=yon_gtk_builder_get_widget(builder,"GroupAddButton"); + window->GroupRemoveButton=yon_gtk_builder_get_widget(builder,"GroupRemoveButton"); window->default_password=NULL; window->default_root_password=NULL; @@ -123,7 +133,7 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->UsersBootCheck),1); } if (strstr(sync_parameters,"shutdown")){ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->UsersShutdownCheck),1); + gtk_switch_set_active(GTK_SWITCH(window->UsersShutdownSwitch),1); } } @@ -215,7 +225,11 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ g_signal_connect(G_OBJECT(window->PasswordHashCombo),"changed",G_CALLBACK(on_additional_settings_changed),window); g_signal_connect(G_OBJECT(window->DefaultUserAdministratorCheck),"toggled",G_CALLBACK(on_additional_settings_changed),window); g_signal_connect(G_OBJECT(window->UsersBootCheck),"toggled",G_CALLBACK(on_additional_settings_changed),window); - g_signal_connect(G_OBJECT(window->UsersShutdownCheck),"toggled",G_CALLBACK(on_additional_settings_changed),window); + g_signal_connect(G_OBJECT(window->UsersShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window); + g_signal_connect(G_OBJECT(window->GroupsBootCheck),"toggled",G_CALLBACK(on_additional_settings_changed),window); + g_signal_connect(G_OBJECT(window->GroupsShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window); + yon_gtk_revealer_set_from_switch(GTK_REVEALER(window->UserShutdownRevealer),GTK_SWITCH(window->UsersShutdownSwitch)); + yon_gtk_revealer_set_from_switch(GTK_REVEALER(window->GroupShutdownRevealer),GTK_SWITCH(window->GroupsShutdownSwitch)); // g_signal_connect(G_OBJECT(window->UsersBootCheck),"toggled",G_CALLBACK(on_users_boot_toggled),NULL); // g_signal_connect(G_OBJECT(window->UsersShutdownCheck),"toggled",G_CALLBACK(on_users_shutdown_toggled),NULL); @@ -228,6 +242,8 @@ void on_ubl_settings_usergroups_additional_settings_open(GtkWidget *, main_windo g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window)); + g_signal_connect(G_OBJECT(window->UsersBootCheck),"toggled",G_CALLBACK(on_additional_settings_changed),window); + g_signal_connect(G_OBJECT(window->UsersShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window); gtk_widget_show(window->Window); } \ No newline at end of file diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index e348159..a8bf6f3 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -243,7 +243,18 @@ typedef struct{ GtkWidget *AcceptButton; GtkWidget *EncryptAllPasswordsButton; GtkWidget *UsersBootCheck; - GtkWidget *UsersShutdownCheck; + GtkWidget *UsersShutdownSwitch; + GtkWidget *UserShutdownRevealer; + GtkWidget *UsersTree; + GtkWidget *UserAddButton; + GtkWidget *UserRemoveButton; + + GtkWidget *GroupsBootCheck; + GtkWidget *GroupsShutdownSwitch; + GtkWidget *GroupShutdownRevealer; + GtkWidget *GroupsTree; + GtkWidget *GroupAddButton; + GtkWidget *GroupRemoveButton; const char *default_user_name; const char *default_password; diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 05d3158..9b0fc92 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -103,8 +103,10 @@ #define DESCRYPT_DESCRIPTION_LABEL _("descrypt (Hash function from the DES family of algorithms)") #define NTHASH_DESCRIPTION_LABEL _("NTHash (Hash function from the NT Windows family of algorithms)") -#define ADDITIONAL_BOOT_LABEL _("While booting the operating system, apply the settings of all users from the configuration") -#define ADDITIONAL_SHUTDOWN_LABEL _("While shutdown, save the settings of all users with UID>=1000 to the configuration") +#define ADDITIONAL_USER_BOOT_LABEL _("While booting the operating system, apply the settings of all users from the configuration") +#define ADDITIONAL_USER_SHUTDOWN_LABEL _("While shutdown, save the settings of all users with UID>=1000 to the configuration") +#define ADDITIONAL_GROUP_BOOT_LABEL _("While booting the operating system, apply the settings of all groups from the configuration") +#define ADDITIONAL_GROUP_SHUTDOWN_LABEL _("While shutdown, save the settings of all groups with GID>=1000 to the configuration") //ubl-settings-usergroups-group-creation.glade #define CONFIGURE_GROUP_TITLE_LABEL _("Configure group") diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index 4f83b00..d324745 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -13,7 +13,18 @@ - + + + + + + + + + + + + True False @@ -39,6 +50,26 @@ False com.ublinux.ubl-settings-usergroups.lock-symbolic + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.trash-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.trash-symbolic + 600 False @@ -442,7 +473,7 @@ - + True True @@ -464,20 +495,107 @@ True False - slide-up - + True - True - in - 150 + False + 5 - + True True - UsersShutdownList - both + in + 150 + + + True + True + UsersShutdownList + both + + + + + + + + + + Syncronization type + + + + + + + + Minimal UID + + + + + + + + Maximum UID + + + + + + + + + + True + True + 0 + + + + + True + False + vertical + 5 + + + True + True + True + image6 + + + + False + True + 0 + + + + + True + True + True + image7 + + + + False + True + 1 + + + + False + True + 1 + @@ -500,14 +618,14 @@ - True + False True 1 - While booting the operating system, apply the settings of all users from the configuration + While booting the operating system, apply the settings of all groups from the configuration True True False @@ -547,7 +665,7 @@ True False - While shutdown, save the settings of all users with UID>=1000 to the configuration + While shutdown, save the settings of all groups with GID>=1000 to the configuration False @@ -556,7 +674,7 @@ - + True True @@ -580,18 +698,107 @@ False slide-up - + True - True - in - 150 + False + 5 - + True True - GroupsShutdownList - both + in + 150 + + + True + True + GroupsShutdownList + both + + + column + + + + + + + + column + + + + + + + + column + + + + + + + + column + + + + + + + + + + True + True + 0 + + + + + True + False + vertical + 5 + + + True + True + True + image8 + + + + False + True + 0 + + + + + True + True + True + image9 + + + + False + True + 1 + + + + False + True + 1 + @@ -614,7 +821,7 @@ - True + False True 3