diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-10-02 06:50:33 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-10-02 18:06:02 -0400 |
commit | 2a615e2e458944285578e61fca3f3053a5b2f730 (patch) | |
tree | b94f4e72b52c2e77618a4f2ecb7c683c5c73820c /gtk/gtksidebar.c | |
parent | 7eac2bc4c346ce4401f512fdd8187d0eb9eb3e71 (diff) | |
download | gtk+-2a615e2e458944285578e61fca3f3053a5b2f730.tar.gz |
GtkSidebar: Scroll when needed
Diffstat (limited to 'gtk/gtksidebar.c')
-rw-r--r-- | gtk/gtksidebar.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gtk/gtksidebar.c b/gtk/gtksidebar.c index 6c295507db..bac651aeab 100644 --- a/gtk/gtksidebar.c +++ b/gtk/gtksidebar.c @@ -22,10 +22,12 @@ #include "config.h" #include "gtksidebar.h" + +#include "gtklabel.h" #include "gtklistbox.h" +#include "gtkscrolledwindow.h" #include "gtkseparator.h" #include "gtkstylecontext.h" -#include "gtklabel.h" #include "gtkprivate.h" #include "gtkintl.h" @@ -179,15 +181,24 @@ gtk_sidebar_init (GtkSidebar *sidebar) { GtkStyleContext *style; GtkSidebarPrivate *priv; + GtkWidget *sw; priv = gtk_sidebar_get_instance_private (sidebar); - priv->list = GTK_LIST_BOX (gtk_list_box_new ()); + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_show (sw); + gtk_widget_set_no_show_all (sw, TRUE); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC); - _gtk_bin_set_child (GTK_BIN (sidebar), GTK_WIDGET (priv->list)); - gtk_widget_set_parent (GTK_WIDGET (priv->list), GTK_WIDGET (sidebar)); + _gtk_bin_set_child (GTK_BIN (sidebar), sw); + gtk_widget_set_parent (sw, GTK_WIDGET (sidebar)); + + priv->list = GTK_LIST_BOX (gtk_list_box_new ()); gtk_widget_show (GTK_WIDGET (priv->list)); - gtk_widget_set_no_show_all (GTK_WIDGET (priv->list), TRUE); + + gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (priv->list)); gtk_list_box_set_header_func (priv->list, update_header, sidebar, NULL); gtk_list_box_set_sort_func (priv->list, sort_list, sidebar, NULL); |