From: Predrag "Pele" Balorda Date: Fri, 27 Nov 1998 00:56:29 +0000 (+0000) Subject: Misc. fixes and additions to gtk-tool - works and looks nicer now. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~1016 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=60de7d64ff370e991153b71902ffb77246f52246;p=openldap Misc. fixes and additions to gtk-tool - works and looks nicer now. --- diff --git a/contrib/gtk-tool/ChangeLog b/contrib/gtk-tool/ChangeLog index 879527571c..a46e0ba56f 100644 --- a/contrib/gtk-tool/ChangeLog +++ b/contrib/gtk-tool/ChangeLog @@ -1,6 +1,17 @@ ChangeLog for gtk-tool -26/11/1998 +26/11/1998 - Pele + * Added nice icons in the browser pane - looks decent now. + * Fixed scrolling in the data (right) pane - now scrolls if there is + a long tab + * removed class My_Scroller + * removed file Gtk_LdapItem.cc (useless) + * commented-out the part where data gets reused instead of re-querying + the server, stupid I know, but for the time being if resolves some + problems with replacement of right pane. + * Misc. fixes + +26/11/1998 - Pele * First appearance of ChangeLog * Fixed removal of scrolled window on the right hand side thus making gtk-tool a viable project to be worked on diff --git a/contrib/gtk-tool/Gtk_LdapTreeItem.cc b/contrib/gtk-tool/Gtk_LdapTreeItem.cc index baaba04174..26a8b8b983 100644 --- a/contrib/gtk-tool/Gtk_LdapTreeItem.cc +++ b/contrib/gtk-tool/Gtk_LdapTreeItem.cc @@ -1,14 +1,46 @@ #include "Gtk_LdapTreeItem.h" +#include 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; @@ -17,30 +49,46 @@ int Gtk_LdapTreeItem::search() { 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; iappend(t); } ldap_value_free(values); @@ -51,14 +99,21 @@ int Gtk_LdapTreeItem::search() { } } 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; } @@ -68,16 +123,19 @@ void Gtk_LdapTreeItem::select_impl() { 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())); diff --git a/contrib/gtk-tool/Gtk_LdapTreeItem.h b/contrib/gtk-tool/Gtk_LdapTreeItem.h index 1e728ef337..ab7e562f09 100644 --- a/contrib/gtk-tool/Gtk_LdapTreeItem.h +++ b/contrib/gtk-tool/Gtk_LdapTreeItem.h @@ -4,6 +4,11 @@ #include #include #include +/*#include "XPMLabelBox.h"*/ + +#define ROOT_NODE 1 +#define BRANCH_NODE 2 +#define LEAF_NODE 3 class My_Window; @@ -15,10 +20,12 @@ public: LDAPMessage *result_identifier; My_Window *par; Gtk_Notebook *notebook; + Gtk_HBox *xpm_label; Gtk_LdapTreeItem(); Gtk_LdapTreeItem(char *c, My_Window *w); Gtk_LdapTreeItem(GtkTreeItem *t); - int search(); + void setType(int t); + int getDetails(); void select_impl(); void collapse_impl(); void expand_impl(); diff --git a/contrib/gtk-tool/Makefile b/contrib/gtk-tool/Makefile index 4fc862a060..db8f5d7dc5 100644 --- a/contrib/gtk-tool/Makefile +++ b/contrib/gtk-tool/Makefile @@ -2,14 +2,14 @@ HOME_LOCATION=$(shell pwd) CC= gcc CPLUS= g++ OPTS=-g -DmyDEBUG -INCLUDES=`gtkmm-config --cflags` -I/usr/include -I/usr/local/gnome/include -I. +INCLUDES=`gtkmm-config --cflags` -I. LDFLAGS=`gtkmm-config --libs` -L/usr/lib -L/usr/X11/lib -L/usr/local/gnome/lib -L/usr/local/ldap/lib -lldap -llber LIBS=-lXext -lgtkmm -lX11 -lXt -lXxf86dga .EXPORT_ALL_VARIABLES: -SOURCES= My_Window.cc My_Scroller.cc Gtk_LdapTreeItem.cc main.cc -OBJECTS= My_Window.o My_Scroller.o Gtk_LdapTreeItem.o main.o +SOURCES= My_Window.cc Gtk_LdapTreeItem.cc main.cc +OBJECTS= My_Window.o Gtk_LdapTreeItem.o main.o ################################################################################ diff --git a/contrib/gtk-tool/My_Window.cc b/contrib/gtk-tool/My_Window.cc index 0b1eabafea..67d4f1b124 100644 --- a/contrib/gtk-tool/My_Window.cc +++ b/contrib/gtk-tool/My_Window.cc @@ -12,7 +12,8 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) { 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(); @@ -73,6 +74,7 @@ Gtk_LdapItem* My_Window::make_tree(My_Window *p, LDAP* l_i, char* b_d) { 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; @@ -86,19 +88,20 @@ Gtk_LdapItem* My_Window::make_tree(My_Window *p, LDAP* l_i, char* b_d) { 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; diff --git a/contrib/gtk-tool/My_Window.h b/contrib/gtk-tool/My_Window.h index 7ccce31346..ce4a6f34f8 100644 --- a/contrib/gtk-tool/My_Window.h +++ b/contrib/gtk-tool/My_Window.h @@ -4,7 +4,7 @@ #include "gtk.h" #include #include -#include "My_Scroller.h" +/*#include "My_Scroller.h"*/ #include "Gtk_LdapItem.h" #include "Gtk_LdapTreeItem.h" class Gtk_LdapTreeItem; @@ -13,8 +13,8 @@ class My_Scroller; class My_Window : public Gtk_Window { public: - Gtk_ScrolledWindow *scroller; - My_Scroller *scroller2; + Gtk_ScrolledWindow *scroller, *scroller2; +// My_Scroller *scroller2; Gtk_Entry *urlfield; Gtk_Button *display_button; Gtk_Paned *pane; diff --git a/contrib/gtk-tool/TODO b/contrib/gtk-tool/TODO index 27d85943a9..fd144406b0 100644 --- a/contrib/gtk-tool/TODO +++ b/contrib/gtk-tool/TODO @@ -9,8 +9,6 @@ Priorities: Optional: comments in the source code - figure out how to insert nice little icons infront of every - tree item on the left side. port it to NT so we can use it with the NT port of OpenLDAP (is there a NT port of Gtk+?) diff --git a/contrib/gtk-tool/main.cc b/contrib/gtk-tool/main.cc index 224a8bcd20..e83cff8b21 100644 --- a/contrib/gtk-tool/main.cc +++ b/contrib/gtk-tool/main.cc @@ -47,7 +47,10 @@ int main(int argc, char **argv) { tree = new Gtk_Tree(); treeresult = window->make_tree(window, ld, base_dn); treeitem = new Gtk_LdapTreeItem(*treeresult->treeitem); - tree->append(treeitem); +// treeitem->remove_c(treeitem->getchild()->gtkobj()); +// gtk_widget_destroy(GTK_WIDGET(treeitem->xpm_label->gtkobj())); + treeresult->treeitem->setType(ROOT_NODE); + tree->append(*treeitem); if (treeresult->tree != NULL) { subtree = new Gtk_Tree(*treeresult->tree); printf("inserting %s into root\n", base_dn); @@ -57,11 +60,11 @@ int main(int argc, char **argv) { window->scroller->add(tree); tree->show(); window->scroller->show(); - treeitem->search(); + treeitem->getDetails(); window->set_title("Hello"); window->activate(); - window->set_usize(450, 450); + window->set_usize(600, 500); window->show();