You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ubl-settings-diskquota/source/view_check_user_table.c

89 lines
2.9 KiB

#include "view_check_user_table.h"
char* glade_path = NULL;
char* flag_u_g = NULL;
table_u_g* table_widgets;
table_u_g *setup_table_u_g(){
/* Widgets getting | Получение виджетов */
table_widgets = malloc(sizeof(table_u_g));
device_disk_parsed();
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
table_widgets->Window = yon_gtk_builder_get_widget(builder,"tableUserGroupWindow");
table_widgets->btnCancel = yon_gtk_builder_get_widget(builder,"quotegroupSaveButton1");
table_widgets->btnSave = yon_gtk_builder_get_widget(builder,"quotegroupCancelButton1");
table_widgets->treeViewCheckUsersGroups = yon_gtk_builder_get_widget(builder,"treeViewCheckUsersGroups");
table_widgets->liststoreUsersGroups = GTK_LIST_STORE(gtk_builder_get_object(builder, "liststoreUsersGroups"));
int size = 0;
if (strcmp(flag_u_g, "group")==0) {
char** array_groups = philos_list_group(&size);
table_u_g_fill_tree_view(array_groups, size);
}
else if (strcmp(flag_u_g, "user") == 0) {
char** array_user = philos_list_user(&size);
table_u_g_fill_tree_view(array_user, size);
}
table_u_g_event();
}
void table_u_g_set_glade_path(char* _glade_path) {
glade_path = _glade_path;
}
void table_u_g_get_data() {
}
void table_u_g_set_flag(char* _flag_u_g) {
flag_u_g = _flag_u_g;
}
void table_u_g_fill_tree_view(char** array, int size) {
GtkTreeModel *model = GTK_TREE_MODEL(table_widgets->liststoreUsersGroups);
g_object_ref(table_widgets->liststoreUsersGroups);
gtk_list_store_clear(table_widgets->liststoreUsersGroups);
for (int i=0; i<size; i++){
GtkTreeIter iter;
gtk_list_store_append(table_widgets->liststoreUsersGroups,&iter);
gtk_list_store_set(table_widgets->liststoreUsersGroups,&iter,
0,0,
1,array[i],
-1);
}
gtk_tree_view_set_model(GTK_TREE_VIEW(table_widgets->treeViewCheckUsersGroups), model);
}
void table_u_g_show(GtkWidget *self, char* glade_path) {
if (table_widgets != NULL) {
gtk_widget_show(table_widgets->Window);
}
else {
setup_table_u_g(glade_path);
gtk_widget_show(table_widgets->Window);
}
}
void table_u_g_event() {
g_signal_connect(G_OBJECT(table_widgets->btnCancel), "clicked",G_CALLBACK(table_u_g_on_hide_subwindow),NULL);
g_signal_connect(G_OBJECT(table_widgets->Window), "destroy", G_CALLBACK(table_u_g_destroy), NULL);
}
void table_u_g_destroy(GtkWidget *self) {
table_widgets = NULL;
}
void table_u_g_localization(table_u_g *widgets) {
}
void table_u_g_on_hide_subwindow(GtkWidget *self) {
gtk_widget_destroy(gtk_widget_get_toplevel(self));
table_widgets = NULL;
}
table_u_g *table_u_g_get_widget_filters() {
return table_widgets;
}