]> git.0d.be Git - empathy.git/commitdiff
Change a bit the generic account setting API.
authorXavier Claessens <xclaesse@src.gnome.org>
Sun, 10 Feb 2008 20:25:51 +0000 (20:25 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Sun, 10 Feb 2008 20:25:51 +0000 (20:25 +0000)
svn path=/trunk/; revision=622

libempathy-gtk/empathy-account-widget.c
libempathy-gtk/empathy-account-widget.h
libempathy-gtk/empathy-ui-utils.c
libempathy-gtk/empathy-ui-utils.h
python/pyempathygtk/pyempathygtk.defs

index aed38ff0f6f78733af13be76dafcb9445a93ccc2..3cb5e00ea7958f1e4aa46364f2506463e883aeff 100644 (file)
@@ -73,7 +73,7 @@ account_widget_int_changed_cb (GtkWidget *widget,
        const gchar *param_name;
        gint         value;
 
        const gchar *param_name;
        gint         value;
 
-       value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
+       value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
        param_name = g_object_get_data (G_OBJECT (widget), "param_name");
 
        if (value == 0) {
        param_name = g_object_get_data (G_OBJECT (widget), "param_name");
 
        if (value == 0) {
@@ -84,7 +84,7 @@ account_widget_int_changed_cb (GtkWidget *widget,
                empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %d", param_name, val);
                gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), val);
        } else {
                empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %d", param_name, val);
                gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), val);
        } else {
-               empathy_debug (DEBUG_DOMAIN, "Setting %s to %d", param_name, (gint) value);
+               empathy_debug (DEBUG_DOMAIN, "Setting %s to %d", param_name, value);
                mc_account_set_param_int (account, param_name, (gint) value);
        }
 }
                mc_account_set_param_int (account, param_name, (gint) value);
        }
 }
@@ -164,14 +164,6 @@ account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
        gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_port), port);
 }
 
        gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_port), port);
 }
 
-static void
-account_widget_destroy_cb (GtkWidget *widget,
-                          McAccount *account)
-{
-       empathy_debug (DEBUG_DOMAIN, "destroyed!");
-       g_object_unref (account);
-}
-
 static void
 account_widget_setup_widget (GtkWidget   *widget,
                             McAccount   *account,
 static void
 account_widget_setup_widget (GtkWidget   *widget,
                             McAccount   *account,
@@ -179,6 +171,8 @@ account_widget_setup_widget (GtkWidget   *widget,
 {
        g_object_set_data_full (G_OBJECT (widget), "param_name", 
                                g_strdup (param_name), g_free);
 {
        g_object_set_data_full (G_OBJECT (widget), "param_name", 
                                g_strdup (param_name), g_free);
+       g_object_set_data_full (G_OBJECT (widget), "account", 
+                               g_object_ref (account), g_object_unref);
 
        if (GTK_IS_SPIN_BUTTON (widget)) {
                gint value = 0;
 
        if (GTK_IS_SPIN_BUTTON (widget)) {
                gint value = 0;
@@ -372,12 +366,11 @@ accounts_widget_generic_setup (McAccount *account,
        g_object_unref (protocol);
 }
 
        g_object_unref (protocol);
 }
 
-static GtkWidget *
-account_widget_new_valist (McAccount   *account,
-                          GladeXML    *gui,
-                          const gchar *root,
-                          const gchar *first_widget_name,
-                          va_list      args)
+static void
+account_widget_handle_params_valist (McAccount   *account,
+                                    GladeXML    *gui,
+                                    const gchar *first_widget_name,
+                                    va_list      args)
 {
        GtkWidget   *widget;
        const gchar *widget_name;
 {
        GtkWidget   *widget;
        const gchar *widget_name;
@@ -396,34 +389,23 @@ account_widget_new_valist (McAccount   *account,
 
                account_widget_setup_widget (widget, account, param_name);
        }
 
                account_widget_setup_widget (widget, account, param_name);
        }
-
-       widget = glade_xml_get_widget (gui, root);
-       g_signal_connect (widget, "destroy",
-                         G_CALLBACK (account_widget_destroy_cb),
-                         g_object_ref (account));
-
-       return widget;
 }
 
 }
 
-GtkWidget *
-empathy_account_widget_new_with_glade (McAccount   *account,
-                                      GladeXML    *gui,
-                                      const gchar *root,
-                                      const gchar *first_widget_name,
-                                      ...)
+void
+empathy_account_widget_handle_params (McAccount   *account,
+                                     GladeXML    *gui,
+                                     const gchar *first_widget_name,
+                                     ...)
 {
 {
-       GtkWidget *widget;
-       va_list    args;
+       va_list args;
 
 
-       g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
+       g_return_if_fail (MC_IS_ACCOUNT (account));
 
        va_start (args, first_widget_name);
 
        va_start (args, first_widget_name);
-       widget = account_widget_new_valist (account, gui, root,
-                                           first_widget_name,
-                                           args);
+       account_widget_handle_params_valist (account, gui,
+                                            first_widget_name,
+                                            args);
        va_end (args);
        va_end (args);
-
-       return widget;
 }
 
 void
 }
 
 void
@@ -449,10 +431,6 @@ emapthy_account_widget_add_forget_button (McAccount   *account,
        g_signal_connect (entry_password, "changed",
                          G_CALLBACK (account_widget_password_changed_cb),
                          button_forget);
        g_signal_connect (entry_password, "changed",
                          G_CALLBACK (account_widget_password_changed_cb),
                          button_forget);
-
-       g_object_set_data_full (G_OBJECT (entry_password), "account",
-                               g_object_ref (account),
-                               g_object_unref);
 }
 
 GtkWidget *
 }
 
 GtkWidget *
@@ -475,10 +453,6 @@ empathy_account_widget_generic_new (McAccount *account)
        
        accounts_widget_generic_setup (account, table_settings);
 
        
        accounts_widget_generic_setup (account, table_settings);
 
-       g_signal_connect (sw, "destroy",
-                         G_CALLBACK (account_widget_destroy_cb),
-                         g_object_ref (account));
-
        gtk_widget_show_all (sw);
 
        return sw;
        gtk_widget_show_all (sw);
 
        return sw;
@@ -490,12 +464,13 @@ empathy_account_widget_salut_new (McAccount *account)
        GladeXML  *glade;
        GtkWidget *widget;
 
        GladeXML  *glade;
        GtkWidget *widget;
 
-       glade = empathy_glade_get ("empathy-account-widget-salut.glade",
-                                  "vbox_salut_settings",
-                                  NULL);
+       glade = empathy_glade_get_file ("empathy-account-widget-salut.glade",
+                                       "vbox_salut_settings",
+                                       NULL,
+                                       "vbox_salut_settings", &widget,
+                                       NULL);
 
 
-       widget = empathy_account_widget_new_with_glade (account, glade,
-                       "vbox_salut_settings",
+       empathy_account_widget_handle_params (account, glade,
                        "entry_published", "published-name",
                        "entry_nickname", "nickname",
                        "entry_first_name", "first-name",
                        "entry_published", "published-name",
                        "entry_nickname", "nickname",
                        "entry_first_name", "first-name",
@@ -517,12 +492,13 @@ empathy_account_widget_msn_new (McAccount *account)
        GladeXML  *glade;
        GtkWidget *widget;
 
        GladeXML  *glade;
        GtkWidget *widget;
 
-       glade = empathy_glade_get ("empathy-account-widget-msn.glade",
-                                  "vbox_msn_settings",
-                                  NULL);
+       glade = empathy_glade_get_file ("empathy-account-widget-msn.glade",
+                                       "vbox_msn_settings",
+                                       NULL,
+                                       "vbox_msn_settings", &widget,
+                                       NULL);
 
 
-       widget = empathy_account_widget_new_with_glade (account, glade,
-                       "vbox_msn_settings",
+       empathy_account_widget_handle_params (account, glade,
                        "entry_id", "account",
                        "entry_password", "password",
                        "entry_server", "server",
                        "entry_id", "account",
                        "entry_password", "password",
                        "entry_server", "server",
@@ -551,12 +527,12 @@ empathy_account_widget_jabber_new (McAccount *account)
        glade = empathy_glade_get_file ("empathy-account-widget-jabber.glade",
                                        "vbox_jabber_settings",
                                        NULL,
        glade = empathy_glade_get_file ("empathy-account-widget-jabber.glade",
                                        "vbox_jabber_settings",
                                        NULL,
+                                       "vbox_jabber_settings", &widget,
                                        "spinbutton_port", &spinbutton_port,
                                        "checkbutton_ssl", &checkbutton_ssl,
                                        NULL);
 
                                        "spinbutton_port", &spinbutton_port,
                                        "checkbutton_ssl", &checkbutton_ssl,
                                        NULL);
 
-       widget = empathy_account_widget_new_with_glade (account, glade,
-                       "vbox_jabber_settings",
+       empathy_account_widget_handle_params (account, glade,
                        "entry_id", "account",
                        "entry_password", "password",
                        "entry_resource", "resource",
                        "entry_id", "account",
                        "entry_password", "password",
                        "entry_resource", "resource",
@@ -576,10 +552,6 @@ empathy_account_widget_jabber_new (McAccount *account)
                          G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
                          spinbutton_port);
 
                          G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
                          spinbutton_port);
 
-       g_object_set_data_full (G_OBJECT (spinbutton_port), "account",
-                               g_object_ref (account),
-                               g_object_unref);
-
        g_object_unref (glade);
 
        gtk_widget_show (widget);
        g_object_unref (glade);
 
        gtk_widget_show (widget);
index 191997ece4c4aedff37369bc489325d63a7cde05..25a65c183145eb4aaa05bc1f11039594949e4d88 100644 (file)
@@ -32,9 +32,8 @@
 
 G_BEGIN_DECLS
 
 
 G_BEGIN_DECLS
 
-GtkWidget *empathy_account_widget_new_with_glade    (McAccount   *account,
+void       empathy_account_widget_handle_params     (McAccount   *account,
                                                     GladeXML    *glade,
                                                     GladeXML    *glade,
-                                                    const gchar *root,
                                                     const gchar *first_widget_name,
                                                     ...);
 void       emapthy_account_widget_add_forget_button (McAccount   *account,
                                                     const gchar *first_widget_name,
                                                     ...);
 void       emapthy_account_widget_add_forget_button (McAccount   *account,
index 23875f7220a43052cd49c7c41c91d434bc58ab94..9c66e73ba15dc8554f11f77fc4467a02ff880f8e 100644 (file)
@@ -53,13 +53,17 @@ struct SizeData {
        gboolean preserve_aspect_ratio;
 };
 
        gboolean preserve_aspect_ratio;
 };
 
-GladeXML *
-empathy_glade_get (const gchar *filename,
-                  const gchar *root,
-                  const gchar *domain)
+static GladeXML *
+get_glade_file (const gchar *filename,
+               const gchar *root,
+               const gchar *domain,
+               const gchar *first_required_widget,
+               va_list      args)
 {
 {
-       GladeXML *gui;
-       gchar    *path;
+       GladeXML   *gui;
+       gchar      *path;
+       const char *name;
+       GtkWidget **widget_ptr;
 
        path = g_build_filename (UNINSTALLED_GLADE_DIR, filename, NULL);
        if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
 
        path = g_build_filename (UNINSTALLED_GLADE_DIR, filename, NULL);
        if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
@@ -75,22 +79,6 @@ empathy_glade_get (const gchar *filename,
                g_warning ("Couldn't find necessary glade file '%s'", filename);
        }
 
                g_warning ("Couldn't find necessary glade file '%s'", filename);
        }
 
-       return gui;
-}
-
-static GladeXML *
-get_glade_file (const gchar *filename,
-               const gchar *root,
-               const gchar *domain,
-               const gchar *first_required_widget,
-               va_list      args)
-{
-       GladeXML   *gui;
-       const char *name;
-       GtkWidget **widget_ptr;
-
-       gui = empathy_glade_get (filename, root, domain);
-
        for (name = first_required_widget; name; name = va_arg (args, char *)) {
                widget_ptr = va_arg (args, void *);
 
        for (name = first_required_widget; name; name = va_arg (args, char *)) {
                widget_ptr = va_arg (args, void *);
 
index fedf8f7be4408bfcde52cc15051dedd2994d9ded..1fb29a97d09360cfea1b1a4d308d298ef93df6de 100644 (file)
@@ -47,9 +47,6 @@ G_BEGIN_DECLS
 #define G_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
 
 /* Glade */
 #define G_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
 
 /* Glade */
-GladeXML *      empathy_glade_get                       (const gchar      *filename,
-                                                        const gchar      *root,
-                                                        const gchar      *domain);
 void            empathy_glade_get_file_simple           (const gchar      *filename,
                                                         const gchar      *root,
                                                         const gchar      *domain,
 void            empathy_glade_get_file_simple           (const gchar      *filename,
                                                         const gchar      *root,
                                                         const gchar      *domain,
index 4f5e0f5a41f1e5319c66f947e1fffaef9ed5bd9c..8b7929e3dc1bbfb43fe1f7c5af4ba9ae9e53b5c2 100644 (file)
 
 ;; From empathy-account-widget.h
 
 
 ;; From empathy-account-widget.h
 
-(define-function empathy_account_widget_new_with_glade
-  (c-name "empathy_account_widget_new_with_glade")
-  (return-type "GtkWidget*")
+(define-function empathy_account_widget_handle_params
+  (c-name "empathy_account_widget_handle_params")
+  (return-type "none")
   (parameters
     '("McAccount*" "account")
     '("GladeXML*" "glade")
   (parameters
     '("McAccount*" "account")
     '("GladeXML*" "glade")
-    '("const-gchar*" "root")
     '("const-gchar*" "first_widget_name")
   )
   (varargs #t)
     '("const-gchar*" "first_widget_name")
   )
   (varargs #t)
 
 ;; From empathy-ui-utils.h
 
 
 ;; From empathy-ui-utils.h
 
-(define-function empathy_glade_get
-  (c-name "empathy_glade_get")
-  (return-type "GladeXML*")
-  (parameters
-    '("const-gchar*" "filename")
-    '("const-gchar*" "root")
-    '("const-gchar*" "domain")
-  )
-)
-
 (define-function empathy_glade_get_file_simple
   (c-name "empathy_glade_get_file_simple")
   (return-type "none")
 (define-function empathy_glade_get_file_simple
   (c-name "empathy_glade_get_file_simple")
   (return-type "none")