Chris,
  If I interpret what you are trying to do correctly (not necessarily a
given), then I would have thought that GtkScrolledWindow (possibly in
conjunction with GtkViewport) would be the tool for the job.

James


On 26 January 2014 14:50, Chris Angelico <ros...@gmail.com> wrote:

> My application has a status bar which can have an arbitrary number of
> items added to it. Currently, I use an Hbox with no padding, which
> works fine as long as there aren't too many statusbar elements added;
> but if there are a lot, the tail starts wagging the dog, in that the
> size of the window becomes dictated by the status bar (which normally
> is supposed to be subtle, not intrusive/controlling). So I figured
> that wrapping elements onto another line of status bar would be a more
> useful way to lay them out, but that's really tricky. Enter TextView:
> it's a widget designed to handle wrapping, and it can have child
> widgets embedded in it.
>
> Here's some proof of concept code. (This is in Pike, so you may not be
> able to run it directly.)
>
> int main()
> {
>     GTK2.setup_gtk();
>     object
> buf=GTK2.TextBuffer(),view=GTK2.TextView(buf)->set_editable(0)->set_wrap_mode(GTK2.WRAP_WORD)->set_cursor_visible(0);
>     view->modify_base(GTK2.STATE_NORMAL,GTK2.GdkColor(240,240,240));
>     foreach (({"Asdf asdf","Qwer qwer","Zxcv zxcv","Testing,
> testing","1, 2, 3, 4"}),string x)
>     {
>
> view->add_child_at_anchor(GTK2.Frame()->add(GTK2.Label(x))->set_shadow_type(GTK2.SHADOW_ETCHED_OUT),
>             buf->create_child_anchor(buf->get_end_iter()));
>         buf->insert(buf->get_end_iter(),"  ",-1);
>     }
>
> GTK2.Window(GTK2.WindowToplevel)->set_default_size(500,300)->add(GTK2.Vbox(0,0)
>         ->add(GTK2.Label("Blah blah blah, this\nhas lots and\nlots of
> content\n\nLorem ipsum dolor sit\namet"))
>         ->pack_start(GTK2.Button("This sets the base width"),0,0,0)
>         ->pack_start(view,0,0,0)
>     )->show_all()->signal_connect("delete-event",lambda() {exit(0);});
>     return -1;
> }
>
> Two questions.
>
> Firstly: Is this a really REALLY stupid thing to do? When I Googled
> for a wrapping layout manager, nothing mentioned this possibility, so
> I'm wondering if this is somehow fundamentally bad and I just haven't
> seen it.
>
> And secondly: The TextArea defaults to having a white background, but
> I want to use the window's default background. On my system, setting
> the color to (240,240,240) does that, but that means I'm explicitly
> setting a color, so it's going to be grey even if the UI theme
> specifies that a window's background should be vibrant orange. Is
> there a way to tell the TextView not to draw its background, or
> alternatively, a way to query the default background color for a
> window?
>
> Thanks in advance!
>
> ChrisA
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to