[Commits] ldifexport_extension.c 1.6 1.7 wizard.c 1.2 1.3 wizard.h 1.1 1.2

miras at claws-mail.org miras at claws-mail.org
Sat Dec 31 15:32:24 CET 2011


Update of /home/claws-mail/contacts/extensions/export
In directory claws-mail:/tmp/cvs-serv17716/extensions/export

Modified Files:
	ldifexport_extension.c wizard.c wizard.h 
Log Message:
2011-12-31 [mir]	0.6.0cvs63

	* extensions/example/src/example-extension.c
	* extensions/export/ldifexport_extension.c
	* extensions/export/wizard.c
	* extensions/export/wizard.h
	* extensions/import/ldifimport_extension.c
	* src/extension.h
	    Necessary changes to be able to support more
	    possibilities for making extensions.

Index: wizard.c
===================================================================
RCS file: /home/claws-mail/contacts/extensions/export/wizard.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- wizard.c	13 Dec 2011 14:56:29 -0000	1.2
+++ wizard.c	31 Dec 2011 14:32:22 -0000	1.3
@@ -40,6 +40,7 @@
 #include "utils.h"
 #include "gtk-utils.h"
 #include "mainwindow.h"
+#include "extension.h"
 
 #define NUMPAGES 3
 typedef struct {
@@ -51,7 +52,7 @@
 } PageInfo;
 
 typedef struct {
-	MainWindow*		main;
+	MenuItem*		item;
 	GtkWidget*		filename;
 	GtkWidget*		suffix;
 	GtkWidget*		rdn;
@@ -78,7 +79,7 @@
 	Container* container = (Container *) data;
 	
 	debug_print("apply called\n");
-	container->callback(container->data, container->main);
+	container->callback(container->data, container->item);
 }
 
 static void wizard_file_chooser(GtkButton* btn, gpointer data) {
@@ -86,7 +87,7 @@
 	Container* export = (Container *) data;
 	
 	dialog = gtk_file_chooser_dialog_new(_("Create file"),
-					      GTK_WINDOW(export->main->window),
+					      GTK_WINDOW(export->item->mainwindow->window),
 					      GTK_FILE_CHOOSER_ACTION_SAVE,
 					      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 					      GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
@@ -343,7 +344,7 @@
 	}
 }
 
-void show_export_wizard(gpointer mainwindow, WIZARD_CALLBACK callback) {
+void show_export_wizard(gpointer item, WIZARD_CALLBACK callback) {
 	PageInfo page[NUMPAGES] = {
     	{ NULL, -1, _("Choose file name"),				GTK_ASSISTANT_PAGE_CONTENT,	FALSE},
     	{ NULL, -1, _("Construct DN for record"),		GTK_ASSISTANT_PAGE_CONTENT,	TRUE},
@@ -357,14 +358,14 @@
 
 	Container* container = g_new0(Container, 1);
 	container->data = g_new0(ExportData, 1);
-	container->main = (MainWindow *) mainwindow;
+	container->item = (MenuItem *) item;
 	container->callback = callback;
 	
 	GtkWidget *wizard;
 	
 	wizard = gtk_assistant_new();
 	gtk_widget_modify_bg(wizard, GTK_STATE_NORMAL, &color);
-	gtk_window_set_transient_for(GTK_WINDOW(wizard), GTK_WINDOW(container->main->window));
+	gtk_window_set_transient_for(GTK_WINDOW(wizard), GTK_WINDOW(container->item->mainwindow->window));
 	gtk_widget_set_size_request(wizard, 450, 300);
 	gtk_window_set_title(GTK_WINDOW(wizard), _("Export to LDIF"));
 	g_signal_connect(G_OBJECT(wizard), "cancel", G_CALLBACK(wizard_close_cancel), container);

Index: wizard.h
===================================================================
RCS file: /home/claws-mail/contacts/extensions/export/wizard.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- wizard.h	13 Dec 2011 14:29:42 -0000	1.1
+++ wizard.h	31 Dec 2011 14:32:22 -0000	1.2
@@ -51,7 +51,7 @@
 
 typedef void (*WIZARD_CALLBACK) (ExportData* data, gpointer user_data);
 
-void show_export_wizard(gpointer mainwindow, WIZARD_CALLBACK callback);
+void show_export_wizard(gpointer menu_item, WIZARD_CALLBACK callback);
 void export_data_free(ExportData** data);
 
 G_END_DECLS

Index: ldifexport_extension.c
===================================================================
RCS file: /home/claws-mail/contacts/extensions/export/ldifexport_extension.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ldifexport_extension.c	17 Dec 2011 02:54:25 -0000	1.6
+++ ldifexport_extension.c	31 Dec 2011 14:32:22 -0000	1.7
@@ -58,8 +58,6 @@
 static Plugin* plugin;
 static AddressBook* abook;
 static GtkTreeView* view;
-GtkWidget* action;
-MainWindow* Main = NULL;
 
 static gchar* get_dn(Contact* contact, ExportData* data) {
 	gchar *tmp = NULL, *dn = NULL;
@@ -171,12 +169,12 @@
 	return g_string_free(text, FALSE);
 }
 
-static gchar* get_contacts_as_ldif(MainWindow* win, ExportData* data) {
+static gchar* get_contacts_as_ldif(MenuItem* item, ExportData* data) {
 	GString* text = g_string_new("");
 	gchar* ldif;
 	GList* list;
 
-	view = GTK_TREE_VIEW(win->abook_list);
+	view = GTK_TREE_VIEW(item->mainwindow->abook_list);
 	plugin = get_selected_plugin(view);
 	abook = get_selected_address_book(view);
 
@@ -194,11 +192,10 @@
 }
 
 static void make_ldif(ExportData* data, gpointer user_data) {
-	const gchar* name;
 	GString* export;
 	gchar* text = NULL;
 	GError* error = NULL;
-	MainWindow* Main = (MainWindow *) user_data;
+	MenuItem* item = (MenuItem *) user_data;
 	GtkTreeIter* iter = NULL;
 	GtkTreeSelection* row;
 	
@@ -210,12 +207,11 @@
 	/* get file name for write, get abook, get contact list,
 	 * convert to ldif, save text to file*/
 	if (data->filename) {
-		name = gtk_widget_get_name(action);
-		if (strcmp("toolsmenu", name) == 0) {
-			view = GTK_TREE_VIEW(Main->abook_list);
+		if (item->parent && strcmp("tools", item->parent) == 0) {
+			view = GTK_TREE_VIEW(item->mainwindow->abook_list);
 			abook = get_selected_address_book(view);
 			if (abook == NULL) {
-				iter = set_selection_combobox(Main->window,
+				iter = set_selection_combobox(item->mainwindow->window,
 								_("[New Contact] Choose address book"),
 								gtk_tree_view_get_model(view),
 								BOOK_NAME_COLUMN);
@@ -229,7 +225,7 @@
 			}
 		}
 
-		text = get_contacts_as_ldif(Main, data);
+		text = get_contacts_as_ldif(item, data);
 		export = g_string_new(LDIF_Version);
 		export = g_string_append(export, "\n");
 		export = g_string_append(export, text);
@@ -237,11 +233,11 @@
 		
 		text = g_string_free(export, FALSE);
 		if (! g_file_set_contents(data->filename, text, -1, &error)) {
-			show_message(Main->window, GTK_UTIL_MESSAGE_ERROR, error->message);
+			show_message(item->mainwindow->window, GTK_UTIL_MESSAGE_ERROR, error->message);
 			g_clear_error(&error);
 		}
 		else {
-			show_message(Main->window, GTK_UTIL_MESSAGE_INFO,
+			show_message(item->mainwindow->window, GTK_UTIL_MESSAGE_INFO,
 				_("Data successfully exported as LDIF to file\n%s"),
 				data->filename);
 		}
@@ -251,11 +247,10 @@
 }
 
 static void ldif_export(GtkWidget* widget, gpointer data) {
-	Main = (MainWindow *) data;
+	MenuItem* item = (MenuItem *) data;
 	
-	action = widget;
 	debug_print("LDIF Export\n");
-	show_export_wizard(Main, make_ldif);
+	show_export_wizard(item, make_ldif);
 }
 
 static void setup(const MainWindow* mainwindow, gpointer object) {
@@ -263,24 +258,25 @@
 	MenuItem* menu_item;
 	
 	menu = gtk_image_menu_item_new_with_mnemonic("_LDIF");
-	gtk_widget_set_name(menu, "toolsmenu");
-    g_signal_connect(menu, "activate",
-            G_CALLBACK(ldif_export), (gpointer) mainwindow);
     menu_item = menu_item_new();
     menu_item->menu = CONTACTS_MAIN_MENU;
     menu_item->parent = "tools";
 	menu_item->sublabel = "_Export";
     menu_item->submenu = TRUE;
+	menu_item->mainwindow = mainwindow;
+    g_signal_connect(menu, "activate",
+            G_CALLBACK(ldif_export), (gpointer) menu_item);
 	add_menu_item(GTK_IMAGE_MENU_ITEM(menu), menu_item);
 
 	menu = gtk_image_menu_item_new_with_mnemonic("_LDIF");
 	gtk_widget_set_name(menu, "contextmenu");
-    g_signal_connect(menu, "activate",
-            G_CALLBACK(ldif_export), (gpointer) mainwindow);
     menu_item = menu_item_new();
     menu_item->menu = CONTACTS_ADDRESSBOOK_MENU;
     menu_item->sublabel = "_Export";
     menu_item->submenu = TRUE;
+	menu_item->mainwindow = mainwindow;
+    g_signal_connect(menu, "activate",
+            G_CALLBACK(ldif_export), (gpointer) menu_item);
 	add_menu_item(GTK_IMAGE_MENU_ITEM(menu), menu_item);
 }
 



More information about the Commits mailing list