SF.net SVN: geany-plugins:[1751] trunk/geany-plugins/geanysendmail

frlan at users.sourceforge.net frlan at xxxxx
Thu Nov 18 23:41:02 UTC 2010


Revision: 1751
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1751&view=rev
Author:   frlan
Date:     2010-11-18 23:41:01 +0000 (Thu, 18 Nov 2010)

Log Message:
-----------
GeanySendMail: Make usage of new plugin APIv199 and its dialogs_show_input(). Based on a patch by Nick. Thanks very much

Modified Paths:
--------------
    trunk/geany-plugins/geanysendmail/ChangeLog
    trunk/geany-plugins/geanysendmail/README
    trunk/geany-plugins/geanysendmail/src/geanysendmail.c

Modified: trunk/geany-plugins/geanysendmail/ChangeLog
===================================================================
--- trunk/geany-plugins/geanysendmail/ChangeLog	2010-11-16 16:07:46 UTC (rev 1750)
+++ trunk/geany-plugins/geanysendmail/ChangeLog	2010-11-18 23:41:01 UTC (rev 1751)
@@ -1,3 +1,9 @@
+2010-11-19  Frank Lanitz  <frank(at)frank(dot)uvena(dot)de>
+
+ * Apply a patch by Nick to make usage of new dialogs_show_input() 
+   function from plugin APIv199.
+
+
 2010-09-23  Frank Lanitz  <frank at frank.uvena.de>
 
  * Replace deprecated PLUGIN_KEY_GROUP macro.

Modified: trunk/geany-plugins/geanysendmail/README
===================================================================
--- trunk/geany-plugins/geanysendmail/README	2010-11-16 16:07:46 UTC (rev 1750)
+++ trunk/geany-plugins/geanysendmail/README	2010-11-18 23:41:01 UTC (rev 1751)
@@ -25,7 +25,7 @@
 prepared package e.g. from your distribution you probably need to
 install an additional package, this might be called geany-dev or
 geany-devel. Please note that in order to compile and use this plugin,
-you need Geany 0.19 or later (Geany Plugin API v147 or higher).
+you need Geany 0.20 or later (Geany Plugin API v199 or higher).
 
 Furthermore you need, of course, a C compiler and the Make tool. The
 GNU versions of these tools are recommended.

Modified: trunk/geany-plugins/geanysendmail/src/geanysendmail.c
===================================================================
--- trunk/geany-plugins/geanysendmail/src/geanysendmail.c	2010-11-16 16:07:46 UTC (rev 1750)
+++ trunk/geany-plugins/geanysendmail/src/geanysendmail.c	2010-11-18 23:41:01 UTC (rev 1751)
@@ -35,7 +35,7 @@
 GeanyData		*geany_data;
 GeanyFunctions	*geany_functions;
 
-PLUGIN_VERSION_CHECK(188)
+PLUGIN_VERSION_CHECK(199)
 
 PLUGIN_SET_TRANSLATABLE_INFO(
 	LOCALEDIR,
@@ -63,12 +63,6 @@
 static GtkWidget *main_menu_item = NULL;
 
 
-static void on_enter_key_pressed_in_entry(G_GNUC_UNUSED GtkWidget *widget, gpointer dialog )
-{
-	gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
-}
-
-
 /* Callback for sending file as attachment */
 static void
 send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata)
@@ -78,10 +72,6 @@
 	gchar	*command = NULL;
 	GError	*error = NULL;
 	GString	*cmd_str = NULL;
-	GtkWidget	*dialog = NULL;
-	GtkWidget 	*label = NULL;
-	GtkWidget 	*entry = NULL;
-	GtkWidget	*vbox = NULL;
 	GKeyFile 	*config = g_key_file_new();
 	gchar 		*config_dir = g_path_get_dirname(config_file);
 	gchar 		*data;
@@ -106,44 +96,22 @@
 
 			if ((use_address_dialog == TRUE) && (g_strrstr(mailer, "%r") != NULL))
 			{
-				dialog = gtk_dialog_new_with_buttons(_("Recipient's Address"),
+ 				gchar *input = dialogs_show_input(_("Recipient's Address"),
 										GTK_WINDOW(geany->main_widgets->window),
-										GTK_DIALOG_DESTROY_WITH_PARENT,
-										GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-										GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-										NULL);
-				gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
- 				vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog));
- 				gtk_widget_set_name(dialog, "GeanyDialog");
- 				gtk_box_set_spacing(GTK_BOX(vbox), 10);
+										_("Enter the recipient's e-mail address:"),
+										address);
 
- 				label = gtk_label_new(_("Enter the recipient's e-mail address:"));
- 				gtk_widget_show(label);
- 				gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- 				entry = gtk_entry_new();
- 				gtk_widget_show(entry);
- 				if (address != NULL)
- 					gtk_entry_set_text(GTK_ENTRY(entry), address);
-
- 				gtk_container_add(GTK_CONTAINER(vbox), label);
- 				gtk_container_add(GTK_CONTAINER(vbox), entry);
- 				gtk_widget_show(vbox);
-
-				g_signal_connect(G_OBJECT(entry), "activate",
-					G_CALLBACK(on_enter_key_pressed_in_entry), dialog);
-
-				if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
+				if (input)
 				{
 					g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
 
 					g_free(address);
- 					address = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
+ 					address = input;
 
  					g_key_file_set_string(config, "tools", "address", address);
  				}
  				else
  				{
-					gtk_widget_destroy(dialog);
 					return;
 				}
 
@@ -173,10 +141,14 @@
 				if (! utils_string_replace_all(cmd_str, "%r", address))
  					ui_set_statusbar(FALSE,
 					_("Recipient address placeholder not found. The executed command might have failed."));
+					g_free(address);
 			}
 			else
+			{
 				/* Removes %r if option was not activ but was included into command */
 				utils_string_replace_all(cmd_str, "%r", NULL);
+				g_free(address);
+			}
 
 			utils_string_replace_all(cmd_str, "%b", g_path_get_basename(locale_filename));
 
@@ -190,12 +162,6 @@
 
 			g_free(locale_filename);
 			g_free(command);
-
-			if (dialog != NULL)
-			{
-				gtk_widget_destroy(dialog);
-			}
-
 		}
 		else
 		{


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