From: Colin Leroy Date: Wed, 1 Feb 2006 17:52:48 +0000 (+0000) Subject: 2006-02-01 [colin] 2.0.0cvs7 X-Git-Tag: REL_2_1_0~190 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=8c8e367e2a2f4c682cc859fd2851e611a88e980e 2006-02-01 [colin] 2.0.0cvs7 * src/compose.c * src/prefs_account.c * src/prefs_common.c * src/common/defs.h * src/common/utils.c * src/common/utils.h Add ability to edit the signature file from the account preferences, and use a default for the text editor. Patch by Fabien Vantard --- diff --git a/ChangeLog b/ChangeLog index f16675ec1..fe4b6c439 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-02-01 [colin] 2.0.0cvs7 + + * src/compose.c + * src/prefs_account.c + * src/prefs_common.c + * src/common/defs.h + * src/common/utils.c + * src/common/utils.h + Add ability to edit the signature file + from the account preferences, and use + a default for the text editor. + Patch by Fabien Vantard + 2006-02-01 [colin] 2.0.0cvs6 * src/mimeview.c diff --git a/PATCHSETS b/PATCHSETS index 2b3067fdf..a8ae71de6 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1190,3 +1190,4 @@ ( cvs diff -u -r 1.382.2.231 -r 1.382.2.232 src/compose.c; cvs diff -u -r 1.274.2.93 -r 1.274.2.94 src/mainwindow.c; cvs diff -u -r 1.94.2.75 -r 1.94.2.76 src/messageview.c; cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/prefs_send.c; ) > 2.0.0cvs4.patchset ( cvs diff -u -r 1.18.2.15 -r 1.18.2.16 src/jpilot.c; cvs diff -u -r 1.1.2.20 -r 1.1.2.21 src/prefs_summaries.c; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/prefs_wrapping.c; cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/gtk/icon_legend.c; cvs diff -u -r 1.1.2.32 -r 1.1.2.33 src/gtk/quicksearch.c; ) > 2.0.0cvs5.patchset ( cvs diff -u -r 1.83.2.59 -r 1.83.2.60 src/mimeview.c; cvs diff -u -r 1.2.2.20 -r 1.2.2.21 src/gtk/filesel.c; cvs diff -u -r 1.1.4.7 -r 1.1.4.8 src/gtk/filesel.h; cvs diff -u -r 1.5.2.25 -r 1.5.2.26 src/gtk/pluginwindow.c; ) > 2.0.0cvs6.patchset +( cvs diff -u -r 1.382.2.232 -r 1.382.2.233 src/compose.c; cvs diff -u -r 1.105.2.47 -r 1.105.2.48 src/prefs_account.c; cvs diff -u -r 1.204.2.73 -r 1.204.2.74 src/prefs_common.c; cvs diff -u -r 1.9.2.21 -r 1.9.2.22 src/common/defs.h; cvs diff -u -r 1.36.2.52 -r 1.36.2.53 src/common/utils.c; cvs diff -u -r 1.20.2.30 -r 1.20.2.31 src/common/utils.h; ) > 2.0.0cvs7.patchset diff --git a/configure.ac b/configure.ac index 506c922ce..d807e08fe 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=0 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=6 +EXTRA_VERSION=7 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/common/defs.h b/src/common/defs.h index ed1f7fdf8..dac842bb6 100644 --- a/src/common/defs.h +++ b/src/common/defs.h @@ -96,6 +96,7 @@ /* #define DEFAULT_INC_PROGRAM "imget" */ #define DEFAULT_SENDMAIL_CMD "/usr/sbin/sendmail -t -i" #define DEFAULT_BROWSER_CMD "mozilla-firefox -remote 'openURL(%s,new-window)'" +#define DEFAULT_EDITOR_CMD "gedit %s" #define DEFAULT_MIME_CMD "metamail -d -b -x -c %s '%s'" #define DEFAULT_IMAGE_VIEWER_CMD "display '%s'" #define DEFAULT_AUDIO_PLAYER_CMD "play '%s'" diff --git a/src/common/utils.c b/src/common/utils.c index 66c9d2398..c2af46a55 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -3593,6 +3593,30 @@ gint open_uri(const gchar *uri, const gchar *cmdline) return 0; } +gint open_txt_editor(const gchar *filepath, const gchar *cmdline) +{ + gchar buf[BUFFSIZE]; + gchar *p; + + g_return_val_if_fail(filepath != NULL, -1); + + if (cmdline && + (p = strchr(cmdline, '%')) && *(p + 1) == 's' && + !strchr(p + 2, '%')) + g_snprintf(buf, sizeof(buf), cmdline, filepath); + else { + if (cmdline) + g_warning("Open Text Editor command line is invalid " + "(there must be only one '%%s'): %s", + cmdline); + g_snprintf(buf, sizeof(buf), DEFAULT_EDITOR_CMD, filepath); + } + + execute_command_line(buf, TRUE); + + return 0; +} + time_t remote_tzoffset_sec(const gchar *zone) { static gchar ustzstr[] = "PSTPDTMSTMDTCSTCDTESTEDT"; diff --git a/src/common/utils.h b/src/common/utils.h index 0f9005a57..4e6a3f949 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -487,6 +487,8 @@ gchar *get_command_output (const gchar *cmdline); /* open URI with external browser */ gint open_uri(const gchar *uri, const gchar *cmdline); +/* open file with text editor */ +gint open_txt_editor(const gchar *filepath, const gchar *cmdline); /* time functions */ time_t remote_tzoffset_sec (const gchar *zone); diff --git a/src/compose.c b/src/compose.c index 54e569147..aa329d89e 100644 --- a/src/compose.c +++ b/src/compose.c @@ -6651,7 +6651,6 @@ static void compose_exec_ext_editor(Compose *compose) #ifdef G_OS_UNIX static gint compose_exec_ext_editor_real(const gchar *file) { - static gchar *def_cmd = "emacs %s"; gchar buf[1024]; gchar *p; gchar **cmdline; @@ -6679,7 +6678,7 @@ static gint compose_exec_ext_editor_real(const gchar *file) if (prefs_common.ext_editor_cmd) g_warning("External editor command line is invalid: '%s'\n", prefs_common.ext_editor_cmd); - g_snprintf(buf, sizeof(buf), def_cmd, file); + g_snprintf(buf, sizeof(buf), DEFAULT_EDITOR_CMD, file); } cmdline = strsplit_with_quote(buf, " ", 1024); diff --git a/src/prefs_account.c b/src/prefs_account.c index 06e5e1fc9..cde192257 100644 --- a/src/prefs_account.c +++ b/src/prefs_account.c @@ -65,6 +65,7 @@ static GtkWidget *sigfile_radiobtn; static GtkWidget *sigcmd_radiobtn; static GtkWidget *entry_sigpath; static GtkWidget *signature_browse_button; +static GtkWidget *signature_edit_button; static GSList *prefs_pages = NULL; @@ -596,6 +597,9 @@ static void prefs_account_sigcmd_radiobtn_cb (GtkWidget *widget, static void prefs_account_signature_browse_cb (GtkWidget *widget, gpointer data); +static void prefs_account_signature_edit_cb (GtkWidget *widget, + gpointer data); + static void pop_bfr_smtp_tm_set_sens (GtkWidget *widget, gpointer data); @@ -1922,6 +1926,16 @@ static void prefs_account_compose_create(void) g_signal_connect(G_OBJECT(signature_browse_button), "clicked", G_CALLBACK(prefs_account_signature_browse_cb), NULL); + #if GTK_CHECK_VERSION(2, 6, 0) + signature_edit_button = gtk_button_new_from_stock (GTK_STOCK_EDIT); + #else + signature_edit_button = gtk_button_new_with_label (_(" Edit... ")); + #endif + gtk_widget_show (signature_edit_button); + gtk_box_pack_start (GTK_BOX (hbox2), signature_edit_button, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(signature_edit_button), "clicked", + G_CALLBACK(prefs_account_signature_edit_cb), entry_sigpath); + PACK_FRAME (vbox1, frame, _("Automatically set the following addresses")); table = gtk_table_new (3, 2, FALSE); @@ -2555,11 +2569,13 @@ static void prefs_account_select_folder_cb(GtkWidget *widget, gpointer data) static void prefs_account_sigfile_radiobtn_cb(GtkWidget *widget, gpointer data) { gtk_widget_set_sensitive(GTK_WIDGET(signature_browse_button), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(signature_edit_button), TRUE); } static void prefs_account_sigcmd_radiobtn_cb(GtkWidget *widget, gpointer data) { gtk_widget_set_sensitive(GTK_WIDGET(signature_browse_button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(signature_edit_button), FALSE); } static void prefs_account_signature_browse_cb(GtkWidget *widget, gpointer data) @@ -2579,6 +2595,12 @@ static void prefs_account_signature_browse_cb(GtkWidget *widget, gpointer data) g_free(utf8_filename); } +static void prefs_account_signature_edit_cb(GtkWidget *widget, gpointer data) +{ + const gchar *sigpath = gtk_entry_get_text(GTK_ENTRY(data)); + open_txt_editor(sigpath, prefs_common.ext_editor_cmd); +} + static void prefs_account_edit_custom_header(void) { prefs_custom_header_open(&tmp_ac_prefs); diff --git a/src/prefs_common.c b/src/prefs_common.c index 92b09d017..39ba419e4 100644 --- a/src/prefs_common.c +++ b/src/prefs_common.c @@ -509,7 +509,7 @@ static PrefParam param[] = { &prefs_common.uri_cmd, P_STRING, NULL, NULL, NULL}, {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING, NULL, NULL, NULL}, - {"ext_editor_command", "gedit %s", + {"ext_editor_command", DEFAULT_EDITOR_CMD, &prefs_common.ext_editor_cmd, P_STRING, NULL, NULL, NULL}, {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click,