[empathy/mc5] Add a way to hook up to the apply sensitivity



commit f274e990d552235090b689071f5d464007948d52
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Aug 4 11:45:42 2009 +0200

    Add a way to hook up to the apply sensitivity

 libempathy-gtk/empathy-account-widget.c |   27 ++++++++++++++++++++++++---
 libempathy-gtk/empathy-account-widget.h |    3 ++-
 2 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 99b4509..4a6b8f2 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -68,15 +68,27 @@ enum {
   PROP_SIMPLE
 };
 
+enum {
+  HANDLE_APPLY,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget)
 
 static void
 account_widget_handle_apply_sensitivity (EmpathyAccountWidget *self)
 {
   EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  gboolean is_valid;
+
+  is_valid = empathy_account_settings_is_valid (priv->settings);
 
-  gtk_widget_set_sensitive (priv->apply_button,
-      empathy_account_settings_is_valid (priv->settings));
+  if (!priv->simple)
+    gtk_widget_set_sensitive (priv->apply_button, is_valid);
+
+  g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid);
 }
 
 static gboolean
@@ -950,6 +962,13 @@ empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
   g_object_class_install_property (oclass, PROP_SIMPLE, param_spec);
 
+  signals[HANDLE_APPLY] =
+    g_signal_new ("handle-apply", G_TYPE_FROM_CLASS (klass),
+        G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+        g_cclosure_marshal_VOID__BOOLEAN,
+        G_TYPE_NONE,
+        1, G_TYPE_BOOLEAN);
+
   g_type_class_add_private (klass, sizeof (EmpathyAccountWidgetPriv));
 }
 
@@ -1000,7 +1019,7 @@ empathy_account_widget_new_for_protocol (const char *protocol,
 
 GtkWidget *
 empathy_account_widget_simple_new_for_protocol (const char *protocol,
-    EmpathyAccountSettings *settings)
+    EmpathyAccountSettings *settings, EmpathyAccountWidget **object)
 {
   EmpathyAccountWidget *self;
 
@@ -1011,5 +1030,7 @@ empathy_account_widget_simple_new_for_protocol (const char *protocol,
     (EMPATHY_TYPE_ACCOUNT_WIDGET, "protocol", protocol,
         "settings", settings, "simple", TRUE, NULL);
 
+  *object = self;
+
   return self->ui_details->widget;
 }
diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h
index 7e6c331..ab4e62b 100644
--- a/libempathy-gtk/empathy-account-widget.h
+++ b/libempathy-gtk/empathy-account-widget.h
@@ -64,7 +64,8 @@ GtkWidget *empathy_account_widget_new_for_protocol (const char *protocol,
                                                     EmpathyAccountSettings *settings);
 GtkWidget * empathy_account_widget_simple_new_for_protocol
     (const char *protocol,
-     EmpathyAccountSettings *settings);
+     EmpathyAccountSettings *settings,
+     EmpathyAccountWidget **object);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]