On Jan 5, 2007, at 9:57 PM, Michael McGinn wrote:
> This is my first email to the distribution list and I am new to
> Gtk2-perl.
Welcome!
> The first question is related to manipulating an array in a
> SimpleList/TreeView. I’m having trouble figuring out how to
> identify which row or rows have been selected. Once the row is
> selected I want to either insert an additional row or delete the
> row. These actions will be triggered by a signal from a popup menu
> which contains an Insert Row and Delete Row option.
>
> I created the SimpleList and populated it with data and have
> created the popup menu tied to the SimpleList. The only thing that
> seems to be missing is identifying the selected row so I can pass
> it to ‘splice’ for a delete or do whatever else is required.
You can get the indices of the selected row or rows with
Gtk2::Ex::Simple::List::get_selected_indices():
my @selected = $slist->get_selected_indices;
These are the zero-based index numbers of the row array, suitable for
use with slice().
You can also use conventional gtk+ methods, based on the
TreeSelection object:
my $selection = $slist->get_selection; # SimpleList isa
TreeView, you see
my $n_selected = $selection->count_selected_rows;
my @paths = $selection->get_selected_rows; # returns a list of
TreePath objects
These are described in the Gtk2::Ex::Simple::List (or deprecated
Gtk2::SimpleList) and Gtk2::TreeSelection manpages, respectively.
> The second question is related to manipulating the columns of a
> SimpleList/TreeView. I can’t figure out how to move or resize a
> column. I have set the column to resizable and have made the column
> clickable.
You also need to make the TreeViewColumn "reorderable":
$column->set_reorderable (TRUE);
or, using object properties,
$column->set (reorderable => TRUE);
You can fetch columns with either $treeview->get_column($index) or
@ary = $treeview->get_columns, so something like
foreach my $column ($slist->get_columns) {
$column->set (resizable => TRUE,
clickable => TRUE,
reorderable => TRUE);
}
should get you going easily.
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeViewColumn.html#gtk-
tree-view-column-set-reorderable
Note that reordering the view columns has no effect on the model.
> The third question is related to updating a TextView as activity is
> progressing. Currently the TextView display is only updated after
> the processing is finished. I have a number of separate functions
> that make system calls and I want to be able to update the TextView
> to reflect the activity at the time and not wait until it’s all
> complete.
You're not returning control the main loop, which is where screen
updates happen. Instead of system() or backticks, use a pipe-open
and an IO watch, as described in the faq:
"How do I keep my GUI updating while doing a long file read?"
http://live.gnome.org/GTK2-Perl/
FrequentlyAskedQuestions#head-20b1c1d3a92f0c61515cb88d15e06b686eba6cbc
There are several threads discussing this very topic on the mailing
list (hence its inclusion in the faq ;-), which may help with the
fine details.
http://www.google.com/search?q=site:mail.gnome.org+gtk-perl-list+io
+watch
_______________________________________________
gtk-perl-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list