network: Replace a callback with a signal
This commit is contained in:
parent
3d06da2d30
commit
125d971ebe
4 changed files with 24 additions and 31 deletions
|
@ -59,9 +59,9 @@ enable_toggled (CEPage8021xSecurity *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stuff_changed (WirelessSecurity *sec, gpointer user_data)
|
security_item_changed_cb (CEPage8021xSecurity *self)
|
||||||
{
|
{
|
||||||
ce_page_changed (CE_PAGE (user_data));
|
ce_page_changed (CE_PAGE (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -80,7 +80,7 @@ finish_setup (CEPage8021xSecurity *self, gpointer unused, GError *error, gpointe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wireless_security_set_changed_notify (WIRELESS_SECURITY (self->security), stuff_changed, self);
|
g_signal_connect_object (WIRELESS_SECURITY (self->security), "changed", G_CALLBACK (security_item_changed_cb), self, G_CONNECT_SWAPPED);
|
||||||
self->security_widget = wireless_security_get_widget (WIRELESS_SECURITY (self->security));
|
self->security_widget = wireless_security_get_widget (WIRELESS_SECURITY (self->security));
|
||||||
parent = gtk_widget_get_parent (self->security_widget);
|
parent = gtk_widget_get_parent (self->security_widget);
|
||||||
if (parent)
|
if (parent)
|
||||||
|
|
|
@ -174,9 +174,9 @@ security_combo_changed (CEPageSecurity *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stuff_changed_cb (WirelessSecurity *sec, gpointer user_data)
|
security_item_changed_cb (CEPageSecurity *self)
|
||||||
{
|
{
|
||||||
ce_page_changed (CE_PAGE (user_data));
|
ce_page_changed (CE_PAGE (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -187,7 +187,7 @@ add_security_item (CEPageSecurity *self,
|
||||||
const char *text,
|
const char *text,
|
||||||
gboolean adhoc_valid)
|
gboolean adhoc_valid)
|
||||||
{
|
{
|
||||||
wireless_security_set_changed_notify (sec, stuff_changed_cb, self);
|
g_signal_connect_object (sec, "changed", G_CALLBACK (security_item_changed_cb), self, G_CONNECT_SWAPPED);
|
||||||
gtk_list_store_append (model, iter);
|
gtk_list_store_append (model, iter);
|
||||||
gtk_list_store_set (model, iter,
|
gtk_list_store_set (model, iter,
|
||||||
S_NAME_COLUMN, text,
|
S_NAME_COLUMN, text,
|
||||||
|
|
|
@ -36,16 +36,20 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WSChangedFunc changed_notify;
|
|
||||||
gpointer changed_notify_data;
|
|
||||||
gboolean adhoc_compatible;
|
gboolean adhoc_compatible;
|
||||||
|
|
||||||
char *username, *password;
|
char *username, *password;
|
||||||
gboolean always_ask, show_password;
|
gboolean always_ask, show_password;
|
||||||
} WirelessSecurityPrivate;
|
} WirelessSecurityPrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (WirelessSecurity, wireless_security, G_TYPE_OBJECT)
|
G_DEFINE_TYPE_WITH_PRIVATE (WirelessSecurity, wireless_security, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CHANGED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wireless_security_dispose (GObject *object)
|
wireless_security_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
|
@ -77,6 +81,15 @@ wireless_security_class_init (WirelessSecurityClass *klass)
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->dispose = wireless_security_dispose;
|
object_class->dispose = wireless_security_dispose;
|
||||||
|
|
||||||
|
signals[CHANGED] =
|
||||||
|
g_signal_new ("changed",
|
||||||
|
G_TYPE_FROM_CLASS (object_class),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
0,
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
@ -87,26 +100,12 @@ wireless_security_get_widget (WirelessSecurity *self)
|
||||||
return WIRELESS_SECURITY_GET_CLASS (self)->get_widget (self);
|
return WIRELESS_SECURITY_GET_CLASS (self)->get_widget (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
wireless_security_set_changed_notify (WirelessSecurity *self,
|
|
||||||
WSChangedFunc func,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
|
|
||||||
|
|
||||||
g_return_if_fail (WIRELESS_IS_SECURITY (self));
|
|
||||||
|
|
||||||
priv->changed_notify = func;
|
|
||||||
priv->changed_notify_data = user_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wireless_security_notify_changed (WirelessSecurity *self)
|
wireless_security_notify_changed (WirelessSecurity *self)
|
||||||
{
|
{
|
||||||
WirelessSecurityPrivate *priv = wireless_security_get_instance_private (self);
|
g_return_if_fail (WIRELESS_IS_SECURITY (self));
|
||||||
|
|
||||||
if (priv->changed_notify)
|
g_signal_emit (self, signals[CHANGED], 0);
|
||||||
(*(priv->changed_notify)) (self, priv->changed_notify_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
|
@ -28,8 +28,6 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
G_DECLARE_DERIVABLE_TYPE (WirelessSecurity, wireless_security, WIRELESS, SECURITY, GObject)
|
G_DECLARE_DERIVABLE_TYPE (WirelessSecurity, wireless_security, WIRELESS, SECURITY, GObject)
|
||||||
|
|
||||||
typedef void (*WSChangedFunc) (WirelessSecurity *sec, gpointer user_data);
|
|
||||||
|
|
||||||
struct _WirelessSecurityClass {
|
struct _WirelessSecurityClass {
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
@ -41,10 +39,6 @@ struct _WirelessSecurityClass {
|
||||||
|
|
||||||
GtkWidget *wireless_security_get_widget (WirelessSecurity *sec);
|
GtkWidget *wireless_security_get_widget (WirelessSecurity *sec);
|
||||||
|
|
||||||
void wireless_security_set_changed_notify (WirelessSecurity *sec,
|
|
||||||
WSChangedFunc func,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
gboolean wireless_security_validate (WirelessSecurity *sec, GError **error);
|
gboolean wireless_security_validate (WirelessSecurity *sec, GError **error);
|
||||||
|
|
||||||
void wireless_security_add_to_size_group (WirelessSecurity *sec,
|
void wireless_security_add_to_size_group (WirelessSecurity *sec,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue