]> git.0d.be Git - empathy.git/commitdiff
Simplify SIP account config UI. Fixes bug #527452 (Frederic Peters).
authorXavier Claessens <xclaesse@src.gnome.org>
Wed, 16 Apr 2008 08:34:52 +0000 (08:34 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Wed, 16 Apr 2008 08:34:52 +0000 (08:34 +0000)
svn path=/trunk/; revision=948

libempathy-gtk/Makefile.am
libempathy-gtk/empathy-account-widget-sip.c [new file with mode: 0644]
libempathy-gtk/empathy-account-widget-sip.glade
libempathy-gtk/empathy-account-widget-sip.h [new file with mode: 0644]
libempathy-gtk/empathy-account-widget.c
libempathy-gtk/empathy-account-widget.h
libempathy-gtk/empathy-accounts-dialog.c

index 9d31ac4f3426f5cc3c98b0e96738a0af433499f3..c4f07cf74919fc8f4278cfdb1216984fcc13b472 100644 (file)
@@ -27,6 +27,7 @@ libempathy_gtk_la_SOURCES =                   \
        empathy-conf.c                          \
        empathy-theme.c                         \
        empathy-account-widget-irc.c            \
+       empathy-account-widget-sip.c            \
        empathy-contact-dialogs.c               \
        empathy-new-message-dialog.c            \
        empathy-theme-irc.c                     \
@@ -73,6 +74,7 @@ libempathy_gtk_headers =                      \
        empathy-conf.h                          \
        empathy-theme.h                         \
        empathy-account-widget-irc.h            \
+       empathy-account-widget-sip.h            \
        empathy-contact-dialogs.h               \
        empathy-new-message-dialog.h            \
        empathy-theme-irc.h                     \
diff --git a/libempathy-gtk/empathy-account-widget-sip.c b/libempathy-gtk/empathy-account-widget-sip.c
new file mode 100644 (file)
index 0000000..a8a7514
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2007-2008 Guillaume Desmottes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors: Guillaume Desmottes <gdesmott@gnome.org>
+ *          Frederic Peters <fpeters@0d.be>
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+
+#include <libmissioncontrol/mc-account.h>
+#include <libmissioncontrol/mc-protocol.h>
+
+#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-debug.h>
+
+#include "empathy-account-widget.h"
+#include "empathy-account-widget-sip.h"
+#include "empathy-ui-utils.h"
+
+#define DEBUG_DOMAIN "AccountWidgetSIP"
+
+typedef struct {
+  McAccount *account;
+
+  GtkWidget *vbox_settings;
+
+  GtkWidget *entry_stun_server;
+  GtkWidget *spinbutton_stun_part;
+  GtkWidget *checkbutton_discover_stun;
+} EmpathyAccountWidgetSip;
+
+static void
+account_widget_sip_destroy_cb (GtkWidget *widget,
+                               EmpathyAccountWidgetSip *settings)
+{
+  g_object_unref (settings->account);
+  g_slice_free (EmpathyAccountWidgetSip, settings);
+}
+
+static void
+account_widget_sip_discover_stun_toggled_cb (
+    GtkWidget *checkbox,
+    EmpathyAccountWidgetSip *settings)
+{
+  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox))) {
+    gtk_widget_set_sensitive(settings->entry_stun_server, TRUE);
+    gtk_widget_set_sensitive(settings->spinbutton_stun_part, TRUE);
+  } else {
+    gtk_widget_set_sensitive(settings->entry_stun_server, FALSE);
+    gtk_widget_set_sensitive(settings->spinbutton_stun_part, FALSE);
+  }
+}
+
+/**
+ * empathy_account_widget_sip_new:
+ * @account: the #McAccount to configure
+ *
+ * Creates a new SIP account widget to configure a given #McAccount
+ *
+ * Returns: The toplevel container of the configuration widget
+ */
+GtkWidget *
+empathy_account_widget_sip_new (McAccount *account)
+{
+  EmpathyAccountWidgetSip *settings;
+  GladeXML *glade;
+  gchar *filename;
+
+  settings = g_slice_new0 (EmpathyAccountWidgetSip);
+  settings->account = g_object_ref (account);
+
+  filename = empathy_file_lookup ("empathy-account-widget-sip.glade",
+      "libempathy-gtk");
+  glade = empathy_glade_get_file (filename,
+      "vbox_sip_settings",
+      NULL,
+      "vbox_sip_settings", &settings->vbox_settings,
+      "entry_stun-server", &settings->entry_stun_server,
+      "spinbutton_stun-port", &settings->spinbutton_stun_part,
+      "checkbutton_discover-stun", &settings->checkbutton_discover_stun,
+      NULL);
+  g_free (filename);
+
+  empathy_account_widget_handle_params (account, glade,
+      "entry_userid", "account",
+      "entry_password", "password",
+      "entry_proxy","proxy-host",
+      "spinbutton_port", "port",
+      "entry_transport", "transport",
+      "checkbutton_discover-binding","discover-binding",
+      "entry_keepalive-mechanism", "keepalive-mechanism",
+      "entry_keepalive-interval", "keepalive-interval",
+      "checkbutton_discover-stun", "discover-stun",
+      "entry_stun-server", "stun-server",
+      "spinbutton_stun-port", "stun-port",
+      "entry_local-ip", "local-ip-address",
+      "spinbutton_local-port", "local-port",
+      "entry_extra-auth-user", "extra-auth-user",
+      "entry_extra-auth-password", "extra-auth-password",
+      NULL);
+
+  empathy_account_widget_add_forget_button (account, glade,
+                                            "button_forget",
+                                            "entry_password");
+
+  account_widget_sip_discover_stun_toggled_cb (settings->checkbutton_discover_stun,
+                                               settings);
+
+  empathy_glade_connect (glade, settings,
+      "vbox_sip_settings", "destroy", account_widget_sip_destroy_cb,
+      "checkbutton_discover-stun", "toggled", account_widget_sip_discover_stun_toggled_cb,
+      NULL);
+
+  g_object_unref (glade);
+
+  return settings->vbox_settings;
+}
index 5f78509e67f845adfa8d430b720867fabf01d18f..2182be9f318daa483173b9ffdf824d6a35d0ae95 100644 (file)
         <child>
           <widget class="GtkTable" id="table1">
             <property name="visible">True</property>
-            <property name="n_rows">3</property>
+            <property name="n_rows">2</property>
             <property name="n_columns">2</property>
             <property name="column_spacing">12</property>
             <property name="row_spacing">6</property>
-            <child>
-              <widget class="GtkEntry" id="entry_registar">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-              </widget>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="y_options"></property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="label_registar">
-                <property name="visible">True</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">_Registrar:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">entry_registar</property>
-              </widget>
-              <packing>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
-              </packing>
-            </child>
             <child>
               <widget class="GtkLabel" id="label_password">
                 <property name="visible">True</property>
                 <child>
                   <widget class="GtkTable" id="table_advanced_sip_settings">
                     <property name="visible">True</property>
-                    <property name="n_rows">14</property>
+                    <property name="n_rows">13</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">6</property>
                     <property name="row_spacing">6</property>
                       <widget class="GtkCheckButton" id="checkbutton_discover-binding">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="label" translatable="yes">Discover Binding</property>
+                        <property name="label" translatable="yes" comments="update our user agent's IP address, as in the Contact header URI, based on information reflected by the proxy as per RFC 3581.">Discover Binding</property>
                         <property name="use_underline">True</property>
                         <property name="response_id">0</property>
                         <property name="draw_indicator">True</property>
                       <widget class="GtkCheckButton" id="checkbutton_discover-stun">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="label" translatable="yes">Discover Stun</property>
+                        <property name="label" translatable="yes" comments="look up the DNS SRV record at the service's domain for the host name of a STUN server.">Discover STUN</property>
                         <property name="use_underline">True</property>
                         <property name="response_id">0</property>
                         <property name="draw_indicator">True</property>
                         <property name="y_options"></property>
                       </packing>
                     </child>
-                    <child>
-                      <widget class="GtkCheckButton" id="checkbutton_avoid-difficult">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="label" translatable="yes">Avoid Difficult</property>
-                        <property name="use_underline">True</property>
-                        <property name="response_id">0</property>
-                        <property name="draw_indicator">True</property>
-                      </widget>
-                      <packing>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">13</property>
-                        <property name="bottom_attach">14</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
+                   <child>
                       <widget class="GtkSpinButton" id="spinbutton_local-port">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
diff --git a/libempathy-gtk/empathy-account-widget-sip.h b/libempathy-gtk/empathy-account-widget-sip.h
new file mode 100644 (file)
index 0000000..7e8e5a2
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2007-2008 Guillaume Desmottes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors: Frederic Peters <fpeters@0d.be>
+ */
+
+#ifndef __EMPATHY_ACCOUNT_WIDGET_SIP_H__
+#define __EMPATHY_ACCOUNT_WIDGET_SIP_H__
+
+#include <gtk/gtkwidget.h>
+#include <libmissioncontrol/mc-account.h>
+
+G_BEGIN_DECLS
+
+GtkWidget * empathy_account_widget_sip_new (McAccount *account);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_ACCOUNT_WIDGET_SIP_H__ */
index 88cb509c115f1ac02f71b80867a8635e7b15dee4..6e14d4857a508e762d1fe5c74fda99e2d8dc1f02 100644 (file)
@@ -537,55 +537,6 @@ empathy_account_widget_msn_new (McAccount *account)
        return widget;
 }
 
-GtkWidget *
-empathy_account_widget_sip_new (McAccount *account)
-{
-       GladeXML    *glade;
-       GtkWidget   *widget;
-       gchar       *filename;
-
-       filename = empathy_file_lookup ("empathy-account-widget-sip.glade",
-                                       "libempathy-gtk");
-
-       glade = empathy_glade_get_file (filename,
-                                       "vbox_sip_settings",
-                                       NULL,
-                                       "vbox_sip_settings", &widget,
-                                       NULL);
-       
-       g_free (filename);
-
-       empathy_account_widget_handle_params (account, glade,
-               "entry_userid", "account",
-               "entry_password", "password",
-               "entry_registar", "registar",
-               "entry_proxy","proxy-host",
-               "spinbutton_port", "port",
-               "entry_transport", "transport",
-               "checkbutton_discover-binding","discover-binding",
-               "entry_keepalive-mechanism", "keepalive-mechanism",
-               "entry_keepalive-interval", "keepalive-interval",
-               "checkbutton_discover-stun", "discover-stun",
-               "entry_stun-server", "stun-server",
-               "spinbutton_stun-port", "stun-port",
-               "entry_local-ip", "local-ip-address",
-               "spinbutton_local-port", "local-port",
-               "entry_extra-auth-user", "extra-auth-user",
-               "entry_extra-auth-password", "extra-auth-password",
-               "checkbutton_avoid-difficult", "avoid-difficult",
-               NULL);
-
-       empathy_account_widget_add_forget_button (account, glade,
-                                                 "button_forget",
-                                                 "entry_password");
-
-       g_object_unref (glade);
-
-       gtk_widget_show (widget);
-
-       return widget;
-}
-
 GtkWidget *
 empathy_account_widget_jabber_new (McAccount *account)
 {
index 11e0448f11a3f1983a18a705ce50c6aca5067672..52e907d0019d9945840c8c0b55c9864efc774d20 100644 (file)
@@ -47,7 +47,6 @@ GtkWidget *empathy_account_widget_jabber_new        (McAccount   *account);
 GtkWidget *empathy_account_widget_icq_new           (McAccount   *account);
 GtkWidget *empathy_account_widget_aim_new           (McAccount   *account);
 GtkWidget *empathy_account_widget_yahoo_new         (McAccount   *account);
-GtkWidget *empathy_account_widget_sip_new          (McAccount   *account);
 GtkWidget *empathy_account_widget_groupwise_new     (McAccount   *account);
 
 G_END_DECLS
index 0ea4416a3bc68ba7fd62996bfc7cd5d0e98ed7ff..be0f67a8ea11ab1056106b99f9af8c12789a6eb6 100644 (file)
@@ -46,6 +46,7 @@
 #include "empathy-profile-chooser.h"
 #include "empathy-account-widget.h"
 #include "empathy-account-widget-irc.h"
+#include "empathy-account-widget-sip.h"
 
 #define DEBUG_DOMAIN "AccountDialog"