diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index cbd7828..2c71d36 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -715,6 +715,20 @@ yon_confirmation_window *yon_delete_confirmation_new(){ return window; } +void yon_system_delete_confirmation_open(main_window *widgets){ + yon_confirmation_window *window = yon_delete_confirmation_new(); + gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window)); + GtkTreeIter iter,itar; + 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(yon_delete_confirmation_save),dict); + GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore1); + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SystemTree)),&model,&iter)){ + gtk_tree_model_get(model,&iter,1,,2,,) + } +} + void yon_delete_confirmation_open(main_window *widgets){ yon_confirmation_window *window = yon_delete_confirmation_new(); gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window)); @@ -1329,7 +1343,7 @@ void on_GID_update(GtkWidget *, ubl_settings_usergroups_group_creation_window *w for (int i=0;i2&&minimumprev_busy){ prev_busy=atol(parsed[2]); } @@ -2815,10 +2829,46 @@ void on_main_delete(GtkWidget *, main_window *widgets){ dialog_confirmation_data *data=malloc(sizeof(dialog_confirmation_data)); data->function=NULL; data->data=NULL; - if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))==0){ + int active = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook)); + switch(active){ + case 0: + yon_delete_confirmation_open(widgets); - } else { + break; + case 1: yon_group_delete_confirmation_open(widgets); + break; + case 2:{ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore1); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SystemTree)),&model,&iter)){ + char *target; + gtk_tree_model_get(model,&iter,2,&target,-1); + dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); + int found = !!config(USERADD(target)); + if (found){ + data->action_text = SYSTEM_USER_CONFIG_REMOVE_CONFIRMATION_LABEL(target); + data->function=NULL; + data->data=NULL; + } else { + data->action_text = SYSTEM_USER_SYSTEM_REMOVE_CONFIRMATION_LABEL(target); + data->function=NULL; + data->data=NULL; + + } + if (yon_confirmation_dialog_call(widgets->Window,&data)!=GTK_RESPONSE_ACCEPT){ + return; + } + if (found){ + yon_delete_confirmation_open(widgets); + } else { + yon_system_delete_confirmation_open(widgets); + } + } + }break; + case 3:{ + + }break; } } diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 5f76afc..e2f969f 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -56,6 +56,11 @@ #define SYSTEM_GROUP_SYNC_CONFIRMATION_LABEL(target) yon_char_unite(_("This group doesn't exist in configuration. Are you sure want to add group")," ",target," ", _("to configuration?"),NULL) #define SYSTEM_GROUP_ADD_CONFIRMATION_LABEL(target) yon_char_unite(_("This group exists in configuration. Are you sure want to update group")," ",target," ", _("data at configuration?"),NULL) +#define SYSTEM_USER_SYSTEM_REMOVE_CONFIRMATION_LABEL(target) yon_char_unite(_("This user doesn't exist in configuration and will be removed from the system. Are you sure want to remove user")," ",target," ", _("from the system??"),NULL) +#define SYSTEM_USER_CONFIG_REMOVE_CONFIRMATION_LABEL(target) yon_char_unite(_("This user exists in configuration. Are you sure want to remove user")," ",target," ", _("?"),NULL) +#define SYSTEM_GROUP_SYSTEM_REMOVE_CONFIRMATION_LABEL(target) yon_char_unite(_("This group doesn't exist in configuration and will be removed from the system. Are you sure want to remove group")," ",target," ", _("from the system?"),NULL) +#define SYSTEM_GROUP_CONFIG_REMOVE_CONFIRMATION_LABEL(target) yon_char_unite(_("This group exists in configuration. Are you sure want to remove group")," ",target,"", _("?"),NULL) + //ubl-settings-usergroups-additional-settings.glade #define ADDITIONAL_SETTINGS_TITLE_LABEL _("Additional settings")