mirror of
https://github.com/altlinux/admc.git
synced 2025-03-27 14:50:25 +03:00
rename Type column to Category
add get_entry() instead of straight shget(entries) add row expanded/collapsed func's
This commit is contained in:
parent
4627520f71
commit
33e6b5ad4c
@ -255,6 +255,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">containers_model_filter</property>
|
||||
<signal name="row-collapsed" handler="containers_row_collapsed_func" swapped="no"/>
|
||||
<signal name="row-expanded" handler="containers_row_expanded_func" swapped="no"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection">
|
||||
<signal name="changed" handler="containers_selection_changed_func" swapped="no"/>
|
||||
@ -305,7 +307,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Type</property>
|
||||
<property name="title" translatable="yes">Category</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
|
@ -38,7 +38,7 @@ void attributes_value_edited_func(
|
||||
char* old_value;
|
||||
gtk_tree_model_get(model, &iter, ATTRIBUTES_COLUMN_VALUE, &old_value, -1);
|
||||
|
||||
entry* e = shget(entries, attributes_target);
|
||||
entry* e = get_entry(attributes_target);
|
||||
bool edit_success = entry_edit_value(e, attribute_name, new_text);
|
||||
|
||||
if (edit_success) {
|
||||
@ -67,7 +67,7 @@ void attributes_populate_model() {
|
||||
GtkTreeStore* model = GTK_TREE_STORE(gtk_tree_view_get_model(attributes_view));
|
||||
gtk_tree_store_clear(model);
|
||||
|
||||
entry* e = shget(entries, attributes_target);
|
||||
entry* e = get_entry(attributes_target);
|
||||
|
||||
// Target is invalid
|
||||
// NOTE: this is valid behavior and can occur when target entry is deleted for example
|
||||
|
@ -26,6 +26,31 @@ void containers_refilter() {
|
||||
gtk_tree_model_filter_refilter(model_filter);
|
||||
}
|
||||
|
||||
void containers_row_expanded_func(
|
||||
GtkTreeView *tree_view,
|
||||
GtkTreeIter *iter,
|
||||
GtkTreePath *path,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkTreeModel* model = gtk_tree_view_get_model(tree_view);
|
||||
|
||||
char* dn;
|
||||
gtk_tree_model_get(model, iter, CONTAINERS_COLUMN_DN, &dn, -1);
|
||||
|
||||
printf("containers_row_expanded %s\n", dn);
|
||||
|
||||
free(dn);
|
||||
}
|
||||
|
||||
void containers_row_collapsed_func(
|
||||
GtkTreeView *tree_view,
|
||||
GtkTreeIter *iter,
|
||||
GtkTreePath *path,
|
||||
gpointer user_data)
|
||||
{
|
||||
// printf("containers_row_expanded %s\n", dn);
|
||||
}
|
||||
|
||||
void containers_selection_changed_func(GtkTreeSelection* selection, gpointer user_data) {
|
||||
// Get selected iter
|
||||
GtkTreeView* view = gtk_tree_selection_get_tree_view(selection);
|
||||
@ -59,7 +84,7 @@ gboolean containers_filter_func(
|
||||
gtk_tree_model_get(model, iter, CONTAINERS_COLUMN_DN, &dn, -1);
|
||||
|
||||
if (dn != NULL) {
|
||||
entry* e = shget(entries, dn);
|
||||
entry* e = get_entry(dn);
|
||||
char* showInAdvancedViewOnly = entry_get_attribute_or_none(e, "showInAdvancedViewOnly");
|
||||
if (!advanced_view_is_on() && streql(showInAdvancedViewOnly, "TRUE")) {
|
||||
visible = FALSE;
|
||||
@ -73,7 +98,7 @@ gboolean containers_filter_func(
|
||||
|
||||
void containers_populate_model_recursive(GtkTreeStore* model, char* node_dn, GtkTreeIter* parent) {
|
||||
// Populate model with name's of entries
|
||||
entry* e = shget(entries, node_dn);
|
||||
entry* e = get_entry(node_dn);
|
||||
|
||||
// Skip if entry is not a container
|
||||
if (!entry_is_container(e)) {
|
||||
|
@ -40,7 +40,7 @@ gboolean contents_filter_func(
|
||||
char* dn;
|
||||
gtk_tree_model_get(model, iter, CONTENTS_COLUMN_DN, &dn, -1);
|
||||
if (dn != NULL) {
|
||||
entry* e = shget(entries, dn);
|
||||
entry* e = get_entry(dn);
|
||||
STR_ARRAY showInAdvancedViewOnly = entry_get_attribute(e, "showInAdvancedViewOnly");
|
||||
if (!advanced_view_is_on() && showInAdvancedViewOnly != NULL && streql(showInAdvancedViewOnly[0], "TRUE")) {
|
||||
visible = FALSE;
|
||||
@ -92,7 +92,7 @@ void contents_populate_model() {
|
||||
return;
|
||||
}
|
||||
|
||||
entry* e = shget(entries, contents_target);
|
||||
entry* e = get_entry(contents_target);
|
||||
|
||||
// Target is invalid
|
||||
// NOTE: this is valid behavior and can occur when target entry is deleted for example
|
||||
@ -103,7 +103,7 @@ void contents_populate_model() {
|
||||
// Populate model
|
||||
for (int i = 0; i < arrlen(e->children); i++) {
|
||||
char* child_dn = e->children[i];
|
||||
entry* child = shget(entries, child_dn);
|
||||
entry* child = get_entry(child_dn);
|
||||
|
||||
GtkTreeIter this_node;
|
||||
gtk_list_store_append(model, &this_node);
|
||||
@ -116,9 +116,7 @@ void contents_populate_model() {
|
||||
gtk_list_store_set(model, &this_node, CONTENTS_COLUMN_NAME, name, -1);
|
||||
|
||||
char* category_dn = entry_get_attribute_or_none(child, "objectCategory");
|
||||
char category[DN_LENGTH_MAX];
|
||||
first_element_in_dn(category, category_dn, DN_LENGTH_MAX);
|
||||
gtk_list_store_set(model, &this_node, CONTENTS_COLUMN_CATEGORY, category, -1);
|
||||
gtk_list_store_set(model, &this_node, CONTENTS_COLUMN_CATEGORY, category_dn, -1);
|
||||
|
||||
char* description = entry_get_attribute_or_none(child, "description");
|
||||
gtk_list_store_set(model, &this_node, CONTENTS_COLUMN_DESCRIPTION, description, -1);
|
||||
|
@ -6,3 +6,4 @@ void contents_init(GtkBuilder* builder);
|
||||
void contents_change_target(const char* new_target_dn);
|
||||
void contents_populate_model();
|
||||
void contents_refilter();
|
||||
void contents_selection_changed_func(GtkTreeSelection* selection, gpointer user_data);
|
18
src/entry.c
18
src/entry.c
@ -15,6 +15,10 @@
|
||||
|
||||
entries_map* entries;
|
||||
|
||||
entry* get_entry(const char* dn) {
|
||||
return shget(entries, dn);
|
||||
}
|
||||
|
||||
void entry_load(const char* dn) {
|
||||
entry* e = (entry*)malloc(sizeof(entry));
|
||||
|
||||
@ -293,7 +297,7 @@ entry* make_fake_entry(const char* name, entry* parent, bool container, const ch
|
||||
add_fake_attribute(e, "objectClass", "class");
|
||||
}
|
||||
|
||||
add_fake_attribute(e, "ObjectCategory", category);
|
||||
add_fake_attribute(e, "objectCategory", category);
|
||||
|
||||
for (int i = 0; i < shlen(e->attributes); i++) {
|
||||
attributes_map a = e->attributes[i];
|
||||
@ -309,7 +313,7 @@ void entry_init_fake() {
|
||||
|
||||
// Load entries recursively
|
||||
entry_load(HEAD_DN);
|
||||
|
||||
|
||||
// HEAD_DN= "DC=domain,DC=alt"
|
||||
entry* head = make_fake_entry(HEAD_DN, NULL, true, "Person");
|
||||
|
||||
@ -347,12 +351,15 @@ bool entry_new(const char* name, NewEntryType type) {
|
||||
char parent_dn[DN_LENGTH_MAX];
|
||||
switch (type) {
|
||||
case NewEntryType_User: {
|
||||
snrpintf("CN=Users,%s", DN_LENGTH_MAX, HEAD_DN);
|
||||
break;
|
||||
}
|
||||
case NewEntryType_Computer: {
|
||||
snrpintf("CN=Computers,%s", DN_LENGTH_MAX, HEAD_DN);
|
||||
break;
|
||||
}
|
||||
case NewEntryType_OU: {
|
||||
snrpintf("CN=Computers,%s", DN_LENGTH_MAX, HEAD_DN);
|
||||
break;
|
||||
}
|
||||
case NewEntryType_Group: {
|
||||
@ -362,11 +369,8 @@ bool entry_new(const char* name, NewEntryType type) {
|
||||
|
||||
entry* parent = shget(entries, parent_dn);
|
||||
|
||||
char entry_dn[1000];
|
||||
strcpy(entry_dn, "CN=");
|
||||
strcat(entry_dn, name);
|
||||
strcat(entry_dn, ",");
|
||||
strcat(entry_dn, parent->dn);
|
||||
char entry_dn[DN_LENGTH_MAX];
|
||||
snrpintf("CN=%s,%s", DN_LENGTH_MAX, name, parent->dn);
|
||||
|
||||
int result;
|
||||
switch (type) {
|
||||
|
@ -32,14 +32,13 @@ typedef enum {
|
||||
NewEntryType_Group
|
||||
} NewEntryType;
|
||||
|
||||
extern entries_map* entries;
|
||||
|
||||
void entry_init();
|
||||
void entry_init_fake();
|
||||
void entry_load(const char* dn);
|
||||
STR_ARRAY entry_get_attribute(entry* e, const char* key);
|
||||
char* entry_get_attribute_or_none(entry* e, const char* key);
|
||||
bool entry_new(const char* name, NewEntryType type);
|
||||
entry* get_entry(const char* dn);
|
||||
void entry_delete(entry* e);
|
||||
bool entry_attribute_exists(entry* e, const char* key, const char* value);
|
||||
bool entry_is_container(entry* e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user