General question about inheritance of properties in GTK

2006-11-11 Thread Clarity ThroughConfusion

Hi,

I am planning on creating some custom widgets that have some additional 
functionality over standard GTK widgets.
As these widgets are very close to the GTK standard widgets, I am planning 
on deriving the custom widget from a GTK standard widget and hopefully avoid 
reimplementing the common functionality.


However, I am having problems understanding the inheritance of properties, 
could anyone help me understand the following:


1. How can I reuse the parent widgets properties along with my new 
properties I have created using g_object_class_install_property?


2. Are the parents properties inherited and set by default in the child?

3. Do I need to have case statements for each parent property (in addition 
to my new ones) in set_property() function?


I have looked through the developer.gnome.org ebooks and done a google, but 
can not find any helpful info.


Regards

Clarity

_
Windows Live™ Messenger has arrived. Click here to download it for free! 
http://imagine-msn.com/messenger/launch80/?locale=en-gb


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

Re: Scrolling a Tree View before it's realized

2006-11-11 Thread Attilio Fiandrotti
Liam R E Quin wrote:
> On Sat, 2006-11-11 at 11:51 +0100, Attilio Fiandrotti wrote:
> [...]
> 
>>I eventually managed this by scrolling the treeview from a callback that 
>>gets fired after the expose event is fired.
>>In order to have scrolling performed only the first time expose event is 
>>fired, i use a global flag which i reset from inside the callback the 
>>first time it's run.
> 
> 
> An alternative might be to have the signal handler disconnect the
> signal.

That's what i did, as suggested by tomas: disconnecting the signal 
handler from the treeview after it has run one time.
Now scrolling works perfectly.
By the way, is it so obvious you should wait for your treeview to be 
realized before scrolling it?
IIRC, this is not explicitly mentioned in the documentation.

cheers

Attilio

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


Re: Scrolling a Tree View before it's realized

2006-11-11 Thread Liam R E Quin
On Sat, 2006-11-11 at 11:51 +0100, Attilio Fiandrotti wrote:
[...]
> I eventually managed this by scrolling the treeview from a callback that 
> gets fired after the expose event is fired.
> In order to have scrolling performed only the first time expose event is 
> fired, i use a global flag which i reset from inside the callback the 
> first time it's run.

An alternative might be to have the signal handler disconnect the
signal.

Or is that what you mean by a second signal handler?  The first
time handler would look like:
replace the signal handler with the redraw function
scroll the view
call the redraw function
and the other is the redraw function.

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org

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


Re: Scrolling a Tree View before it's realized

2006-11-11 Thread Attilio Fiandrotti
[EMAIL PROTECTED] wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> On Sat, Nov 11, 2006 at 11:51:20AM +0100, Attilio Fiandrotti wrote:
> 
>>Attilio Fiandrotti wrote:
>>
>>>Hi
>>>
>>>In an application i add many items to a ListStore and make it scroll on 
>>>the fly to the default option row,  like this
> 
> [...]
> 
>>I eventually managed this by scrolling the treeview from a callback that 
>>gets fired after the expose event is fired.
>>In order to have scrolling performed only the first time expose event is 
>>fired, i use a global flag which i reset from inside the callback the 
>>first time it's run.
>>I now would like to know if there is a way to run a signal handler only 
>>once and without using a second signal handler or global flags.
> 
> 
> You just might want to call g_signal_handler_disconnect from whithin the 
> signal
> handler. You'll have to stash the handler ID you get from
> g_signal_connect() somewhere accessible from the handler (for example in
> the user data struct).
> 
> OTOH, g_signal_add_emission_hook()  seems to be the function made for
> you :)
> 
> In an emission hook function you just return FALSE if you want the hook
> to be removed. You'll have to check whether your particular signal
> accepts emission hooks, though.

disconnecting the signal handler from within the callback function did 
the trick.

thanks

Attilio
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Passing events to an SDL app embedded in a GTK Widget

2006-11-11 Thread Mike Cruse
Hi,

I am writing a python app that needs to embed an SDL app in a GTK
widget. I am using an eventbox widget because it has it's own window.

I set the SDL_WINDOWID environment variable with the window id of the
eventbox and run the app. SDL apps look at this variable and use that
window id as the target for display.

It all works nicely except no mouse events get delivered to the embedded
app.

I thought that when the eventbox window contents gets focus, that is
where the events would go but I am missing something.

Is there a way to let the mouse events get through?

Here is an (incomplete) example of the kind of thing I am trying to do.

evb = xml.get_widget('event_box1')
evb.realize()
os.environ['SDL_WINDOWID'] = '%d' % evb.window.xid
os.spawnl(os.P_NOWAIT, '/usr/bin/neverball')

back to GTK event processing.

Thanks for any help.




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


Re: Glade GUI: changing mechanism

2006-11-11 Thread Stephen Watson
"Olexiy Avramchenko" <[EMAIL PROTECTED]> 31/Oct/2006 12:58:37 >>>
>On 10/31/06, Johan Kohler <[EMAIL PROTECTED]> wrote:
>> Isn't it possible to "inline" the .glade file in the compiled code?
>> Ie. Instead of reading from a  text file, it reads from a declared
>> constant.  I think that one can inline pixmaps in this way using GTK.
>
>Sure, it's possible to embed xml into executable and load it with
>glade_xml_new_from_buffer(). This is a good way for the people who
>afraid someone will change their UI appearance.

I find glade_xml_new_from_buffer() crashes when it tries to
load a non-stock image.  Is this a known bug?



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


Passing events to an SDL app embedded in a GTK Widget

2006-11-11 Thread Mike Cruse
Hi,

sorry if this is a duplicate. I sent it from a non subscribed email
the first time.


I am writing a python app that needs to embed an SDL app in a GTK
widget. I am using an eventbox widget because it has it's own window.

I set the SDL_WINDOWID environment variable with the window id of the
eventbox and run the app. SDL apps look at this variable and use that
window id as the target for display.

It all works nicely except no mouse events get delivered to the embedded
app.

I thought that when the eventbox window contents gets focus, that is
where the events would go but I am missing something.

Is there a way to let the mouse events get through?

Here is an (incomplete) example of the kind of thing I am trying to do.

evb = xml.get_widget('event_box1')
evb.realize()
os.environ['SDL_WINDOWID'] = '%d' % evb.window.xid
os.spawnl(os.P_NOWAIT, '/usr/bin/neverball')

back to GTK event processing.

Thanks for any help.




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


Re: Mutex or atomic operations for multithread app?

2006-11-11 Thread John Cupitt
On 11/11/06, Tomasz Jankowski <[EMAIL PROTECTED]> wrote:
> I looking for someone, who will say if my idea is bad or good ;)
> I have an object based on GObject, which have quite many int variables. This
> object is used by many threads and i'm wondering if I really need to use
> mutex when I want to access those variables. Can I use atomically access to
> int variables using g_atomic* functions instead using mutex? Is it a good
> solution or it may occur memory access problems?

It will be much faster, but you can't use them in many cases.

The big problem is if you have sevaral variables which have to change
together, for example if you have an (x, y) coordinate pair. If you
don't use a mutex, a writer thread could be only half way though
updating the coordinate when a reader thread tests the values.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Mutex or atomic operations for multithread app?

2006-11-11 Thread Tomasz Jankowski
Hi there!

I looking for someone, who will say if my idea is bad or good ;)
I have an object based on GObject, which have quite many int variables. This
object is used by many threads and i'm wondering if I really need to use
mutex when I want to access those variables. Can I use atomically access to
int variables using g_atomic* functions instead using mutex? Is it a good
solution or it may occur memory access problems?
-- 
Tom
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Scrolling a Tree View before it's realized

2006-11-11 Thread tomas
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Sat, Nov 11, 2006 at 11:51:20AM +0100, Attilio Fiandrotti wrote:
> Attilio Fiandrotti wrote:
> > Hi
> > 
> > In an application i add many items to a ListStore and make it scroll on 
> > the fly to the default option row,  like this
[...]
> I eventually managed this by scrolling the treeview from a callback that 
> gets fired after the expose event is fired.
> In order to have scrolling performed only the first time expose event is 
> fired, i use a global flag which i reset from inside the callback the 
> first time it's run.
> I now would like to know if there is a way to run a signal handler only 
> once and without using a second signal handler or global flags.

You just might want to call g_signal_handler_disconnect from whithin the signal
handler. You'll have to stash the handler ID you get from
g_signal_connect() somewhere accessible from the handler (for example in
the user data struct).

OTOH, g_signal_add_emission_hook()  seems to be the function made for
you :)

In an emission hook function you just return FALSE if you want the hook
to be removed. You'll have to check whether your particular signal
accepts emission hooks, though.

HTH
- -- tomás
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFVcWbBcgs9XrR2kYRAk3UAJ9oIricfwjX9IEnJlt9mK5UET3KAwCcDo88
i+DwGPKPRpIrpaGsZQnYo4k=
=RtUR
-END PGP SIGNATURE-

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

Re: Scrolling a Tree View before it's realized

2006-11-11 Thread Attilio Fiandrotti
Attilio Fiandrotti wrote:
> Hi
> 
> In an application i add many items to a ListStore and make it scroll on 
> the fly to the default option row,  like this
> 
> for (i = 0; i < NUMBER_OF_ITEMS; i++) {
>  gtk_list_store_append (store, &iter);
>  gtk_list_store_set (store, &iter, MY_COLUMN, mystrings[i], -1);
>  if (default_option_index == i) {
>  path = gtk_tree_model_get_path(model, &iter);
>  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), path, NULL, 
> FALSE, 0.5, 0);
>  gtk_tree_view_set_cursor (GTK_TREE_VIEW(view), path, NULL, FALSE);
>  gtk_tree_path_free (path);
>  }
> }
> 
> Later i pack the TreeView into proper box hierarchy and eventually show 
> the gtkwindow and within contained widgets.
> 
> Now, scrolling works inconsistently, as the row gets indeed selected but 
> the scrolling is only "partial".
> I wonder if this is because i'm attempting to scroll to a row in a 
> treeview which has not been realized yet.
> In the case, does performing scroll after widget realization, from 
> within a proper callback, will solve this issue?

I eventually managed this by scrolling the treeview from a callback that 
gets fired after the expose event is fired.
In order to have scrolling performed only the first time expose event is 
fired, i use a global flag which i reset from inside the callback the 
first time it's run.
I now would like to know if there is a way to run a signal handler only 
once and without using a second signal handler or global flags.

thanks

Attilio
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list