1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3
* Copyright (C) 2007 Collabora Ltd.
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
* Authors: Xavier Claessens <xclaesse@gmail.com>
20
* Cosimo Cecchi <anarki@lilik.it>
27
#include <glib/gi18n.h>
29
#include <glade/glade.h>
31
#include <libmissioncontrol/mc-profile.h>
33
#include <libempathy/empathy-utils.h>
34
#include <libempathy/empathy-debug.h>
36
#include "empathy-account-widget-salut.h"
37
#include "empathy-ui-utils.h"
39
#define DEBUG_DOMAIN "AccountWidgetMSN"
44
GtkWidget *vbox_settings;
45
GtkWidget *entry_nickname;
46
GtkWidget *entry_published;
47
GtkWidget *entry_first_name;
48
GtkWidget *entry_last_name;
49
GtkWidget *entry_email;
51
} EmpathyAccountWidgetSalut;
54
account_widget_salut_entry_focus_cb (GtkWidget *widget,
56
EmpathyAccountWidgetSalut *settings)
61
if (widget == settings->entry_nickname) {
64
else if (widget == settings->entry_published) {
65
param = "published-name";
67
else if (widget == settings->entry_first_name) {
70
else if (widget == settings->entry_last_name) {
73
else if (widget == settings->entry_email) {
76
else if (widget == settings->entry_jid) {
83
str = gtk_entry_get_text (GTK_ENTRY (widget));
84
if (G_STR_EMPTY (str)) {
87
mc_account_unset_param (settings->account, param);
88
mc_account_get_param_string (settings->account, param, &value);
89
empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %s", param, value);
90
gtk_entry_set_text (GTK_ENTRY (widget), value ? value : "");
93
empathy_debug (DEBUG_DOMAIN, "Setting %s to %s", param, str);
94
mc_account_set_param_string (settings->account, param, str);
101
account_widget_salut_destroy_cb (GtkWidget *widget,
102
EmpathyAccountWidgetSalut *settings)
104
g_object_unref (settings->account);
109
account_widget_salut_setup (EmpathyAccountWidgetSalut *settings)
111
gchar *nickname = NULL;
112
gchar *published_name = NULL;
113
gchar *first_name = NULL;
114
gchar *last_name = NULL;
118
mc_account_get_param_string (settings->account, "nickname", &nickname);
119
mc_account_get_param_string (settings->account, "published-name", &published_name);
120
mc_account_get_param_string (settings->account, "first-name", &first_name);
121
mc_account_get_param_string (settings->account, "last-name", &last_name);
122
mc_account_get_param_string (settings->account, "email", &email);
123
mc_account_get_param_string (settings->account, "jid", &jid);
125
gtk_entry_set_text (GTK_ENTRY (settings->entry_nickname), nickname ? nickname : "");
126
gtk_entry_set_text (GTK_ENTRY (settings->entry_published), published_name ? published_name : "");
127
gtk_entry_set_text (GTK_ENTRY (settings->entry_first_name), first_name ? first_name : "");
128
gtk_entry_set_text (GTK_ENTRY (settings->entry_last_name), last_name ? last_name : "");
129
gtk_entry_set_text (GTK_ENTRY (settings->entry_email), email ? email : "");
130
gtk_entry_set_text (GTK_ENTRY (settings->entry_jid), jid ? jid : "");
133
g_free (published_name);
142
empathy_account_widget_salut_new (McAccount *account)
144
EmpathyAccountWidgetSalut *settings;
147
settings = g_new0 (EmpathyAccountWidgetSalut, 1);
148
settings->account = g_object_ref (account);
150
glade = empathy_glade_get_file ("empathy-account-widget-salut.glade",
151
"vbox_salut_settings",
153
"vbox_salut_settings", &settings->vbox_settings,
154
"entry_published", &settings->entry_published,
155
"entry_nickname", &settings->entry_nickname,
156
"entry_first_name", &settings->entry_first_name,
157
"entry_last_name", &settings->entry_last_name,
158
"entry_email", &settings->entry_email,
159
"entry_jid", &settings->entry_jid,
162
account_widget_salut_setup (settings);
164
empathy_glade_connect (glade,
166
"vbox_salut_settings", "destroy", account_widget_salut_destroy_cb,
167
"entry_nickname", "focus-out-event", account_widget_salut_entry_focus_cb,
168
"entry_published", "focus-out-event", account_widget_salut_entry_focus_cb,
169
"entry_first_name", "focus-out-event", account_widget_salut_entry_focus_cb,
170
"entry_last_name", "focus-out-event", account_widget_salut_entry_focus_cb,
171
"entry_email", "focus-out-event", account_widget_salut_entry_focus_cb,
172
"entry_jid", "focus-out-event", account_widget_salut_entry_focus_cb,
175
g_object_unref (glade);
177
gtk_widget_show (settings->vbox_settings);
179
return settings->vbox_settings;