miscelaneous updates and fixes to gtk-tool

This commit is contained in:
Predrag "Pele" Balorda 1998-12-10 13:05:05 +00:00
parent 545048451c
commit 6b854dff20
7 changed files with 81 additions and 34 deletions

View File

@ -1,5 +1,11 @@
ChangeLog for gtk-tool
09/12/1998 - Pele
* Display of all ldap options in their proper widgets (sliders for
timeout, radio buttons for booleans etc.) when server selected
* Code cleanups
* Misc fixes
03/12/1998 - Pele
* Added support for multiple servers (via multiple -s options)
* More testing

View File

@ -141,13 +141,15 @@ char* Gtk_LdapServer::getOptDescription(int option) {
int Gtk_LdapServer::getOptType(int option) {
debug("Gtk_LdapServer::getOptType(%i) ", option);
int type; /* 0 = int, 1 = string, 2 = boolean */
/* types:
* 0 = int, 1 = string, 2 = boolean,
* 3 = range, 4 = LDAPAPIInfo, 5 = unknown
*/
int type;
switch(option) {
/* ints */
case LDAP_OPT_DEREF:
case LDAP_OPT_DESC:
case LDAP_OPT_SIZELIMIT:
case LDAP_OPT_TIMELIMIT:
case LDAP_OPT_ERROR_NUMBER:
case LDAP_OPT_PROTOCOL_VERSION: type = 0; break;
/* strings */
@ -157,10 +159,15 @@ int Gtk_LdapServer::getOptType(int option) {
case LDAP_OPT_REFERRALS:
case LDAP_OPT_DNS:
case LDAP_OPT_RESTART: type = 2; break;
/* range */
case LDAP_OPT_SIZELIMIT:
case LDAP_OPT_TIMELIMIT: type = 3; break;
/* api */
case LDAP_OPT_API_INFO: type = 4; break;
/* unknowns */
case LDAP_OPT_SERVER_CONTROLS:
case LDAP_OPT_CLIENT_CONTROLS:
case LDAP_OPT_API_INFO:
default: type = 0; break;
default: type = 5; break;
}
debug("%i\n", type);
return type;
@ -169,19 +176,23 @@ int Gtk_LdapServer::getOptType(int option) {
int Gtk_LdapServer::getOptions() {
debug("Gtk_LdapServer::getOptions()\n");
if (this->notebook != NULL) return 0;
LDAPAPIInfo api;
Gtk_HBox *hbox, *mini_hbox;
Gtk_VBox *vbox, *mini_vbox;
Gtk_Table *table;
Gtk_Label *label;
Gtk_RadioButton *radio1, *radio2;
char *s_value;
Gtk_HScale *scale;
Gtk_Adjustment *adjustment;
char *description = NULL, *s_value = NULL;
int i_value;
char *thing;
int things[9] = {
string label_string;
int things[10] = {
LDAP_OPT_API_INFO,
// LDAP_OPT_CLIENT_CONTROLS,
LDAP_OPT_CLIENT_CONTROLS,
// LDAP_OPT_DESC,
LDAP_OPT_DEREF,
// LDAP_OPT_DEREF,
LDAP_OPT_DNS,
// LDAP_OPT_ERROR_NUMBER,
// LDAP_OPT_ERROR_STRING,
@ -189,7 +200,7 @@ int Gtk_LdapServer::getOptions() {
LDAP_OPT_PROTOCOL_VERSION,
LDAP_OPT_REFERRALS,
LDAP_OPT_RESTART,
// LDAP_OPT_SERVER_CONTROLS,
LDAP_OPT_SERVER_CONTROLS,
LDAP_OPT_SIZELIMIT,
LDAP_OPT_TIMELIMIT
};
@ -200,23 +211,22 @@ int Gtk_LdapServer::getOptions() {
// debug("getting ldap options");
// vbox = new Gtk_VBox();
table = new Gtk_Table(11, 2, TRUE);
table = new Gtk_Table(10, 1, TRUE);
for (int i=0; i<9; i++) {
for (int i=0; i<10; i++) {
// debug("%i\n", i);
hbox = new Gtk_HBox(TRUE, 2);
hbox->border_width(2);
thing = this->getOptDescription(things[i]);
label = new Gtk_Label(thing);
description = this->getOptDescription(things[i]);
label = new Gtk_Label(description);
label->set_justify(GTK_JUSTIFY_LEFT);
label->set_alignment(0, 0);
hbox->pack_start(*label);
label->show();
int tipus = this->getOptType(things[i]);
switch (tipus) {
switch (this->getOptType(things[i])) {
case 0:
ldap_get_option(NULL, things[i], &i_value);
debug("%s value %d\n", thing, i_value);
ldap_get_option(this->ld, things[i], &i_value);
debug("%s value %d\n", description, i_value);
sprintf(s_value, "%d", i_value);
label = new Gtk_Label(s_value);
label->set_justify(GTK_JUSTIFY_LEFT);
@ -234,8 +244,6 @@ int Gtk_LdapServer::getOptions() {
break;
case 2:
ldap_get_option(this->ld, things[i], &i_value);
// sprintf(s_value, "%s", i_value == (int) LDAP_OPT_ON ? "on" : "off");
// label = new Gtk_Label(s_value);
radio1 = new Gtk_RadioButton(static_cast<GSList*>(0), "Enabled");
radio2 = new Gtk_RadioButton(*radio1, "Disabled");
if (i_value == 1) radio1->set_state(true);
@ -249,8 +257,36 @@ int Gtk_LdapServer::getOptions() {
hbox->pack_end(*mini_hbox);
mini_hbox->show();
break;
case 3:
ldap_get_option(this->ld, things[i], &i_value);
adjustment = new Gtk_Adjustment(i_value, 1.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);
scale->set_digits(0);
scale->set_draw_value(true);
hbox->pack_end(*scale);
scale->show();
break;
case 4:
#ifdef LDAP_API_INFO_VERSION
api.ldapai_info_version = LDAP_API_INFO_VERSION;
#else
api.ldapai_info_version = 1;
#endif
if (ldap_get_option(this->ld, things[i], &api) != LDAP_SUCCESS) {
perror(this->getOptDescription(things[i]));
break;
}
s_value = api.ldapai_vendor_name;
label = new Gtk_Label(s_value);
label->set_justify(GTK_JUSTIFY_LEFT);
label->set_alignment(0, 0);
hbox->pack_end(*label);
label->show();
break;
default:
label = new Gtk_Label("Nothing");
label = new Gtk_Label("Not implemented (yet)");
label->set_justify(GTK_JUSTIFY_LEFT);
label->set_alignment(0, 0);
hbox->pack_end(*label);
@ -259,7 +295,7 @@ int Gtk_LdapServer::getOptions() {
}
// hbox->pack_end(*label);
// label->show();
table->attach_defaults(*hbox, 0, 2, i, i+1);
table->attach_defaults(*hbox, 0, 1, i, i+1);
hbox->show();
}
table->border_width(2);
@ -313,8 +349,8 @@ void Gtk_LdapServer::show_impl() {
void Gtk_LdapServer::select_impl() {
debug("%s selected\n", this->hostname);
Gtk_c_signals_Item *sig=(Gtk_c_signals_Item *)internal_getsignalbase();
if (this->showDetails() == 0) debug("%s select_impl done\n", this->hostname);
if (!sig->select) return;
this->showDetails();
sig->select(GTK_ITEM(gtkobj()));
}

View File

@ -80,7 +80,7 @@ Gtk_LdapTree* Gtk_LdapTreeItem::getSubtree(LDAP *ld, int counter) {
}
void Gtk_LdapTreeItem::setType(int t) {
debug("Gtk_LdapTreeItem::setType(%i)\n", t);
debug("Gtk_LdapTreeItem::setType(%s)\n", this->objectClass);
Gtk_Pixmap *xpm_icon;
Gtk_Label *label;
if (this->getchild() != NULL) {
@ -97,6 +97,8 @@ void Gtk_LdapTreeItem::setType(int t) {
xpm_icon=new Gtk_Pixmap(*xpm_label, leaf_node);
else if (strcasecmp(this->objectClass,"alias") == 0)
xpm_icon=new Gtk_Pixmap(*xpm_label, alias_node);
else if (strcasecmp(this->objectClass,"rfc822mailgroup") == 0)
xpm_icon=new Gtk_Pixmap(*xpm_label, rfc822mailgroup_node);
else xpm_icon=new Gtk_Pixmap(*xpm_label, general_node);
label = new Gtk_Label(this->rdn);
xpm_label->pack_start(*xpm_icon, false, false, 1);
@ -145,12 +147,14 @@ int Gtk_LdapTreeItem::getDetails() {
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, "objectclass") == 0) {
// debug("processing objectclass\n");
if (strcasecmp(values[0],"top") == 0)
this->objectClass = strdup(values[1]);
else this->objectClass = values[0];
else this->objectClass = strdup(values[0]);
}
table = new Gtk_CList(1, titles);
for (int i=0; i<ldap_count_values(values); i++) {
// debug("%i:%s\n",i, values[i]);
const gchar *t[] = { values[i] };
table->append(t);
}

View File

@ -10,6 +10,7 @@
#include "icons/branch_node.h"
#include "icons/leaf_node.h"
#include "icons/alias_node.h"
#include "icons/rfc822mailgroup_node.h"
#include "icons/general_node.h"
#define ROOT_NODE 1

View File

@ -1,7 +1,7 @@
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

View File

@ -1,7 +1,7 @@
#include <My_Window.h>
My_Window::My_Window(GtkWindowType t) : Gtk_Window(t) {
cout << "My_Window(t)" << endl;
debug("My_Window(t)\n");
Gtk_VBox *main_hbox;
Gtk_HBox *top_hbox;
Gtk_VBox *bottom_hbox;

View File

@ -24,7 +24,7 @@ int main(int argc, char **argv) {
while ((c = getopt(argc, argv, "s:p:h")) != -1) {
switch (c) {
case 's':
cout << "host" << endl;
debug("host\n");
hosts = hosts->append(strdup(optarg));
break;
case 'p':
@ -35,7 +35,7 @@ int main(int argc, char **argv) {
exit(-1);
}
}
cout << hosts->length() << "hosts" << endl;
debug("%i hosts\n", hosts->length());
for (int f=0; f<hosts->length(); f++) {
debug("%s\n", hosts->nth_data(f));
}
@ -48,6 +48,10 @@ int main(int argc, char **argv) {
Gtk_Main m(&argc, &argv);
window = new My_Window(GTK_WINDOW_TOPLEVEL);
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++) {
@ -69,10 +73,6 @@ int main(int argc, char **argv) {
window->scroller->show();
// treeitem->showDetails();
// treeitem->select();
window->set_title("gtk-tool");
window->activate();
window->set_usize(600, 500);
window->show();
m.run();
return 0;