]> git.armaanb.net Git - chorizo.git/blobdiff - browser.c
draft 8
[chorizo.git] / browser.c
index 1d31c9e71c82d92f7d841fd249b69235bf68b528..93df003240ee8855f62cad9dbc56c951ae324381 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -146,11 +146,13 @@ client_new(const gchar *uri, WebKitWebView *related_wv)
                                if (g_str_has_suffix(path, ".js")) {
                                        g_file_get_contents(path, &source, NULL,
                                                            NULL);
+                                       // clang-format off
                                        wkscript = webkit_user_script_new(
                                                source,
-                                               WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
-                                               WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START,
+                                         WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
+                                   WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START,
                                                NULL, NULL);
+                                       // clang-format on
                                        webkit_user_content_manager_add_script(
                                                ucm, wkscript);
                                        webkit_user_script_unref(wkscript);
@@ -169,13 +171,15 @@ client_new(const gchar *uri, WebKitWebView *related_wv)
                                if (g_str_has_suffix(path, ".css")) {
                                        g_file_get_contents(path, &source, NULL,
                                                            NULL);
+                                       // clang-format off
                                        wkstyle = webkit_user_style_sheet_new(
                                                source,
-                                               WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
-                                               WEBKIT_USER_STYLE_LEVEL_USER,
+                                         WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
+                                                  WEBKIT_USER_STYLE_LEVEL_USER,
                                                NULL, NULL);
-                                       webkit_user_content_manager_add_style_sheet(
+                                   webkit_user_content_manager_add_style_sheet(
                                                ucm, wkstyle);
+                                       // clang-format on
                                        webkit_user_style_sheet_unref(wkstyle);
                                }
                                g_free(path);
@@ -190,9 +194,12 @@ client_new(const gchar *uri, WebKitWebView *related_wv)
 
                c->settings = webkit_web_view_get_settings(
                        WEBKIT_WEB_VIEW(c->web_view));
-               if (cfg.verbose)
-                       webkit_settings_set_enable_write_console_messages_to_stdout(
+               if (cfg.verbose) {
+                       // clang-format off
+               webkit_settings_set_enable_write_console_messages_to_stdout(
                                c->settings, true);
+                       // clang-format on
+               }
                webkit_settings_set_enable_developer_extras(c->settings, TRUE);
        } else {
                c->web_view = webkit_web_view_new_with_related_view(related_wv);
@@ -492,11 +499,7 @@ changed_title(GObject *obj, GParamSpec *pspec, gpointer data)
        u = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
        t = webkit_web_view_get_title(WEBKIT_WEB_VIEW(c->web_view));
 
-       u = u == NULL ? "chorizo" : u;
-       u = u[0] == 0 ? "chorizo" : u;
-
-       t = t == NULL ? u : t;
-       t = t[0] == 0 ? u : t;
+       if (t == NULL) t = (u == NULL) ? "chorizo" : u;
 
        gchar *name = malloc(strlen(t) + 4);
        if (!name) allocfail();
@@ -525,11 +528,13 @@ changed_uri(GObject *obj, GParamSpec *pspec, gpointer data)
 
                // No g_get_user_state_dir unfortunately
                gchar *state_env = getenv("XDG_STATE_DIR");
-               gchar *state_dir = (state_env) ?
-                                                state_env :
-                                                g_build_filename(g_get_home_dir(),
+               // clang-format off
+               gchar *state_dir = (state_env)
+                                       ? state_env
+                                       : g_build_filename(g_get_home_dir(),
                                                            ".local", "state",
                                                            "chorizo", NULL);
+               // clang-format on
 
                gchar *history_file =
                        g_build_filename(state_dir, "history", NULL);
@@ -540,7 +545,8 @@ changed_uri(GObject *obj, GParamSpec *pspec, gpointer data)
                                fprintf(fp, "%s\n", t);
                                fclose(fp);
                        } else {
-                               perror("chorizo: error: could not open history file");
+                               perror("chorizo: error: could not open history"
+                                      "file");
                        }
                }
                g_free(history_file);
@@ -639,7 +645,8 @@ grab_feeds_finished(GObject *object, GAsyncResult *result, gpointer data)
                        jsc_context_get_exception(jsc_value_get_context(value));
                if (exception != NULL) {
                        fprintf(stderr,
-                               "chorizo: warning: error running javascript: %s\n",
+                               "chorizo: warning: error running javascript:"
+                               "%s\n",
                                jsc_exception_get_message(exception));
                } else {
                        c->feed_html = str_value;
@@ -910,11 +917,14 @@ trust_user_certs(WebKitWebContext *wc)
                        g_free(absfile);
                        if (cert == NULL)
                                fprintf(stderr,
-                                       "chorizo: warning: could not load trusted cert: %s\n",
+                                       "chorizo: warning: could not load"
+                                       "trusted cert: %s\n",
                                        file);
                        else
-                               webkit_web_context_allow_tls_certificate_for_host(
+                               // clang-format off
+                             webkit_web_context_allow_tls_certificate_for_host(
                                        wc, cert, file);
+                       // clang-format on
                        file = g_dir_read_name(dir);
                }
                g_dir_close(dir);