[Glade-devel] [patch, glade3] glade_util_flash_message()



Paolo wrote:

Hi!

The patch attached implements a utility function to display 
messages in the statusbar and uses it to display the "Project 
Saved" message.

Note: I'm not sure that this patch is ready for inclusion, so 
don't apply it unless you reviewed it carefully and you are 
confident it's ok.

I'm sending it out for review and maybe to get some advices, 
because I have at least a couple of doubts:

First thing, I'm not sure if I got the gtk_timeout behaviur right.

Second, I'm quite puzzled by this whole context_id thing used 
for the statusbar. I thought that assigning a different 
context id for each project you would get the following 
beahviour: suppose you save a project, a "Project Saved" 
message is displayed; then you change project (before the 
message is removed by the timeout); I thought that at this 
point the message would be hidden because in the statusbar is 
disaplyed the message stack relative to the current project. 
This does not happen, so now I wonder why I have to set up 
different context_ids when the resulting behavoiur is the 
same as when you simply pass "1" every time you need a context_id.

Ok, I'm sorry I didn't explained why I removed the "1" as context_id,
and used a real context_id as returned by gtk_statusbar_get_context_id.

Nowhere in the public documentation says that you can use a context_id
before you've allocated it with get_context_id, so just using "1" as
context_id was undefined behaviour.  I also skimmed a bit the source of
GtkStatusBar and I didn't say anything that imply that you can just use
"1", so I put a real context_id.

Now, what's the purpose of context id?

We have several "users" of the status bar.  The menu wants to add
messages to the status bar, events add messages (as "project saved"),
etc.

Think about the following use-case:

* The user is over a menu item: We pop the latest message in the status
bar that came from the menu, and we push a new message (say "Menu Item
1")
* A event happens (say auto-save): pop latest message from events, and
push a new message (say "Project auto-saved").  Arm a timer to pop the
message after 2 seconds.
* The user moves to another menu item: pop latest message from the menu,
and push a new message (say "Menu item 2").
* The timer fires, and it pops the latest message from events.

If you don't have a way to say where the message comes from (events or
menu, in this example), you end having:

Menu Item 1 -> Project auto-saved -> Menu Item 2 -> Nothing

The timer would remove "Menu Item 2" when it should just remove "Project
auto-saved".

You should also take in account that the context id doesn't have any
effect on the message displayed.  To show the messages the whole thing
just looks like a stack.  The context id it's just there to help you
push or pop the right kind of message.

I will take later a deeper look at your patch.

Thank you for your help!

Cheers,






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]