]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-account-widget-sip.c
Updated Basque language
[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
31 #include <libempathy/empathy-utils.h>
32
33 #include "empathy-account-widget.h"
34 #include "empathy-account-widget-private.h"
35 #include "empathy-account-widget-sip.h"
36 #include "empathy-ui-utils.h"
37
38 typedef struct {
39   EmpathyAccountWidget *self;
40   GtkWidget *vbox_settings;
41
42   GtkWidget *entry_stun_server;
43   GtkWidget *spinbutton_stun_part;
44   GtkWidget *checkbutton_discover_stun;
45 } EmpathyAccountWidgetSip;
46
47 static void
48 account_widget_sip_destroy_cb (GtkWidget *widget,
49                                EmpathyAccountWidgetSip *settings)
50 {
51   g_slice_free (EmpathyAccountWidgetSip, settings);
52 }
53
54 static void
55 account_widget_sip_discover_stun_toggled_cb (
56     GtkWidget *checkbox,
57     EmpathyAccountWidgetSip *settings)
58 {
59   gboolean active;
60
61   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
62   gtk_widget_set_sensitive (settings->entry_stun_server, !active);
63   gtk_widget_set_sensitive (settings->spinbutton_stun_part, !active);
64 }
65
66 void
67 empathy_account_widget_sip_build (EmpathyAccountWidget *self,
68     const char *filename,
69     GtkWidget **table_common_settings)
70 {
71   EmpathyAccountWidgetSip *settings;
72   GtkWidget *vbox_settings;
73   gboolean is_simple;
74
75   g_object_get (self, "simple", &is_simple, NULL);
76
77   if (is_simple)
78     {
79       self->ui_details->gui = empathy_builder_get_file (filename,
80           "vbox_sip_simple", &vbox_settings,
81           NULL);
82
83       empathy_account_widget_handle_params (self,
84           "entry_userid_simple", "account",
85           "entry_password_simple", "password",
86           NULL);
87
88       self->ui_details->default_focus = g_strdup ("entry_userid_simple");
89     }
90   else
91     {
92       settings = g_slice_new0 (EmpathyAccountWidgetSip);
93       settings->self = self;
94
95       self->ui_details->gui = empathy_builder_get_file (filename,
96           "table_common_settings", table_common_settings,
97           "vbox_sip_settings", &vbox_settings,
98           "entry_stun-server", &settings->entry_stun_server,
99           "spinbutton_stun-port", &settings->spinbutton_stun_part,
100           "checkbutton_discover-stun", &settings->checkbutton_discover_stun,
101           NULL);
102       settings->vbox_settings = vbox_settings;
103
104       empathy_account_widget_handle_params (self,
105           "entry_userid", "account",
106           "entry_password", "password",
107           "checkbutton_discover-stun", "discover-stun",
108           "entry_stun-server", "stun-server",
109           "spinbutton_stun-port", "stun-port",
110           NULL);
111
112       account_widget_sip_discover_stun_toggled_cb (
113           settings->checkbutton_discover_stun,
114           settings);
115
116       empathy_builder_connect (self->ui_details->gui, settings,
117           "vbox_sip_settings", "destroy", account_widget_sip_destroy_cb,
118           "checkbutton_discover-stun", "toggled",
119           account_widget_sip_discover_stun_toggled_cb,
120           NULL);
121
122       self->ui_details->add_forget = TRUE;
123       self->ui_details->default_focus = g_strdup ("entry_userid");
124     }
125
126   self->ui_details->widget = vbox_settings;
127 }