#include "Gtk_LdapTreeItem.h"
+#include <gtk--/base.h>
Gtk_LdapTreeItem::Gtk_LdapTreeItem() : Gtk_TreeItem() {
}
-Gtk_LdapTreeItem::Gtk_LdapTreeItem(char *c, My_Window *w) : Gtk_TreeItem(c) {
+
+Gtk_LdapTreeItem::Gtk_LdapTreeItem(char *c, My_Window *w) : Gtk_TreeItem() {
this->rdn = c;
this->par = w;
}
+
Gtk_LdapTreeItem::Gtk_LdapTreeItem(GtkTreeItem *t) : Gtk_TreeItem(t) {
}
-int Gtk_LdapTreeItem::search() {
+
+void Gtk_LdapTreeItem::setType(int t) {
+// printf("Gtk_LdapTreeItem::setType(%d)\n", t);
+ Gtk_Pixmap *xpm_icon;
+ Gtk_Label *label;
+ if (this->getchild() != NULL) {
+ // printf("There's a label in here - removing");
+ xpm_label = new Gtk_HBox(GTK_HBOX(this->getchild()->gtkobj()));
+ xpm_label->remove_c(xpm_label->children()->nth_data(0));
+ xpm_label->remove_c(xpm_label->children()->nth_data(0));
+ // xpm_label->remove_c(GTK_WIDGET(xpm_icon->gtkobj()));
+ // printf("done\n");
+ }
+ else xpm_label = new Gtk_HBox();
+ switch (t) {
+ case 1: xpm_icon = new Gtk_Pixmap(*xpm_label, "root_node.xpm"); break;
+ case 2: xpm_icon = new Gtk_Pixmap(*xpm_label, "branch_node.xpm"); break;
+ default: xpm_icon = new Gtk_Pixmap(*xpm_label, "leaf_node.xpm"); break;
+ }
+ label = new Gtk_Label(this->rdn);
+ xpm_label->pack_start(*xpm_icon, false, false, 1);
+ xpm_label->pack_start(*label, false, false, 1);
+ xpm_icon->show();
+ label->show();
+ xpm_label->show();
+ if (this->getchild() == NULL) this->add(xpm_label);
+ else printf("There's still a child here!\n");
+}
+
+int Gtk_LdapTreeItem::getDetails() {
int error, entriesCount;
BerElement *ber;
LDAPMessage *entry;
Gtk_Label *label;
GList *child_list;
Gtk_Notebook *g;
+ Gtk_Viewport *viewport;
+ viewport = new Gtk_Viewport();
+/*
if (this->notebook != NULL) {
- if (par->scroller2->children != NULL) {
- par->scroller2->remove_child(0);
+ printf("Data on %s available\n", this->rdn);
+ if (par->scroller2->children() != NULL) {
+ // if (par->scroller2->children[0] != NULL) {
+ printf(".");
+ // par->scroller2->release(par->scroller2->children()->nth_data(0));
+ par->scroller2->remove_c(par->scroller2->children()->nth_data(0));
+ // par->scroller2->remove_child(0);
}
- par->scroller2->add_child(this->notebook);
- // par->scroller2->remove((Gtk_Object)par->scroller2->children()->first());
- this->notebook->reparent(*par->scroller2);
+ // par->scroller2->add_child(this->notebook);
+ viewport->add(this->notebook);
+ printf(".");
+ par->scroller2->add(viewport); //this->notebook);
+ printf(".");
+ // this->notebook->reparent(*par->scroller2);
this->notebook->show();
+ printf(".");
+ viewport->show();
+ printf(".");
par->scroller2->show();
+ printf(".");
return 0;
}
+*/
error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &result_identifier);
entriesCount = ldap_count_entries(ld, result_identifier);
if (entriesCount == 0) return 0;
notebook = new Gtk_Notebook();
notebook->set_tab_pos(GTK_POS_LEFT);
- gchar *titles[] = { "values" };
+ const gchar *titles[] = { "values" };
for (entry = ldap_first_entry(ld, result_identifier); entry != NULL; entry = ldap_next_entry(ld, result_identifier)) {
for (attribute = ldap_first_attribute(ld, entry, &ber); attribute != NULL; attribute = ldap_next_attribute(ld, entry, ber)) {
table = new Gtk_CList(1, titles);
values = ldap_get_values(ld, entry, attribute);
for (int i=0; i<ldap_count_values(values); i++) {
- gchar *t[] = { values[i] };
+ const gchar *t[] = { values[i] };
table->append(t);
}
ldap_value_free(values);
}
}
if (par->scroller2 != NULL) {
- cout << "Scroller2 exists" << endl;
- if (par->scroller2->children[0] != NULL) {
- cout << "There are children in scroller2" << endl;
- par->scroller2->remove_child(0);
+ // cout << "Scroller2 exists" << endl;
+ if (par->scroller2->children() != NULL ) {
+ // if (par->scroller2->children[0] != NULL) {
+ // cout << "There are children in scroller2" << endl;
+ // par->scroller2->release(par->scroller2->children()->nth_data(0));
+ par->scroller2->remove_c(par->scroller2->children()->nth_data(0));
+ // par->scroller2->remove_child(0);
}
- par->scroller2->add_child(this->notebook);
+ // par->scroller2->add_child(this->notebook);
+ viewport->add(this->notebook);
+ par->scroller2->add(viewport); //this->notebook);
this->notebook->show();
+ viewport->show();
par->scroller2->show();
+ cout << "Added details for " << this->rdn << endl;
}
return 0;
}
Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
if (!sig->select) return;
sig->select(GTK_ITEM(gtkobj()));
- this->search();
+ this->getDetails();
}
+
void Gtk_LdapTreeItem::collapse_impl() {
- cout << this->dn << " collapsed" << endl;
+// cout << this->dn << " collapsed" << endl;
Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
if (!sig->collapse) return;
sig->collapse(GTK_TREE_ITEM(gtkobj()));
// gtk_widget_hide(GTK_WIDGET(GTK_TREE(GTK_TREE_ITEM (this->gtkobj())->subtree)));
}
+
void Gtk_LdapTreeItem::expand_impl() {
+// cout << this->dn << " expanded" << endl;
Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
if (!sig->expand) return;
sig->expand(GTK_TREE_ITEM(gtkobj()));
pane->add1(*this->scroller);
this->scroller->show();
- this->scroller2 = new My_Scroller();
+// this->scroller2 = new My_Scroller();
+ this->scroller2 = new Gtk_ScrolledWindow();
this->scroller2->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
pane->add2(*this->scroller2);
this->scroller2->show();
treeitem->dn = b_d; treeitem->ld = l_i;
treeresult = new Gtk_LdapItem();
if (entriesCount == 0) {
+ treeitem->setType(LEAF_NODE);
treeresult->treeitem = new Gtk_LdapTreeItem(*treeitem);
treeresult->tree = NULL;
return treeresult;
s = ldap_explode_dn(ldap_get_dn(l_i, entry), 1);
subtreeresult = make_tree(p, l_i, ldap_get_dn(l_i, entry));
subtreeitem = new Gtk_LdapTreeItem(*subtreeresult->treeitem);
+ // printf("inserting %s into %s", s[0], c);
subtree->append(*subtreeitem);
- printf("inserting %s into %s", s[0], c);
if (subtreeresult->tree != NULL) {
- printf(".");
+ // printf(".");
subsubtree = new Gtk_Tree(*subtreeresult->tree);
- printf(".");
+ // printf(".");
subtreeitem->set_subtree(*subsubtree);
- printf(".");
+ // printf(".");
}
subtreeitem->show();
- printf("\n");
+ // printf("\n");
entry = ldap_next_entry(l_i, entry);
}
+ treeitem->setType(BRANCH_NODE);
treeresult->treeitem = new Gtk_LdapTreeItem(*treeitem);
treeresult->tree = new Gtk_Tree(*subtree);
return treeresult;