SF.net SVN: geany-plugins: [57] trunk/geanysendmail/src/geanysendmail.c

frlan at users.sourceforge.net frlan at xxxxx
Mon Jun 2 21:45:24 UTC 2008


Revision: 57
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=57&view=rev
Author:   frlan
Date:     2008-06-02 14:45:24 -0700 (Mon, 02 Jun 2008)

Log Message:
-----------
GeanySendMail: Repairing of wrong usage of the plugin_configure() function. Thanks to Nick for final patch.

Modified Paths:
--------------
    trunk/geanysendmail/src/geanysendmail.c

Modified: trunk/geanysendmail/src/geanysendmail.c
===================================================================
--- trunk/geanysendmail/src/geanysendmail.c	2008-05-30 16:47:47 UTC (rev 56)
+++ trunk/geanysendmail/src/geanysendmail.c	2008-06-02 21:45:24 UTC (rev 57)
@@ -3,7 +3,7 @@
  *
  *      Copyright 2007, 2008 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
  * 		Copyright 2007 Enrico Tröger <enrico.troeger at uvena.de>
- *		Copyright 2007 Nick Treleaven <nick.treleaven at btinternet.com>
+ *		Copyright 2007,2008 Nick Treleaven <nick.treleaven at btinternet.com>
  *
  *      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
@@ -202,73 +202,38 @@
 	}
 }
 
-void plugin_configure(GtkWidget *parent)
+
+static struct
 {
-	GtkWidget	*dialog, *label1, *label2, *entry, *vbox;
-	GtkWidget	*checkbox_icon_to_toolbar = NULL;
-	GKeyFile 	*config = g_key_file_new();
-	gchar 		*config_dir = g_path_get_dirname(config_file);
-	gint 		tmp;
-	GtkTooltips *tooltip = NULL;
+	GtkWidget *entry;
+	GtkWidget *checkbox_icon_to_toolbar;
+}
+pref_widgets;
 
-	tooltip = gtk_tooltips_new();
+static void
+on_configure_response(GtkDialog *dialog, gint response, gpointer user_data)
+{
+	if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
+	{
+		GKeyFile 	*config = g_key_file_new();
+		gchar 		*config_dir = g_path_get_dirname(config_file);
 
-	dialog = gtk_dialog_new_with_buttons(_("Mail Configuration"),
-		GTK_WINDOW(parent), GTK_DIALOG_DESTROY_WITH_PARENT,
-		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
-	vbox = p_ui->dialog_vbox_new(GTK_DIALOG(dialog));
-	gtk_widget_set_name(dialog, "GeanyDialog");
-	gtk_box_set_spacing(GTK_BOX(vbox), 10);
+		g_free(mailer);
+		mailer = g_strdup(gtk_entry_get_text(GTK_ENTRY(pref_widgets.entry)));
 
-	// add a label and a text entry to the dialog
-	label1 = gtk_label_new(_("Path and options for the mail client:"));
-	gtk_widget_show(label1);
-	gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
-	entry = gtk_entry_new();
-	gtk_widget_show(entry);
-	if (mailer != NULL)
-		gtk_entry_set_text(GTK_ENTRY(entry), mailer);
-
-	label2 = gtk_label_new(_("Note: \%f will be replaced by your filename."));
-	gtk_widget_show(label2);
-	gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
-
-	checkbox_icon_to_toolbar = gtk_check_button_new_with_label(_("Showing icon in toolbar (EXPERIMENTAL)"));
-	gtk_tooltips_set_tip(tooltip, checkbox_icon_to_toolbar,
-			     _
-			     ("Shows a icon in the toolbar to send file more easy."),
-			     NULL);
-	gtk_button_set_focus_on_click(GTK_BUTTON(checkbox_icon_to_toolbar), FALSE);
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox_icon_to_toolbar), icon_in_toolbar);
-	gtk_widget_show(checkbox_icon_to_toolbar); 
-	
-	gtk_container_add(GTK_CONTAINER(vbox), label1);
-	gtk_container_add(GTK_CONTAINER(vbox), entry);
-	gtk_container_add(GTK_CONTAINER(vbox), label2);
-	gtk_box_pack_start(GTK_BOX(vbox), checkbox_icon_to_toolbar, TRUE, FALSE, 2);
-		
-	gtk_widget_show(vbox);
-
-	// run the dialog and check for the response code
-	tmp = gtk_dialog_run(GTK_DIALOG(dialog));
-	if (tmp == GTK_RESPONSE_ACCEPT)
-	{
-		g_free(mailer);
-		mailer = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
-		
-		if (icon_in_toolbar == FALSE && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox_icon_to_toolbar)) == TRUE)
+		if (icon_in_toolbar == FALSE && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pref_widgets.checkbox_icon_to_toolbar)) == TRUE)
 		{
 			icon_in_toolbar = TRUE;
 			show_icon();
 		}
-		else if (icon_in_toolbar == TRUE && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox_icon_to_toolbar)) == FALSE)
+		else if (icon_in_toolbar == TRUE && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pref_widgets.checkbox_icon_to_toolbar)) == FALSE)
 		{
 			cleanup_icon();
 			icon_in_toolbar = FALSE;
 		}
 		else
 		{
-			icon_in_toolbar = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox_icon_to_toolbar));
+			icon_in_toolbar = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pref_widgets.checkbox_icon_to_toolbar));
 		}
 			
 		g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
@@ -290,8 +255,49 @@
 		g_key_file_free(config);
 		g_free(config_dir);
 	}
+}
 
-	gtk_widget_destroy(dialog);
+GtkWidget *plugin_configure(GtkDialog *dialog)
+{
+	GtkWidget	*label1, *label2, *vbox;
+	gint 		tmp;
+	GtkTooltips *tooltip = NULL;
+
+	tooltip = gtk_tooltips_new();
+
+	vbox = gtk_vbox_new(FALSE, 6);
+	
+	/* add a label and a text entry to the dialog */
+	label1 = gtk_label_new(_("Path and options for the mail client:"));
+	gtk_widget_show(label1);
+	gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
+	pref_widgets.entry = gtk_entry_new();
+	gtk_widget_show(pref_widgets.entry);
+	if (mailer != NULL)
+		gtk_entry_set_text(GTK_ENTRY(pref_widgets.entry), mailer);
+
+	label2 = gtk_label_new(_("Note: \%f will be replaced by your filename."));
+	gtk_widget_show(label2);
+	gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);
+
+	pref_widgets.checkbox_icon_to_toolbar = gtk_check_button_new_with_label(_("Showing icon in toolbar (EXPERIMENTAL)"));
+	gtk_tooltips_set_tip(tooltip, pref_widgets.checkbox_icon_to_toolbar,
+			     _
+			     ("Shows a icon in the toolbar to send file more easy."),
+			     NULL);
+	gtk_button_set_focus_on_click(GTK_BUTTON(pref_widgets.checkbox_icon_to_toolbar), FALSE);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pref_widgets.checkbox_icon_to_toolbar), icon_in_toolbar);
+	gtk_widget_show(pref_widgets.checkbox_icon_to_toolbar); 
+	
+	gtk_container_add(GTK_CONTAINER(vbox), label1);
+	gtk_container_add(GTK_CONTAINER(vbox), pref_widgets.entry);
+	gtk_container_add(GTK_CONTAINER(vbox), label2);
+	gtk_box_pack_start(GTK_BOX(vbox), pref_widgets.checkbox_icon_to_toolbar, TRUE, FALSE, 2);
+		
+	gtk_widget_show(vbox);
+
+	g_signal_connect(dialog, "response", G_CALLBACK(on_configure_response), NULL);
+	return vbox;
 }
 
 /* Called by Geany to initialize the plugin */
@@ -307,7 +313,6 @@
 	GtkWidget *menu_mail_submenu = NULL;
 	GtkWidget *menu_mail_attachment = NULL;
 
-
 	locale_init();
 
 	config_file = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list