]> git.sur5r.net Git - openldap/commitdiff
Misc. fixes and additions to gtk-tool - works and looks nicer now.
authorPredrag "Pele" Balorda <pele@openldap.org>
Fri, 27 Nov 1998 00:56:29 +0000 (00:56 +0000)
committerPredrag "Pele" Balorda <pele@openldap.org>
Fri, 27 Nov 1998 00:56:29 +0000 (00:56 +0000)
contrib/gtk-tool/ChangeLog
contrib/gtk-tool/Gtk_LdapTreeItem.cc
contrib/gtk-tool/Gtk_LdapTreeItem.h
contrib/gtk-tool/Makefile
contrib/gtk-tool/My_Window.cc
contrib/gtk-tool/My_Window.h
contrib/gtk-tool/TODO
contrib/gtk-tool/main.cc

index 879527571c60171d0e4a9b1c1e32549d72f74ee2..a46e0ba56f814b6fb030935c15f7bcb9ec970bca 100644 (file)
@@ -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
index baaba0417466df77dbaddef7eeafa3a2665cea2f..26a8b8b9839bdbde02dbe8368bd507520073820d 100644 (file)
@@ -1,14 +1,46 @@
 #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;
@@ -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; i<ldap_count_values(values); i++) {
-                               gchar *t[] = { values[i] };
+                               const gchar *t[] = { values[i] };
                                table->append(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()));
index 1e728ef3375572a0ea81d1c3acc205c9f8dcd3fc..ab7e562f09126a1eeb9e584f08c18565b7354e67 100644 (file)
@@ -4,6 +4,11 @@
 #include <My_Window.h>
 #include <lber.h>
 #include <ldap.h>
+/*#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();
index 4fc862a06019632404e919d3135259c5b47eb34b..db8f5d7dc541153f6d5a35054751deaf893975c3 100644 (file)
@@ -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
 
 ################################################################################
 
index 0b1eabafea1469d935ff95199b2d0a5d3a9d2462..67d4f1b124c4a92e40c42c8ff56ff2fcc972464e 100644 (file)
@@ -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;
index 7ccce313469d8b9d9a65d387103f242430ff5ccf..ce4a6f34f859d8a3e9d3cd341efd5ff07b6f041a 100644 (file)
@@ -4,7 +4,7 @@
 #include "gtk.h"
 #include <lber.h>
 #include <ldap.h>
-#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;
index 27d85943a9ef7d03448154230bc245430a9ed08b..fd144406b029bcef0e38bdc08350373fd9d40707 100644 (file)
@@ -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+?)
 
index 224a8bcd200a15b125295a30aa444aac70155f64..e83cff8b21c2faad7e8cbef698f21df5c0a76154 100644 (file)
@@ -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();