spawn functions?

2012-04-12 Thread haratron
Hello,

it seems that the spawn* functions of Gtk have not been ported to gtk2-perl.
I have this problem where I need to launch an external process from a
button's click callback. It's a TTS (text to speech) application that
has play, pause and stop buttons. The actual speech is been done by a
python script that I need to execute (don't ask..). The GUI in
gtk-perl shouldn't block, so that I am able to e.g. press pause/stop
while the voice speaks. I've tried a lot of ways but it always ends up
to one of the following:
- GUI gets blocked and I can't press pause/stop buttons
- GUI doesn't block (usually when I'm forking from within the
callback) but once the python script is done speaking, the gtk-perl
GUI is closed as well. I read this is a problem of gtk and there are
the spawn* functions to compensate for that.

How can I do this?
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list


RE: Unable To Keep Showing Last Item In Gtk2::TreeView

2012-04-12 Thread Williams, James P2 (N-UNITED SPACE ALLIANCE, LLC)
 Williams, James P2 james.p2.willi...@lmco.com wrote:
  How can I keep my automatic scrolling, even after these kinds of events?
  I’ve tried reacting to various signals, but the tree view seems too stale
  for $tree-get_visible_range() or $tree-scroll_to_cell() to work.
 You might react to size-allocate events, but a slightly different approach
 is necessary. Here's a hack around your test code:

Your suggestion was enough to get something running.  I had to keep track of 
how many items were added, and had to watch for scroll bar changes.  As far as 
I can tell, the scroll bar stays at the bottom now unless I move it, even if I 
resize the window to be shorter.  My modified version follows, for reference.

Thanks,

Jim

#!/usr/bin/perl

use strict;
use warnings;

use Glib qw(TRUE FALSE);
use Gtk2 -init;

my($numAdded)=0;

my($win,$tree)=createWin();
Glib::Timeout-add(1000,sub {tickCB($tree)});

$win-show_all();
Gtk2-main();


#
# Creates the widgets in the application.  Returns the main
# window and tree view.
#
sub createWin
{
   my($win,$scroll,$tree,$model,$mustScroll);


   $win=new Gtk2::Window();
   $win-set_default_size(250,300);
   $win-signal_connect(destroy = \Gtk2::main_quit);

   $win-add($scroll=new Gtk2::ScrolledWindow());
   $scroll-add($tree=new Gtk2::TreeView());
   $tree-set_rules_hint(TRUE);

   $tree-insert_column_with_attributes(-1,'Goo',
  new Gtk2::CellRendererText(),text = 0);
   $tree-set_model($model=
  new Gtk2::ListStore('Glib::String'));

   $tree-signal_connect(
  size_allocate = sub {sizeCB(\$mustScroll,@_)});

   $model-signal_connect(
  row_inserted = sub {rowCB(\$mustScroll,$tree,@_)});

   $scroll-get_vadjustment()-signal_connect(
  value_changed = sub {$numAdded=0});

   addWords($model,100);
   showLast($tree,\$mustScroll);

   return ($win,$tree);
}


#
# Called at regular intervals to add more random words to
# the bottom of the tree view.  If the previous word was
# visible beforehand, scrolls the tree view so the new
# words are visible.
#
sub tickCB
{
   my($tree)=@_;

   addWords($tree-get_model(),100);
   return TRUE;
}


#
# Adds random words to the bottom of the tree view.
#
sub addWords
{
   my($model,$numAdd)=@_;
   my(@cons)=grep !/[aeiou]/,'a' .. 'z';

   for (1 .. $numAdd) {
  $model-set($model-append(),0,
 $cons[rand @cons] . 'oo');
  $numAdded++;
   }
}


#
# Scrolls the tree view so the last row is visible.
#
sub showLast
{
   my($tree,$mustScroll)=@_;
   my($numRows)=$tree-get_model()-iter_n_children(undef);

   $tree-scroll_to_cell(
  new Gtk2::TreePath($numRows-1),undef,TRUE,0.0,1.0);
   $$mustScroll=TRUE;
   $numAdded=0;
}


#
# Called each time the tree view is resized.  This is where
# we correct the scroll bar, moving it to the bottom if
# appropriate.
#
sub sizeCB
{
   my($mustScroll,$tree,$rect)=@_;

   showLast($tree,$mustScroll) if $$mustScroll;
}


#
# Called each time a row is added to the model.
#
sub rowCB
{
   my($mustScroll,$tree,$model,$path,$it)=@_;
   my($numRows)=$model-iter_n_children(undef);
   my($lastVis);


   if ($tree-realized()) {
  $lastVis=($tree-get_visible_range())[1];
  $$mustScroll=$lastVis 
 $lastVis-get_indices() == $numRows-2-$numAdded;
   } else {
  $$mustScroll=TRUE;
   }
}

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


Re: Gtk2::Builder and locales

2012-04-12 Thread Chris Debenham
Does anyone have any ideas on this?
It is rather annoying that locale stuff doesn't work with Gtk2::Builder :(

On 28 March 2012 12:13, Chris Debenham ch...@adebenham.com wrote:

 I recently migrated my app (www.lyricue.org) from Glade to GtkBuilder but
 in the process found that translation of the ui files is not being done.
 Anything I translate directly in code (via 'gettext()' ) works as does any
 of the built-in strings (such as Exit)
 It is like the Gtk2::Builder object is not binding to the domain correctly
 although I have an explicit $builder-set_translation_domain('lyricue') call
 That translating individual strings works suggests that the lyricue.mo
 file is installed correctly and is found so I am not sure what is going on
 here.
 I found a similar/related bug at
 https://bugzilla.gnome.org/show_bug.cgi?id=574520 but I tried replicating
 their solution in perl without success.

 Is anyone else using Gtk2::Builder and if so is i18n working?

 Thanks,
Chris

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