remove space in front of colon
[claws.git] / src / browseldap.c
index 847c462c96ae6d7989df13c243c9d8109ab584c6..117d77ea4ddbdfa488c695b76077390e30eae1fb 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2003 Match Grun
+ * Copyright (C) 2003-2012 Match Grun and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 /*
@@ -23,6 +23,7 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #ifdef USE_LDAP
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkhbbox.h>
-#include <gtk/gtkbutton.h>
+#include <gtk/gtk.h>
 
 #include <pthread.h>
 #include "gtkutils.h"
@@ -114,19 +109,21 @@ static gint browse_callback_entry(
        GList *node;
        NameValuePair *nvp;
 
-       /* printf( "browse_callback_entry...\n" ); */
+       debug_print("browse_callback_entry...\n");
        pthread_mutex_lock( & _browseMutex_ );
        /* Append contents to end of display queue */
        node = listValues;
        while( node ) {
                nvp = ( NameValuePair * ) node->data;
-               /* ldapqry_print_name_value( nvp, stdout ); */
+               debug_print("adding to list: %s->%s\n",
+                               nvp->name?nvp->name:"null",
+                               nvp->value?nvp->value:"null");
                _displayQueue_ = g_list_append( _displayQueue_, nvp );
                node->data = NULL;
                node = g_list_next( node );
        }
        pthread_mutex_unlock( & _browseMutex_ );
-       /* printf( "browse_callback_entry...done\n" ); */
+       /* g_print( "browse_callback_entry...done\n" ); */
 
        return 0;
 }
@@ -142,6 +139,7 @@ static gint browse_callback_entry(
 static gint browse_callback_end(
                LdapQuery *qry, gint queryID, gint status, gpointer data )
 {
+       debug_print("search completed\n");
        _searchComplete_ = TRUE;
        return 0;
 }
@@ -182,7 +180,7 @@ static gint browse_delete_event(
 static void browse_key_pressed(
                GtkWidget *widget, GdkEventKey *event, gboolean *cancelled )
 {
-       if (event && event->keyval == GDK_Escape) {
+       if (event && event->keyval == GDK_KEY_Escape) {
                gtk_main_quit();
        }
 }
@@ -213,12 +211,12 @@ static void browse_create( void ) {
        GtkWidget *close_btn;
        gint top;
 
+       debug_print("creating browse widget\n");
        window = gtk_dialog_new();
        gtk_widget_set_size_request( window, BROWSELDAP_WIDTH, BROWSELDAP_HEIGHT );
        gtk_container_set_border_width( GTK_CONTAINER(window), 0 );
        gtk_window_set_title( GTK_WINDOW(window), _("Browse Directory Entry") );
        gtk_window_set_position( GTK_WINDOW(window), GTK_WIN_POS_MOUSE );
-       gtk_window_set_modal( GTK_WINDOW(window), TRUE );
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(browse_delete_event), NULL);
        g_signal_connect(G_OBJECT(window), "key_press_event",
@@ -236,7 +234,7 @@ static void browse_create( void ) {
 
        /* First row */
        top = 0;
-       label = gtk_label_new(_("Server Name :"));
+       label = gtk_label_new(_("Server Name:"));
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
 
@@ -246,7 +244,7 @@ static void browse_create( void ) {
 
        /* Second row */
        top++;
-       label = gtk_label_new(_("Distinguished Name (dn) :"));
+       label = gtk_label_new(_("Distinguished Name (dn):"));
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
 
@@ -265,18 +263,18 @@ static void browse_create( void ) {
                                        GTK_POLICY_AUTOMATIC );
        gtk_box_pack_start( GTK_BOX(vlbox), tree_win, TRUE, TRUE, 0 );
 
-       list_entry = gtk_clist_new( N_COLS );
+       list_entry = gtk_cmclist_new( N_COLS );
        gtk_container_add( GTK_CONTAINER(tree_win), list_entry );
-       gtk_clist_column_titles_show( GTK_CLIST(list_entry) );
-       gtk_clist_set_column_title(
-               GTK_CLIST(list_entry), COL_NAME, _( "LDAP Name" ) );
-       gtk_clist_set_column_title(
-               GTK_CLIST(list_entry), COL_VALUE, _( "Attribute Value" ) );
-       gtk_clist_set_selection_mode(
-               GTK_CLIST(list_entry), GTK_SELECTION_BROWSE );
-       gtk_clist_set_column_width( GTK_CLIST(list_entry),
+       gtk_cmclist_column_titles_show( GTK_CMCLIST(list_entry) );
+       gtk_cmclist_set_column_title(
+               GTK_CMCLIST(list_entry), COL_NAME, _( "LDAP Name" ) );
+       gtk_cmclist_set_column_title(
+               GTK_CMCLIST(list_entry), COL_VALUE, _( "Attribute Value" ) );
+       gtk_cmclist_set_selection_mode(
+               GTK_CMCLIST(list_entry), GTK_SELECTION_BROWSE );
+       gtk_cmclist_set_column_width( GTK_CMCLIST(list_entry),
                COL_NAME, COL_WIDTH_NAME );
-       gtk_clist_set_auto_sort( GTK_CLIST(list_entry), TRUE );
+       gtk_cmclist_set_auto_sort( GTK_CMCLIST(list_entry), TRUE );
 
        /* Button panel */
        gtkut_stock_button_set_create(&hbbox, &close_btn, GTK_STOCK_CLOSE,
@@ -322,8 +320,11 @@ static gboolean browse_idle( gpointer data ) {
                        nvp = ( NameValuePair * ) node->data;
                        text[COL_NAME]  = nvp->name;
                        text[COL_VALUE] = nvp->value;
-                       gtk_clist_append(
-                               GTK_CLIST(browseldap_dlg.list_entry), text );
+                       debug_print("Adding row to list: %s->%s\n",
+                                               nvp->name?nvp->name:"null",
+                                               nvp->value?nvp->value:"null");
+                       gtk_cmclist_append(
+                               GTK_CMCLIST(browseldap_dlg.list_entry), text );
 
                        /* Free up entry */
                        ldapqry_free_name_value( nvp );
@@ -338,10 +339,10 @@ static gboolean browse_idle( gpointer data ) {
        if( _searchComplete_ ) {
                /* Remove idler */
                if( _browseIdleID_ != 0 ) {
-                       gtk_idle_remove( _browseIdleID_ );
+                       g_source_remove( _browseIdleID_ );
                        _browseIdleID_ = 0;
-                       gtk_clist_select_row(
-                               GTK_CLIST( browseldap_dlg.list_entry ), 0, 0 );
+                       gtk_cmclist_select_row(
+                               GTK_CMCLIST( browseldap_dlg.list_entry ), 0, 0 );
                }
        }
 
@@ -366,8 +367,8 @@ gboolean browseldap_entry( AddressDataSource *ds, const gchar *dn ) {
        gtk_widget_grab_focus(browseldap_dlg.close_btn);
        gtk_widget_show(browseldap_dlg.window);
        manage_window_set_transient(GTK_WINDOW(browseldap_dlg.window));
-
-       gtk_clist_select_row( GTK_CLIST( browseldap_dlg.list_entry ), 0, 0 );
+       gtk_window_set_modal(GTK_WINDOW(browseldap_dlg.window), TRUE);
+       gtk_cmclist_select_row( GTK_CMCLIST( browseldap_dlg.list_entry ), 0, 0 );
        gtk_widget_show(browseldap_dlg.window);
 
        gtk_label_set_text( GTK_LABEL(browseldap_dlg.label_address ), "" );
@@ -379,28 +380,32 @@ gboolean browseldap_entry( AddressDataSource *ds, const gchar *dn ) {
                GTK_LABEL(browseldap_dlg.label_server ),
                ldapsvr_get_name( server ) );
 
+       debug_print("browsing server: %s\n", ldapsvr_get_name(server));
        /* Setup search */
        _searchComplete_ = FALSE;
        _queryID_ = ldaplocate_search_setup(
                        server, dn, browse_callback_entry, browse_callback_end );
-       _browseIdleID_ = gtk_idle_add( ( GtkFunction ) browse_idle, NULL );
+       debug_print("query id: %d\n", _queryID_);
+       _browseIdleID_ = g_idle_add( (GSourceFunc) browse_idle, NULL );
 
        /* Start search */
+       debug_print("starting search\n");
        ldaplocate_search_start( _queryID_ );
 
        /* Display dialog */
        gtk_main();
        gtk_widget_hide( browseldap_dlg.window );
-
+       gtk_window_set_modal(GTK_WINDOW(browseldap_dlg.window), FALSE);
        /* Stop query */
+       debug_print("stopping search\n");
        ldaplocate_search_stop( _queryID_ );
 
        if( _browseIdleID_ != 0 ) {
-               gtk_idle_remove( _browseIdleID_ );
+               g_source_remove( _browseIdleID_ );
                _browseIdleID_ = 0;
        }
        browse_clear_queue();
-       gtk_clist_clear( GTK_CLIST( browseldap_dlg.list_entry ) );
+       gtk_cmclist_clear( GTK_CMCLIST( browseldap_dlg.list_entry ) );
 
        return TRUE;
 }