ChangeLog for gtk-tool
+12/01/1999 - Pele
+ * Added some defines for U-MICH compatibility
+ * Updated to the latest Gtk-- API (in Gtk-- CVS tree)
+ * Minor fixes due to the new and cleaner Gtk-- API
+ * A new server can be added by entering a hostname into the
+ "url" field at the top and clicking on "Query Server" button
+ (note that one server still has to be supplied on the command line -
+ I'll try and fix this tomorrow...to do with ldap_get_opt)
+ * Somewhat "smarter" Makefile - can someone please look into integrating
+ gtk-tool into the openldap autoconf stuff?
+
09/12/1998 - Pele
* Display of all ldap options in their proper widgets (sliders for
timeout, radio buttons for booleans etc.) when server selected
Gtk_Pixmap *xpm_icon;
Gtk_Label *label;
char *c = NULL;
- if (this->getchild() != NULL) {
- xpm_label = new Gtk_HBox(GTK_HBOX(this->getchild()->gtkobj()));
+ if (this->get_child() != NULL) {
+ xpm_label = new Gtk_HBox(GTK_HBOX(this->get_child()->gtkobj()));
xpm_label->remove_c(xpm_label->children()->nth_data(0));
xpm_label->remove_c(xpm_label->children()->nth_data(0));
}
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->getchild() == NULL) this->add(xpm_label);
+ if (this->get_child() == NULL) this->add(xpm_label);
label->show();
xpm_label->show();
xpm_icon->show();
int Gtk_LdapServer::showDetails() {
debug("Gtk_LdapServer::showDetails()\n");
+ if (this->notebook == NULL) this->getOptions();
if (this->notebook != NULL) {
-// debug("Have notebook here");
- if (par->viewport->getchild() != NULL) {
-// debug(" and viewport has children");
- par->viewport->remove_c(par->viewport->getchild()->gtkobj());
-// debug(" which have been removed");
+ debug("Have a notebook here");
+ if (par->viewport2->get_child() != NULL) {
+ debug(" and viewport has children");
+ par->viewport2->remove(par->viewport2->get_child());
+ debug(" which have been removed");
}
-// else debug(" and viewport without children");
- par->viewport->add(this->notebook);
+ else debug(" and viewport without children");
+ par->viewport2->add(this->notebook);
this->notebook->show();
- par->viewport->show();
+ par->viewport2->show();
return 0;
}
- if (this->getOptions() != 0) return 1;
- this->showDetails();
-// debug("done\n");
+ debug("done\n");
return 0;
}
return entriesCount;
}
+#ifndef LDAP_GET_OPT /* a temporary fix for usability with (old) U-MICH api */
char* Gtk_LdapServer::getOptDescription(int option) {
debug("Gtk_LdapServer::getOptDescription(%i) ", option);
char *c;
debug("%i\n", type);
return type;
}
+#endif /* LDAP_GET_OPT */
int Gtk_LdapServer::getOptions() {
debug("Gtk_LdapServer::getOptions()\n");
if (this->notebook != NULL) return 0;
+#ifdef LDAP_GET_OPT /* a temporary fix for usability with (old) U-MICH api */
+ Gtk_Label *label;
+ label = new Gtk_Label("This tool has been compiled with (old) U-MICH API (no LDAP_GET_OPT)\nCompile with the latest -devel (from OpenLDAP cvs tree)\nto get some nice options here");
+ this->notebook = new Gtk_Frame("LDAP Options");
+ this->notebook->add(*label);
+ label->show();
+ this->notebook->show();
+ return 0;
+#else
LDAPAPIInfo api;
Gtk_HBox *hbox, *mini_hbox;
Gtk_VBox *vbox, *mini_vbox;
for (int i=0; i<10; i++) {
// debug("%i\n", i);
hbox = new Gtk_HBox(TRUE, 2);
- hbox->border_width(2);
+ hbox->set_border_width(2);
description = this->getOptDescription(things[i]);
label = new Gtk_Label(description);
label->set_justify(GTK_JUSTIFY_LEFT);
ldap_get_option(this->ld, things[i], &i_value);
radio1 = new Gtk_RadioButton(static_cast<GSList*>(0), "Enabled");
radio2 = new Gtk_RadioButton(*radio1, "Disabled");
- if (i_value == 1) radio1->set_state(true);
- else radio2->set_state(true);
+ if (i_value == 1) radio1->set_active(true);
+ else radio2->set_active(true);
mini_hbox = new Gtk_HBox(FALSE, 2);
- mini_hbox->border_width(2);
+ mini_hbox->set_border_width(2);
mini_hbox->pack_start(*radio1);
radio1->show();
mini_hbox->pack_end(*radio2);
table->attach_defaults(*hbox, 0, 1, i, i+1);
hbox->show();
}
- table->border_width(2);
+ table->set_border_width(2);
this->notebook = new Gtk_Frame("LDAP Options");
this->notebook->add(*table);
table->show();
return 0;
+#endif /* LDAP_GET_OPT */
}
Gtk_Tree* Gtk_LdapServer::getSubtree() {
// tree->show();
}
// this->set_subtree(*tree);
- debug("getTree() done\n");
+ debug("getSubtree() done\n");
return tree;
}
-
+/*
void Gtk_LdapServer::show_impl() {
debug("%s showed\n", this->hostname);
- Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
- sig->show(GTK_WIDGET(gtkobj()));
+ BaseClassType *sig=static_cast<BaseClassType *>(get_parent_class());
+ if (!sig->show) return;
+ sig->show(gtkobj());
+// Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
+// sig->show(GTK_WIDGET(gtkobj()));
}
-
+*/
void Gtk_LdapServer::select_impl() {
debug("%s selected\n", this->hostname);
- Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
- if (!sig->select) return;
+// Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
+// if (!sig->select) return;
this->showDetails();
- sig->select(GTK_ITEM(gtkobj()));
+// sig->select(GTK_ITEM(gtkobj()));
+ Gtk_TreeItem::select_impl();
}
void Gtk_LdapServer::collapse_impl() {
debug("%s collapsed\n", this->hostname);
- Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
- if (!sig->collapse) return;
- sig->collapse(GTK_TREE_ITEM(gtkobj()));
+// 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)));
+ Gtk_TreeItem::collapse_impl();
}
void Gtk_LdapServer::expand_impl() {
debug("%s expanded\n", this->hostname);
- Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
- if (!sig->expand) return;
- sig->expand(GTK_TREE_ITEM(gtkobj()));
+ Gtk_TreeItem::expand_impl();
+// BaseClassType *sig=static_cast<BaseClassType *>(get_parent_class());
+// if (!sig->expand)
+// { return; }
+// sig->expand(gtkobj());
+// Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
+// if (!sig->expand) return;
+// sig->expand(GTK_TREE_ITEM(gtkobj()));
// Gtk_Tree *t;
// t = new Gtk_Tree(GTK_TREE(GTK_TREE_ITEM(this->gtkobj())->subtree));
// bool vis = t->visible();
void setType(int t);
int getConfig();
Gtk_Tree* getSubtree();
+#ifndef LDAP_GET_OPT
char* getOptDescription(int option);
int getOptType(int option);
+#endif
int getOptions();
int showDetails();
- void show_impl();
+// void show_impl();
void select_impl();
void collapse_impl();
void expand_impl();
Gtk_LdapTree::iterator i;
debug("iterator\n");
for (i=this->begin(); i!=this->end();i++) {
- item = (Gtk_LdapTreeItem *)GTK_TREE_ITEM((*i));
+ // item = (Gtk_LdapTreeItem *)GTK_TREE_ITEM((*i));
+ item = (Gtk_LdapTreeItem *)(*i);
debug("#%s#\n", item->dn);
- if (item->gtkobj()->subtree == NULL) {
+ if (item->get_subtree() == NULL) {
+ debug("ding!\n");
tree = item->getSubtree(item->ld, 1);
if (tree != NULL) item->set_subtree(*tree);
}
}
debug("done\n");
- Gtk_c_signals_Tree *sig=(Gtk_c_signals_Tree *)internal_getsignalbase();
- sig->show(GTK_WIDGET(gtkobj()));
+ Gtk_Tree::show_impl();
}
#include "Gtk_LdapTreeItem.h"
-#include <gtk--/base.h>
Gtk_LdapTreeItem::Gtk_LdapTreeItem() : Gtk_TreeItem() {
this->objectClass = NULL;
debug("Gtk_LdapTreeItem::setType(%s)\n", this->objectClass);
Gtk_Pixmap *xpm_icon;
Gtk_Label *label;
- if (this->getchild() != NULL) {
- xpm_label = new Gtk_HBox(GTK_HBOX(this->getchild()->gtkobj()));
+ if (this->get_child() != NULL) {
+ xpm_label = new Gtk_HBox(GTK_HBOX(this->get_child()->gtkobj()));
xpm_label->remove_c(xpm_label->children()->nth_data(0));
xpm_label->remove_c(xpm_label->children()->nth_data(0));
}
label = new Gtk_Label(this->rdn);
xpm_label->pack_start(*xpm_icon, false, false, 1);
xpm_label->pack_start(*label, false, false, 1);
- if (this->getchild() == NULL) this->add(xpm_label);
+ if (this->get_child() == NULL) this->add(xpm_label);
label->show();
xpm_label->show();
xpm_icon->show();
int Gtk_LdapTreeItem::showDetails() {
debug("Gtk_LdapTreeItem::showDetails()\n");
+ if (this->notebook == NULL) this->getDetails();
if (this->notebook != NULL) {
- if (par->viewport->getchild() != NULL) {
- par->viewport->remove_c(par->viewport->getchild()->gtkobj());
+ debug("Have a notebook here");
+ if (par->viewport2->get_child() != NULL) {
+ debug(" and the viewport has children");
+ par->viewport2->remove(par->viewport2->get_child());
+ debug(" which have been removed");
}
- par->viewport->add(this->notebook);
+ else debug(" and viewport has no children");
+ par->viewport2->add(*this->notebook);
this->notebook->show();
- par->viewport->show();
+ par->viewport2->show();
return 0;
}
- else this->getDetails();
- this->showDetails();
+ else debug("No notebook and no details");
return 0;
}
BerElement *ber;
LDAPMessage *entry;
char *attribute, **values;
+ char attrib[32];
Gtk_CList *table;
Gtk_Label *label;
GList *child_list;
- Gtk_Notebook *g;
+// 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);
if (entriesCount == 0) return 0;
- notebook = new Gtk_Notebook();
- notebook->set_tab_pos(GTK_POS_LEFT);
+ this->notebook = new Gtk_Notebook();
+ this->notebook->set_tab_pos(GTK_POS_LEFT);
const gchar *titles[] = { "values" };
for (entry = ldap_first_entry(ld, result_identifier); entry != NULL; entry = ldap_next_entry(ld, result_identifier)) {
table->append(t);
}
ldap_value_free(values);
- label = new Gtk_Label(attribute);
+ sprintf(attrib, "%s", attribute);
+ label = new Gtk_Label(attrib);
label->set_alignment(0, 0);
label->set_justify(GTK_JUSTIFY_LEFT);
- notebook->append_page(*table, *label);
+ this->notebook->append_page(*table, *label);
table->show();
label->show();
}
debug("done\n");
return 0;
}
-
+/*
void Gtk_LdapTreeItem::show_impl() {
debug("%s showed\n", this->dn);
- Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
- sig->show(GTK_WIDGET(gtkobj()));
+// Gtk_c_signals_Base *sig=(Gtk_c_signals_Base *)internal_getsignalbase();
+// sig->show(GTK_WIDGET(gtkobj()));
}
-
+*/
void Gtk_LdapTreeItem::select_impl() {
debug("%s selected\n", this->dn);
-// gtk_item_select(GTK_ITEM(GTK_TREE_ITEM(this->gtkobj())));
- Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
- if (!sig->select) return;
- sig->select(GTK_ITEM(gtkobj()));
this->showDetails();
+ Gtk_TreeItem::select_impl();
}
void Gtk_LdapTreeItem::collapse_impl() {
debug("%s collapsed\n", this->dn);
- 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)));
+ Gtk_TreeItem::collapse_impl();
}
void Gtk_LdapTreeItem::expand_impl() {
Gtk_LdapTreeItem *item;
G_List<GtkWidget> *list;
Gtk_Tree *tree;
- Gtk_c_signals_TreeItem *sig=(Gtk_c_signals_TreeItem *)internal_getsignalbase();
- if (!sig->expand) return;
- sig->expand(GTK_TREE_ITEM(gtkobj()));
-// Gtk_Tree *t;
-// t = new Gtk_Tree(GTK_TREE(GTK_TREE_ITEM(this->gtkobj())->subtree));
-// bool vis = t->visible();
-// if (vis == false) {
-// gtk_widget_show(GTK_WIDGET(GTK_TREE(GTK_TREE_ITEM (this->gtkobj())->subtree)));
-// cout << this->dn << " expanded" << endl;
-// }
-// else {
-// gtk_widget_hide(GTK_WIDGET(GTK_TREE(GTK_TREE_ITEM (this->gtkobj())->subtree)));
-// cout << this->dn << " collapsed" << endl;
-// }
+ Gtk_TreeItem::expand_impl();
}
void setType(int t);
int getDetails();
int showDetails();
- void show_impl();
+// void show_impl();
void select_impl();
void collapse_impl();
void expand_impl();
HOME_LOCATION=$(shell pwd)
-CC= gcc
CPLUS= g++
-OPTS=-g -DDEBUG
+OPTS=-g #-DDEBUG
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 -L/usr/local/kerberos/lib -lkrb5 -lkrb4
LIBS=-lXext -lgtkmm -lX11 -lXt -lXxf86dga
.EXPORT_ALL_VARIABLES:
-SOURCES= My_Window.cc Gtk_LdapTree.cc Gtk_LdapTreeItem.cc Gtk_LdapServer.cc utils.cc main.cc
-OBJECTS= My_Window.o Gtk_LdapTree.o Gtk_LdapTreeItem.o Gtk_LdapServer.o utils.o main.o
+SOURCES=My_Window.cc Gtk_LdapTree.cc Gtk_LdapTreeItem.cc Gtk_LdapServer.cc utils.cc main.o
+OBJECTS=My_Window.o Gtk_LdapTree.o Gtk_LdapTreeItem.o Gtk_LdapServer.o utils.o main.o
################################################################################
-all: $(OBJECTS) $(SOURCES)
+all: main
+main: $(OBJECTS)
$(CPLUS) $(OBJECTS) -o main $(LDFLAGS)
exec
+main.o: main.cc
+ $(CPLUS) -c $(OPTS) $(INCLUDES) $<
+
exec: all
chmod a+x main
ls -al main
-%.o: %.c
- $(CC) -c $(OPTS) $(INCLUDES) $<
-
-%.o: %.cc
+%.o: %.cc %.h
$(CPLUS) -c $(OPTS) $(INCLUDES) $<
clean:
pane = new Gtk_HPaned();
this->scroller = new Gtk_ScrolledWindow();
+ this->viewport = new Gtk_Viewport();
this->scroller->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-// this->scroller->set_usize(this->height(), 400);
+ this->scroller->add(*this->viewport);
pane->add1(*this->scroller);
this->scroller->show();
+ this->viewport->show();
-// this->scroller2 = new My_Scroller();
this->scroller2 = new Gtk_ScrolledWindow();
- this->viewport = new Gtk_Viewport();
+ this->viewport2 = new Gtk_Viewport();
this->scroller2->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- this->scroller2->add(*this->viewport);
+ this->scroller2->add(*this->viewport2);
pane->add2(*this->scroller2);
this->scroller2->show();
+ this->viewport2->show();
top_hbox = new Gtk_HBox();
menu = new Gtk_Menu();
menu->append(*menuitem);
this->menubar = new Gtk_MenuBar();
file_menu = new Gtk_MenuItem("File");
- file_menu->set_submenu(menu);
+ file_menu->set_submenu(*menu);
this->menubar->append(*file_menu);
menuitem->show();
menu->show();
this->urlfield = new Gtk_Entry();
top_hbox->pack_start(*this->urlfield, TRUE, TRUE, 1);
this->urlfield->show();
- this->display_button = new Gtk_Button("Display");
- connect_to_method(this->display_button->clicked, this, &do_display);
+ this->display_button = new Gtk_Button("Query Server");
+ connect_to_method(this->display_button->clicked, this, &getHost);
top_hbox->pack_end(*this->display_button, FALSE, FALSE, 1);
this->display_button->show();
cout << this->urlfield->get_text() << endl;
}
+void My_Window::getHost() {
+ debug("My_Window::getHost()\n");
+ Gtk_Tree *tree, *subtree;
+ Gtk_LdapServer *treeitem;
+ char *host, *prt;
+ int port;
+
+// viewport = (Gtk_Viewport *) GTK_VIEWPORT(this->scroller->children()->nth_data(1));
+// viewport = (Gtk_Viewport *)this->scroller->children()->nth_data(1);
+ if (this->viewport->get_child()!=NULL) {
+ tree = (Gtk_Tree *)(this->viewport->get_child());
+ }
+ else {
+ tree = new Gtk_Tree();
+ }
+ string thing;
+ thing = this->urlfield->get_text();
+ gchar **c;
+ c = g_strsplit(thing.c_str(), ":", 2);
+ host = c[0];
+ prt = c[1]; //strtok(NULL, "\0");
+ if (prt != NULL) port = atoi(prt);
+ else port = LDAP_PORT;
+ treeitem = new Gtk_LdapServer(this, host, port);
+ subtree = treeitem->getSubtree();
+ tree->append(*treeitem);
+ treeitem->set_subtree(*subtree);
+ treeitem->show();
+ this->viewport->add(tree);
+ tree->show();
+ this->viewport->show();
+ this->scroller->show();
+}
+
gint My_Window::delete_event_impl(GdkEventAny*) {
Gtk_Main::instance()->quit();
return 0;
#define MY_WINDOW_H
#include "cpluscommon.h"
#include "gtk.h"
+#include "Gtk_LdapServer.h"
+#include "Gtk_LdapTreeItem.h"
class My_Window : public Gtk_Window {
public:
Gtk_ScrolledWindow *scroller, *scroller2;
- Gtk_Viewport *viewport;
-// My_Scroller *scroller2;
+ Gtk_Viewport *viewport, *viewport2;
Gtk_Entry *urlfield;
Gtk_Button *display_button;
Gtk_Paned *pane;
~My_Window();
int debug(const char *c,...);
void do_display();
+ void getHost();
gint delete_event_impl(GdkEventAny *);
};
#endif
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
debug("%s\n", hosts->nth_data(f));
}
if (hosts->length() == 0) {
+#ifdef LDAP_GET_OPT
+ printf("Supply me with a host please (hint: use -s\n");
+ exit(0);
+#else
ldap_get_option(NULL, LDAP_OPT_HOST_NAME, host);
hosts = hosts->append(host);
+#endif /* LDAP_GET_OPT */
}
if (port == 0) port = LDAP_PORT;
Gtk_Main m(&argc, &argv);
window = new My_Window(GTK_WINDOW_TOPLEVEL);
+
+// viewport = new Gtk_Viewport();
+ if (hosts!=NULL) {
+ tree = new Gtk_Tree();
+ for (int f=0; f<hosts->length(); f++) {
+ host = strtok(hosts->nth_data(f), ":");
+ prt = strtok(NULL, "\0");
+ if (prt != NULL) port = atoi(prt);
+ else port = LDAP_PORT;
+ treeitem = new Gtk_LdapServer(window, host, port);
+ subtree = treeitem->getSubtree();
+ tree->append(*treeitem);
+ treeitem->set_subtree(*subtree);
+ treeitem->show();
+ }
+ window->viewport->add(tree);
+ tree->show();
+ }
+
+// window->scroller->add(viewport);
+ window->viewport->show();
+ window->scroller->show();
+
window->set_title("gtk-tool");
window->activate();
window->set_usize(600, 500);
window->show();
- tree = new Gtk_Tree();
- for (int f=0; f<hosts->length(); f++) {
- host = strtok(hosts->nth_data(f), ":");
- prt = strtok(NULL, "\0");
- if (prt != NULL) port = atoi(prt);
- else port = LDAP_PORT;
- treeitem = new Gtk_LdapServer(window, host, port);
- subtree = treeitem->getSubtree();
- tree->append(*treeitem);
- treeitem->set_subtree(*subtree);
- treeitem->show();
- }
- viewport = new Gtk_Viewport();
- viewport->add(tree);
- window->scroller->add(viewport);
- tree->show();
- viewport->show();
- window->scroller->show();
-// treeitem->showDetails();
-// treeitem->select();
-
m.run();
return 0;
}