Re: [pygtk] 'About' strangeness.

2003-09-02 Thread Christian Reis
On Tue, Sep 02, 2003 at 01:09:09PM +1000, Malcolm Tredinnick wrote:
> Does this clarify things? If not, please sing out, because my psychic
> abilities tell me that Christian may end up using his cut-and-paste
> buttons to drop portions into the FAQ (possibly as an extension to
> 10.6), so it would be good if it was vaguely understandable.

Heh. -> FAQ 10.13

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq10.013.htp

I moved the cruft out from 10.6 into there, and from your explanation
I'm assuming this will happen with any GtkDialog subclass. Correct me if
I'm wrong.

By the way, can't we get a stack trace to show why exactly we crash when
emit_stop_by_name() isn't called in the response handler?

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-02 Thread Christian Reis
On Tue, Sep 02, 2003 at 02:16:15PM +1000, Malcolm Tredinnick wrote:
> > Except, as you've pointed out, that it's used for the Escape key
> > handling. If you catch 'close', the escape key works. Otherwise it's
> > ignored. I like making it go away with an escape key, so I'll keep the
> > close handler.
> 
> Fair enough. The Escape key binding seems pretty non-intuitive to me for
> the About box (it's just a mysterious accelerator with no mouse
> equivalent), so I tend to ignore it. But your view has validity too.

In modal dialogs, Escape is conventioned as the "get the hell out of
here" key, so it's a good usability practice to have it close the dialog
(or any other modal dialog, for that matter).

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-02 Thread Malcolm Tredinnick
On Tue, 2003-09-02 at 13:58, Colin Fox wrote:
> On Mon, 2003-09-01 at 20:09, Malcolm Tredinnick wrote:
[...]
> > For your standard GtkDialog widget, the only way the 'close' signal is
> > emitted is when the Escape key is pressed. Widgets deriving from
> > GtkDialog may have other buttons that are hooked up to emit 'close', but
> > by default it is only bound to the Escape key (try it and see for the
> > About dialog -- you can close it with Escape and it emits the predicted
> > signal).
> > 
> > So, in short, for something like the About dialog box: connect to
> > 'response', hide the dialog box and then call the emit_stop_by_name()
> > method. Connect to 'delete' and ignore it by returning gtk.TRUE. Ignore
> > 'close' -- it is not useful in this case.
> > 
> 
> Except, as you've pointed out, that it's used for the Escape key
> handling. If you catch 'close', the escape key works. Otherwise it's
> ignored. I like making it go away with an escape key, so I'll keep the
> close handler.

Fair enough. The Escape key binding seems pretty non-intuitive to me for
the About box (it's just a mysterious accelerator with no mouse
equivalent), so I tend to ignore it. But your view has validity too.

> > Does this clarify things? If not, please sing out, because my psychic
> > abilities tell me that Christian may end up using his cut-and-paste
> > buttons to drop portions into the FAQ (possibly as an extension to
> > 10.6), so it would be good if it was vaguely understandable.
> 
> Amazing - Jedi powers & psychic abilities. Who said programmers were
> boring? :)
> 
> Just to sum it up - this is what I needed in my program to make the
> about box work completely (these handlers are part of a class):
> 
> def on_aboutbox_response( self, dialog, arg1, *args ):
>   # system-defined GtkDialog responses are always negative,
>   # in which case we want to hide it
>   print "aboutbox_response"
>   if arg1 < 0:
>   dialog.hide()
>   dialog.emit_stop_by_name( 'response' )
> 
> def on_aboutbox_close(self, widget, event=None):
>   self.aboutbox.hide()
>   return gtk.TRUE
> 
> def on_aboutbox_delete_event(self, widget, event=None):
>   self.aboutbox.hide()
>   return gtk.TRUE

The self.aboutbox.hide() call is not strictly required in the
delete-event handler. This is because if a GtkDialog receives a
delete-event signal, it will emit a response signal (this is documented
in the C language GTK API documentation and backed up by the C source
code). So just preventing the further propogation of the delete-event
signal should be sufficient (you can't ignore it or your widget gets
destroyed which is what started us down this thread). Of course, leaving
it in does no harm either, since calling hide() on an already hidden
widget is fine.

> Naturally, the 'close' and 'delete_event' signals could point at the
> same handler. It's just useful to have them separate for debugging.
> 
> I still think the response handler having to do an emit_stop_by_name()
> is weird. Why can't I just hide it, like the other handlers?

Because life sucks. :)

Seriously, I do not know -- but all my own various attempts to do this
other ways have failed (as well as other peoples' on this list), so I'm
now walking the party line on this one.

Cheers,
Malcolm

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-02 Thread Colin Fox
On Mon, 2003-09-01 at 20:09, Malcolm Tredinnick wrote:
> > This causes it to work properly if the user clicks the "Ok" button, but
> > it's a hack. Why should you have to force a signal to be stopped just
> > because you're using an about box? I don't think the old versions of the
> > library required such contortions... Regardless, if the user clicks the
> > close box, it will still crash when you try to re-invoke it.
> > 
> > I'm catching the close signal, and it NEVER gets sent. That seems to be
> > a bug, too. Same with the delete event. The ONLY event sent by the about
> > box is 'response'. 
> 
> OK, pretend I am waving my hand in a Jedi-like fashion and saying "There
> is no problem here". Convinced? I'm not kidding ... everything is
> working normally.

Cool! Being a gnome developer gives you Jedi powers! 

> If you are still reading this, my powers are weaker than I thought, so
> here is an explanation of what is going on...

Your explanation is quite clear. Thank you!

> For your standard GtkDialog widget, the only way the 'close' signal is
> emitted is when the Escape key is pressed. Widgets deriving from
> GtkDialog may have other buttons that are hooked up to emit 'close', but
> by default it is only bound to the Escape key (try it and see for the
> About dialog -- you can close it with Escape and it emits the predicted
> signal).
> 
> So, in short, for something like the About dialog box: connect to
> 'response', hide the dialog box and then call the emit_stop_by_name()
> method. Connect to 'delete' and ignore it by returning gtk.TRUE. Ignore
> 'close' -- it is not useful in this case.
> 

Except, as you've pointed out, that it's used for the Escape key
handling. If you catch 'close', the escape key works. Otherwise it's
ignored. I like making it go away with an escape key, so I'll keep the
close handler.

> Does this clarify things? If not, please sing out, because my psychic
> abilities tell me that Christian may end up using his cut-and-paste
> buttons to drop portions into the FAQ (possibly as an extension to
> 10.6), so it would be good if it was vaguely understandable.

Amazing - Jedi powers & psychic abilities. Who said programmers were
boring? :)

Just to sum it up - this is what I needed in my program to make the
about box work completely (these handlers are part of a class):

def on_aboutbox_response( self, dialog, arg1, *args ):
# system-defined GtkDialog responses are always negative,
# in which case we want to hide it
print "aboutbox_response"
if arg1 < 0:
dialog.hide()
dialog.emit_stop_by_name( 'response' )

def on_aboutbox_close(self, widget, event=None):
self.aboutbox.hide()
return gtk.TRUE

def on_aboutbox_delete_event(self, widget, event=None):
self.aboutbox.hide()
return gtk.TRUE

Naturally, the 'close' and 'delete_event' signals could point at the
same handler. It's just useful to have them separate for debugging.

I still think the response handler having to do an emit_stop_by_name()
is weird. Why can't I just hide it, like the other handlers?

Regards,
  cf
-- 
Colin Fox <[EMAIL PROTECTED]>
CF Consulting Inc.


signature.asc
Description: This is a digitally signed message part
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-02 Thread Malcolm Tredinnick
On Tue, 2003-09-02 at 04:59, Colin Fox wrote:
[...]
> Hmm. I put this in:
> 
> def on_aboutbox_response( dialog, arg1, *args ):
> if arg1 < 0:
> dialog.hide()
> dialog.emit_stop_by_name( 'response' )
> 
> This causes it to work properly if the user clicks the "Ok" button, but
> it's a hack. Why should you have to force a signal to be stopped just
> because you're using an about box? I don't think the old versions of the
> library required such contortions... Regardless, if the user clicks the
> close box, it will still crash when you try to re-invoke it.
> 
> I'm catching the close signal, and it NEVER gets sent. That seems to be
> a bug, too. Same with the delete event. The ONLY event sent by the about
> box is 'response'. 

OK, pretend I am waving my hand in a Jedi-like fashion and saying "There
is no problem here". Convinced? I'm not kidding ... everything is
working normally.

If you are still reading this, my powers are weaker than I thought, so
here is an explanation of what is going on...

A GtkDialog box has two main signals it implements: 'close' and
'response'. It also inherits the 'delete-event' signal from the
GtkWidget class which also has a role to play here.

The 'response' signal is emitted pretty much whenever any action happens
that causes the dialog box to finish running. The response signal
emission will contain a "response ID" which can be user-defined or any
one of the gtk.RESPONSE_* constants in pyGTK. The standard values
correspond to things like one of the standard buttons being pushed or
the window being destroyed. You can act differently based on the
response ID.

The 'delete' signal is emitted whenever the corresponding GtkWidget is
deleted in a "strange" (for want of a better word) way. The main case
here is when the user closes the window via the window manager (Alt-F4,
or clicking on the 'X' button in a typical window manager, for example).
In that case, you also get a 'response' signal, so generally you just
ignore the 'delete' signal (return gtk.TRUE as has been mentioned
elsewhere).

For your standard GtkDialog widget, the only way the 'close' signal is
emitted is when the Escape key is pressed. Widgets deriving from
GtkDialog may have other buttons that are hooked up to emit 'close', but
by default it is only bound to the Escape key (try it and see for the
About dialog -- you can close it with Escape and it emits the predicted
signal).

So, in short, for something like the About dialog box: connect to
'response', hide the dialog box and then call the emit_stop_by_name()
method. Connect to 'delete' and ignore it by returning gtk.TRUE. Ignore
'close' -- it is not useful in this case.

Does this clarify things? If not, please sing out, because my psychic
abilities tell me that Christian may end up using his cut-and-paste
buttons to drop portions into the FAQ (possibly as an extension to
10.6), so it would be good if it was vaguely understandable.

Cheers,
Malcolm
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-02 Thread Malcolm Tredinnick
On Mon, 2003-09-01 at 18:22, Colin Fox wrote:
> On Mon, 2003-09-01 at 00:48, Malcolm Tredinnick wrote:
> > Set the 'name' and 'version' properties on the GnomeAbout widget before
> > the widget is shown. I can see the logic of not setting the version
> > number in Glade (it changes more often than you want to change your
> > .glade file), but the lack of name setting has always seemed a bit odd,
> > I agree.
> 
> Cool. So now I have:
> 
> aboutbox.set_property('name','Demo Program')
> aboutbox.set_property('version','0.1')
> 
> and it works. I don't remember seeing any docs on this anywhere.
> Would it be worth putting this into the FAQ?
> 
> > By the way, the name you want shown in the about box is not necessarily
> > the name string you pass in to the gnome.init() method. It really wants
> > to be the same as whatever the 'human-readable-name' property of
> > GnomeProgram to (if you set that property), but that is getting pretty
> > subtle (not a lot of programs do that).
> 
> Ok - is there some documentation somewhere that states all of the
> properties of the various Gnome components and their purposes?

Not really. The libgnome (C language) API documentation explains some of
this, but bits of it need updating, since I didn't understand some bits
when I wrote it (and other bits were written by other people going back
as far as GNOME 1.0 in places).

However, I just looked and it does not contain a list of properties that
can set on things like the GnomeProgram object. That needs looking into
at some point. The state of GNOME developer documentation always makes
me feel sad, but it's such an enormous job to fix everything and
baby-step fixes are the only way to work.

I cannot really recommend the way I learnt this as the best method: I
wrote a lot of the libgnome API documentation, so at one point a couple
of years ago (just pre-GNOME 2.0) I had read pretty much every line of
code in libgnome and libgnomeui. It was not particularly fun. :-(

Cheers,
Malcolm

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-01 Thread Colin Fox
On Thu, 2003-10-02 at 09:34, Jon Willeke wrote:
> See PyGTK FAQ 10.6 for my description of how to use gnome.ui.About:
> 
>

> 
> In short, you have to stop the emission of the "reponse" signal. 
Returning 
> True is not sufficient.
> 
> I've asked in GNOME bug 119405 whether this is expected behavior. 
There is 
> a tentative response that is not.

Hmm. I put this in:

def on_aboutbox_response( dialog, arg1, *args ):
if arg1 < 0:
dialog.hide()
dialog.emit_stop_by_name( 'response' )

This causes it to work properly if the user clicks the "Ok" button, but
it's a hack. Why should you have to force a signal to be stopped just
because you're using an about box? I don't think the old versions of the
library required such contortions... Regardless, if the user clicks the
close box, it will still crash when you try to re-invoke it.

I'm catching the close signal, and it NEVER gets sent. That seems to be
a bug, too. Same with the delete event. The ONLY event sent by the about
box is 'response'. 

Also the fact that there's a segfault instead of a normal python
stacktrace indicates this is a bug within one of the libraries, though I
have no idea which one.

cf
-- 
Colin Fox <[EMAIL PROTECTED]>
CF Consulting Inc.


signature.asc
Description: This is a digitally signed message part
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-01 Thread Jon Willeke
See PyGTK FAQ 10.6 for my description of how to use gnome.ui.About:



In short, you have to stop the emission of the "reponse" signal.  Returning 
True is not sufficient.

I've asked in GNOME bug 119405 whether this is expected behavior.  There is 
a tentative response that is not.

At 01:11 AM 9/1/03 -0700, Colin Fox wrote:
On Mon, 2003-09-01 at 00:51, David M. Cook wrote:
> > If I show the about box, then dismiss it, then show it again, my program
> > aborts immediately with a segfault. No traceback stack or anything. I've
> > tried handling the 'response' and 'close' signals (hiding the dialog &
> > returning gtk.TRUE), to no avail.
>
> You also need to handle the delete_event signal and keep it from 
propagating
> by returning gtk.TRUE.

Hmm. The About box is getting stranger. I am now catching delete_event,
close & response. Here are my functions:
def on_about2_delete_event(widget, event=None):
print "delete_event"
return gtk.TRUE
def on_about2_response(widget, event=None):
print "response"
return gtk.TRUE
def on_about2_close(widget, event=None):
print "close"
return gtk.TRUE
I have the appropriate signals set up in Glade, calling these functions.

According to this, the ONLY function getting called is
on_about2_response(). The delete & close functions never execute.
And I still get a segfault when I try to re-show the about box.

cf

ps. I wonder if this has anything to do with the problem James has
mentioned about the improper invocation of gnome_program_init() from
libgnome?
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-01 Thread Christian Reis
On Mon, Sep 01, 2003 at 01:22:00AM -0700, Colin Fox wrote:
> Cool. So now I have:
> 
> aboutbox.set_property('name','Demo Program')
> aboutbox.set_property('version','0.1')
> 
> and it works. I don't remember seeing any docs on this anywhere.
> Would it be worth putting this into the FAQ?

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq19.007.htp

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-01 Thread Colin Fox
On Mon, 2003-09-01 at 00:48, Malcolm Tredinnick wrote:
> Set the 'name' and 'version' properties on the GnomeAbout widget before
> the widget is shown. I can see the logic of not setting the version
> number in Glade (it changes more often than you want to change your
> .glade file), but the lack of name setting has always seemed a bit odd,
> I agree.

Cool. So now I have:

aboutbox.set_property('name','Demo Program')
aboutbox.set_property('version','0.1')

and it works. I don't remember seeing any docs on this anywhere.
Would it be worth putting this into the FAQ?

> By the way, the name you want shown in the about box is not necessarily
> the name string you pass in to the gnome.init() method. It really wants
> to be the same as whatever the 'human-readable-name' property of
> GnomeProgram to (if you set that property), but that is getting pretty
> subtle (not a lot of programs do that).

Ok - is there some documentation somewhere that states all of the
properties of the various Gnome components and their purposes?

Thanks for the help!
  cf
-- 
Colin Fox <[EMAIL PROTECTED]>
CF Consulting Inc.


signature.asc
Description: This is a digitally signed message part
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-01 Thread Colin Fox
On Mon, 2003-09-01 at 00:51, David M. Cook wrote:
> > If I show the about box, then dismiss it, then show it again, my program
> > aborts immediately with a segfault. No traceback stack or anything. I've
> > tried handling the 'response' and 'close' signals (hiding the dialog &
> > returning gtk.TRUE), to no avail.
> 
> You also need to handle the delete_event signal and keep it from propagating
> by returning gtk.TRUE.

Hmm. The About box is getting stranger. I am now catching delete_event,
close & response. Here are my functions:

def on_about2_delete_event(widget, event=None):
print "delete_event"
return gtk.TRUE

def on_about2_response(widget, event=None):
print "response"
return gtk.TRUE

def on_about2_close(widget, event=None):
print "close"
return gtk.TRUE

I have the appropriate signals set up in Glade, calling these functions.

According to this, the ONLY function getting called is
on_about2_response(). The delete & close functions never execute.

And I still get a segfault when I try to re-show the about box.

cf

ps. I wonder if this has anything to do with the problem James has
mentioned about the improper invocation of gnome_program_init() from
libgnome?
-- 
Colin Fox <[EMAIL PROTECTED]>
CF Consulting Inc.


signature.asc
Description: This is a digitally signed message part
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-01 Thread David M. Cook
On Mon, Sep 01, 2003 at 12:40:11AM -0700, Colin Fox wrote:

> In addition to my previous message about the missing yellow star in the
> About menu, the "Gnome About" dialog itself is causing me some grief.
> 
> If I show the about box, then dismiss it, then show it again, my program
> aborts immediately with a segfault. No traceback stack or anything. I've
> tried handling the 'response' and 'close' signals (hiding the dialog &
> returning gtk.TRUE), to no avail.

You also need to handle the delete_event signal and keep it from propagating
by returning gtk.TRUE.

Dave Cook
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-01 Thread Malcolm Tredinnick
On Mon, 2003-09-01 at 17:48, Malcolm Tredinnick wrote:
> On Mon, 2003-09-01 at 17:40, Colin Fox wrote:
> > In addition to my previous message about the missing yellow star in the
> > About menu, the "Gnome About" dialog itself is causing me some grief.
> > 
> > If I show the about box, then dismiss it, then show it again, my program
> > aborts immediately with a segfault. No traceback stack or anything. I've
> > tried handling the 'response' and 'close' signals (hiding the dialog &
> > returning gtk.TRUE), to no avail.
> 
> Catch the 'delete' signal and ignore it (return gtk.TRUE). That will
> prevent the widget from being deleted.

Sorry, that should be the 'delete-event' signal.

Typing without checking. :-(

Cheers,
Malcolm

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] 'About' strangeness.

2003-09-01 Thread Malcolm Tredinnick
On Mon, 2003-09-01 at 17:40, Colin Fox wrote:
> In addition to my previous message about the missing yellow star in the
> About menu, the "Gnome About" dialog itself is causing me some grief.
> 
> If I show the about box, then dismiss it, then show it again, my program
> aborts immediately with a segfault. No traceback stack or anything. I've
> tried handling the 'response' and 'close' signals (hiding the dialog &
> returning gtk.TRUE), to no avail.

Catch the 'delete' signal and ignore it (return gtk.TRUE). That will
prevent the widget from being deleted.

> Also, in Glade, the dialog box shows "programname X.X" - however when I
> bring up the about box from my program, nothing is shown in that space.

Set the 'name' and 'version' properties on the GnomeAbout widget before
the widget is shown. I can see the logic of not setting the version
number in Glade (it changes more often than you want to change your
.glade file), but the lack of name setting has always seemed a bit odd,
I agree.

By the way, the name you want shown in the about box is not necessarily
the name string you pass in to the gnome.init() method. It really wants
to be the same as whatever the 'human-readable-name' property of
GnomeProgram to (if you set that property), but that is getting pretty
subtle (not a lot of programs do that).

Cheers,
Malcolm
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/