+2005-10-20 [colin] 1.9.15cvs84
+
+ * configure.ac
+ * src/folderview.c
+ * src/headerview.c
+ * src/main.c
+ * src/prefs_common.c
+ * src/prefs_common.h
+ * src/prefs_message.c
+ * src/textview.c
+ * src/textview.h
+ * src/common/defs.h
+ * src/common/utils.c
+ * src/common/utils.h
+ * src/gtk/gtkutils.c
+ * src/gtk/gtkutils.h
+ Migrate config to .sylpheed-claws (Automatically)
+ Add a way to get the Xface in the TextView
+
2005-10-20 [colin] 1.9.15cvs83
* src/gtk/Makefile.am
( cvs diff -u -r 1.179.2.80 -r 1.179.2.81 src/imap.c; cvs diff -u -r 1.1.4.23 -r 1.1.4.24 src/etpan/imap-thread.c; ) > 1.9.15cvs81.patchset
( cvs diff -u -r 1.83.2.48 -r 1.83.2.49 src/mimeview.c; ) > 1.9.15cvs82.patchset
( cvs diff -u -r 1.20.2.5 -r 1.20.2.6 src/gtk/Makefile.am; cvs diff -u -r 1.4.2.18 -r 1.4.2.19 src/gtk/about.c; diff -u /dev/null src/gtk/authors.h; ) > 1.9.15cvs83.patchset
+( cvs diff -u -r 1.654.2.963 -r 1.654.2.964 configure.ac; cvs diff -u -r 1.207.2.76 -r 1.207.2.77 src/folderview.c; cvs diff -u -r 1.8.2.10 -r 1.8.2.11 src/headerview.c; cvs diff -u -r 1.115.2.61 -r 1.115.2.62 src/main.c; cvs diff -u -r 1.204.2.66 -r 1.204.2.67 src/prefs_common.c; cvs diff -u -r 1.103.2.34 -r 1.103.2.35 src/prefs_common.h; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/prefs_message.c; cvs diff -u -r 1.96.2.79 -r 1.96.2.80 src/textview.c; cvs diff -u -r 1.12.2.8 -r 1.12.2.9 src/textview.h; cvs diff -u -r 1.9.2.18 -r 1.9.2.19 src/common/defs.h; cvs diff -u -r 1.36.2.46 -r 1.36.2.47 src/common/utils.c; cvs diff -u -r 1.20.2.25 -r 1.20.2.26 src/common/utils.h; cvs diff -u -r 1.5.2.15 -r 1.5.2.16 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.13 -r 1.4.2.14 src/gtk/gtkutils.h; ) > 1.9.15cvs84.patchset
MICRO_VERSION=15
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=83
+EXTRA_VERSION=84
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
AC_SUBST(PASSCRYPT_KEY, $with_passcrypt_key)
dnl RC dir (will be default at a certain point in time)
-AC_ARG_WITH(config-dir, [ --with-config-dir=RCDIR Local configuration dir (default: .sylpheed-gtk2)],
- ac_cv_with_config_dir="$withval", ac_cv_with_config_dir=".sylpheed-gtk2")
+AC_ARG_WITH(config-dir, [ --with-config-dir=RCDIR Local configuration dir (default: .sylpheed-claws)],
+ ac_cv_with_config_dir="$withval", ac_cv_with_config_dir=".sylpheed-claws")
if test x"$ac_cv_with_config_dir" = x""; then
- ac_cv_with_config_dir=".sylpheed-gtk2"
+ ac_cv_with_config_dir=".sylpheed-claws"
fi
AC_DEFINE_UNQUOTED(CFG_RC_DIR, "$ac_cv_with_config_dir", Configuration directory)
#define DRAFT_DIR "draft"
#define TRASH_DIR "trash"
#define RC_DIR CFG_RC_DIR
+#define OLD_GTK2_RC_DIR ".sylpheed-gtk2"
+#define OLD_GTK1_RC_DIR ".sylpheed"
#define NEWS_CACHE_DIR "newscache"
#define IMAP_CACHE_DIR "imapcache"
#define MBOX_CACHE_DIR "mboxcache"
result = mailcap_get_command_in_file("/etc/mailcap", type);
return result;
}
+
+gint copy_dir(const gchar *src, const gchar *dst)
+{
+ GDir *dir;
+ const gchar *name;
+
+ if ((dir = g_dir_open(src, 0, NULL)) == NULL) {
+ g_warning("failed to open directory: %s\n", src);
+ return -1;
+ }
+
+ if (make_dir(dst) < 0)
+ return -1;
+
+ while ((name = g_dir_read_name(dir)) != NULL) {
+ gchar *old_file, *new_file;
+ old_file = g_strconcat(src, G_DIR_SEPARATOR_S, name, NULL);
+ new_file = g_strconcat(dst, G_DIR_SEPARATOR_S, name, NULL);
+ debug_print("copying: %s -> %s\n", old_file, new_file);
+ if (g_file_test(old_file, G_FILE_TEST_IS_REGULAR)) {
+ gint r = copy_file(old_file, new_file, TRUE);
+ if (r < 0)
+ return r;
+ } else if (g_file_test(old_file, G_FILE_TEST_IS_DIR)) {
+ gint r = copy_dir(old_file, new_file);
+ if (r < 0)
+ return r;
+ }
+ }
+ return 0;
+}
gint move_file (const gchar *src,
const gchar *dest,
gboolean overwrite);
+gint copy_dir (const gchar *src,
+ const gchar *dest);
gint copy_file_part_to_fp (FILE *fp,
off_t offset,
size_t length,
}
}
-static GtkWidget *label_window_create(const gchar *str)
-{
- GtkWidget *window;
- GtkWidget *label;
-
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(window, 380, 60);
- gtk_container_set_border_width(GTK_CONTAINER(window), 8);
- gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
- gtk_window_set_title(GTK_WINDOW(window), str);
- gtk_window_set_modal(GTK_WINDOW(window), TRUE);
- gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
- manage_window_set_transient(GTK_WINDOW(window));
-
- label = gtk_label_new(str);
- gtk_container_add(GTK_CONTAINER(window), label);
- gtk_widget_show(label);
-
- gtk_widget_show_now(window);
-
- return window;
-}
-
void folderview_rescan_tree(Folder *folder, gboolean rebuild)
{
GtkWidget *window;
#include <stdarg.h>
#include <sys/stat.h>
+#if HAVE_LIBCOMPFACE
+# include <compface.h>
+#endif
+
#if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
# include <wchar.h>
# include <wctype.h>
#include "menu.h"
#include "prefs_account.h"
#include "prefs_common.h"
+#include "manage_window.h"
gboolean gtkut_get_font_size(GtkWidget *widget,
gint *width, gint *height)
gdk_window_set_icon(widget->window, NULL, xpm, bmp);
}
+GtkWidget *label_window_create(const gchar *str)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_widget_set_size_request(window, 380, 60);
+ gtk_container_set_border_width(GTK_CONTAINER(window), 8);
+ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
+ gtk_window_set_title(GTK_WINDOW(window), str);
+ gtk_window_set_modal(GTK_WINDOW(window), TRUE);
+ gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
+ manage_window_set_transient(GTK_WINDOW(window));
+
+ label = gtk_label_new(str);
+ gtk_container_add(GTK_CONTAINER(window), label);
+ gtk_widget_show(label);
+
+ gtk_widget_show_now(window);
+
+ return window;
+}
+
GtkWidget *gtkut_account_menu_new(GList *ac_list,
GCallback callback,
gpointer data)
#endif
return button;
}
+
+#if HAVE_LIBCOMPFACE
+gint create_xpm_from_xface(gchar *xpm[], const gchar *xface)
+{
+ static gchar *bit_pattern[] = {
+ "....",
+ "...#",
+ "..#.",
+ "..##",
+ ".#..",
+ ".#.#",
+ ".##.",
+ ".###",
+ "#...",
+ "#..#",
+ "#.#.",
+ "#.##",
+ "##..",
+ "##.#",
+ "###.",
+ "####"
+ };
+
+ static gchar *xface_header = "48 48 2 1";
+ static gchar *xface_black = "# c #000000";
+ static gchar *xface_white = ". c #ffffff";
+
+ gint i, line = 0;
+ const guchar *p;
+ gchar buf[WIDTH * 4 + 1]; /* 4 = strlen("0x0000") */
+
+ p = xface;
+
+ strcpy(xpm[line++], xface_header);
+ strcpy(xpm[line++], xface_black);
+ strcpy(xpm[line++], xface_white);
+
+ for (i = 0; i < HEIGHT; i++) {
+ gint col;
+
+ buf[0] = '\0';
+
+ for (col = 0; col < 3; col++) {
+ gint figure;
+
+ p += 2; /* skip '0x' */
+
+ for (figure = 0; figure < 4; figure++) {
+ gint n = 0;
+
+ if ('0' <= *p && *p <= '9') {
+ n = *p - '0';
+ } else if ('a' <= *p && *p <= 'f') {
+ n = *p - 'a' + 10;
+ } else if ('A' <= *p && *p <= 'F') {
+ n = *p - 'A' + 10;
+ }
+
+ strcat(buf, bit_pattern[n]);
+ p++; /* skip ',' */
+ }
+
+ p++; /* skip '\n' */
+ }
+
+ strcpy(xpm[line++], buf);
+ p++;
+ }
+
+ return 0;
+}
+#endif
GtkTextIter *match_pos);
gchar *gtkut_text_view_get_selection (GtkTextView *textview);
-
+GtkWidget *label_window_create(const gchar *str);
void gtkut_window_popup (GtkWidget *window);
void gtkut_widget_get_uposition (GtkWidget *widget,
GtkWidget *gtkut_get_browse_file_btn(const gchar *label);
GtkWidget *gtkut_get_browse_directory_btn(const gchar *label);
-
+#if HAVE_LIBCOMPFACE
+gint create_xpm_from_xface(gchar *xpm[], const gchar *xface);
+#endif
#endif /* __GTKUTILS_H__ */
static void headerview_show_xface (HeaderView *headerview,
MsgInfo *msginfo);
-static gint create_xpm_from_xface (gchar *xpm[],
- const gchar *xface);
#endif
HeaderView *headerview_create(void)
{
g_free(headerview);
}
-
-#if HAVE_LIBCOMPFACE
-static gint create_xpm_from_xface(gchar *xpm[], const gchar *xface)
-{
- static gchar *bit_pattern[] = {
- "....",
- "...#",
- "..#.",
- "..##",
- ".#..",
- ".#.#",
- ".##.",
- ".###",
- "#...",
- "#..#",
- "#.#.",
- "#.##",
- "##..",
- "##.#",
- "###.",
- "####"
- };
-
- static gchar *xface_header = "48 48 2 1";
- static gchar *xface_black = "# c #000000";
- static gchar *xface_white = ". c #ffffff";
-
- gint i, line = 0;
- const guchar *p;
- gchar buf[WIDTH * 4 + 1]; /* 4 = strlen("0x0000") */
-
- p = xface;
-
- strcpy(xpm[line++], xface_header);
- strcpy(xpm[line++], xface_black);
- strcpy(xpm[line++], xface_white);
-
- for (i = 0; i < HEIGHT; i++) {
- gint col;
-
- buf[0] = '\0';
-
- for (col = 0; col < 3; col++) {
- gint figure;
-
- p += 2; /* skip '0x' */
-
- for (figure = 0; figure < 4; figure++) {
- gint n = 0;
-
- if ('0' <= *p && *p <= '9') {
- n = *p - '0';
- } else if ('a' <= *p && *p <= 'f') {
- n = *p - 'a' + 10;
- } else if ('A' <= *p && *p <= 'F') {
- n = *p - 'A' + 10;
- }
-
- strcat(buf, bit_pattern[n]);
- p++; /* skip ',' */
- }
-
- p++; /* skip '\n' */
- }
-
- strcpy(xpm[line++], buf);
- p++;
- }
-
- return 0;
-}
-#endif
return FALSE;
}
+static gboolean migrate_old_config(const gchar *old_cfg_dir, const gchar *new_cfg_dir)
+{
+ gchar *message = g_strdup_printf(_("Configuration for Sylpheed-Claws %s found.\n"
+ "Do you want to migrate this configuration?"),
+ !strcmp(old_cfg_dir, OLD_GTK1_RC_DIR)?
+ _("1.0.5 or previous"):_("1.9.15 or previous"));
+ gint r = 0;
+ GtkWidget *window = NULL;
+ if (alertpanel(_("Migration of configuration"),
+ message,
+ GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
+ return FALSE;
+
+ window = label_window_create(_("Copying configuration..."));
+ GTK_EVENTS_FLUSH();
+ r = copy_dir(old_cfg_dir, new_cfg_dir);
+ gtk_widget_destroy(window);
+ if (r != 0) {
+ alertpanel_error(_("Migration failed!"));
+ }
+ return (r == 0);
+}
+
int main(int argc, char *argv[])
{
gchar *userrc;
G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
gtk_rc_parse(userrc);
g_free(userrc);
+
+ CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
+ if (!is_dir_exist(RC_DIR)) {
+ gboolean r = FALSE;
+ if (is_dir_exist(OLD_GTK2_RC_DIR))
+ r = migrate_old_config(OLD_GTK2_RC_DIR, RC_DIR);
+ else if (is_dir_exist(OLD_GTK1_RC_DIR))
+ r = migrate_old_config(OLD_GTK1_RC_DIR, RC_DIR);
+ if (r == FALSE && !is_dir_exist(RC_DIR) && make_dir(RC_DIR) < 0)
+ exit(1);
+ }
+
userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
gtk_rc_parse(userrc);
g_free(userrc);
"gtk-can-change-accels",
(glong)TRUE, "XProperty");
- CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
-
- MAKE_DIR_IF_NOT_EXIST(RC_DIR);
-
CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), 1);
MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
P_BOOL, NULL, NULL, NULL},
{"display_header", "TRUE", &prefs_common.display_header, P_BOOL,
NULL, NULL, NULL},
+ {"display_xface", "TRUE", &prefs_common.display_xface,
+ P_BOOL, NULL, NULL, NULL},
{"render_html", "TRUE", &prefs_common.render_html, P_BOOL,
NULL, NULL, NULL},
{"line_space", "2", &prefs_common.line_space, P_INT,
gboolean conv_mb_alnum;
gboolean display_header_pane;
gboolean display_header;
+ gboolean display_xface;
gint line_space;
gboolean render_html;
gboolean textview_cursor_visible;
GtkWidget *chkbtn_mbalnum;
GtkWidget *chkbtn_disphdrpane;
GtkWidget *chkbtn_disphdr;
+ GtkWidget *chkbtn_dispxface;
GtkWidget *chkbtn_html;
GtkWidget *spinbtn_linespc;
GtkWidget *chkbtn_attach_desc;
} MessagePage;
+static void disphdr_pane_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget)
+{
+ gboolean is_active;
+
+ is_active = gtk_toggle_button_get_active(toggle_btn);
+
+ gtk_widget_set_sensitive(widget, !is_active);
+}
+
+
void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
gpointer data)
{
GtkWidget *chkbtn_mbalnum;
GtkWidget *chkbtn_disphdrpane;
GtkWidget *chkbtn_disphdr;
+ GtkWidget *chkbtn_dispxface;
GtkWidget *button_edit_disphdr;
GtkWidget *chkbtn_html;
GtkWidget *hbox_linespc;
PACK_CHECK_BUTTON(vbox2, chkbtn_disphdrpane,
_("Display header pane above message view"));
+#if HAVE_LIBCOMPFACE
+ PACK_CHECK_BUTTON(vbox2, chkbtn_dispxface,
+ _("Display X-Face in message view"));
+#endif
+ gtk_widget_set_sensitive(chkbtn_dispxface,
+ !prefs_common.display_header_pane);
+
+ g_signal_connect(G_OBJECT(chkbtn_disphdrpane), "toggled",
+ G_CALLBACK(disphdr_pane_toggled), chkbtn_dispxface);
+
hbox1 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
prefs_common.conv_mb_alnum);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_disphdrpane),
prefs_common.display_header_pane);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_dispxface),
+ prefs_common.display_xface);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_disphdr),
prefs_common.display_header);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_html),
prefs_message->window = GTK_WIDGET(window);
prefs_message->chkbtn_mbalnum = chkbtn_mbalnum;
prefs_message->chkbtn_disphdrpane = chkbtn_disphdrpane;
+ prefs_message->chkbtn_dispxface = chkbtn_dispxface;
prefs_message->chkbtn_disphdr = chkbtn_disphdr;
prefs_message->chkbtn_html = chkbtn_html;
prefs_message->spinbtn_linespc = spinbtn_linespc;
GTK_TOGGLE_BUTTON(page->chkbtn_mbalnum));
prefs_common.display_header_pane = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(page->chkbtn_disphdrpane));
+ prefs_common.display_xface = gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(page->chkbtn_dispxface));
prefs_common.display_header = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(page->chkbtn_disphdr));
prefs_common.render_html = gtk_toggle_button_get_active(
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
+#if HAVE_LIBCOMPFACE
+# include <compface.h>
+#endif
+
+#if HAVE_LIBCOMPFACE
+#define XPM_XFACE_HEIGHT (HEIGHT + 3) /* 3 = 1 header + 2 colors */
+#endif
#include "main.h"
#include "summaryview.h"
{N_("/_Save image..."), NULL, save_file_cb, 0, NULL},
};
+static void scrolled_cb (GtkAdjustment *adj, TextView *textview)
+{
+#if HAVE_LIBCOMPFACE
+ if (textview->image) {
+ gint x, y;
+ gtk_text_view_buffer_to_window_coords(
+ GTK_TEXT_VIEW(textview->text),
+ GTK_TEXT_WINDOW_RIGHT, 5, 5, &x, &y);
+ gtk_text_view_move_child(GTK_TEXT_VIEW(textview->text),
+ textview->image, 5, y);
+ }
+#endif
+}
TextView *textview_create(void)
{
GtkClipboard *clipboard;
GtkItemFactory *link_popupfactory, *mail_popupfactory, *file_popupfactory;
GtkWidget *link_popupmenu, *mail_popupmenu, *file_popupmenu;
+ GtkAdjustment *adj;
gint n_entries;
debug_print("Creating text view...\n");
G_CALLBACK(textview_leave_notify), textview);
g_signal_connect(G_OBJECT(text), "visibility-notify-event",
G_CALLBACK(textview_visibility_notify), textview);
+ adj = gtk_scrolled_window_get_vadjustment(
+ GTK_SCROLLED_WINDOW(scrolledwin));
+ g_signal_connect(G_OBJECT(adj), "value-changed",
+ G_CALLBACK(scrolled_cb), textview);
gtk_widget_show(scrolledwin);
return sorted_headers;
}
+#if HAVE_LIBCOMPFACE
+static void textview_show_xface(TextView *textview)
+{
+ gchar xface[2048];
+ MsgInfo *msginfo = textview->messageview->msginfo;
+ static gchar *xpm_xface[XPM_XFACE_HEIGHT];
+ static gboolean xpm_xface_init = TRUE;
+ GdkPixmap *pixmap;
+ GdkBitmap *mask;
+ GtkTextView *text = GTK_TEXT_VIEW(textview->text);
+
+ gtk_text_view_set_border_window_size(text, GTK_TEXT_WINDOW_RIGHT, 0);
+
+ if (prefs_common.display_header_pane
+ || !prefs_common.display_xface)
+ goto bail;
+
+ if (!msginfo)
+ goto bail;
+
+ if (!msginfo->xface || strlen(msginfo->xface) < 5) {
+ goto bail;
+ }
+
+ strncpy(xface, msginfo->xface, sizeof(xface));
+
+ if (uncompface(xface) < 0) {
+ g_warning("uncompface failed\n");
+ goto bail;
+ }
+
+ if (xpm_xface_init) {
+ gint i;
+
+ for (i = 0; i < XPM_XFACE_HEIGHT; i++) {
+ xpm_xface[i] = g_malloc(WIDTH + 1);
+ *xpm_xface[i] = '\0';
+ }
+ xpm_xface_init = FALSE;
+ }
+
+ create_xpm_from_xface(xpm_xface, xface);
+
+ pixmap = gdk_pixmap_create_from_xpm_d
+ (textview->text->window, &mask,
+ &textview->text->style->white, xpm_xface);
+
+ gtk_text_view_set_border_window_size(text, GTK_TEXT_WINDOW_RIGHT,
+ WIDTH+10);
+
+ if (textview->image)
+ gtk_widget_destroy(textview->image);
+
+ textview->image = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_widget_show(textview->image);
+ gtk_text_view_add_child_in_window(text, textview->image,
+ GTK_TEXT_WINDOW_RIGHT, 5, 5);
+
+ gtk_widget_show_all(textview->text);
+
+ return;
+bail:
+ if (textview->image)
+ gtk_widget_destroy(textview->image);
+ textview->image = NULL;
+
+}
+#endif
+
static void textview_show_header(TextView *textview, GPtrArray *headers)
{
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "\n", 1,
"header", NULL);
}
+#if HAVE_LIBCOMPFACE
+ textview_show_xface(textview);
+#endif
}
gboolean textview_search_string(TextView *textview, const gchar *str,
RemoteURI *uri_hover;
GtkTextIter uri_hover_start_iter;
GtkTextIter uri_hover_end_iter;
+ GtkWidget *image;
};
TextView *textview_create (void);