From 32676b06198998a09c9a38097874ce026d85e3c6 Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Fri, 11 Mar 2011 22:20:14 +0000 Subject: filter by directory and some filter fixes --- src/util.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index bd20d14..6cb6e11 100644 --- a/src/util.c +++ b/src/util.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -36,19 +37,20 @@ GRegex *trg_uri_host_regex_new(void) { - return g_regex_new("^[^:/?#]+:?//([^/?#]*)", 0, 0, NULL); + return g_regex_new("^[^:/?#]+:?//([^/?#]*)", G_REGEX_OPTIMIZE, 0, + NULL); } -gchar *trg_uri_host_extract(GRegex *rx, const gchar *uri) +gchar *trg_gregex_get_first(GRegex * rx, const gchar * src) { GMatchInfo *mi = NULL; - gchar *host = NULL; - g_regex_match (rx, uri, 0, &mi); + gchar *dst = NULL; + g_regex_match(rx, src, 0, &mi); if (mi) { - host = g_match_info_fetch(mi, 1); - g_match_info_free (mi); + dst = g_match_info_fetch(mi, 1); + g_match_info_free(mi); } - return host; + return dst; } void trg_error_dialog(GtkWindow * parent, int status, @@ -66,6 +68,17 @@ void trg_error_dialog(GtkWindow * parent, int status, g_free((gpointer) msg); } +gboolean gconf_client_get_bool_or_true(GConfClient * gconf, gchar * key) +{ + GError *error = NULL; + gboolean value = gconf_client_get_bool(gconf, key, &error); + if (error) { + g_error_free(error); + return TRUE; + } + return value; +} + const gchar *make_error_message(JsonObject * response, int status) { if (status == FAIL_JSON_DECODE) { -- cgit v1.2.3