]> git.armaanb.net Git - chorizo.git/commitdiff
Remove GtkLevelBar, use bar included in GtkEntry
authorPeter Hofmann <scm@uninformativ.de>
Sun, 29 Jan 2017 12:06:47 +0000 (13:06 +0100)
committerPeter Hofmann <scm@uninformativ.de>
Sun, 29 Jan 2017 12:22:16 +0000 (13:22 +0100)
I was still seeing this warning whenever the GtkLevelBar was set to a
value of 0:

    Negative content width -2 (allocation 0, extents 1x1) while
    allocating gadget (node block, owner GtkLevelBar)

This happens even in a minimal test program:

    #include <gtk/gtk.h>

    int
    main(int argc, char **argv)
    {
        GtkWidget *win, *progress;

        gtk_init(&argc, &argv);

        win = gtk_window_new(GTK_WINDOW_TOPLEVEL);

        progress = gtk_level_bar_new();
        gtk_level_bar_set_value(GTK_LEVEL_BAR(progress), 0);

        gtk_container_add(GTK_CONTAINER(win), progress);
        gtk_widget_show_all(win);
        gtk_main();
    }

It would appear that it's illegal to call gtk_level_bar_set_value() with
a value of 0. Or, and that's just as likely, I don't understand how a
GtkLevelBar is supposed to work. You don't even have to call
gtk_level_bar_set_value() at all, since 0 is the default value of such a
bar.

All of this doesn't really matter, though, since GtkEntry has a built-in
progress bar that we can use.

CC #20.

CHANGES
browser.c

diff --git a/CHANGES b/CHANGES
index 175205c4fd696f1b74a06deb6b3db455ac82b8a4..7bb3ea55101532bc15a691e38342005f0ca71585 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,10 @@ next
   - Lariza now uses WebKit's multi-process model. This means that (most)
     tabs run as independent processes. If one tab crashes, it should not
     affect the others.
+  - The GtkLevelBar to show page loading progress has been removed.
+    Instead, we now use the progress bar which is already included in
+    GtkEntry (the input box). This is mostly a cosmetic change, but it
+    also eliminates some GTK warnings.
 
   [Added]
   - An external user-supplied program can be called for the current URI
index 39ce18a496633e543b677acb86d8f289da4b6ffc..c71ad56109b9c281e97cb0bc8d38473e229af33f 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -55,8 +55,6 @@ struct Client
     gchar *external_handler_uri;
     gchar *hover_uri;
     GtkWidget *location;
-    GtkWidget *progress;
-    GtkWidget *top_box;
     GtkWidget *vbox;
     GtkWidget *web_view;
     GtkWidget *win;
@@ -207,17 +205,8 @@ client_new(const gchar *uri, WebKitWebView *related_wv, gboolean show)
     g_signal_connect(G_OBJECT(c->location), "key-press-event",
                      G_CALLBACK(key_location), c);
 
-    /* XXX Progress bars don't work/look as intended anymore. Level bars
-     * are a dirty workaround (kind of). */
-    c->progress = gtk_level_bar_new();
-    gtk_level_bar_set_value(GTK_LEVEL_BAR(c->progress), 1);
-
-    c->top_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-    gtk_box_pack_start(GTK_BOX(c->top_box), c->location, TRUE, TRUE, 0);
-    gtk_box_pack_start(GTK_BOX(c->top_box), c->progress, FALSE, FALSE, 0);
-
     c->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-    gtk_box_pack_start(GTK_BOX(c->vbox), c->top_box, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(c->vbox), c->location, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(c->vbox), c->web_view, TRUE, TRUE, 0);
 
     gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
@@ -327,7 +316,7 @@ changed_load_progress(GObject *obj, GParamSpec *pspec, gpointer data)
     gdouble p;
 
     p = webkit_web_view_get_estimated_load_progress(WEBKIT_WEB_VIEW(c->web_view));
-    gtk_level_bar_set_value(GTK_LEVEL_BAR(c->progress), p);
+    gtk_entry_set_progress_fraction(GTK_ENTRY(c->location), p);
 }
 
 void
@@ -769,7 +758,7 @@ key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data)
         if (((GdkEventKey *)event)->keyval == GDK_KEY_Escape)
         {
             webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(c->web_view));
-            gtk_level_bar_set_value(GTK_LEVEL_BAR(c->progress), 0);
+            gtk_entry_set_progress_fraction(GTK_ENTRY(c->location), 0);
         }
     }
     else if (event->type == GDK_BUTTON_PRESS)