Trouble with signal ID lookup for "popped-up"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Trouble with signal ID lookup for "popped-up"

Eric Williams
Hello,

I am trying to lookup the signal ID for "popped-up" (GtkMenu).

However the ID returned is always 0. Here is the code I am using:

g_signal_lookup ("popped-up", GTK_TYPE_WIDGET)

I tried using GTK_TYPE_MENU instead, but then I get the error: unable to
lookup signal "popped-up" of unloaded type 'GtkMenu'. Am I doing
something incorrectly?


Eric
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
'-'
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with signal ID lookup for "popped-up"

'-'
Hi,

Is GtkMenu a dynamic class? Might need to demand-create it by increasing
its reference count, and keep the reference alive, until you no longer
need the signal ID. Otherwise ID can be different, or not exist, at the
time you try actually using it, as signals get destroyed and created
again:

```c
GObjectClass *class = g_type_class_ref (GTK_TYPE_MENU);
g_signal_lookup ("popped-up", GTK_TYPE_MENU);
// Do something with the signal...

g_type_class_unref (class);
// Shouldn't be relying on the signal at this point.
```

Cheers,
Makepost

On 2018-01-09 23:16, Eric Williams wrote:

> Hello,
>
> I am trying to lookup the signal ID for "popped-up" (GtkMenu).
>
> However the ID returned is always 0. Here is the code I am using:
>
> g_signal_lookup ("popped-up", GTK_TYPE_WIDGET)
>
> I tried using GTK_TYPE_MENU instead, but then I get the error: unable
> to lookup signal "popped-up" of unloaded type 'GtkMenu'. Am I doing
> something incorrectly?
>
>
> Eric
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with signal ID lookup for "popped-up"

Eric Williams
Hello,

On 01/09/2018 05:58 PM, '-' wrote:

> Hi,
>
> Is GtkMenu a dynamic class? Might need to demand-create it by increasing
> its reference count, and keep the reference alive, until you no longer
> need the signal ID. Otherwise ID can be different, or not exist, at the
> time you try actually using it, as signals get destroyed and created again:
>
> ```c
> GObjectClass *class = g_type_class_ref (GTK_TYPE_MENU);
> g_signal_lookup ("popped-up", GTK_TYPE_MENU);
> // Do something with the signal...
>
> g_type_class_unref (class);
> // Shouldn't be relying on the signal at this point.
> ```

This did the trick, thank you!

Eric
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list