Re: Mysterious option
- From: Darko Obradovic <dobradovic gmx de>
- To: balsa-list gnome org
- Subject: Re: Mysterious option
- Date: Thu, 19 Feb 2004 18:26:57 +0100
Am 13.02.2004 21:12 schrieb(en) Darko Obradovic:
> Now I discovered "Edit->Edit with Gnome Editor" in the compose
> window, so this makes some sense now, yes.
> But I consider it a quite irritating feature, not sure if it's useful
> to have? I selected it and got the text loaded in gedit. So what
> then? Editing and saving doesn't impress balsa at all. *confused*
Ok, by now I read through the source and understand the idea:
Balsa creates a tempfile, starts the gnome-editor in a new thread,
waits for it to exit and then uses the (hopefully modified) tempfile.
So you theoretically could write your mails with an external editor.
First: imho this seems to be one of those features one of a thousand
requested for some personal preference, I think it's way to special to
include it into balsa, it offers all you need to edit a mail, if
there's seriously a problem, fix it in the internal editor.
Second: It doesn't work with gedit anyways, as it's tab-based and not
bound to one process per file. That's what irritated me when testing
this feature. And gedit will be the standard editor for most people.
So, I'd suggest to remove this feature. I realize there's been quite
some work done on this, it was really interesting to read through as I
didn't get in touch with threads before, but I'm convinced it's
obsolete by now. If the maintainers agree here, I've attached a patch
agains 2.0.16 which should remove it cleanly, it compiles and runs
fine.
bye,
Darko Obradovic, who has no gpgme-0.4.3 yet...
diff -ruN balsa-2.0.16/src/balsa-app.h balsa-2.0.16-no_external_editor/src/balsa-app.h
--- balsa-2.0.16/src/balsa-app.h 2004-01-11 15:10:02.000000000 +0100
+++ balsa-2.0.16-no_external_editor/src/balsa-app.h 2004-02-19 17:49:38.997321032 +0100
@@ -293,9 +293,6 @@
gboolean source_escape_specials;
gboolean debug;
- /* external editor */
- gboolean edit_headers;
-
/* arp --- string to prefix "replied to" messages. */
gchar *quote_str;
diff -ruN balsa-2.0.16/src/pref-manager.c balsa-2.0.16-no_external_editor/src/pref-manager.c
--- balsa-2.0.16/src/pref-manager.c 2003-11-22 00:45:46.000000000 +0100
+++ balsa-2.0.16-no_external_editor/src/pref-manager.c 2004-02-19 17:46:14.046478296 +0100
@@ -116,9 +116,6 @@
GtkWidget *debug_message_menu;
GtkWidget *fatal_message_menu;
- /* External editor preferences */
- GtkWidget *edit_headers;
-
/* arp */
GtkWidget *quote_str;
@@ -547,10 +544,6 @@
g_signal_connect(G_OBJECT(pui->forward_attached), "toggled",
G_CALLBACK(properties_modified_cb), property_box);
- /* external editor */
- g_signal_connect(G_OBJECT(pui->edit_headers), "toggled",
- G_CALLBACK(properties_modified_cb), property_box);
-
/* arp */
g_signal_connect(G_OBJECT(pui->quote_str), "changed",
G_CALLBACK(properties_modified_cb), property_box);
@@ -815,9 +808,6 @@
}
}
- /* external editor */
- balsa_app.edit_headers = GTK_TOGGLE_BUTTON(pui->edit_headers)->active;
-
/* arp */
g_free(balsa_app.quote_str);
balsa_app.quote_str =
@@ -1100,10 +1090,6 @@
gtk_widget_set_sensitive(pui->wraplength,
GTK_TOGGLE_BUTTON(pui->wordwrap)->active);
- /* external editor */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->edit_headers),
- balsa_app.edit_headers);
-
/* arp */
gtk_entry_set_text(GTK_ENTRY(pui->quote_str), balsa_app.quote_str);
entry_widget = gnome_entry_gtk_entry(GNOME_ENTRY(pui->quote_pattern));
@@ -1989,8 +1975,6 @@
pui->quote_str = attach_entry(_("Reply Prefix:"), 1, GTK_TABLE(table));
- pui->edit_headers =
- pm_group_add_check(group, _("Edit headers in external editor"));
pui->autoquote =
pm_group_add_check(group, _("Automatically quote original "
"when replying"));
diff -ruN balsa-2.0.16/src/save-restore.c balsa-2.0.16-no_external_editor/src/save-restore.c
--- balsa-2.0.16/src/save-restore.c 2003-11-22 00:45:34.000000000 +0100
+++ balsa-2.0.16-no_external_editor/src/save-restore.c 2004-02-19 17:48:10.111833680 +0100
@@ -929,9 +929,6 @@
/* Compose window ... */
gnome_config_push_prefix(BALSA_CONFIG_PREFIX "Compose/");
- balsa_app.edit_headers =
- gnome_config_get_bool("ExternEditorEditHeaders=false");
-
g_free(balsa_app.quote_str);
balsa_app.quote_str = gnome_config_get_string("QuoteString=> ");
g_free(balsa_app.compose_headers);
@@ -1241,7 +1238,6 @@
gnome_config_push_prefix(BALSA_CONFIG_PREFIX "Compose/");
gnome_config_set_string("ComposeHeaders", balsa_app.compose_headers);
- gnome_config_set_bool("ExternEditorEditHeaders", balsa_app.edit_headers);
gnome_config_set_string("QuoteString", balsa_app.quote_str);
gnome_config_pop_prefix();
diff -ruN balsa-2.0.16/src/sendmsg-window.c balsa-2.0.16-no_external_editor/src/sendmsg-window.c
--- balsa-2.0.16/src/sendmsg-window.c 2004-01-19 19:22:46.000000000 +0100
+++ balsa-2.0.16-no_external_editor/src/sendmsg-window.c 2004-02-19 18:00:17.715221152 +0100
@@ -66,12 +66,6 @@
#include "toolbar-factory.h"
#define GNOME_MIME_BUG_WORKAROUND 1
-typedef struct {
- pid_t pid_editor;
- gchar *filename;
- BalsaSendmsg *bsmsg;
-} balsa_edit_with_gnome_data;
-
static gchar *read_signature(BalsaSendmsg *bsmsg);
static gint include_file_cb(GtkWidget *, BalsaSendmsg *);
@@ -124,7 +118,6 @@
static gint set_locale(BalsaSendmsg *, gint);
-static void edit_with_gnome(GtkWidget* widget, BalsaSendmsg* bsmsg);
static void change_identity_dialog_cb(GtkWidget*, BalsaSendmsg*);
static void repl_identity_signature(BalsaSendmsg* bsmsg,
LibBalsaIdentity* new_ident,
@@ -288,13 +281,6 @@
N_("Select the Identity to use for the message"),
change_identity_dialog_cb,
BALSA_PIXMAP_MENU_IDENTITY),
- GNOMEUIINFO_SEPARATOR,
-#define EDIT_MENU_EDIT_GNOME EDIT_MENU_SELECT_IDENT + 2
- GNOMEUIINFO_ITEM_STOCK(N_("_Edit with Gnome-Editor"),
- N_("Edit the current message with "
- "the default Gnome editor"),
- edit_with_gnome,
- BALSA_PIXMAP_MENU_IDENTITY), /*FIXME: Other icon */
GNOMEUIINFO_END
};
@@ -675,174 +661,6 @@
{ N_("Subject:"), G_STRUCT_OFFSET(BalsaSendmsg, subject[1])}
};
-static gboolean
-edit_with_gnome_check(gpointer data) {
- FILE *tmp;
- balsa_edit_with_gnome_data *data_real = (balsa_edit_with_gnome_data *)data;
- GtkTextBuffer *buffer;
-
- pid_t pid;
- gint curposition;
- gchar line[81]; /* FIXME:All lines should wrap at this line */
- /* Editor not ready */
- pid = waitpid (data_real->pid_editor, NULL, WNOHANG);
- if(pid == -1) {
- perror("waitpid");
- return TRUE;
- } else if(pid == 0) return TRUE;
-
- tmp = fopen(data_real->filename, "r");
- if(tmp == NULL){
- perror("fopen");
- return TRUE;
- }
- gdk_threads_enter();
- if (balsa_app.edit_headers) {
- while (fgets(line, sizeof(line), tmp)) {
- guint i;
-
- if (line[strlen(line) - 1] == '\n')
- line[strlen(line) - 1] = '\0';
-
- for (i = 0; i < ELEMENTS(headers); i++) {
- gchar *p = _(headers[i].label);
- guint len = strlen(p);
-
- if (!strncmp(line, p, len)) {
- GtkWidget *widget =
- G_STRUCT_MEMBER(GtkWidget *, data_real->bsmsg,
- headers[i].struct_offset);
- gtk_entry_set_text(GTK_ENTRY(widget), line + len + 1);
- break;
- }
- }
- if (i >= ELEMENTS(headers))
- break;
- }
- }
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(data_real->bsmsg->text));
-
- gtk_text_buffer_set_text(buffer, "", 0);
- curposition = 0;
- while(fgets(line, sizeof(line), tmp))
- libbalsa_insert_with_url(buffer, line, NULL, NULL, NULL);
- g_free(data_real->filename);
- fclose(tmp);
- unlink(data_real->filename);
- gtk_widget_set_sensitive(data_real->bsmsg->text, TRUE);
- g_free(data);
- gdk_threads_leave();
-
- return FALSE;
-}
-
-/* Edit the current file with an external editor.
- *
- * We fork twice current process, so we get:
- *
- * - Old (parent) process (this needs to continue because we don't want
- * balsa to 'hang' until the editor exits
- * - New (child) process (forks and waits for child to finish)
- * - New (grandchild) process (executes editor)
- */
-static void
-edit_with_gnome(GtkWidget* widget, BalsaSendmsg* bsmsg)
-{
- static const char TMP_PATTERN[] = "/tmp/balsa-edit-XXXXXX";
- gchar filename[sizeof(TMP_PATTERN)];
- balsa_edit_with_gnome_data *data =
- g_malloc(sizeof(balsa_edit_with_gnome_data));
- pid_t pid;
- FILE *tmp;
- int tmpfd;
- GtkTextBuffer *buffer =
- gtk_text_view_get_buffer(GTK_TEXT_VIEW(bsmsg->text));
- GtkTextIter start, end;
- gchar *p;
- GnomeVFSMimeApplication *app;
- char **argv;
- int argc;
-
- sw_buffer_save(bsmsg);
- strcpy(filename, TMP_PATTERN);
- tmpfd = mkstemp(filename);
- app = gnome_vfs_mime_get_default_application ("text/plain");
- if (app) {
- gboolean adduri = (app->expects_uris ==
- GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS);
- argc = 2;
- argv = g_new0 (char *, argc+1);
- argv[0] = g_strdup(app->command);
- argv[1] = g_strdup_printf("%s%s", adduri ? "file:" : "", filename);
-
- /* this does not work really well with gnome-terminal
- * that quits before the text editing application quits.
- * Blame gnome-terminal.
- * WORKAROUND: if the terminal is gnome-terminal,
- * --disable-factory option is added as well.
- */
- if (app->requires_terminal) {
- gnome_prepend_terminal_to_vector(&argc, &argv);
- if(strstr(argv[0], "gnome-terminal")) {
- int i;
- gchar ** new_argv = g_new(char*, ++argc+1);
- new_argv[0] = argv[0];
- new_argv[1] = g_strdup("--disable-factory");
- for(i=2; i<=argc; i++)
- new_argv[i] = argv[i-1];
- g_free(argv);
- argv = new_argv;
- }
- }
- gnome_vfs_mime_application_free (app);
- } else {
- balsa_information_parented(GTK_WINDOW(bsmsg->window),
- LIBBALSA_INFORMATION_ERROR,
- _("Gnome editor is not defined"
- " in your preferred applications."));
- return;
- }
-
-
- tmp = fdopen(tmpfd, "w+");
-
- if(balsa_app.edit_headers) {
- guint i;
-
- for (i = 0; i < ELEMENTS(headers); i++) {
- GtkWidget *widget = G_STRUCT_MEMBER(GtkWidget *, bsmsg,
- headers[i].struct_offset);
- const gchar *p = gtk_entry_get_text(GTK_ENTRY(widget));
- fprintf(tmp, "%s %s\n", _(headers[i].label), p);
- }
- fprintf(tmp, "\n");
- }
-
- gtk_widget_set_sensitive(GTK_WIDGET(bsmsg->text), FALSE);
- gtk_text_buffer_get_bounds(buffer, &start, &end);
- p = gtk_text_iter_get_text(&start, &end);
- fputs(p, tmp);
- g_free(p);
- fclose(tmp);
- if ((pid = fork()) < 0) {
- perror ("fork");
- return;
- }
- if (pid == 0) {
- setpgid(0, 0);
- execvp (argv[0], argv);
- perror ("execvp");
- g_strfreev (argv);
- exit(127);
- }
- g_strfreev (argv);
- /* Return immediately. We don't want balsa to 'hang' */
- data->pid_editor = pid;
- data->filename = g_strdup(filename);
- data->bsmsg = bsmsg;
- g_timeout_add(200, (GSourceFunc)edit_with_gnome_check, data);
-}
-
static void
change_identity_dialog_cb(GtkWidget* widget, BalsaSendmsg* bsmsg)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]