]> git.armaanb.net Git - chorizo.git/commitdiff
draft 3
authorArmaan Bhojwani <me@armaanb.net>
Wed, 20 Oct 2021 01:17:16 +0000 (21:17 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Wed, 20 Oct 2021 01:17:16 +0000 (21:17 -0400)
browser.c

index b35d383ae76e3c8164dea37ee8f9cd94bcffb4fd..84a2a4a3a1dad2c0a8a78dadf086c3e2be90ee82 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -264,7 +264,7 @@ client_new(const gchar *uri, WebKitWebView *related_wv, gboolean show,
                gtk_box_pack_end(GTK_BOX(locbox), privindicator, FALSE, FALSE,
                                 5);
        }
-       gtk_box_pack_start(GTK_BOX(locbox), c->jsbutton, FALSE, FALSE, 5);
+       gtk_box_pack_start(GTK_BOX(locbox), c->jsbutton, FALSE, FALSE, 0);
 
        g_signal_connect(G_OBJECT(c->location), "key-press-event",
                         G_CALLBACK(key_location), c);
@@ -525,20 +525,14 @@ changed_uri(GObject *obj, GParamSpec *pspec, gpointer data)
        FILE *fp;
        t = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
 
-       /*
-       * When a web process crashes, we get a "notify::uri" signal, but we
-       * can no longer read a meaningful URI. It's just an empty string
-       * now. Not updating the location bar in this scenario is important,
-       * because we would override the "WEB PROCESS CRASHED" message.
-       */
        if (t != NULL && strlen(t) > 0) {
                set_uri(t, c);
 
                //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(),
+                                                state_env :
+                                                g_build_filename(g_get_home_dir(),
                                                            ".local", "state",
                                                            "chorizo", NULL);
 
@@ -558,15 +552,19 @@ changed_uri(GObject *obj, GParamSpec *pspec, gpointer data)
                g_free(state_dir);
        }
 }
+
 gboolean
 crashed_web_view(WebKitWebView *web_view, gpointer data)
 {
-       gchar *t;
        struct Client *c = (struct Client *)data;
-       t = g_strdup_printf("WEB PROCESS CRASHED: %s",
-                           webkit_web_view_get_uri(WEBKIT_WEB_VIEW(web_view)));
-       gtk_entry_set_text(GTK_ENTRY(c->location), t);
-       g_free(t);
+       GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
+       GtkWidget *dialog = gtk_message_dialog_new(
+               GTK_WINDOW(c->vbox), flags, GTK_MESSAGE_ERROR,
+               GTK_BUTTONS_CLOSE, "ERROR: Web process %s crashed.",
+               webkit_web_view_get_uri(WEBKIT_WEB_VIEW(web_view)),
+               g_strerror(errno));
+       gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_destroy(dialog);
 
        return TRUE;
 }
@@ -734,7 +732,7 @@ init_default_web_context(void)
        WebKitWebContext *wc;
        WebKitCookieManager *cm;
        wc = (cfg.private) ? webkit_web_context_new_ephemeral() :
-                            webkit_web_context_get_default();
+                                  webkit_web_context_get_default();
 
        p = g_build_filename(g_get_user_config_dir(), "chorizo", "adblock",
                             NULL);
@@ -865,7 +863,7 @@ key_common(GtkWidget *widget, GdkEvent *event, gpointer data)
                                        "document.activeElement.blur();",
                                        NULL, NULL, c);
                                return TRUE;
-                       } else if (GDK_KEY_r == key) {
+                       } else if (GDK_KEY_semicolon == key) {
                                webkit_web_view_reload_bypass_cache(
                                        WEBKIT_WEB_VIEW(c->web_view));
                                return TRUE;
@@ -1284,7 +1282,7 @@ main(int argc, char **argv)
 
        gtk_init(&argc, &argv);
 
-       //Keep clipboard contents after program closes
+       // Keep clipboard contents after program closes
        gtk_clipboard_store(gtk_clipboard_get_for_display(
                gdk_display_get_default(), GDK_SELECTION_CLIPBOARD));