]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-account-widget-sip.c
Add en_GB in gitignore
[empathy.git] / libempathy-gtk / empathy-account-widget-sip.c
1 /*
2  * Copyright (C) 2007-2008 Guillaume Desmottes
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors: Guillaume Desmottes <gdesmott@gnome.org>
19  *          Frederic Peters <fpeters@0d.be>
20  */
21
22 #include "config.h"
23
24 #include <stdlib.h>
25 #include <string.h>
26 #include <sys/stat.h>
27
28 #include <glib/gi18n-lib.h>
29 #include <gtk/gtk.h>
30 #include <glade/glade.h>
31
32 #include <libmissioncontrol/mc-account.h>
33 #include <libmissioncontrol/mc-protocol.h>
34
35 #include <libempathy/empathy-utils.h>
36
37 #include "empathy-account-widget.h"
38 #include "empathy-account-widget-sip.h"
39 #include "empathy-ui-utils.h"
40
41 typedef struct {
42   McAccount *account;
43
44   GtkWidget *vbox_settings;
45
46   GtkWidget *entry_stun_server;
47   GtkWidget *spinbutton_stun_part;
48   GtkWidget *checkbutton_discover_stun;
49 } EmpathyAccountWidgetSip;
50
51 static void
52 account_widget_sip_destroy_cb (GtkWidget *widget,
53                                EmpathyAccountWidgetSip *settings)
54 {
55   g_object_unref (settings->account);
56   g_slice_free (EmpathyAccountWidgetSip, settings);
57 }
58
59 static void
60 account_widget_sip_discover_stun_toggled_cb (
61     GtkWidget *checkbox,
62     EmpathyAccountWidgetSip *settings)
63 {
64   gboolean active;
65
66   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
67   gtk_widget_set_sensitive(settings->entry_stun_server, !active);
68   gtk_widget_set_sensitive(settings->spinbutton_stun_part, !active);
69 }
70
71 /**
72  * empathy_account_widget_sip_new:
73  * @account: the #McAccount to configure
74  *
75  * Creates a new SIP account widget to configure a given #McAccount
76  *
77  * Returns: The toplevel container of the configuration widget
78  */
79 GtkWidget *
80 empathy_account_widget_sip_new (McAccount *account)
81 {
82   EmpathyAccountWidgetSip *settings;
83   GladeXML *glade;
84   gchar *filename;
85
86   settings = g_slice_new0 (EmpathyAccountWidgetSip);
87   settings->account = g_object_ref (account);
88
89   filename = empathy_file_lookup ("empathy-account-widget-sip.glade",
90       "libempathy-gtk");
91   glade = empathy_glade_get_file (filename,
92       "vbox_sip_settings",
93       NULL,
94       "vbox_sip_settings", &settings->vbox_settings,
95       "entry_stun-server", &settings->entry_stun_server,
96       "spinbutton_stun-port", &settings->spinbutton_stun_part,
97       "checkbutton_discover-stun", &settings->checkbutton_discover_stun,
98       NULL);
99   g_free (filename);
100
101   empathy_account_widget_handle_params (account, glade,
102       "entry_userid", "account",
103       "entry_password", "password",
104       "checkbutton_discover-stun", "discover-stun",
105       "entry_stun-server", "stun-server",
106       "spinbutton_stun-port", "stun-port",
107       NULL);
108
109   empathy_account_widget_add_forget_button (account, glade,
110                                             "button_forget",
111                                             "entry_password");
112
113   account_widget_sip_discover_stun_toggled_cb (settings->checkbutton_discover_stun,
114                                                settings);
115
116   empathy_glade_connect (glade, settings,
117       "vbox_sip_settings", "destroy", account_widget_sip_destroy_cb,
118       "checkbutton_discover-stun", "toggled", account_widget_sip_discover_stun_toggled_cb,
119       NULL);
120
121   g_object_unref (glade);
122
123   return settings->vbox_settings;
124 }