static void save_file_cb (TextView *textview,
guint action,
void *data);
+static void open_image_cb (TextView *textview,
+ guint action,
+ void *data);
static GtkItemFactoryEntry textview_link_popup_entries[] =
{
static GtkItemFactoryEntry textview_file_popup_entries[] =
{
- {N_("/_Save this image..."), NULL, save_file_cb, 0, NULL},
+ {N_("/_Open image"), NULL, open_image_cb, 0, NULL},
+ {N_("/_Save image..."), NULL, save_file_cb, 0, NULL},
};
if (!bold_font_desc) {
bold_font_desc = pango_font_description_from_string
- (BOLD_FONT);
+ (NORMAL_FONT);
pango_font_description_set_weight
(bold_font_desc, PANGO_WEIGHT_BOLD);
}
charset = textview->messageview->forced_charset;
else
charset = procmime_mimeinfo_get_parameter(mimeinfo, "charset");
-
+printf("charset %s\n", charset);
textview_set_font(textview, charset);
conv = conv_code_converter_new(charset);
textview->show_all_headers = all_headers;
}
+#define CHANGE_TAG_FONT(tagname, font) { \
+ tag = gtk_text_tag_table_lookup(tags, tagname); \
+ if (tag) \
+ g_object_set(G_OBJECT(tag), "font-desc", font, NULL); \
+}
+
void textview_set_font(TextView *textview, const gchar *codeset)
{
+ GtkTextTag *tag;
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview->text));
+ GtkTextTagTable *tags = gtk_text_buffer_get_tag_table(buffer);
+
+ if (NORMAL_FONT) {
+ PangoFontDescription *font_desc, *bold_font_desc;
+ font_desc = pango_font_description_from_string
+ (NORMAL_FONT);
+ bold_font_desc = pango_font_description_from_string
+ (NORMAL_FONT);
+ if (font_desc) {
+ gtk_widget_modify_font(textview->text, font_desc);
+ CHANGE_TAG_FONT("header", font_desc);
+ pango_font_description_free(font_desc);
+ }
+ if (bold_font_desc) {
+ pango_font_description_set_weight
+ (bold_font_desc, PANGO_WEIGHT_BOLD);
+ CHANGE_TAG_FONT("header_title", bold_font_desc);
+ pango_font_description_free(bold_font_desc);
+ }
+ }
+
if (prefs_common.textfont) {
- PangoFontDescription *font_desc = NULL;
+ PangoFontDescription *font_desc;
font_desc = pango_font_description_from_string
(prefs_common.textfont);
NULL);
}
+static void open_image_cb (TextView *textview, guint action, void *data)
+{
+ RemoteURI *uri = g_object_get_data(G_OBJECT(textview->file_popup_menu),
+ "menu_button");
+
+ static gchar *default_cmdline = DEFAULT_IMAGE_VIEWER_CMD;
+ gchar buf[1024];
+ const gchar *cmd;
+ const gchar *def_cmd;
+ const gchar *p;
+ gchar *filename = NULL;
+ gchar *tmp_filename = NULL;
+
+ if (uri == NULL)
+ return;
+
+ if (uri->filename == NULL)
+ return;
+
+ filename = g_strdup(uri->filename);
+
+ if (!g_utf8_validate(filename, -1, NULL)) {
+ gchar *tmp = conv_filename_to_utf8(filename);
+ g_free(filename);
+ filename = tmp;
+ }
+
+ subst_for_filename(filename);
+
+ tmp_filename = g_filename_from_uri(uri->uri, NULL, NULL);
+ copy_file(tmp_filename, filename, FALSE);
+ g_free(tmp_filename);
+
+ cmd = prefs_common.mime_image_viewer;
+ def_cmd = default_cmdline;
+
+ if (cmd && (p = strchr(cmd, '%')) && *(p + 1) == 's' &&
+ !strchr(p + 2, '%'))
+ g_snprintf(buf, sizeof(buf), cmd, filename);
+ else {
+ if (cmd)
+ g_warning("Image viewer command line is invalid: '%s'", cmd);
+ if (def_cmd)
+ g_snprintf(buf, sizeof(buf), def_cmd, filename);
+ else
+ return;
+ }
+
+ execute_command_line(buf, TRUE);
+
+ g_free(filename);
+
+ g_object_set_data(G_OBJECT(textview->file_popup_menu), "menu_button",
+ NULL);
+}
+
static void save_file_cb (TextView *textview, guint action, void *data)
{
RemoteURI *uri = g_object_get_data(G_OBJECT(textview->file_popup_menu),