[balsa/gtk3] Add the option to use system fonts
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Add the option to use system fonts
- Date: Sun, 9 Jun 2013 23:27:38 +0000 (UTC)
commit 064a78b3b6cca04dda93afffa6c2b4efe3ac5c23
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Jun 9 19:04:00 2013 -0400
Add the option to use system fonts
* src/balsa-app.h: new member gboolean use_system_fonts.
* src/balsa-app.c (balsa_app_init): initialize it.
* src/balsa-mime-widget-message.c (add_header_gchar): respect
it.
* src/balsa-mime-widget-text.c (balsa_mime_widget_new_text),
(bm_modify_font_from_string): ditto.
* src/pref-manager.c (open_preferences_manager), (apply_prefs),
(attach_font_button), (preview_font_group),
(use_system_fonts_cb): allow user to choose it.
* src/save-restore.c (config_global_load), (config_save): save
and restore it.
* src/sendmsg-window.c (create_email_or_string_entry),
(create_text_area): respect it also for compose window.
ChangeLog | 18 +++++++++
doc/C/preferences-display-options.page | 12 +++++--
doc/ChangeLog | 10 +++++
doc/de/preferences-display-options.page | 12 +++++--
doc/es/preferences-display-options.page | 12 +++++--
doc/fr/preferences-display-options.page | 10 +++++-
doc/sl/preferences-display-options.page | 10 +++++-
src/balsa-app.c | 1 +
src/balsa-app.h | 3 +-
src/balsa-mime-widget-message.c | 28 ++++++++-------
src/balsa-mime-widget-text.c | 8 +++--
src/pref-manager.c | 60 +++++++++++++++++++++++++++---
src/save-restore.c | 3 ++
src/sendmsg-window.c | 22 +++++++----
14 files changed, 167 insertions(+), 42 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cda46d3..702a0e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-06-09 Peter Bloomfield
+
+ Add the option to use system fonts
+
+ * src/balsa-app.h: new member gboolean use_system_fonts.
+ * src/balsa-app.c (balsa_app_init): initialize it.
+ * src/balsa-mime-widget-message.c (add_header_gchar): respect
+ it.
+ * src/balsa-mime-widget-text.c (balsa_mime_widget_new_text),
+ (bm_modify_font_from_string): ditto.
+ * src/pref-manager.c (open_preferences_manager), (apply_prefs),
+ (attach_font_button), (preview_font_group),
+ (use_system_fonts_cb): allow user to choose it.
+ * src/save-restore.c (config_global_load), (config_save): save
+ and restore it.
+ * src/sendmsg-window.c (create_email_or_string_entry),
+ (create_text_area): respect it also for compose window.
+
2013-05-30 Peter Bloomfield
* src/sendmsg-window.c (balsa_sendmsg_destroy_handler),
diff --git a/doc/C/preferences-display-options.page b/doc/C/preferences-display-options.page
index 785ac0b..4924bc8 100644
--- a/doc/C/preferences-display-options.page
+++ b/doc/C/preferences-display-options.page
@@ -108,9 +108,15 @@ id="preferences-display-options">
<title>
<gui>Fonts</gui>
</title>
- <p>Choose the fonts that you want to be used to display a
- message. You can choose a distinct font for the message's
- subject line.</p>
+ <p>Using system fonts to view and compose messages makes the
+ display consistent with other applications. If you choose this
+ option, the message's subject line will be made bold.</p>
+ <p>Alternatively, you can choose your own font to view or
+ compose a message, with a different weight or font for the
+ subject line. A fixed-width font such as Monospace can be useful
+ for viewing source code, or formatted text such as tables or
+ <link href= "https://en.wikipedia.org/wiki/ASCII_art">ASCII
+ art</link>.</p>
</item>
<item>
<title>
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 22a17cb..2929d58 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,13 @@
+2013-06-09 Peter Bloomfield <peter w500 bellsouth net>
+
+ reviewed by: <delete if not using a buddy>
+
+ * C/preferences-display-options.page:
+ * de/preferences-display-options.page:
+ * es/preferences-display-options.page:
+ * fr/preferences-display-options.page:
+ * sl/preferences-display-options.page:
+
2013-05-01 Peter Bloomfield
We no longer use color in addresses
diff --git a/doc/de/preferences-display-options.page b/doc/de/preferences-display-options.page
index 290bc37..c22fbca 100644
--- a/doc/de/preferences-display-options.page
+++ b/doc/de/preferences-display-options.page
@@ -128,9 +128,15 @@
<title>
<gui>Fonts</gui>
</title>
- <p>Choose the fonts that you want to be used to display a
- message. You can choose a distinct font for the message's
- subject line.</p>
+ <p>Using system fonts to view and compose messages makes the
+ display consistent with other applications. If you choose this
+ option, the message's subject line will be made bold.</p>
+ <p>Alternatively, you can choose your own font to view or
+ compose a message, with a different weight or font for the
+ subject line. A fixed-width font such as Monospace can be useful
+ for viewing source code, or formatted text such as tables or
+ <link href="https://en.wikipedia.org/wiki/ASCII_art">ASCII
+ art</link>.</p>
</item>
<item>
<title>
diff --git a/doc/es/preferences-display-options.page b/doc/es/preferences-display-options.page
index 6f6149a..d58c265 100644
--- a/doc/es/preferences-display-options.page
+++ b/doc/es/preferences-display-options.page
@@ -128,9 +128,15 @@
<title>
<gui>Fonts</gui>
</title>
- <p>Choose the fonts that you want to be used to display a
- message. You can choose a distinct font for the message's
- subject line.</p>
+ <p>Using system fonts to view and compose messages makes the
+ display consistent with other applications. If you choose this
+ option, the message's subject line will be made bold.</p>
+ <p>Alternatively, you can choose your own font to view or
+ compose a message, with a different weight or font for the
+ subject line. A fixed-width font such as Monospace can be useful
+ for viewing source code, or formatted text such as tables or
+ <link href="https://en.wikipedia.org/wiki/ASCII_art">ASCII
+ art</link>.</p>
</item>
<item>
<title>
diff --git a/doc/fr/preferences-display-options.page b/doc/fr/preferences-display-options.page
index 8f60619..3ba9ecf 100644
--- a/doc/fr/preferences-display-options.page
+++ b/doc/fr/preferences-display-options.page
@@ -123,7 +123,15 @@
<title>
<gui>Fonts</gui>
</title>
- <p>Choisissez la police de caractères à utiliser pour l'affichage des messages. Vous pouvez choisir
une police différente pour la ligne Sujet du message.</p>
+ <p>Using system fonts to view and compose messages makes the
+ display consistent with other applications. If you choose this
+ option, the message's subject line will be made bold.</p>
+ <p>Alternatively, you can choose your own font to view or
+ compose a message, with a different weight or font for the
+ subject line. A fixed-width font such as Monospace can be useful
+ for viewing source code, or formatted text such as tables or
+ <link href="https://en.wikipedia.org/wiki/ASCII_art">ASCII
+ art</link>.</p>
</item>
<item>
<title>
diff --git a/doc/sl/preferences-display-options.page b/doc/sl/preferences-display-options.page
index 9f6bc18..30a0517 100644
--- a/doc/sl/preferences-display-options.page
+++ b/doc/sl/preferences-display-options.page
@@ -123,7 +123,15 @@
<title>
<gui>Fonts</gui>
</title>
- <p>Izberite pisave, ki jih želite uporabiti za prikaz sporočila. Za vrstico zadeve lahko uporabite
drugačno pisavo.</p>
+ <p>Using system fonts to view and compose messages makes the
+ display consistent with other applications. If you choose this
+ option, the message's subject line will be made bold.</p>
+ <p>Alternatively, you can choose your own font to view or
+ compose a message, with a different weight or font for the
+ subject line. A fixed-width font such as Monospace can be useful
+ for viewing source code, or formatted text such as tables or
+ <link href="https://en.wikipedia.org/wiki/ASCII_art">ASCII
+ art</link>.</p>
</item>
<item>
<title>
diff --git a/src/balsa-app.c b/src/balsa-app.c
index 6f8dcf6..eb9db56 100644
--- a/src/balsa-app.c
+++ b/src/balsa-app.c
@@ -360,6 +360,7 @@ balsa_app_init(void)
balsa_app.quote_regex = g_strdup(DEFAULT_QUOTE_REGEX);
/* font */
+ balsa_app.use_system_fonts = FALSE;
balsa_app.message_font = NULL;
balsa_app.subject_font = NULL;
diff --git a/src/balsa-app.h b/src/balsa-app.h
index 8ed4b1d..cb63219 100644
--- a/src/balsa-app.h
+++ b/src/balsa-app.h
@@ -313,7 +313,8 @@ extern struct BalsaApplication {
GList *open_mailbox_list; /* data is a pointer to the mailbox */
gchar *current_mailbox_url;/* remember for next session */
- /* font used to display messages */
+ /* fonts */
+ gboolean use_system_fonts;
gchar *message_font;
gchar *subject_font;
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 83049a5..49a8d19 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -522,9 +522,7 @@ add_header_gchar(BalsaMessage * bm, GtkGrid * grid,
{
gint row;
GtkWidget *lab;
- PangoAttrList *attr_list;
PangoFontDescription *font_desc;
- PangoAttribute *attr;
if (!(bm->shown_headers == HEADERS_ALL ||
libbalsa_find_word(header, balsa_app.selected_headers)))
@@ -534,17 +532,21 @@ add_header_gchar(BalsaMessage * bm, GtkGrid * grid,
while (gtk_grid_get_child_at(grid, 0, row))
row++;
- attr_list = pango_attr_list_new();
- font_desc =
- pango_font_description_from_string(strcmp(header, "subject") ?
- balsa_app.message_font :
- balsa_app.subject_font);
- attr = pango_attr_font_desc_new(font_desc);
- pango_font_description_free(font_desc);
- pango_attr_list_insert(attr_list, attr);
+ if (balsa_app.use_system_fonts) {
+ font_desc = pango_font_description_new();
+ if (strcmp(header, "subject") == 0)
+ /* Use bold for the subject line */
+ pango_font_description_set_weight(font_desc,
+ PANGO_WEIGHT_BOLD);
+ } else {
+ font_desc =
+ pango_font_description_from_string(strcmp(header, "subject") ?
+ balsa_app.message_font :
+ balsa_app.subject_font);
+ }
lab = gtk_label_new(label);
- gtk_label_set_attributes(GTK_LABEL(lab), attr_list);
+ gtk_widget_override_font(lab, font_desc);
gtk_grid_attach(grid, lab, 0, row, 1, 1);
gtk_label_set_selectable(GTK_LABEL(lab), TRUE);
gtk_misc_set_alignment(GTK_MISC(lab), 0, 0);
@@ -561,7 +563,7 @@ add_header_gchar(BalsaMessage * bm, GtkGrid * grid,
lab = gtk_label_new(sanitized);
g_free(sanitized);
- gtk_label_set_attributes(GTK_LABEL(lab), attr_list);
+ gtk_widget_override_font(lab, font_desc);
gtk_label_set_line_wrap_mode(GTK_LABEL(lab), PANGO_WRAP_WORD_CHAR);
gtk_label_set_selectable(GTK_LABEL(lab), TRUE);
gtk_misc_set_alignment(GTK_MISC(lab), 0, 0);
@@ -588,7 +590,7 @@ add_header_gchar(BalsaMessage * bm, GtkGrid * grid,
gtk_grid_attach(grid, hbox, 1, row, 1, 1);
}
- pango_attr_list_unref(attr_list);
+ pango_font_description_free(font_desc);
}
static void
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index af3fed4..0575a02 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -193,7 +193,8 @@ balsa_mime_widget_new_text(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(mw->widget), GTK_WRAP_WORD_CHAR);
/* set the message font */
- bm_modify_font_from_string(mw->widget, balsa_app.message_font);
+ if (!balsa_app.use_system_fonts)
+ bm_modify_font_from_string(mw->widget, balsa_app.message_font);
if (libbalsa_message_body_is_flowed(mime_body)) {
/* Parse, but don't wrap. */
@@ -336,8 +337,9 @@ create_text_widget(const char * content_type)
static void
bm_modify_font_from_string(GtkWidget * widget, const char *font)
{
- PangoFontDescription *desc =
- pango_font_description_from_string(balsa_app.message_font);
+ PangoFontDescription *desc;
+
+ desc = pango_font_description_from_string(font);
gtk_widget_override_font(widget, desc);
pango_font_description_free(desc);
}
diff --git a/src/pref-manager.c b/src/pref-manager.c
index 30b881f..83907aa 100644
--- a/src/pref-manager.c
+++ b/src/pref-manager.c
@@ -145,8 +145,11 @@ typedef struct _PropertyUI {
/* arp */
GtkWidget *quote_str;
+ GtkWidget *use_system_fonts; /* toggle button */
+ GtkWidget *message_font_label; /* label */
GtkWidget *message_font_button; /* font used to display messages */
- GtkWidget *subject_font_button; /* font used to display messages */
+ GtkWidget *subject_font_label; /* label */
+ GtkWidget *subject_font_button; /* font used to display subjects */
GtkWidget *use_default_font_size; /* toggle button */
GtkWidget *date_format;
@@ -365,6 +368,7 @@ static void browse_modified_cb(GtkWidget * widget, GtkWidget * pbox);
static void mark_quoted_modified_cb(GtkWidget * widget, GtkWidget * pbox);
static void wrap_modified_cb(GtkWidget * widget, GtkWidget * pbox);
+static void use_system_fonts_cb(GtkWidget * widget, GtkWidget * pbox);
static void font_modified_cb(GtkWidget * widget, GtkWidget * pbox);
static void default_font_size_cb(GtkWidget * widget, GtkWidget * pbox);
@@ -697,6 +701,8 @@ open_preferences_manager(GtkWidget * widget, gpointer data)
property_box);
/* message font */
+ g_signal_connect(G_OBJECT(pui->use_system_fonts), "toggled",
+ G_CALLBACK(use_system_fonts_cb), property_box);
g_signal_connect(G_OBJECT(pui->message_font_button), "font-set",
G_CALLBACK(font_modified_cb), property_box);
g_signal_connect(G_OBJECT(pui->subject_font_button), "font-set",
@@ -994,6 +1000,10 @@ apply_prefs(GtkDialog * pbox)
balsa_app.quote_str =
g_strdup(gtk_entry_get_text(GTK_ENTRY(pui->quote_str)));
+ /* fonts */
+ balsa_app.use_system_fonts =
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+ (pui->use_system_fonts));
check_font_button(pui->message_font_button, &balsa_app.message_font);
check_font_button(pui->subject_font_button, &balsa_app.subject_font);
@@ -2369,9 +2379,9 @@ font_button_check_font_size(GtkWidget * button, GtkWidget * widget)
static gboolean
attach_font_button(const gchar * label, gint row, GtkGrid * grid,
GtkWidget * page, const gchar * font,
- GtkWidget ** button)
+ GtkWidget ** label_widget, GtkWidget ** button)
{
- attach_label(label, grid, row, page);
+ *label_widget = attach_label(label, grid, row, page);
*button = gtk_font_button_new_with_font(font);
gtk_widget_set_hexpand(*button, TRUE);
@@ -2394,26 +2404,41 @@ preview_font_group(GtkWidget * page)
GtkWidget *group;
GtkGrid *grid;
gboolean use_default_font_size = FALSE;
+ gint row;
group = pm_group_new(_("Fonts"));
grid = (GtkGrid *) create_grid(page);
pm_group_add(group, (GtkWidget *) grid, FALSE);
- if (attach_font_button(_("Message font:"), 0, grid, page,
+ row = 0;
+ pui->use_system_fonts =
+ gtk_check_button_new_with_label(_("Use system fonts"));
+ gtk_widget_set_hexpand(pui->use_system_fonts, TRUE);
+ gtk_grid_attach(grid, pui->use_system_fonts,
+ 0, row, 2, 1);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->use_system_fonts),
+ balsa_app.use_system_fonts);
+
+ ++row;
+ if (attach_font_button(_("Message font:"), row, grid, page,
balsa_app.message_font,
+ &pui->message_font_label,
&pui->message_font_button))
use_default_font_size = TRUE;
- if (attach_font_button(_("Subject font:"), 1, grid, page,
+ ++row;
+ if (attach_font_button(_("Subject font:"), row, grid, page,
balsa_app.subject_font,
+ &pui->subject_font_label,
&pui->subject_font_button))
use_default_font_size = TRUE;
+ ++row;
pui->use_default_font_size =
gtk_check_button_new_with_label(_("Use default font size"));
gtk_widget_set_hexpand(pui->use_default_font_size, TRUE);
gtk_grid_attach(grid, pui->use_default_font_size,
- 0, 2, 2, 1);
+ 0, row, 2, 1);
if (use_default_font_size) {
gtk_font_button_set_show_size(GTK_FONT_BUTTON
@@ -2424,6 +2449,14 @@ preview_font_group(GtkWidget * page)
(pui->use_default_font_size), TRUE);
}
+ if (balsa_app.use_system_fonts) {
+ gtk_widget_set_sensitive(pui->message_font_label, FALSE);
+ gtk_widget_set_sensitive(pui->message_font_button, FALSE);
+ gtk_widget_set_sensitive(pui->subject_font_label, FALSE);
+ gtk_widget_set_sensitive(pui->subject_font_button, FALSE);
+ gtk_widget_set_sensitive(pui->use_default_font_size, FALSE);
+ }
+
return group;
}
@@ -3367,6 +3400,21 @@ convert_8bit_cb(GtkWidget * widget, GtkWidget * pbox)
*/
static void
+use_system_fonts_cb(GtkWidget * widget, GtkWidget * pbox)
+{
+ gboolean use_custom_fonts =
+ !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
+ properties_modified_cb(widget, pbox);
+
+ gtk_widget_set_sensitive(pui->message_font_label, use_custom_fonts);
+ gtk_widget_set_sensitive(pui->message_font_button, use_custom_fonts);
+ gtk_widget_set_sensitive(pui->subject_font_label, use_custom_fonts);
+ gtk_widget_set_sensitive(pui->subject_font_button, use_custom_fonts);
+ gtk_widget_set_sensitive(pui->use_default_font_size, use_custom_fonts);
+}
+
+static void
font_modified_cb(GtkWidget * widget, GtkWidget * pbox)
{
gboolean show_size =
diff --git a/src/save-restore.c b/src/save-restore.c
index a77c555..8cf08ee 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -752,6 +752,8 @@ config_global_load(void)
load_color("UrlColor", DEFAULT_URL_COLOR, &balsa_app.url_color);
/* ... font used to display messages */
+ balsa_app.use_system_fonts =
+ libbalsa_conf_get_bool("UseSystemFonts=false");
g_free(balsa_app.message_font);
balsa_app.message_font =
libbalsa_conf_get_string("MessageFont=" DEFAULT_MESSAGE_FONT);
@@ -1273,6 +1275,7 @@ config_save(void)
libbalsa_mailbox_get_threading_type(NULL));
libbalsa_conf_set_bool("MarkQuoted", balsa_app.mark_quoted);
libbalsa_conf_set_string("QuoteRegex", balsa_app.quote_regex);
+ libbalsa_conf_set_bool("UseSystemFonts", balsa_app.use_system_fonts);
libbalsa_conf_set_string("MessageFont", balsa_app.message_font);
libbalsa_conf_set_string("SubjectFont", balsa_app.subject_font);
libbalsa_conf_set_bool("WordWrap", balsa_app.browse_wrap);
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 25bd26f..d63e636 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -2602,7 +2602,6 @@ static void
create_email_or_string_entry(GtkWidget * grid, const gchar * label,
int y_pos, GtkWidget * arr[])
{
- PangoFontDescription *desc;
GtkWidget *mnemonic_widget;
mnemonic_widget = arr[1];
@@ -2615,9 +2614,13 @@ create_email_or_string_entry(GtkWidget * grid, const gchar * label,
GNOME_PAD_SMALL);
gtk_grid_attach(GTK_GRID(grid), arr[0], 0, y_pos, 1, 1);
- desc = pango_font_description_from_string(balsa_app.message_font);
- gtk_widget_override_font(arr[1], desc);
- pango_font_description_free(desc);
+ if (!balsa_app.use_system_fonts) {
+ PangoFontDescription *desc;
+
+ desc = pango_font_description_from_string(balsa_app.message_font);
+ gtk_widget_override_font(arr[1], desc);
+ pango_font_description_free(desc);
+ }
gtk_widget_set_hexpand(arr[1], TRUE);
gtk_grid_attach(GTK_GRID(grid), arr[1], 1, y_pos, 1, 1);
@@ -3220,7 +3223,6 @@ static GtkWidget *
create_text_area(BalsaSendmsg * bsmsg)
{
GtkTextView *text_view;
- PangoFontDescription *desc;
GtkTextBuffer *buffer;
GtkWidget *scroll;
@@ -3234,9 +3236,13 @@ create_text_area(BalsaSendmsg * bsmsg)
gtk_text_view_set_right_margin(text_view, 2);
/* set the message font */
- desc = pango_font_description_from_string(balsa_app.message_font);
- gtk_widget_override_font(bsmsg->text, desc);
- pango_font_description_free(desc);
+ if (!balsa_app.use_system_fonts) {
+ PangoFontDescription *desc;
+
+ desc = pango_font_description_from_string(balsa_app.message_font);
+ gtk_widget_override_font(bsmsg->text, desc);
+ pango_font_description_free(desc);
+ }
buffer = gtk_text_view_get_buffer(text_view);
#if (HAVE_GTKSOURCEVIEW == 1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]