Re: Gtk2::TreeView get_path_at_pos doesn't return array on Windows

2009-07-16 Thread Dave Howorth
Peter Juhasz wrote:
> (I was instructed on Perlmonks to post this problem here.)
> 
> I'm writing a Gtk2-Perl app with a Gtk2::Ex::Simple::List (which is
> derived from TreeView, hence the title).
> 
> I want to set up one of the columns in a special way, specifically, I
> want this column to hold values from a short list, and each click on a
> cell in this column should toggle the next value from the
> pre-specified list. Run the attached code for clarification.
> 
> Obviously, for this I need to know which column did the user click into.

Thanks for the nice example, which works for me on Linux. I don't have a
 M$ box so can't help you with why it doesn't work there. But maybe
there's a neater other way. Have you tried:

 my ($path, $column) = $tslist->get_cursor;

instead of get_path_at_pos() ?

Cheers, Dave
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Gtk2::TreeView get_path_at_pos doesn't return array on Windows

2009-07-16 Thread Dave Howorth
Peter Juhasz wrote:
> On Thu, Jul 16, 2009 at 11:22 AM, Dave
> Howorth wrote:
>> Peter Juhasz wrote:
>>> (I was instructed on Perlmonks to post this problem here.)

And it's best to keep all replies on-list as well :)

> Yes, in fact I've found the get_cursor method because I needed it for
> a different trick.
> 
> Simply put, I want to enable some rudimentary keyboard functionality
> in my Gtk2::Ex::Simple::List.
> The cells of this list are editable if the user double-clicks on them
> but double-clicking on every cell, every time quickly becomes tedious.
> So I want to set it up so that pressing Tab will set the focus on the
> next cell and also open it for editing.
> 
> I can do this by hijacking the key-pressed-event of the list, getting
> the coordinates of the current cell, calculating the coordinates of
> the next cell, then finally setting the cursor on it with
> set_cursor($new_path, $new_column, TRUE).

As a rule of thumb, I've found that it's not necessary to mess around
with co-ordinates. There's always some way to discover the appropriate
widget's identity but the 'fascination' in the game is discovering just
how in each case ;/

> There is only one problem with this: I have to press Enter to get the
> edited contents of the cell registered. If I just press Tab the cell
> forgets what I've just written into it. How could I force the current
> cell to update itself before I move the cursor to the next cell?

Running your example program, if I edit the text in a cell then move to
another cell with a cursor arrow, it saves the edit. If I use TAB it
saves the edit but doesn't move the cursor (probably need to set up tab
navigation?). I need to press enter or space to start to edit a cell. In
short, it doesn't behave exactly like yours.

I don't know much about this aspect but I think the behaviour is linked
to your platform and perhaps themes. Others will know more (hence
keeping it on the list). But be careful changing behaviour away from
whatever standard people expect.

> I've tried to find answers in the documentation but frankly, I can't
> find my way in the POD.

You'll probably find some old mails from me in the archive with a
similar issue :( The Perl POD generally doesn't repeat stuff that's
already in the C docs, to reduce the maintenance tuits needed. So you
definitely need to look at the C docs. I've also found it helpful to
look at the Python docs, since they include a bit more info sometimes
while the binding is similar to Perl. There are also various tutorials
about trees in particular and gtk in general. You should find links in
the archives of this list.

Cheers, Dave
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: Moved to git

2009-07-16 Thread Thierry Vignaud
Torsten Schoenfeld  writes:

> Aloha,
>
> our modules, like the rest of GNOME, recently switched to git for
> revision tracking.  The repositories can now be checked out with
>
>   git clone git://git.gnome.org/[module]
>
> where [module] is perl-Glib, for example.
>
> I suggest that we stop hand-writing ChangeLog entries now.  I've gone
> ahead and implemented the relevant changes in perl-Glib already.  I've
> also created a stable-1-22 branch in perl-Glib so that unstable stuff
> can go into the master branch now.

Btw, this is'snt showed on site news (http://gtk2-perl.sourceforge.net/)
which still advises GNOME's SVN and offers to browse SVN
(http://svn.gnome.org/viewvc/ instead of
http://git.gnome.org/cgit/perl-Gtk2/ and the like ...)
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


Gtk2::Assistant page flow

2009-07-16 Thread Peter Juhasz
There is one more thing (for now, anyway) I'd like to ask your help about.

I want to set up a Gtk2::Assistant. On the first page of the assistant
there is an Entry field. What I'm trying to achieve is that if the
value entered into this field is invalid (empty or already present in
the database), then an error message would pop up and the assistant
would reset to the first page, to let the user correct their mistake.

Here is a minimal example of what I tried:

#
#!/usr/bin/perl

use strict;
use warnings;
use utf8;
use Gtk2 -init;
use Gtk2::Ex::Dialogs;
use Glib ':constants';

my %gui_strings = (
id_empty_error_title => "Error: empty id",
id_empty_error_text => "You did not give a valid identifier.",
assistant1_title => "Id",
assistant2_title => "Confirm",
assistant2_label => "Well done!",
);


my $id;

my $assistant = Gtk2::Assistant->new;
Gtk2::Ex::Dialogs->set_parent_window( $assistant );
$assistant->signal_connect (delete_event => sub { Gtk2->main_quit; });

my $page = Gtk2::Entry->new();
$assistant->append_page ($page);
$assistant->set_page_title ($page, $gui_strings{assistant1_title});
$assistant->set_page_complete ($page, TRUE);
$assistant->set_page_type ($page, 'intro');
$page->show_all;

my $page2 = Gtk2::Label->new($gui_strings{assistant2_label});
$page2->show;
$assistant->append_page ($page2);
$assistant->set_page_title ($page2, $gui_strings{assistant2_title});
$assistant->set_page_complete ($page2, TRUE);
$assistant->set_page_type ($page2, 'confirm');

$assistant->signal_connect (cancel => \&cancel_callback);
$assistant->signal_connect (close => \&cancel_callback);
$assistant->signal_connect (apply => sub {
# do whatever we have to do with the id, here we just print it
print $id."\n";
});
$assistant->signal_connect (prepare => sub {
my $page_num = $assistant->get_current_page();
$id = $page->get_text();
if ($page_num == 1 and $id eq "") {
new_and_run Gtk2::Ex::Dialogs::ErrorMsg ( title =>
$gui_strings{id_empty_error_title},
  text =>
$gui_strings{id_empty_error_text} );
$assistant->set_current_page(0);
return;
}
});

$assistant->show_all;
Gtk2->main;


sub cancel_callback {
  my $widget = shift;

  $widget->destroy;
  Gtk2->main_quit;
}
#


However, there is a problem. When I leave the entry field empty, the
dialog pops up as expected. But what I get after pressing OK on the
dialog is a blank assistant page! Only after pressing Forward again do
I get back my original first page of the assistant.

What am I doing wrong? The problem is consistent on both Linux and
Windows by the way.

(This one is also reposted from Perlmonks)

Thanks:

Péter Juhász
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list