Re: Combobox and columns



That should be the solution. Meanwhile I found my exactly problem and
the solution
here:     http://www.mrunix.de/forums/archive/index.php/t-41532.html

This is the same as from you but in C.
I will try now in my code...

Thanks a million,
Axel

Am 03.04.2017 um 02:24 schrieb Daniel Kasak:
This bit is a little non-obvious. The related documentation is:
https://developer.gnome.org/gtk3/stable/GtkCellLayout.html#gtk-cell-layout-set-attributes

So you can pass various attributes into the renderer / cell layout /
whatever. I'm still slightly confused by it, but I can make it work :)

In perl, I have a convenience method for setting up renderers for
combos with multi-column models:

---

sub create_combo_renderers {

    my ( $self, $widget, $text_column, $icon_column ) = @_;

    if ( $icon_column ) {
        my $renderer = Gtk3::CellRendererPixbuf->new;
        $widget->pack_start( $renderer, FALSE );
        $widget->set_attributes( $renderer, pixbuf => $icon_column );
    }

    my $renderer = Gtk3::CellRendererText->new;
    $widget->pack_start( $renderer, FALSE );
    $widget->set_attributes( $renderer, text => $text_column );

}

---

It's the last line:
$widget->set_attributes( $renderer, text => $text_column );
 ... that tells the renderer / cell layout which column to use.

Dan


On Mon, Apr 3, 2017 at 8:33 AM, Eric Cashon via gtk-list
<gtk-list gnome org> wrote:
Hi Axel,

How do you want to change the list column combo in your program?

If you use a combo2 box row to change a combo1 box column from a list you
might have a "changed" callback that looks something like the following.

Eric

...
GtkCellRenderer *renderer=NULL;
...
renderer=gtk_cell_renderer_text_new();
...
static void change_column(GtkComboBox *combo2, GtkComboBox *combo1)
  {
    gint row=gtk_combo_box_get_active(combo2);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo1),
GTK_CELL_RENDERER(renderer), "text", row, NULL);
    gtk_widget_queue_draw(GTK_WIDGET(combo1));
  }



-----Original Message-----
From: axel <axel voges freenet de>
To: gtk-list <gtk-list gnome org>
Sent: Sun, Apr 2, 2017 6:39 am
Subject: Combobox and columns

Have a liststore with 4 columns. And a combobox with a cellrenderer.
UI made with Glade. Programm is written in C.

How to choose one of the columns out of the liststore to use/show in the
combobox?
I can set in Glade the actual column but I need it to be done on runtime.



Cheers,
Axel

_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]