[gq-commit] gq/src browse.c,1.60,1.61 formfill.c,1.31,1.32 formfill.h,1.21,1.22 input.c,1.48,1.49 in
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2002-09-27 00:22:18
|
Update of /cvsroot/gqclient/gq/src In directory usw-pr-cvs1:/tmp/cvs-serv16012 Modified Files: browse.c formfill.c formfill.h input.c input.h prefs.c Log Message: * Add tooltips (this is just the beginning) * Implemented the ability to hide empty attributes from the object browser. * The browser "Add as new" button now is only available if the DN was changed Index: browse.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** browse.c 26 Sep 2002 19:03:01 -0000 1.60 --- browse.c 27 Sep 2002 00:22:14 -0000 1.61 *************** *** 330,333 **** --- 330,334 ---- struct ldapserver *server; char *dn; + int hidden = 0; if (ctreenode == NULL) *************** *** 347,350 **** --- 348,354 ---- browsehash = g_hash_table_lookup(hash, "browsehash"); if (browsehash) { + /* but first get current hide status */ + hidden = (int) (g_hash_table_lookup(browsehash, "hide-status")); + browsehash_free(browsehash); g_hash_table_remove(hash, "browsehash"); *************** *** 357,360 **** --- 361,367 ---- g_hash_table_insert(browsehash, "server", server); g_hash_table_insert(browsehash, "edit", GINT_TO_POINTER(1)); + + /* pass on "hide" status */ + g_hash_table_insert(browsehash, "hide-status", GINT_TO_POINTER(hidden)); tmplist = NULL; Index: formfill.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/formfill.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** formfill.c 26 Sep 2002 19:05:20 -0000 1.31 --- formfill.c 27 Sep 2002 00:22:14 -0000 1.32 *************** *** 195,199 **** msg = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "(objectclass=*)", ! server->hide_internal ? attrs : NULL, 0, &res); if (msg == LDAP_SERVER_DOWN) { --- 195,199 ---- msg = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "(objectclass=*)", ! server->hide_internal ? NULL : attrs, 0, &res); if (msg == LDAP_SERVER_DOWN) { Index: formfill.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/formfill.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** formfill.h 2 Aug 2002 06:11:55 -0000 1.21 --- formfill.h 27 Sep 2002 00:22:14 -0000 1.22 *************** *** 89,93 **** GList *values; struct syntax_handler *syntax; ! GtkWidget *event_box; GtkWidget *label; --- 89,93 ---- GList *values; struct syntax_handler *syntax; ! GtkWidget *event_box; GtkWidget *label; Index: input.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** input.c 26 Sep 2002 19:09:21 -0000 1.48 --- input.c 27 Sep 2002 00:22:14 -0000 1.49 *************** *** 59,62 **** --- 59,63 ---- static void add_entry_from_formlist_and_select(GHashTable *hash); static int add_entry_from_formlist_no_close(GHashTable *hash); + static void hide_empty_attributes(GtkToggleButton *button, gpointer hash); *************** *** 99,104 **** --- 100,108 ---- GtkWidget *pixmap; int detail_context; + GtkTooltips *tips; detail_context = error_new_context(_("Error getting entry")); + tips = gtk_tooltips_new(); + target_vbox = g_hash_table_lookup(hash, "target_vbox"); *************** *** 132,135 **** --- 136,145 ---- (gpointer) hash); + gtk_tooltips_set_tip(tips, linebutton, + _("Turn into one-line entry field"), + _("Changes the display type of the current " + "attribute into 'Entry', thus makes the input " + "field a one-line text box.")); + /* textarea button */ textareabutton = gtk_button_new(); *************** *** 152,157 **** --- 162,174 ---- (gpointer) hash); + gtk_tooltips_set_tip(tips, textareabutton, + _("Turn into multi-line entry field"), + _("Changes the display type of the current " + "attribute into 'Multi-line text', thus makes " + "the input field a multi-line text box.")); + /* new attribute button */ newattrbutton = gtk_button_new(); + gtk_object_set_data(GTK_OBJECT(newattrbutton), "transform", "make text"); GTK_WIDGET_UNSET_FLAGS(newattrbutton, GTK_CAN_FOCUS); *************** *** 167,170 **** --- 184,188 ---- gtk_container_add(GTK_CONTAINER(newattrbutton), pixmap); gtk_widget_show(newattrbutton); + gtk_widget_set_sensitive(newattrbutton, 0); /* not implemented */ gtk_box_pack_end(GTK_BOX(hbox1), newattrbutton, FALSE, FALSE, 5); /* gtk_signal_connect(GTK_OBJECT(newattrbutton), "clicked", */ *************** *** 172,177 **** /* (gpointer) hash); */ /* hide empty attributes button */ ! hideattrbutton = gtk_button_new(); gtk_object_set_data(GTK_OBJECT(hideattrbutton), "transform", "make text"); GTK_WIDGET_UNSET_FLAGS(hideattrbutton, GTK_CAN_FOCUS); --- 190,200 ---- /* (gpointer) hash); */ + gtk_tooltips_set_tip(tips, newattrbutton, + _("Adds an attribute to an object of class 'extensibleObject'"), + _("Adds an attribute to an object of class 'extensibleObject'")); + /* hide empty attributes button */ ! hideattrbutton = gtk_toggle_button_new(); ! gtk_object_set_data(GTK_OBJECT(hideattrbutton), "transform", "make text"); GTK_WIDGET_UNSET_FLAGS(hideattrbutton, GTK_CAN_FOCUS); *************** *** 188,195 **** gtk_widget_show(hideattrbutton); gtk_box_pack_end(GTK_BOX(hbox1), hideattrbutton, FALSE, FALSE, 0); ! /* gtk_signal_connect(GTK_OBJECT(hideattrbutton), "clicked", */ ! /* GTK_SIGNAL_FUNC(change_displaytype), */ ! /* (gpointer) hash); */ /* scrolled window with vbox2 inside */ --- 211,225 ---- gtk_widget_show(hideattrbutton); gtk_box_pack_end(GTK_BOX(hbox1), hideattrbutton, FALSE, FALSE, 0); ! gtk_signal_connect(GTK_OBJECT(hideattrbutton), "clicked", ! GTK_SIGNAL_FUNC(hide_empty_attributes), ! (gpointer) hash); + g_hash_table_insert(hash, "hide_attr_button", hideattrbutton); + + gtk_tooltips_set_tip(tips, hideattrbutton, + _("Hide/show empty attributes"), + _("Hides or shows all attributes without values. " + "This is a good way to see immediately what " + "attributes the object really has.")); /* scrolled window with vbox2 inside */ *************** *** 204,213 **** gtk_widget_show(vbox2); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scwin), vbox2); g_hash_table_insert(hash, "vbox_holding_table", vbox2); - /* table inside vbox2, will self-expand */ table = gtk_table_new(3, 2, FALSE); gtk_container_border_width(GTK_CONTAINER(table), 5); ! gtk_table_set_row_spacings(GTK_TABLE(table), 1); gtk_table_set_col_spacings(GTK_TABLE(table), 10); gtk_widget_show(table); --- 234,244 ---- gtk_widget_show(vbox2); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scwin), vbox2); + g_hash_table_insert(hash, "scwin", scwin); g_hash_table_insert(hash, "vbox_holding_table", vbox2); /* table inside vbox2, will self-expand */ table = gtk_table_new(3, 2, FALSE); gtk_container_border_width(GTK_CONTAINER(table), 5); ! /* gtk_table_set_row_spacings(GTK_TABLE(table), 1); */ ! gtk_table_set_row_spacings(GTK_TABLE(table), 0); gtk_table_set_col_spacings(GTK_TABLE(table), 10); gtk_widget_show(table); *************** *** 234,237 **** --- 265,269 ---- button = gtk_button_new_with_label(_("Add as new")); + gtk_widget_set_sensitive(button, FALSE); gtk_widget_show(button); gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0); *************** *** 240,243 **** --- 272,276 ---- (gpointer) hash); GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); + g_hash_table_insert(hash, "add_as_new", button); button = gtk_button_new_with_label(_("Refresh")); *************** *** 443,446 **** --- 476,490 ---- } + static void dn_changed(GtkEditable *editable, + GHashTable *hash) + { + GtkWidget *w = g_hash_table_lookup(hash, "add_as_new"); + char *dn = g_hash_table_lookup(hash, "dn"); + char *val = gtk_editable_get_chars(editable, 0, -1); + if (w) { + gtk_widget_set_sensitive(w, strcmp(dn, val) != 0); + } + g_free(val); + } void build_or_update_inputform(GHashTable *hash, gboolean build) *************** *** 503,506 **** --- 547,555 ---- gtk_entry_set_text(GTK_ENTRY(inputbox), decode_string(value, dn, strlen(dn))); + + gtk_signal_connect(GTK_OBJECT(inputbox), "changed", + GTK_SIGNAL_FUNC(dn_changed), + (gpointer) hash); + g_hash_table_insert(hash, "dn-widget", inputbox); *************** *** 646,649 **** --- 695,701 ---- gtk_style_unref(del_schema); + /* restore the hide-status from a previous LDAP object... */ + set_hide_empty_attributes((int) g_hash_table_lookup(hash, "hide-status"), + hash); } *************** *** 1656,1659 **** --- 1708,1793 ---- } + + static void do_hide_empty_attributes(int hidden, gpointer hash) + { + GList *formlist = g_hash_table_lookup(hash, "formlist"); + GList *children; + GtkWidget *child; + + struct formfill *form; + int i = 0; + int displaytype; + int hideme; + + for ( ; formlist ; formlist = formlist->next ) { + form = (struct formfill *) formlist->data; + hideme = 1; + i++; + + displaytype = form->displaytype; + + for (children = form->widgetList ; children ; + children = children->next) { + child = GTK_WIDGET(children->data); + + if (hidden) { + if (form && displaytype) { + GByteArray *ndata = NULL; + + if (form->dt_handler && form->dt_handler->get_data) { + ndata = form->dt_handler->get_data(form, child); + } + /* don't bother adding in empty fields */ + if (ndata) { + hideme = 0; + g_byte_array_free(ndata, 1); + } + } + } else { + if (child) gtk_widget_show(child); + } + } + + if (hidden && hideme) { + if (form->event_box) gtk_widget_hide(form->event_box); + if (form->label) gtk_widget_hide(form->label); + if (form->vbox) gtk_widget_hide(form->vbox); + if (form->morebutton) gtk_widget_hide(form->morebutton); + for (children = form->widgetList ; children ; + children = children->next) { + child = GTK_WIDGET(children->data); + if (child) gtk_widget_hide(child); + } + } else { + if (form->event_box) gtk_widget_show(form->event_box); + if (form->label) gtk_widget_show(form->label); + if (form->vbox) gtk_widget_show(form->vbox); + if (form->morebutton) gtk_widget_show(form->morebutton); + } + } + + gtk_container_queue_resize(GTK_CONTAINER(g_hash_table_lookup(hash, "scwin"))); + + } + + static void hide_empty_attributes(GtkToggleButton *button, gpointer hash) + { + int hidden = gtk_toggle_button_get_active(button); + do_hide_empty_attributes(hidden, hash); + /* store hide status is hash, to be able to keep this info for + the next LDAP object to be shown in this browser */ + + g_hash_table_insert(hash, "hide-status", GINT_TO_POINTER(hidden)); + } + + void set_hide_empty_attributes(int hidden, gpointer hash) + { + GtkWidget *button = g_hash_table_lookup(hash, "hide_attr_button"); + if (button) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), hidden); + } + } + + /* Index: input.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/input.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** input.h 10 Aug 2002 06:06:38 -0000 1.7 --- input.h 27 Sep 2002 00:22:15 -0000 1.8 *************** *** 52,55 **** --- 52,56 ---- GtkWidget *find_focusbox(GList *formlist); void change_displaytype(GtkWidget *button, gpointer hash); + void set_hide_empty_attributes(int hidden, gpointer hash); #endif Index: prefs.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/prefs.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** prefs.c 26 Sep 2002 19:55:58 -0000 1.27 --- prefs.c 27 Sep 2002 00:22:15 -0000 1.28 *************** *** 314,317 **** --- 314,320 ---- GtkWidget *bindtype; GList *bindtypes; + GtkTooltips *tips; + + tips = gtk_tooltips_new(); if(current_edit_server_window) *************** *** 385,388 **** --- 388,396 ---- gtk_widget_grab_focus(entry); + gtk_tooltips_set_tip(tips, entry, + _("The nickname of the server definition"), + _("The nickname is used to refer to this server " + "definition throughout this application")); + /* LDAP host */ label = gtk_label_new(_("LDAP Host/URI")); *************** *** 401,404 **** --- 409,419 ---- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_tooltips_set_tip(tips, entry, + _("The host name or LDAP URI of the LDAP server"), + _("Either use the name or IP address of the server " + "or an LDAP URI (either ldap or ldaps). An URI " + "is recognized through the existance of a colon " + "in this field")); + /* Port */ label = gtk_label_new(_("LDAP Port")); *************** *** 422,425 **** --- 437,445 ---- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_tooltips_set_tip(tips, entry, + _("The port the LDAP server listens on"), + _("If empty, the well-known LDAP port (389) is " + "assumed. This field is not available if an LDAP " + "URI is used.")); /* Callback on HOST to enable/disable port if user enters a colon... */ *************** *** 447,450 **** --- 467,475 ---- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_tooltips_set_tip(tips, entry, + _("The base DN of the server"), + _("This base DN gets used in search mode, usually " + "though, this application queries the server " + "for its 'namingContexts'")); /* "Details" tab */ *************** *** 493,496 **** --- 518,526 ---- y++; + gtk_tooltips_set_tip(tips, entry, + _("The DN to bind with to the LDAP server"), + _("This is equivalent to a 'username'. Ask the " + "LDAP administrator for the DN to use.")); + /* Bind Password */ label = gtk_label_new(_("Bind Password")); *************** *** 514,517 **** --- 544,558 ---- y++; + gtk_tooltips_set_tip(tips, entry, + _("The password to bind with to the LDAP server"), + _("This is related to the bind DN. Note that the " + "password gets stored in a configuration file. " + "Recent versions of this application actually " + "scramble the password, but this scrambling can " + "easily be reverted. Do not use a valuable " + "password here.")); + + + /* Bind Password (again)*/ label = gtk_label_new(_("Bind Password (again)")); *************** *** 535,538 **** --- 576,583 ---- y++; + gtk_tooltips_set_tip(tips, entry, + _("The password to bind with to the LDAP server (again)"), + _("")); + /* Bind type */ label = gtk_label_new(_("Bind type")); *************** *** 564,567 **** --- 609,617 ---- y++; + gtk_tooltips_set_tip(tips, GTK_WIDGET(GTK_COMBO(bindtype)->entry), + _("How to bind to the LDAP server"), + _("gq supports several different bind types, " + "like Simple, Kerberos or SASL binds.")); + /* Search attribute */ label = gtk_label_new(_("Search Attribute")); *************** *** 581,584 **** --- 631,640 ---- y++; + gtk_tooltips_set_tip(tips, entry, + _("The attribute to 'search' in a search tab."), + _("Search mode in the search tab searches this " + "attribute. This alleviates the user to always " + "use a proper LDAP filter.")); + /* Maximum entries */ label = gtk_label_new(_("Maximum entries")); *************** *** 599,602 **** --- 655,662 ---- y++; + gtk_tooltips_set_tip(tips, entry, + _("The maximum number of entries to return in search mode."), + _("NOTE: A server might impose stricter limits")); + #if HAVE_LDAP_CLIENT_CACHE /* Use local cache */ *************** *** 617,620 **** --- 677,685 ---- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); y++; + + gtk_tooltips_set_tip(tips, entry, + _("Should the OpenLDAP client-side cache be used? And what is its timeout? Anything greater than -1 turns on the cache."), + _("Using this might speed up LDAP operations, but " + "it may also lead to slightly out-of-date data.")); #endif *************** *** 636,639 **** --- 701,709 ---- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_tooltips_set_tip(tips, button, + _("Should the application ask for a bind password?"), + _("This disables the password entered via the " + "preferences dialog. ")); + /* Hide internal attributes */ button = gtk_check_button_new_with_label(_("Hide internal attributes")); *************** *** 646,649 **** --- 716,724 ---- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); z++; + gtk_tooltips_set_tip(tips, button, + _("Do not show attributes internal to the LDAP server"), + _("At least OpenLDAP allows to view several " + "interesting attributes. Setting this option " + "turns them off.")); /* Cache connections */ *************** *** 657,660 **** --- 732,743 ---- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_tooltips_set_tip(tips, button, + _("If set: Do not close the connection between LDAP operations"), + _("Setting this may speed up LDAP operations, as " + "it does not require the overhead to open a new " + "connection to the server for every operation. " + "OTOH it might put additional stress on the " + "server (depends on what you call 'stress')")); + /* Show ref */ button = gtk_check_button_new_with_label(_("Show referrals")); *************** *** 668,671 **** --- 751,759 ---- z++; + + gtk_tooltips_set_tip(tips, button, + _("Try to show LDAP references."), + _("")); + /* Enable TLS */ button = gtk_check_button_new_with_label(_("Enable TLS")); *************** *** 678,681 **** --- 766,773 ---- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); z++; + + gtk_tooltips_set_tip(tips, button, + _("Should we use Transport Layer Security?"), + _("Almost but not quite entirely SSL.")); /* OK and Cancel buttons */ |