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>
35 #include "empathy-account-widget-salut.h"
36 #include "empathy-ui-utils.h"
41 GtkWidget *vbox_settings;
42 GtkWidget *entry_nickname;
43 GtkWidget *entry_published;
44 GtkWidget *entry_first_name;
45 GtkWidget *entry_last_name;
46 GtkWidget *entry_email;
48 } EmpathyAccountWidgetSalut;
51 account_widget_salut_entry_focus_cb (GtkWidget *widget,
53 EmpathyAccountWidgetSalut *settings)
58 if (widget == settings->entry_nickname) {
61 else if (widget == settings->entry_published) {
62 param = "published-name";
64 else if (widget == settings->entry_first_name) {
67 else if (widget == settings->entry_last_name) {
70 else if (widget == settings->entry_email) {
73 else if (widget == settings->entry_jid) {
80 str = gtk_entry_get_text (GTK_ENTRY (widget));
82 if (G_STR_EMPTY (str)) {
85 mc_account_get_param_string (settings->account, param, &value);
86 gtk_entry_set_text (GTK_ENTRY (widget), value ? value : "");
89 mc_account_set_param_string (settings->account, param, str);
96 account_widget_salut_destroy_cb (GtkWidget *widget,
97 EmpathyAccountWidgetSalut *settings)
99 g_object_unref (settings->account);
104 account_widget_salut_setup (EmpathyAccountWidgetSalut *settings)
106 gchar *nickname = NULL;
107 gchar *published_name = NULL;
108 gchar *first_name = NULL;
109 gchar *last_name = NULL;
113 mc_account_get_param_string (settings->account, "nickname", &nickname);
114 mc_account_get_param_string (settings->account, "published-name", &published_name);
115 mc_account_get_param_string (settings->account, "first-name", &first_name);
116 mc_account_get_param_string (settings->account, "last-name", &last_name);
117 mc_account_get_param_string (settings->account, "email", &email);
118 mc_account_get_param_string (settings->account, "jid", &jid);
120 gtk_entry_set_text (GTK_ENTRY (settings->entry_nickname), nickname ? nickname : "");
121 gtk_entry_set_text (GTK_ENTRY (settings->entry_published), published_name ? published_name : "");
122 gtk_entry_set_text (GTK_ENTRY (settings->entry_first_name), first_name ? first_name : "");
123 gtk_entry_set_text (GTK_ENTRY (settings->entry_last_name), last_name ? last_name : "");
124 gtk_entry_set_text (GTK_ENTRY (settings->entry_email), email ? email : "");
125 gtk_entry_set_text (GTK_ENTRY (settings->entry_jid), jid ? jid : "");
128 g_free (published_name);
137 empathy_account_widget_salut_new (McAccount *account)
139 EmpathyAccountWidgetSalut *settings;
142 settings = g_new0 (EmpathyAccountWidgetSalut, 1);
143 settings->account = g_object_ref (account);
145 glade = empathy_glade_get_file ("empathy-account-widget-salut.glade",
146 "vbox_salut_settings",
148 "vbox_salut_settings", &settings->vbox_settings,
149 "entry_published", &settings->entry_published,
150 "entry_nickname", &settings->entry_nickname,
151 "entry_first_name", &settings->entry_first_name,
152 "entry_last_name", &settings->entry_last_name,
153 "entry_email", &settings->entry_email,
154 "entry_jid", &settings->entry_jid,
157 account_widget_salut_setup (settings);
159 empathy_glade_connect (glade,
161 "vbox_salut_settings", "destroy", account_widget_salut_destroy_cb,
162 "entry_nickname", "focus-out-event", account_widget_salut_entry_focus_cb,
163 "entry_published", "focus-out-event", account_widget_salut_entry_focus_cb,
164 "entry_first_name", "focus-out-event", account_widget_salut_entry_focus_cb,
165 "entry_last_name", "focus-out-event", account_widget_salut_entry_focus_cb,
166 "entry_email", "focus-out-event", account_widget_salut_entry_focus_cb,
167 "entry_jid", "focus-out-event", account_widget_salut_entry_focus_cb,
170 g_object_unref (glade);
172 gtk_widget_show (settings->vbox_settings);
174 return settings->vbox_settings;