FIXME: In bar_size_allocate() the width obtained...
authorColin Clark <colin.clark@cclark.uk>
Mon, 6 Sep 2021 11:46:57 +0000 (12:46 +0100)
committerColin Clark <colin.clark@cclark.uk>
Mon, 6 Sep 2021 11:46:57 +0000 (12:46 +0100)
Use the setting from the parent GTK_PANED object, instead of the width
of the bar vbox.

src/bar.c
src/bar.h
src/rcfile.c

index 6fd0ee6..fc22b6d 100644 (file)
--- a/src/bar.c
+++ b/src/bar.c
@@ -628,7 +628,7 @@ static void bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpoi
 {
        BarData *bd = data;
 
-       bd->width = allocation->width;
+       bd->width = gtk_paned_get_position(GTK_PANED(bd->lw->utility_paned));
 }
 
 gint bar_get_width(GtkWidget *bar)
@@ -698,7 +698,6 @@ GtkWidget *bar_new(LayoutWindow *lw)
        g_signal_connect(G_OBJECT(bd->widget), "button_release_event", G_CALLBACK(bar_menu_cb), bd);
 
        bd->width = SIDEBAR_DEFAULT_WIDTH;
-       gtk_widget_set_size_request(bd->widget, bd->width, -1);
 
        box = gtk_hbox_new(FALSE, 0);
        DEBUG_NAME(box);
@@ -749,7 +748,7 @@ GtkWidget *bar_new(LayoutWindow *lw)
 }
 
 
-GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values)
+GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values, LayoutWindow *lw)
 {
        gboolean enabled = TRUE;
        gint width = SIDEBAR_DEFAULT_WIDTH;
@@ -766,16 +765,8 @@ GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names,
                log_printf("unknown attribute %s = %s\n", option, value);
                }
 
-#if !GTK_CHECK_VERSION(3,0,0)
-/** @FIXME In bar_size_allocate() the width obtained is the allocated width. In GTK2 this
- * is the actual width. In GTK3 it is the *minimum* width.
- * This results in the info sidebar being able to increase, but not
- * decrease. There does not seem to be a way in GTK3 to get the actual width of
- * a widget. For GTK3 the only way is to disable it. The width of the sidebar
- * is therefore not preserved across restarts.
- */
-       gtk_widget_set_size_request(bar, width, -1);
-#endif
+       gtk_paned_set_position(GTK_PANED(lw->utility_paned), width);
+
        if (enabled)
                {
                gtk_widget_show(bar);
@@ -790,7 +781,7 @@ GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names,
 GtkWidget *bar_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
 {
        GtkWidget *bar = bar_new(lw);
-       return bar_update_from_config(bar, attribute_names, attribute_values);
+       return bar_update_from_config(bar, attribute_names, attribute_values, lw);
 }
 
 GtkWidget *bar_pane_expander_title(const gchar *title)
index 05b4091..12b81d1 100644 (file)
--- a/src/bar.h
+++ b/src/bar.h
@@ -52,7 +52,7 @@ struct _PaneData {
 
 GtkWidget *bar_new(LayoutWindow *lw);
 GtkWidget *bar_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values);
-GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values);
+GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values, LayoutWindow *lw);
 
 void bar_close(GtkWidget *bar);
 
index aeb949a..3cae313 100644 (file)
@@ -1522,7 +1522,7 @@ static void options_parse_layout(GQParserData *parser_data, GMarkupParseContext
                        }
                else
                        {
-                       bar_update_from_config(lw->bar, attribute_names, attribute_values);
+                       bar_update_from_config(lw->bar, attribute_names, attribute_values, lw);
                        }
 
                options_parse_func_push(parser_data, options_parse_bar, NULL, lw->bar);