diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-28 23:34:47 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-28 23:34:47 (EDT) |
commit | 43d623a086877ff5331cc0e4ed56080bd4480da5 (patch) | |
tree | 375149296ea677d078b617883fd0ecd9bc18d494 /src | |
parent | a82d64e491aa41e3f9985f0af0d53cffec2b20e1 (diff) | |
download | marquee-43d623a086877ff5331cc0e4ed56080bd4480da5.zip marquee-43d623a086877ff5331cc0e4ed56080bd4480da5.tar.gz marquee-43d623a086877ff5331cc0e4ed56080bd4480da5.tar.bz2 |
MqWebView: Factor out extension detection code into functions
Diffstat (limited to 'src')
-rw-r--r-- | src/web-view.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/web-view.c b/src/web-view.c index 970cc96..31540b3 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -911,6 +911,32 @@ get_clean_title(MqWebView *web_view) '_'); } +static gboolean +extension_is_html(const gchar *extension) +{ + return + extension[0] == 'h' && + extension[1] == 't' && + extension[2] == 'm' && + (extension[3] == '\0' || + (extension[3] == 'l' && + extension[4] == '\0')); +} + +static gboolean +extension_is_mhtml(const gchar *extension) +{ + return + extension[0] == 'm' && + extension[1] == 'h' && + extension[2] == 't' && + (extension[3] == '\0' || + (extension[3] == 'm' && + (extension[4] == '\0' || + (extension[4] == 'l' && + extension[5] == '\0')))); +} + static void save_type_changed_cb(GtkComboBox *combo_box, GtkFileChooser *chooser) { @@ -924,14 +950,7 @@ save_type_changed_cb(GtkComboBox *combo_box, GtkFileChooser *chooser) active_id = gtk_combo_box_get_active_id(combo_box); if (g_strcmp0(active_id, "html") == 0) { - if (!( - ext[0] == 'h' && - ext[1] == 't' && - ext[2] == 'm' && - (ext[3] == '\0' || - (ext[3] == 'l' && - ext[4] == '\0' - )))) { + if (!extension_is_html(ext)) { /* Extension is not "htm" or "html". */ ext[0] = '\0'; /* Remove extension. */ new_name = g_strconcat(name, "html", NULL); @@ -939,16 +958,7 @@ save_type_changed_cb(GtkComboBox *combo_box, GtkFileChooser *chooser) g_free(new_name); } } else if (g_strcmp0(active_id, "mhtml") == 0) { - if (!( - ext[0] == 'm' && - ext[1] == 'h' && - ext[2] == 't' && - (ext[3] == '\0' || - (ext[3] == 'm' && - (ext[4] == '\0' || - (ext[4] == 'l' && - ext[5] == '\0' - )))))) { + if (!extension_is_mhtml(ext)) { /* Extension is not "mht", "mhtm", or "mhtml". */ ext[0] = '\0'; /* Remove extension. */ new_name = g_strconcat(name, "mhtml", NULL); |