GtkTreeView does not show data after clear()

2016-11-25 Thread David Lowrence
I'm writing a program in gtk3-perl and am experiencing a problem with a
TreeView that does not display a second load of data after a clear().
FWIW, I'm doing a customer search, and this sub is run if there are
multiple results from a search on a name.

 I am including the code below where this happens..  I'm using xml
generated by glade and loading it with GtkBuilder.  Notice that I'm using
clear() before the first display, on an empty ListStore, and the first pass
displays correctly.  If I do a subsequent search, the dialog shows with the
header for the TreeView, but nothing is shown.  If I eliminate the clear(),
then the data from the previous search is shown (as expected), with the
result of the second search appended, but when clear() is executed, the
data is blank.

I've used the same procedure with Gtk2 in another program, and it worked,
and, in fact, I edited this file to use Gtk2, and edited the .glade file
until it didn't produce errors on load and this worked.  I even rewrote the
program in C, and it works as expected.  Admittedly, when I experimented
with Gtk2, I simply deleted properties and things in the glade file and the
output was not correct, bu6 I don't believe I eliminated anything that
would have corrected the problem.

Of course AFAIK, there is no documentation as of yet for Gtk3-Perl, and I
could be using some incorrect code, but I truly feel that there's a bug in
the Gtk3 code that is doing this.

I've been a bit longwinded, but, to summarize, when $dlg is run the first
time, the tree view displays the data, but on a second pass, after dlear()
ing, nothing (except for the column headers) is shown.

The database engine I'm using is DBI with DBD::Pg (postgresql)

sub select_cust_from_ids {
my $ids = shift;# A list of ID's to search for in the database

#   'dlg_customer_view_multi' is a dialog defined in the glade file.  it is
a dialog
#containing a treeview with its ListStore Model and its columns defined
also in
#the glade file.
my $dlg = $builder->get_object ('dlg_customer_view_multi');
my $view = $builder->get_object ('treeview_customer_data');

# First build a list of placeholders for the query
my @placeholders;

foreach (@$ids) {
push @placeholders, 'cust_id = ?';
}

my $qry = qq/SELECT lastname,firstname,coalesce(mi,''),streetaddr,/ .
qq/city,state,zip,cust_id FROM poolsalesfullview WHERE / .
join (' OR ', @placeholders);

my $custs = $dbh->selectall_arrayref ($qry, undef, @$ids);
   unless ($custs) {
my $msg = 'No data was retrieved...';

if ($dbh->err) {
$msg .= "\n" . $dbh->errstr;
}

my $d = Gtk3::MessageDialog->new ($w_main, 'destroy-with-parent',
'notice', 'gtk-ok', $msg);
$d->run;
$d->destroy;
return;
}

my $m = $view->get_model;
$m->clear;

foreach my $row (@$custs) {
my $iter = $view->get_model->append();

unless ($view->get_model->iter_is_valid($iter)) {
my $d = MessageDialog->new ($dlg, 'destroy-with-parent',
:'warning', 'gtk-close',
'Invalid iter for TreeView');
return;
}

my (@cols, @vals);
my @parms = ($iter);

for (my $x = 0; $x < scalar (@$row); $x++) {
#push(@cols, $x); push (@vals, $row->[$x]);
push (@parms, $x => $row->[$x]);
}

#$view->get_model->set ($iter, \@cols, \@vals);
$view->get_model->set(@parms);
}

# -- Testing --
#this displays the correct data in the second pass
#so it appears that the Liststore itself is being populated correctly
#it seems that somehow, the treeview is losing its relation to the Model
#when the ListStore is clear()-ed when data is in it.

#my $it = $view->get_model->get_iter_first;
#
#while ($it) {
#my ($l,$f);
#$l = $view->get_model->get_value($it, 0);
#$f = $view->get_model->get_value($it, 1);
#print "$f $l\n";
#
#unless ($view->get_model->iter_next($it)) {
#$it = undef;
#}
#} print "\n";
# -- Testing --

$dlg->run;
$dlg->hide;
}
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: "Not a CODE reference" error with Gtk::Bus::add_watch

2016-11-25 Thread Torsten Schoenfeld
On 21.11.2016 23:09, Wouter Verhelst wrote:
> I didn't know about "perli11ndoc", thanks!

If you haven't seen it yet, run "perli11ndoc" without arguments to start
the GUI.
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: GtkTreeView does not show data after clear()

2016-11-25 Thread Torsten Schoenfeld
On 22.11.2016 02:35, David Lowrence wrote:
> Of course AFAIK, there is no documentation as of yet for Gtk3-Perl, and
> I could be using some incorrect code, but I truly feel that there's a
> bug in the Gtk3 code that is doing this.

Well, as always, the C docs are relevant.  Plus, there is "perli11ndoc"
and there are some tutorials; see the newly updated (thanks, Brian!)
 for pointers.

> I've been a bit longwinded, but, to summarize, when $dlg is run the
> first time, the tree view displays the data, but on a second pass, after
> dlear() ing, nothing (except for the column headers) is shown.

It does sound strange that the problem vanishes when you port to Gtk2 or
to C.  The binding for gtk_list_store_clear is trivial, so I think the
problem originates elsewhere.  Can you try to run your program under
"valgrind"?

  valgrind --tool=memcheck perl app.pl

If this doesn't turn up anything obvious, I'd need a minimal standalone
example program that exhibits the problem to investigate further.
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: GtkTreeView does not show data after clear()

2016-11-25 Thread Daniel Kasak
You might want to check out one of my projects - Gtk3::Ex::DBI.

Example constructor:

$self->{param} = Gtk3::Ex::DBI::Datasheet->new(
{
dbh => $self->{globals}->{connections}->{CONTROL}
  , sql => {
  select=> "TEMPLATE_NAME,
PARAM_NAME, PARAM_DESC, PARAM_DEFAULT"
, from  => "param"
, order_by  => "PARAM_NAME"
   }
  , force_upper_case_fields => 1
  , primary_keys=> [ "TEMPLATE_NAME", "PARAM_NAME" ]
  #, dont_update_keys=> 1
  , auto_incrementing   => 0
  , fields  => [
{
name=> "TEMPLATE_NAME"
  , renderer=> "hidden"
  , dont_update => 1
}
  , {
name=> "PARAM_NAME"
  , x_percent   => 30
}
  , {
name=> "PARAM_DESC"
  , x_percent   => 40
}
  , {
name=> "PARAM_DEFAULT"
  , x_percent   => 30
}
]
  , vbox=> $self->{builder}->get_object( "param" )
  , recordset_tools_box => $self->{builder}->get_object(
"PARAM_recordset_tools" )
  , before_insert   => sub { $self->before_param_insert }
  , on_insert   => sub { $self->on_param_insert }
} );

Here's a screenshot of what the above code produces ( it's from an ETL
framework I'm hopefully open-sourcing soon ):
http://tesla.duckdns.org/downloads/param.jpg

The 'vbox' is a Gtk3::Box in your glade window where a datasheet will
be created.
The 'recordset_tools_box' is a Gtk3::Box where a set of buttons will
be created - apply, insert, delete, undo.

In this example, I'm injecting primary keys in because they're not
defined in the database ( data warehouse appliance that doesn't
enforce keys ), but if you have PKs defined in the database, they're
detected and used.

I seriously need to update my website / docs, but for now, install
from cpan and give it a spin, and let me know if you have any
questions.

Dan

On Tue, Nov 22, 2016 at 12:35 PM, David Lowrence  wrote:
> I'm writing a program in gtk3-perl and am experiencing a problem with a
> TreeView that does not display a second load of data after a clear().  FWIW,
> I'm doing a customer search, and this sub is run if there are multiple
> results from a search on a name.
>
>  I am including the code below where this happens..  I'm using xml generated
> by glade and loading it with GtkBuilder.  Notice that I'm using clear()
> before the first display, on an empty ListStore, and the first pass displays
> correctly.  If I do a subsequent search, the dialog shows with the header
> for the TreeView, but nothing is shown.  If I eliminate the clear(), then
> the data from the previous search is shown (as expected), with the result of
> the second search appended, but when clear() is executed, the data is blank.
>
> I've used the same procedure with Gtk2 in another program, and it worked,
> and, in fact, I edited this file to use Gtk2, and edited the .glade file
> until it didn't produce errors on load and this worked.  I even rewrote the
> program in C, and it works as expected.  Admittedly, when I experimented
> with Gtk2, I simply deleted properties and things in the glade file and the
> output was not correct, bu6 I don't believe I eliminated anything that would
> have corrected the problem.
>
> Of course AFAIK, there is no documentation as of yet for Gtk3-Perl, and I
> could be using some incorrect code, but I truly feel that there's a bug in
> the Gtk3 code that is doing this.
>
> I've been a bit longwinded, but, to summarize, when $dlg is run the first
> time, the tree view displays the data, but on a second pass, after dlear()
> ing, nothing (except for the column headers) is shown.
>
> The database engine I'm using is DBI with DBD::Pg (postgresql)
>
> sub select_cust_from_ids {
> my $ids = shift;# A list of ID's to search for in the database
>
> #   'dlg_customer_view_multi' is a dialog defined in the glade file.  it is
> a dialog
> #containing a treeview with its ListStore Model and its columns defined
> also in
> #the glade file.
> my $dlg = $builder->get_object ('dlg_customer_view_multi');
> my $view = $builder->get_object ('treeview_customer_data');
>
> # First build a list of placeholders for the query
> my @placeholders;
>
> foreach (@$ids) {
> push @placeholders, 'cust_id = ?';
> }
>
> my $qry = qq/SELECT lastname,firstname,coalesce(mi,''),streetaddr,/ .
> qq/city,state,zip,cust_id FROM poolsalesfullview WHERE / .
> join (' OR ', @placeholders);
>
> my $custs = $dbh->selectall_arrayref ($qry, undef, @$ids);
>unless ($custs) {
> my $msg = 'No

Re: Updated 'docs' page on Sourceforge

2016-11-25 Thread Brian Manning
On Thu, Nov 24, 2016 at 10:54 PM, Thierry Vignaud
 wrote:
> The title is wrong on
> https://wiki.gnome.org/Projects/GTK-Perl/Introspection
>
> "Introspection for GTK2-Perl"

I think when Torsten first wrote that wiki page, he meant "GTK2-Perl
The Project", and not "GTK2-Perl The Library".

I lack the ability to edit that page; Emmanuele or Torsten, any chance
you can change the heading on that page [1]?

Thanks,

Brian

[1] https://wiki.gnome.org/Projects/GTK-Perl/Introspection
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list