[PATCH 2/2] Use subsurface_os_feature_available() to check for unicode stars support

Lubomir I. Ivanov neolit123 at gmail.com
Fri Oct 19 16:31:07 PDT 2012


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

Mainly affecting older Windows (such as XP), which do not have a more
fully featured unicode fonts installed, such as Arial Unicode MS.

With this patch we do a runtime check of the OS version in a couple of
places and if the OS is old, we use the asterix character and spaces instead
of the unicode star characters.

Linux and OSX should be unaffected by this change unless
subsurface_os_feature_available() returns FALSE for UTF8_FONT_WITH_STARS
at some point.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 divelist.c | 4 ++++
 gtk-gui.c  | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/divelist.c b/divelist.c
index 274773d..3e1e94d 100644
--- a/divelist.c
+++ b/divelist.c
@@ -2280,6 +2280,10 @@ GtkWidget *dive_list_create(void)
 	gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE);
 	gtk_widget_set_size_request(dive_list.tree_view, 200, 200);
 
+	/* check if utf8 stars are available as a default OS feature */
+	if (!subsurface_os_feature_available(UTF8_FONT_WITH_STARS))
+		dl_column[3].header = "*";
+
 	dive_list.nr = divelist_column(&dive_list, dl_column + DIVE_NR);
 	dive_list.date = divelist_column(&dive_list, dl_column + DIVE_DATE);
 	dive_list.stars = divelist_column(&dive_list, dl_column + DIVE_RATING);
diff --git a/gtk-gui.c b/gtk-gui.c
index 5fd16d1..f3da8dc 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1018,6 +1018,15 @@ void init_ui(int *argcp, char ***argvp)
 	gtk_settings_set_long_property(settings, "gtk-menu-images", 1, "subsurface setting");
 	gtk_settings_set_long_property(settings, "gtk-button-images", 1, "subsurface setting");
 
+	/* check if utf8 stars are available as a default OS feature */
+	if (!subsurface_os_feature_available(UTF8_FONT_WITH_STARS)) {
+		star_strings[0] = "     ";
+		star_strings[1] = "*    ";
+		star_strings[2] = "**   ";
+		star_strings[3] = "***  ";
+		star_strings[4] = "**** ";
+		star_strings[5] = "*****";
+	}
 	g_type_init();
 
 	subsurface_open_conf();
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list