Re: difference between "g_signal_emit and g_object_notify" and how to listen to these signals
- From: hong sheng <hong022011 gmail com>
- To: Daniel Yek <danieyek alumni washington edu>
- Cc: networkmanager-list gnome org
- Subject: Re: difference between "g_signal_emit and g_object_notify" and how to listen to these signals
- Date: Wed, 27 Oct 2010 16:30:40 -0700
Hi Daniel,
Thank you very much. I have some more questions.
If I used g_signal_connect at the same program for g_signal_emit, for example, in modemmanager, I can receive that signal because I know the right object for the signal to connect.
However, in a different program, how can I get the right GObject to connect the signal?
For example, in the open source modemmanager, there is a function called " g_signal_emit (self, signals[SIGNAL_QUALITY], 0, quality)", where object: self is a modemclass. If I write my own applet, how can I set "g_signal_connect" with right Object of Modem? I mean how can I get the right object pointer of Modem for the signal to be connected?
In addition, I found in the openSource applet, there is a function to connect signal"SignalQuality" as follows:
dbus_g_proxy_add_signal (info->cdma_proxy, "SignalQuality", G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (info->cdma_proxy, "SignalQuality",
G_CALLBACK (signal_quality_changed_cb), info, NULL);
But I didn't find a place to emit this signal("SignalQuality") either in modemmanager or in the networkmanager. Something missed in modemmanager or networkmanager?
thanks a lot for the help
hong
On Tue, Oct 26, 2010 at 7:52 PM, Daniel Yek
<danieyek alumni washington edu> wrote:
On Wed, October 27, 2010 7:19 am, hong sheng wrote:
> I am reading the NetworkManager code as well as ModemManager code.
> I noticed that NetworkManager is
> using "g_object_notify" to send out the event signals,
> while ModemManager is using "g_signal_emit" to emit signals.
>
> Anyone knows what's the difference between these two function call?
Hi Hong Sheng,
Most of these are pure GTK+ questions.
g_signal_emit_by_name() and g_signal_emit() are the typical ways to emit
GTK+ signals.
g_object_notify() is usually used when implementing a GObject (as opposed
to using a ready-made GObject.)
g_object_notify() emits a "notify" signal for the property property_name
on object.
> In the Applet,
> if I want to listen to the signal sent from g_object_notify,
> what should I listen?
g_signal_connect( G_OBJECT(the_gobject_with_relevant_property),
"notify::DetailNameHere",
G_CALLBACK(my_notify_detailname_property_change_callback),
userdata_or_window_if_desired);
The "notify" signal callback functions have this function prototype:
void my_notify_detailname_property_change_callback(
GObject *the_gobject_with_relevant_property,
GParamSpec *arg1,
gpointer userdata_or_window_if_desired);
> If I want to listen to the signal sent from
> g_signal_emit, how can I implement it?
This is just the same as how you program a GTK+ application normally:
g_signal_connect( G_OBJECT(the_relevant_gobject),
"signal_name",
G_CALLBACK(my_callback_func),
NULL );
The GTK+ mailing list is at:
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
The callback function prototype depends on the signal.
You can, usually, find that out by
looking at (NetworkManager) documentation
(easy for newbies, but I don't know if it is there),
looking for a sample handler (callback) function (easy too),
searching through the (NetworkManager) source code
to find out its default handler and
append an extra userdata argument
(more involved and confusing for newbies.)
The callback function prototype used is not generic to GTK+, but specific
to NetworkManager.
Regards,
--
Daniel Yek
>
> thanks
>
> Xiaohong
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]