/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2003 Match Grun
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2003-2015 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,
* 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/>.
*/
/*
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include "defs.h"
#include <glib.h>
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkbutton.h>
+#include <gtk/gtk.h>
#include "gtkutils.h"
#include "prefs_common.h"
#include "utils.h"
#include "manage_window.h"
#include "filesel.h"
+#include "combobox.h"
#define PAGE_FILE_INFO 0
#define PAGE_DN 1
* \param data User data.
*/
static gboolean export_ldif_key_pressed( GtkWidget *widget, GdkEventKey *event, gpointer data ) {
- if (event && event->keyval == GDK_Escape) {
+ if (event && event->keyval == GDK_KEY_Escape) {
export_ldif_cancel( widget, data );
}
return FALSE;
AlertValue aval;
sFile = gtk_editable_get_chars( GTK_EDITABLE(expldif_dlg.entryLdif), 0, -1 );
- g_strchug( sFile ); g_strchomp( sFile );
+ g_strstrip( sFile );
gtk_entry_set_text( GTK_ENTRY(expldif_dlg.entryLdif), sFile );
exportldif_parse_filespec( _exportCtl_, sFile );
if( errFlag ) return FALSE;
/* Test for directory */
- if( exportldif_test_dir( _exportCtl_ ) ) {
+ if( g_file_test(_exportCtl_->dirOutput,
+ G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) {
return TRUE;
}
"does not exist. OK to create new directory?" ),
_exportCtl_->dirOutput );
aval = alertpanel( _("Create Directory" ),
- msg, GTK_STOCK_YES, GTK_STOCK_NO, NULL );
+ msg, GTK_STOCK_NO, GTK_STOCK_YES, NULL, ALERTFOCUS_FIRST );
g_free( msg );
- if( aval != G_ALERTDEFAULT ) return FALSE;
+ if( aval != G_ALERTALTERNATE ) return FALSE;
/* Create directory */
if( ! exportldif_create_dir( _exportCtl_ ) ) {
"Could not create output directory for LDIF file:\n%s" ),
reason );
aval = alertpanel_full(_("Failed to Create Directory"), msg,
- GTK_STOCK_CLOSE, NULL, NULL, FALSE,
- NULL, ALERT_ERROR, G_ALERTDEFAULT);
+ GTK_STOCK_CLOSE, NULL, NULL, ALERTFOCUS_FIRST, FALSE,
+ NULL, ALERT_ERROR);
g_free( msg );
return FALSE;
}
gboolean retVal = FALSE;
gboolean errFlag = FALSE;
gchar *suffix;
- GtkWidget *menu, *menuItem;
gint id;
/* Set suffix */
suffix = gtk_editable_get_chars( GTK_EDITABLE(expldif_dlg.entrySuffix), 0, -1 );
- g_strchug( suffix ); g_strchomp( suffix );
+ g_strstrip( suffix );
/* Set RDN format */
- menu = gtk_option_menu_get_menu( GTK_OPTION_MENU( expldif_dlg.optmenuRDN ) );
- menuItem = gtk_menu_get_active( GTK_MENU( menu ) );
- id = GPOINTER_TO_INT( gtk_object_get_user_data(GTK_OBJECT(menuItem)) );
+ id = combobox_get_active_data(GTK_COMBO_BOX(expldif_dlg.optmenuRDN));
exportldif_set_rdn( _exportCtl_, id );
exportldif_set_suffix( _exportCtl_, suffix );
"for an LDAP server. Are you sure you wish " \
"to proceed without a suffix?"
),
- GTK_STOCK_YES, GTK_STOCK_NO, NULL );
- if( aval != G_ALERTDEFAULT ) {
+ GTK_STOCK_NO, GTK_STOCK_YES, NULL, ALERTFOCUS_FIRST );
+ if( aval != G_ALERTALTERNATE ) {
gtk_widget_grab_focus( expldif_dlg.entrySuffix );
errFlag = TRUE;
}
expldif_dlg.entryLdif = entryLdif;
}
+static void export_ldif_relative_dn_changed(GtkWidget *widget, gpointer data)
+{
+ gint relativeDN = combobox_get_active_data(GTK_COMBO_BOX(widget));
+ GtkLabel *label = GTK_LABEL(data);
+
+ switch(relativeDN) {
+ case EXPORT_LDIF_ID_UID:
+ gtk_label_set_text(label,
+ _("The address book Unique ID is used to create a DN that is " \
+ "formatted similar to:\n" \
+ " uid=102376,ou=people,dc=claws-mail,dc=org"));
+ break;
+ case EXPORT_LDIF_ID_DNAME:
+ gtk_label_set_text(label,
+ _("The address book Display Name is used to create a DN that " \
+ "is formatted similar to:\n" \
+ " cn=John Doe,ou=people,dc=claws-mail,dc=org"));
+ break;
+ case EXPORT_LDIF_ID_EMAIL:
+ gtk_label_set_text(label,
+ _("The first Email Address belonging to a person is used to " \
+ "create a DN that is formatted similar to:\n" \
+ " mail=john.doe@domain.com,ou=people,dc=claws-mail,dc=org"));
+ break;
+ }
+
+}
+
/**
* Format notebook distinguished name page.
* \param pageNum Page (tab) number.
GtkWidget *label;
GtkWidget *entrySuffix;
GtkWidget *optmenuRDN;
+ GtkWidget *labelRDN;
GtkWidget *checkUseDN;
GtkWidget *checkEMail;
- GtkWidget *menu;
- GtkWidget *menuItem;
- GtkTooltips *toolTip;
+ GtkListStore *store;
+ GtkTreeIter iter;
gint top;
vbox = gtk_vbox_new(FALSE, 8);
GTK_NOTEBOOK( expldif_dlg.notebook ), pageNum ),
label );
- table = gtk_table_new( 5, 2, FALSE );
+ table = gtk_table_new( 6, 2, FALSE );
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
gtk_table_set_row_spacings(GTK_TABLE(table), 8);
gtk_table_attach(GTK_TABLE(table), entrySuffix, 1, 2, top, (top + 1),
GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
- toolTip = gtk_tooltips_new();
- gtk_tooltips_set_tip(
- GTK_TOOLTIPS(toolTip), entrySuffix, _(
+ CLAWS_SET_TIP(entrySuffix, _(
"The suffix is used to create a \"Distinguished Name\" " \
"(or DN) for an LDAP entry. Examples include:\n" \
- " dc=sylpheed,dc=org\n" \
+ " dc=claws-mail,dc=org\n" \
" ou=people,dc=domainname,dc=com\n" \
- " o=Organization Name,c=Country\n"
- ), NULL );
+ " o=Organization Name,c=Country\n"));
/* Second row */
top++;
GTK_FILL, 0, 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- menu = gtk_menu_new();
-
- menuItem = gtk_menu_item_new_with_label( _( "Unique ID" ) );
- gtk_object_set_user_data( GTK_OBJECT( menuItem ),
- GINT_TO_POINTER( EXPORT_LDIF_ID_UID ) );
- gtk_menu_append( GTK_MENU(menu), menuItem );
- gtk_widget_show( menuItem );
- toolTip = gtk_tooltips_new();
- gtk_tooltips_set_tip(
- GTK_TOOLTIPS(toolTip), menuItem, _(
- "The address book Unique ID is used to create a DN that is " \
- "formatted similar to:\n" \
- " uid=102376,ou=people,dc=sylpheed,dc=org"
- ), NULL );
-
- menuItem = gtk_menu_item_new_with_label( _( "Display Name" ) );
- gtk_object_set_user_data( GTK_OBJECT( menuItem ),
- GINT_TO_POINTER( EXPORT_LDIF_ID_DNAME ) );
- gtk_menu_append( GTK_MENU(menu), menuItem );
- gtk_widget_show( menuItem );
- toolTip = gtk_tooltips_new();
- gtk_tooltips_set_tip(
- GTK_TOOLTIPS(toolTip), menuItem, _(
- "The address book Display Name is used to create a DN that " \
- "is formatted similar to:\n" \
- " cn=John Doe,ou=people,dc=sylpheed,dc=org"
- ), NULL );
-
- menuItem = gtk_menu_item_new_with_label( _( "E-Mail Address" ) );
- gtk_object_set_user_data( GTK_OBJECT( menuItem ),
- GINT_TO_POINTER( EXPORT_LDIF_ID_EMAIL ) );
- gtk_menu_append( GTK_MENU(menu), menuItem );
- gtk_widget_show( menuItem );
- toolTip = gtk_tooltips_new();
- gtk_tooltips_set_tip(
- GTK_TOOLTIPS(toolTip), menuItem, _(
- "The first E-Mail Address belonging to a person is used to " \
- "create a DN that is formatted similar to:\n" \
- " mail=john.doe@domain.com,ou=people,dc=sylpheed,dc=org"
- ), NULL );
-
- optmenuRDN = gtk_option_menu_new();
- gtk_option_menu_set_menu( GTK_OPTION_MENU( optmenuRDN ), menu );
+ optmenuRDN = gtkut_sc_combobox_create(NULL, TRUE);
+ store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuRDN)));
+
+ COMBOBOX_ADD(store, _("Unique ID"), EXPORT_LDIF_ID_UID);
+ COMBOBOX_ADD(store, _("Display Name"), EXPORT_LDIF_ID_DNAME);
+ COMBOBOX_ADD(store, _("Email Address"), EXPORT_LDIF_ID_EMAIL);
gtk_table_attach(GTK_TABLE(table), optmenuRDN, 1, 2, top, (top + 1),
GTK_FILL, 0, 0, 0);
- toolTip = gtk_tooltips_new();
- gtk_tooltips_set_tip(
- GTK_TOOLTIPS(toolTip), optmenuRDN, _(
+ CLAWS_SET_TIP(optmenuRDN, _(
"The LDIF file contains several data records that " \
"are usually loaded into an LDAP server. Each data " \
"record in the LDIF file is uniquely identified by " \
"appended to the \"Relative Distinguished Name\" "\
"(or RDN) to create the DN. Please select one of " \
"the available RDN options that will be used to " \
- "create the DN."
- ), NULL );
-
- /* Third row */
+ "create the DN."));
+
+ /* Third row*/
+ top++;
+ labelRDN = gtk_label_new("");
+ gtk_label_set_line_wrap(GTK_LABEL(labelRDN), TRUE);
+ gtk_label_set_justify(GTK_LABEL(labelRDN), GTK_JUSTIFY_CENTER);
+ gtk_table_attach(GTK_TABLE(table), labelRDN, 0, 2, top, (top + 1),
+ GTK_FILL, 0, 0, 0);
+
+ /* Fourth row */
top++;
checkUseDN = gtk_check_button_new_with_label(
_( "Use DN attribute if present in data" ) );
gtk_table_attach(GTK_TABLE(table), checkUseDN, 1, 2, top, (top + 1),
GTK_FILL, 0, 0, 0);
- toolTip = gtk_tooltips_new();
- gtk_tooltips_set_tip(
- GTK_TOOLTIPS(toolTip), checkUseDN, _(
+ CLAWS_SET_TIP(checkUseDN, _(
"The addressbook may contain entries that were " \
"previously imported from an LDIF file. The " \
"\"Distinguished Name\" (DN) user attribute, if " \
"present in the address book data, may be used in " \
"the exported LDIF file. The RDN selected above " \
- "will be used if the DN user attribute is not found."
- ), NULL );
+ "will be used if the DN user attribute is not found."));
- /* Fourth row */
+ /* Fifth row */
top++;
checkEMail = gtk_check_button_new_with_label(
- _( "Exclude record if no E-Mail Address" ) );
+ _( "Exclude record if no Email Address" ) );
gtk_table_attach(GTK_TABLE(table), checkEMail, 1, 2, top, (top + 1),
GTK_FILL, 0, 0, 0);
- toolTip = gtk_tooltips_new();
- gtk_tooltips_set_tip(
- GTK_TOOLTIPS(toolTip), checkEMail, _(
+ CLAWS_SET_TIP(checkEMail, _(
"An addressbook may contain entries without " \
- "E-Mail Addresses. Check this option to ignore " \
- "these records."
- ), NULL );
+ "Email Addresses. Check this option to ignore " \
+ "these records."));
gtk_widget_show_all(vbox);
+ g_signal_connect(G_OBJECT(optmenuRDN), "changed",
+ G_CALLBACK(export_ldif_relative_dn_changed), labelRDN);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(optmenuRDN), 0);
+
+
expldif_dlg.entrySuffix = entrySuffix;
expldif_dlg.optmenuRDN = optmenuRDN;
expldif_dlg.checkUseDN = checkUseDN;
/* First row */
top = 0;
- label = gtk_label_new( _( "Address Book :" ) );
+ label = gtk_label_new( _( "Address Book:" ) );
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);
/* Second row */
top++;
- label = gtk_label_new( _( "File Name :" ) );
+ label = gtk_label_new( _( "File 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);
GtkWidget *hsbox;
GtkWidget *statusbar;
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "expldifdlg");
gtk_widget_set_size_request(window, EXPORTLDIF_WIDTH, EXPORTLDIF_HEIGHT );
gtk_container_set_border_width( GTK_CONTAINER(window), 0 );
gtk_window_set_title( GTK_WINDOW(window),
_("Export Address Book to LDIF File") );
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
- gtk_window_set_modal(GTK_WINDOW(window), TRUE);
+ gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(export_ldif_delete_event),
NULL );
static void export_ldif_create( void ) {
export_ldif_dialog_create();
export_ldif_page_file( PAGE_FILE_INFO, _( "File Info" ) );
- export_ldif_page_dn( PAGE_DN, _( "Distguished Name" ) );
+ export_ldif_page_dn( PAGE_DN, _( "Distinguished Name" ) );
export_ldif_page_finish( PAGE_FINISH, _( "Finish" ) );
gtk_widget_show_all( expldif_dlg.window );
}
ctl->suffix );
}
- gtk_option_menu_set_history(
- GTK_OPTION_MENU( expldif_dlg.optmenuRDN ), ctl->rdnIndex );
+ gtk_combo_box_set_active(
+ GTK_COMBO_BOX( expldif_dlg.optmenuRDN ), ctl->rdnIndex );
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON( expldif_dlg.checkUseDN ), ctl->useDN );
gtk_toggle_button_set_active(
expldif_dlg.cancelled = FALSE;
gtk_widget_show(expldif_dlg.window);
manage_window_set_transient(GTK_WINDOW(expldif_dlg.window));
-
+ gtk_window_set_modal(GTK_WINDOW(expldif_dlg.window), TRUE);
gtk_label_set_text( GTK_LABEL(expldif_dlg.labelBook), cache->name );
gtk_label_set_text( GTK_LABEL(expldif_dlg.labelOutBook), cache->name );
export_ldif_fill_fields( _exportCtl_ );
gtk_main();
gtk_widget_hide(expldif_dlg.window);
+ gtk_window_set_modal(GTK_WINDOW(expldif_dlg.window), FALSE);
exportldif_free( _exportCtl_ );
_exportCtl_ = NULL;