[Commits] ldifimport_extension.c 1.2 1.3
miras at claws-mail.org
miras at claws-mail.org
Sat Dec 17 16:53:00 CET 2011
Update of /home/claws-mail/contacts/extensions/import
In directory claws-mail:/tmp/cvs-serv25861/extensions/import
Modified Files:
ldifimport_extension.c
Log Message:
2011-12-17 [mir] 0.6.0cvs52
* extensions/import/ldifimport_extension.c
Forgot to implement file chooser dialog
to get name of file to import contacts from.
Index: ldifimport_extension.c
===================================================================
RCS file: /home/claws-mail/contacts/extensions/import/ldifimport_extension.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ldifimport_extension.c 17 Dec 2011 02:55:13 -0000 1.2
+++ ldifimport_extension.c 17 Dec 2011 15:52:58 -0000 1.3
@@ -52,6 +52,28 @@
static guint my_id;
+static gchar* ldif_file_chooser(MainWindow* Main) {
+ GtkWidget* dialog;
+ gchar* filename = NULL;
+
+ dialog = gtk_file_chooser_dialog_new(_("Open file"),
+ GTK_WINDOW(Main->window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), get_home());
+/* gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);*/
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ }
+ gtk_widget_destroy(dialog);
+
+ return filename;
+}
+
static void ldif_import(GtkWidget* widget, gpointer data) {
MainWindow* Main = (MainWindow*) data;
LdifParser* parser;
@@ -62,7 +84,7 @@
Record* record;
GtkTreeIter* iter = NULL;
GtkTreeSelection* row;
- GSList *attribs, *cur;
+ GSList *attribs, *cur, *head;
gchar* value;
gchar* err;
@@ -82,9 +104,14 @@
}
plugin = get_selected_plugin(view);
+ gchar* file = ldif_file_chooser(Main);
+ if (!file)
+ return;
+
parser = ldif_parser_new();
- gint fd = open("/home/mir/Projekter/c/claws/claws_rw/new-claws/contacts/test.ldif", O_RDONLY);
- ldif_parser_set_fd(parser, fd);
+ ldif_parser_set_file(parser, file);
+ g_free(file);
+
attribs = plugin->attrib_list();
cur = attribs;
@@ -96,13 +123,12 @@
}
gslist_free(&attribs, attrib_def_free);
ldif_parser_parse(parser);
- close(fd);
if (ldif_parser_get_errors(parser) > 0) {
show_message(Main->window, GTK_UTIL_MESSAGE_WARNING, "%s:%d:%d [%d] %s",
parser->input_name, parser->error_line, parser->error_place,
parser->error_code, parser->error_msg);
}
- cur = ldif_parser_get_records(parser);
+ head = cur = ldif_parser_get_records(parser);
while (cur) {
if (debug_get_mode()) {
ldif_parser_record_dump(cur->data);
@@ -150,7 +176,7 @@
}
cur = cur->next;
}
- gslist_free(&cur, ldif_parser_record_free);
+ gslist_free(&head, ldif_parser_record_free);
ldif_parser_destroy(parser);
}
More information about the Commits
mailing list