]> git.sur5r.net Git - openldap/commitdiff
Modifications to gtk-tool (follow aliases, options, bugfixes)
authorPredrag "Pele" Balorda <pele@openldap.org>
Mon, 3 Jan 2000 12:23:15 +0000 (12:23 +0000)
committerPredrag "Pele" Balorda <pele@openldap.org>
Mon, 3 Jan 2000 12:23:15 +0000 (12:23 +0000)
13 files changed:
contrib/gtk-tool/COPYRIGHT
contrib/gtk-tool/ChangeLog
contrib/gtk-tool/Gtk_LdapServer.cc
contrib/gtk-tool/Gtk_LdapServer.h
contrib/gtk-tool/Gtk_LdapTree.cc
contrib/gtk-tool/Gtk_LdapTreeItem.cc
contrib/gtk-tool/Gtk_LdapTreeItem.h
contrib/gtk-tool/INSTALL
contrib/gtk-tool/My_Window.cc
contrib/gtk-tool/My_Window.h
contrib/gtk-tool/README
contrib/gtk-tool/TODO
contrib/gtk-tool/main.cc

index cf1515dd54435323615f43fb656d466decf64f1c..755a0ddd378b54eae4121d33a6596bd17df58791 100644 (file)
@@ -1,4 +1,4 @@
-Copyright 1998 Predrag Balorda, London, UK
+Copyright 1998,1999,2000 Predrag Balorda, London, UK
 All rights reserved.
 
 Redistribution and use in source and binary forms are permitted only
index dd2a78f794a667916bd1be966cf45405ab8d9399..9eec313150eaf7af4213d0b0199914180fd3d132 100644 (file)
@@ -1,4 +1,13 @@
 ChangeLog for gtk-tool
+03/01/2000 - Pele
+       * Fixed localtime() bug in Linux ?;)
+
+03/01/19100 - Pele
+       * Auto-select the first server if any supplied as arguments
+       * A visual bug in the former (deselect a bit messy)
+       * Follow aliases (not tested with leaf nodes though)
+       * "Show Debug Info" in "Options" menu
+
 28/12/1999 - Pele
        * Updated Gtk-- API from 1.0 to 1.1
        * Added -d switch (for debugging info)
index 9b685db8841efda25d6bc96b23fb51814b210010..fe51dbc1f2e5327a3672d69d0161cdcf65f4bfe9 100644 (file)
@@ -32,31 +32,18 @@ void Gtk_LdapServer::setType(int t) {
        Gtk_Pixmap *xpm_icon;
        Gtk_Label *label;
        char *c = NULL;
-       if (this->get_child() != NULL) {
-               this->remove();
-               /*
-               //xpm_label = new Gtk_HBox(GTK_HBOX(this->get_child()->gtkobj()));
-               xpm_label = new Gtk_HBox(this->get_child());
-               xpm_label->remove_c(xpm_label->children()->nth_data(0));
-               xpm_label->remove_c(xpm_label->children()->nth_data(0));
-               */
-       }
+       if (this->get_child() != NULL) this->remove();
        xpm_label = new Gtk_HBox();
        debug(this->hostname);
        if (strcasecmp(this->hostname,"localhost") == 0)
-               //xpm_icon=new Gtk_Pixmap(*xpm_label, local_server);
                xpm_icon=new Gtk_Pixmap(local_server);
-       else //xpm_icon=new Gtk_Pixmap(*xpm_label, remote_server);
-               xpm_icon=new Gtk_Pixmap(remote_server);
+       else xpm_icon=new Gtk_Pixmap(remote_server);
 //     sprintf(c, "%s:%i", this->hostname, this->port);
 //     printf("%s\n", c);
        label = new Gtk_Label(this->hostname);
        xpm_label->pack_start(*xpm_icon, false, false, 1);
        xpm_label->pack_start(*label, false, false, 1);
        if (this->get_child() == NULL) this->add(*xpm_label);
-       //label->show();
-       //xpm_label->show();
-       //xpm_icon->show();
        this->show_all();
 }
 
@@ -67,20 +54,59 @@ int Gtk_LdapServer::showDetails() {
                debug("Have a notebook here");
                if (par->viewport2->get_child() != NULL) {
                        debug(" and viewport has children");
-                       par->viewport2->remove(); //par->viewport2->get_child());
+                       par->viewport2->remove();
                        debug(" which have been removed\n");
                }
                else debug(" and viewport without children\n");
                par->viewport2->add(*this->notebook);
-               //this->notebook->show();
-               //par->viewport2->show();
-               //return 0;
        }
        this->show_all();
        debug("done\n");
        return 0;
 }
 
+int Gtk_LdapServer::getMonitor() {
+       debug("Gtk_LdapServer::getMonitor()\n");
+       int error, entriesCount;
+       LDAPMessage *entry, *result_identifier;
+       BerElement *ber;
+       char *attribute, **t;
+
+       if ((this->ld = ldap_open(this->hostname, this->port)) == NULL) {
+               perror("connection");
+       }
+
+       error = ldap_search_s(this->ld, "cn=monitor", LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &result_identifier);   
+       entriesCount = ldap_count_entries(this->ld, result_identifier);
+       if (entriesCount == 0) {
+               return 0;
+       }
+
+       debug("%i tree(s)\n", entriesCount);
+       for (entry = ldap_first_entry(this->ld, result_identifier); entry != NULL; entry = ldap_next_entry(this->ld, result_identifier)) {
+               for (attribute = ldap_first_attribute(this->ld, entry, &ber); attribute != NULL; attribute = ldap_next_attribute(this->ld, entry, ber)) {
+                       debug("Attrib: %s\n", attribute);
+                       if (strcasecmp(attribute, "database") == 0) {
+                               debug("have database here\n");
+                               this->databases = NULL;
+                               t = ldap_get_values(this->ld, entry, attribute);
+                               for (int i=0; i<ldap_count_values(t); i++) {
+                                       this->databases = g_list_append(this->databases, strdup(t[i]));
+                               }
+                               ldap_value_free(t);
+                               debug("databases loaded\n");
+                               GList *t;
+                               for (int i=0;i>g_list_length(this->databases);i++) {
+                                       t = g_list_nth(this->databases, i);
+                                       debug("database(%i) %s\n", i, (char*) t->data);
+                               }       
+                       }
+               }
+               debug("entry done\n");
+       }
+       return entriesCount;
+}
+
 int Gtk_LdapServer::getConfig() {
        debug("Gtk_LdapServer::getConfig()\n");
        int error, entriesCount;
@@ -98,31 +124,30 @@ int Gtk_LdapServer::getConfig() {
                return 0;
        }
 
-       debug("%i entry\n", entriesCount);
+//     debug("%i tree(s)\n", entriesCount);
        for (entry = ldap_first_entry(this->ld, result_identifier); entry != NULL; entry = ldap_next_entry(this->ld, result_identifier)) {
                for (attribute = ldap_first_attribute(this->ld, entry, &ber); attribute != NULL; attribute = ldap_next_attribute(this->ld, entry, ber)) {
                        debug("Attrib: %s\n", attribute);
                        if (strcasecmp(attribute, "database") == 0) {
                                debug("have database here\n");
-                               //this->databases = new GList<char>;
                                this->databases = NULL;
                                t = ldap_get_values(this->ld, entry, attribute);
                                for (int i=0; i<ldap_count_values(t); i++) {
                                        this->databases = g_list_append(this->databases, strdup(t[i]));
-                                       //this->databases->push_back(*strdup(t[i]));
                                }
+                       this->databases = g_list_append(this->databases, "ldbm : cn=config");
+                       this->databases = g_list_append(this->databases, "ldbm : cn=monitor");
                                ldap_value_free(t);
                                debug("databases loaded\n");
                                GList *t;
-                               for (int i=0;i>g_list_length(this->databases);i++) {
+                               for (int i=0;i<g_list_length(this->databases);i++) {
                                        t = g_list_nth(this->databases, i);
-//                                     debug("database(%i) %s\n", i, ((gchar*) t->data));
+                                       debug("database(%i) %s\n", i, (char*) t->data);
                                }       
                        }
                }
                debug("entry done\n");
        }
-//     debug("got %i entries\n", entriesCount);
        return entriesCount;
 }
 
@@ -208,7 +233,7 @@ int Gtk_LdapServer::getOptions() {
        Gtk_HScale *scale;
        Gtk_Adjustment *adjustment;
        char *description = NULL, *s_value = NULL;
-       int i_value;
+//     int i_value;
        string label_string;
 
        int things[10] = {
@@ -236,6 +261,7 @@ int Gtk_LdapServer::getOptions() {
        table = new Gtk_Table(10, 1, TRUE);
 
        for (int i=0; i<10; i++) {
+               int i_value;
        //      debug("%i\n", i);
                hbox = new Gtk_HBox(TRUE, 2);
                hbox->set_border_width(2);
@@ -283,7 +309,7 @@ int Gtk_LdapServer::getOptions() {
                        case 3:
                                ldap_get_option(this->ld, things[i], &i_value);
                                debug("i_value: %s\n", i_value);
-                               adjustment = new Gtk_Adjustment(i_value, 1.0, 20.0, 1.0, 1.0, 0.0);
+                               adjustment = new Gtk_Adjustment(i_value, 0.0, 20.0, 1.0, 1.0, 0.0);
                                scale = new Gtk_HScale(*adjustment);
                                scale->set_update_policy(GTK_UPDATE_CONTINUOUS);
                                scale->set_value_pos(GTK_POS_TOP);
@@ -358,7 +384,7 @@ Gtk_Tree* Gtk_LdapServer::getSubtree() {
                subtree = treeitem->getSubtree(this->ld, 1);
                debug("inserting %s into %s\n", treeitem->rdn, this->hostname);
                tree->append(*treeitem);
-               treeitem->set_subtree(*subtree);
+               if (subtree != NULL) treeitem->set_subtree(*subtree);
                treeitem->show();
        //      tree->show();
        }
index e234feb8d5133c888bc8d28b6c2f088fbb1d5e9f..21466a0b6c9dbb0c3f550b053c5949391595a96e 100644 (file)
@@ -36,6 +36,7 @@ public:
        Gtk_LdapServer(GtkTreeItem *t);
        ~Gtk_LdapServer();
        void setType(int t);
+       int getMonitor();
        int getConfig();
        Gtk_Tree* getSubtree();
 #ifndef LDAP_GET_OPT
index 58e596ac4171d6416f1a3598e97fbc80836bfc60..e5b25c793231cfdf10d295cfffb06d99b633147c 100644 (file)
@@ -5,9 +5,10 @@ void Gtk_LdapTree::show_impl() {
        Gtk_LdapTree *tree;
        Gtk_LdapTreeItem *item = NULL;
        Gtk_LdapTree::ItemList &items = this->tree();
-       Gtk_LdapTree::ItemList::iterator i = items.begin();
+       Gtk_LdapTree::ItemList::iterator i; // = items.begin();
        debug("iterator\n");
-       for (i=items.begin(); i!=items.end();i++) {
+       for (i=items.begin(); i!=items.end();++i) {
+//     while (i!=items.end()) {
                item = (Gtk_LdapTreeItem *)(*i);
                debug("new item\n");
                debug("#%s#\n", item->dn);
index ead239f1a75653c418b62c3acc01370151f77ea9..7add7b09546df9b0d1033be922d516edb9bbd5e8 100644 (file)
@@ -29,6 +29,7 @@ Gtk_LdapTree* Gtk_LdapTreeItem::getSubtree(LDAP *ld, int counter) {
        if (counter <= 0) return NULL;
        if (this->gtkobj()->subtree != NULL) {
                //return (Gtk_LdapTree *)GTK_TREE(this->gtkobj()->subtree);
+               debug("This item has a subtree\n");
                return (Gtk_LdapTree *)this->get_subtree(); //gtkobj()->subtree);
        }
        counter--;
@@ -40,7 +41,11 @@ Gtk_LdapTree* Gtk_LdapTreeItem::getSubtree(LDAP *ld, int counter) {
        int entriesCount = 0, error;
 
        this->ld = ld;
-       error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_ONELEVEL, "objectclass=*", NULL, 0, &r_i);
+       if (this->dn == "cn=config" || this->dn == "cn=monitor") error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &r_i);
+       else {
+               if (strcasecmp(this->objectClass,"alias") == 0) error = ldap_search_s(this->ld, this->getAttribute("aliasedobjectname"), LDAP_SCOPE_ONELEVEL, "objectclass=*", NULL, 0, &r_i);
+               else error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_ONELEVEL, "objectclass=*", NULL, 0, &r_i);
+       }
 //     printf("%s\n", ldap_err2string(error));
        entriesCount = ldap_count_entries(this->ld, r_i);
        debug("%i results\n", entriesCount);
@@ -51,9 +56,9 @@ Gtk_LdapTree* Gtk_LdapTreeItem::getSubtree(LDAP *ld, int counter) {
                tree->set_view_lines(false);
                entry = ldap_first_entry(this->ld, r_i);
        //      float i = 1;
-       //      float percent = 100/entriesCount;
-       //      cout << "percent is " << percent << endl;
-       //      this->par->progress.update(0);
+               gfloat percent = 100/entriesCount;
+               cout << "percent is " << percent << endl;
+       //      this->par->progress.set_percentage(percent/100);
        //      this->par->progress.show();
                while (entry != NULL) {
                        subtreeitem = new Gtk_LdapTreeItem(ldap_get_dn(this->ld, entry), this->par, this->ld);
@@ -114,6 +119,8 @@ void Gtk_LdapTreeItem::setType(int t) {
        else if (strcasecmp(this->objectClass,"rfc822mailgroup") == 0)
                //xpm_icon=new Gtk_Pixmap(*xpm_label, rfc822mailgroup_node);
                xpm_icon=new Gtk_Pixmap(rfc822mailgroup_node);
+       else if (strcasecmp(this->objectClass,"LDAPsubentry") == 0)
+               xpm_icon=new Gtk_Pixmap(monitor);
        else //xpm_icon=new Gtk_Pixmap(*xpm_label, general_node);
                xpm_icon=new Gtk_Pixmap(general_node);
        label = new Gtk_Label(this->rdn);
@@ -150,6 +157,25 @@ int Gtk_LdapTreeItem::showDetails() {
        return 0;
 }
 
+char* Gtk_LdapTreeItem::getAttribute(char *c) {
+       int entriesCount, error;
+       BerElement *ber;
+       LDAPMessage *entry;
+       char *attribute, **values;
+       error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &this->result_identifier);
+       entriesCount = ldap_count_entries(this->ld, this->result_identifier);
+       if (entriesCount == 0) return 0;
+       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)) {
+                       values = ldap_get_values(ld, entry, attribute);
+                       if (strcasecmp(attribute, "aliasedobjectname") == 0) {
+                               this->aliasedObjectName = strdup(values[0]);
+                       }
+               }
+       }
+       return this->aliasedObjectName;
+}
+
 int Gtk_LdapTreeItem::getDetails() {
        debug("Gtk_LdapTreeItem::getDetails()\n");
        int error, entriesCount;
@@ -160,7 +186,6 @@ int Gtk_LdapTreeItem::getDetails() {
        Gtk_CList *table;
        Gtk_Label *label;
        GList *child_list;
-//     Gtk_Notebook *g;
        Gtk_Viewport *viewport;
        error = ldap_search_s(this->ld, this->dn, LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, &this->result_identifier);
        entriesCount = ldap_count_entries(this->ld, this->result_identifier);
index fe0a12bdab0bd59544b0e6293344d75e94967999..a5775c542c5484bdf88b13fdd54e419795419c71 100644 (file)
@@ -12,6 +12,7 @@
 #include "icons/alias_node.h"
 #include "icons/rfc822mailgroup_node.h"
 #include "icons/general_node.h"
+#include "icons/monitor.h"
 
 #define ROOT_NODE 1
 #define BRANCH_NODE 2
@@ -25,6 +26,7 @@ public:
        char *dn;
        char *rdn;
        char *objectClass;
+       char *aliasedObjectName;
        LDAP *ld;
        LDAPMessage *result_identifier;
        My_Window *par;
@@ -34,6 +36,7 @@ public:
        Gtk_LdapTreeItem(char *c, My_Window *w, LDAP *ld);
        Gtk_LdapTreeItem(GtkTreeItem *t);
        ~Gtk_LdapTreeItem();
+       gchar* getAttribute(char *c);
        Gtk_LdapTree* getSubtree(LDAP *ld, int i);
        void setType(int t);
        int getDetails();
index 81cb982c8359594aa95e6a0062c6f4537ae53e1a..84a5c594e8c059e50b6e49eb8df94f76d4140916 100644 (file)
@@ -1,13 +1,13 @@
 Please read this carefully
 
 To copile gtk-tool, although OpenLDAP in itself is a very out-of-the-box 
-straightforward piece of code to compile gtk-tool isn't. You will require the
-latest Gtk+/Gtk-- CVS trees on your machine - as of 11 February 1999 so your 
-last weeks' checkout is more than likely allready useless - not my problem, they
-promise API freezes and then don't stick to it...what can I say...a hint for
-the gtk people - Java 1.1
+straightforward piece of code to compile gtk-tool isn't. You will require following:
+
+       Gtk+1.2.x
+       Gtk--1.1.x 
 
 So, latest gtk stuff and if you successfully compiled and installed all that it should be easy. If you didn't I really hope you can take some comfort in that I have provided you with some snapshots of what the thing actually looks like. I hope in the near future I would be able to provide you with a static binary..next week perhaps..I don't know, I'm looking for a job right now so no promises...
+(I'm no longer looking for a job but the situation with spare time seems even worse - I wish I could do this full-time guys, I really do...)
 
 Pele
 pele@openldap.org
index 174d388960d5450b0eb4d3225d7a947a59bbcb41..ee21e9424330c438335a1aa36ecc50b96345398d 100644 (file)
@@ -35,22 +35,22 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) {
        menuitem->activate.connect(slot(this,&My_Window::addServer));
        //connect_to_method(menuitem->activate, this, &addServer);
        sub_menu->append(*menuitem);
-       menuitem->show();
+//     menuitem->show();
        new_menu = new Gtk_MenuItem("New...");
        new_menu->set_submenu(*sub_menu);
-       sub_menu->show();
+//     sub_menu->show();
        menu->append(*new_menu);
-       new_menu->show();
+//     new_menu->show();
 
        menuitem = new Gtk_MenuItem("Quit");
        menuitem->activate.connect(Gtk_Main::quit.slot());      
        menu->append(*menuitem);
-       menuitem->show();
+//     menuitem->show();
        this->menubar = new Gtk_MenuBar();
        file_menu = new Gtk_MenuItem("File (?)");
        file_menu->set_submenu(*menu);
        this->menubar->append(*file_menu);
-       menu->show();
+//     menu->show();
 
        menu = new Gtk_Menu();
        check_menuitem = new Gtk_CheckMenuItem("Show Debug Info");
@@ -61,29 +61,32 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) {
        options_menu = new Gtk_MenuItem("Options");
        options_menu->set_submenu(*menu);
        this->menubar->append(*options_menu);
-       menu->show();
+//     menu->show();
        
-       file_menu->show();
-       options_menu->show();
+//     file_menu->show();
+//     options_menu->show();
 
 //     top_hbox->pack_start(*this->menubar, TRUE, TRUE, 1);
-       this->menubar->show();
+//     this->menubar->show();
        this->urlfield = new Gtk_Entry();
        top_hbox->pack_start(*this->urlfield, TRUE, TRUE, 1);
-       this->urlfield->show();
+//     this->urlfield->show();
        this->display_button = new Gtk_Button("Query Server");
        this->display_button->clicked.connect(slot(this, &My_Window::getHost));
        //connect_to_method(this->display_button->clicked, this, &getHost);
        top_hbox->pack_end(*this->display_button, FALSE, FALSE, 1);
-       this->display_button->show();
+//     this->display_button->show();
 
        this->status = new Gtk_Statusbar();
+//     this->progress = new Gtk_ProgressBar();
+//     this->status->add(*progress);
+//     this->progress->show();
 
        bottom_hbox = new Gtk_VBox();
        bottom_hbox->pack_start(*pane, TRUE, TRUE, 1);
        bottom_hbox->pack_end(*status, FALSE, TRUE, 1);
        pane->show();
-       status->show();
+//     status->show();
 
        main_hbox = new Gtk_VBox();
        main_hbox->pack_start(*this->menubar, FALSE, FALSE, 1);
@@ -94,6 +97,7 @@ My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) {
        this->add(*main_hbox);
        this->destroy.connect(Gtk_Main::quit.slot());   
        main_hbox->show();
+//     this->show_all();
 }
 
 My_Window::~My_Window() {
@@ -157,6 +161,7 @@ void My_Window::getHost() {
        tree->show();
        this->viewport->show();
        this->scroller->show();
+       treeitem->select();
 }
 
 void My_Window::setDebug() {
index c56c6690b31c73b6c6a74d73117f452d8d3b81e2..f68c480473af6f0c56023469d1180c1c056e0445 100644 (file)
@@ -16,7 +16,7 @@ public:
        Gtk_InputDialog *dialog;
        Gtk_Paned *pane;
        Gtk_MenuBar *menubar;
-//     Gtk_ProgressBar progress;
+//     Gtk_ProgressBar *progress;
        Gtk_Statusbar *status;
        My_Window(GtkWindowType t);
        ~My_Window();
index 51e197787120294f577da38de732560edeeaa362..e2579e5af0638c41734075a287372fee8dae2cda 100644 (file)
@@ -1,6 +1,6 @@
-README for gtk-tool v0.6a
+README for gtk-tool v0.7a
 
-This package has been tested and run with the latest Gtk+/Gtk--
+This package has been tested and run with the latest Gtk+1.2/Gtk--1.1
 OpenLDAP 2.0-devel. It should also compile (i.e. it is backward-compatible) with
 the U-MICH (old) API but it has not been tested (read compiled) - however the siplicity of the "problem" and a few ifdefs lead me to believe everything should
 be allright with gtk-tool now. This thing doesn't run as it should, please
@@ -26,6 +26,7 @@ i.e.:
 
 etc...
 It does not accept -b switch as it no longer needs it to aquire databases.
+There's also a -d <level> switch (try it with -d 1) for all the debug info.
 But please feel free to add whatever else you consider neccessary to 
 understanding how this thing works. Enjoy, and I hope this can be useful to 
 you in some miniscule way.
index 70d7d31350e273a47aff8a5d670d00f7667b0766..d316745daa130f34109cb4b50565e5a38dec70f7 100644 (file)
@@ -2,20 +2,17 @@ LOADS!!!
 
 Please someone test this with old U-MICH API - hopefully all is as it should be.
 
-Odd behaviour with tabbed panes - labels misteriously dissapear after you
-select a node for the second time 'round. Anyone any ideas on this?
-
 Priorities:
        Now that we have cn=config we can start using ldap_get_option propperly
        and be able to run/stop server from the gtk-tool. Other things like
        new entries would now come in handy.
        Implement searches
-       port to autoconf (anyone? it should be easy)
+       Integrate with OpenLDAP build - autoconf stuff (anyone?)
 
 Optional:
        comments in the source code     
        port it to NT so we can use it with the NT port of OpenLDAP
-       (is there a NT port of Gtk+?)
+       (they say that there is an NT port of Gtk+?)
 
 Pele
 pele@openldap.org
index f2db2bfc3c2925d5d9b51f348afc8e83639b421c..8b66c2da8a1b2a7d72e95d38ae49607dd88cf441 100644 (file)
@@ -11,7 +11,7 @@ int debug_level = 0;
 int main(int argc, char **argv) {
        My_Window *window;
        Gtk_LdapItem *treeresult;
-       Gtk_Tree *tree, *subtree;
+       Gtk_Tree *tree = NULL, *subtree = NULL;
        Gtk_Tree *machine, *machinetree;
        Gtk_LdapServer *server;
        Gtk_Viewport *viewport;
@@ -36,7 +36,7 @@ int main(int argc, char **argv) {
                                port = atoi(optarg); break;
                        case 'h':
                        default:
-                               fprintf(stderr, "Usage: %s ([-s server[:port]])*\n", argv[0]);
+                               fprintf(stderr, "Usage: %s [-d level] [-s server[:port]]*\n", argv[0]);
                                exit(-1);
                }
                fprintf(stderr,"b");
@@ -54,7 +54,6 @@ int main(int argc, char **argv) {
                        fprintf(stderr,"Why isn't your LDAP_OPT_HOST_NAME defined?\n");
 #endif
                        fprintf(stderr,"Supply me with a host please (hint: use -s)\n");
-               //      exit(1);
                }
        } else {        
                for (int f=0; f<g_list_length(hosts); f++) {
@@ -67,7 +66,6 @@ int main(int argc, char **argv) {
 
        window = new My_Window(GTK_WINDOW_TOPLEVEL);
 
-//     viewport = new Gtk_Viewport();
        if (hosts!=NULL) {
                tree = new Gtk_Tree();
                for (int f=0; f<g_list_length(hosts); f++) {
@@ -82,17 +80,24 @@ int main(int argc, char **argv) {
                        server->show();
                }
                window->viewport->add(*tree);
-               tree->show();
+//             tree->show();
        }
 
-//     window->scroller->add(viewport);
-       window->viewport->show();
-       window->scroller->show();
+//     window->viewport->show();
+//     window->scroller->show();
+
+       //Select first server
+       if (tree != NULL) {
+               Gtk_LdapTree::ItemList &items = tree->tree();
+               Gtk_LdapTree::ItemList::iterator i = items.begin();
+               server = (Gtk_LdapServer *)(* i);
+               server->select_impl();
+       }
 
        window->set_title("gtk-tool");
        window->activate();
        window->set_usize(600, 500);
-       window->show();
+       window->show_all();
 
        m.run();
        return 0;