gobjectification: 2bec3817: A "new" signal for purple objects. The s...
sadrul at pidgin.im
sadrul at pidgin.im
Sun Jun 29 04:20:43 EDT 2008
-----------------------------------------------------------------
Revision: 2bec3817a50dbbc82554c24a7180068faaf9ebf4
Ancestor: eac3b43b25eae0411f5f317eec2a302a83bb3fd2
Author: sadrul at pidgin.im
Date: 2008-06-28T22:09:57
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/2bec3817a50dbbc82554c24a7180068faaf9ebf4
Modified files:
libpurple/account.c libpurple/pobject.c
ChangeLog:
A "new" signal for purple objects. The signal should be emitted only when
the newly created object is in a usable state.
-------------- next part --------------
============================================================
--- libpurple/account.c 73787ae8aa25fbacd7b5ec54e70f6f0778477aa6
+++ libpurple/account.c ab2c4d87a0fa357f925b90f5d2ab4650309a3686
@@ -775,6 +775,8 @@ purple_account_new(const char *username,
TRUE);
}
+ g_signal_emit_by_name(G_OBJECT(account), "new");
+
return account;
}
============================================================
--- libpurple/pobject.c 87f1ae3fbf40bf300b6a9658b01cd7f52fae8d30
+++ libpurple/pobject.c 1a4a7356fa73f484526252aaa3a32f5898c2be01
@@ -26,6 +26,13 @@ struct _PurpleObjectPrivate
gpointer ui_data;
};
+enum
+{
+ SIG_NEW,
+ SIG_LAST
+};
+static guint signals[SIG_LAST] = {0, };
+
static GObjectClass *parent_class;
static void
@@ -49,11 +56,20 @@ purple_object_class_init(PurpleObjectCla
static void
purple_object_class_init(PurpleObjectClass *klass)
{
- GObjectClass *gclass= G_OBJECT_CLASS(klass);
+ GObjectClass *gclass = G_OBJECT_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
gclass->dispose = purple_object_dispose;
+
+ /* Signals */
+
+ /* This signal should be emitted after an object is created, and
+ * the essential properties for the object has been set properly. */
+ signals[SIG_NEW] = g_signal_new("new", G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_ACTION, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
g_type_class_add_private(klass, sizeof(PurpleObjectPrivate));
}
@@ -127,6 +143,7 @@ typedef struct
*/
typedef struct
{
+ GType type;
GCallback callback;
gpointer user_data;
GConnectFlags flags;
@@ -139,6 +156,10 @@ signal_emission_hook_fn(GSignalInvocatio
{
PObjectConnectHook *hook = data;
PurpleObject *obj = PURPLE_OBJECT(g_value_get_object(pvalues + 0));
+
+ if (!G_TYPE_CHECK_INSTANCE_TYPE(obj, hook->type))
+ return TRUE;
+
if (g_signal_handler_find(obj,
G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA | G_SIGNAL_MATCH_DETAIL,
hint->signal_id, hook->detail, NULL,
@@ -178,6 +199,7 @@ purple_type_connect_flags(GType type, co
hook->user_data = data;
hook->flags = flags;
hook->detail = detail;
+ hook->type = type;
return g_signal_add_emission_hook(signal_id, detail,
signal_emission_hook_fn, hook, g_free);
More information about the Commits
mailing list