From 752849381a4b486de3d697d7c57443bea42f9bee Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 23 Aug 2007 10:25:49 +0000 Subject: [PATCH] Add specialised UI for salut settings. Configure a Salut account first 2007-08-23 Xavier Claessens * libempathy-gtk/empathy-account-widget-salut.glade: * libempathy-gtk/empathy-account-widget-salut.c: * libempathy-gtk/empathy-account-widget-salut.h: * libempathy-gtk/empathy-preferences.h: * libempathy-gtk/empathy-accounts-dialog.c: * libempathy-gtk/Makefile.am: * src/empathy.c: * configure.ac: * data/empathy.schemas.in: Add specialised UI for salut settings. Configure a Salut account first time empathy is started with salut CM installed using gnome-about-me information. Fixes bug #447467 (Cosimo Cecchi, Xavier Claessens). svn path=/trunk/; revision=266 --- ChangeLog | 15 + configure.ac | 1 + data/empathy.schemas.in | 15 + libempathy-gtk/Makefile.am | 15 +- libempathy-gtk/empathy-account-widget-salut.c | 184 ++++++++ .../empathy-account-widget-salut.glade | 395 ++++++++++++++++++ libempathy-gtk/empathy-account-widget-salut.h | 34 ++ libempathy-gtk/empathy-accounts-dialog.c | 5 + libempathy-gtk/empathy-preferences.h | 1 + src/empathy.c | 84 ++++ 10 files changed, 743 insertions(+), 6 deletions(-) create mode 100644 libempathy-gtk/empathy-account-widget-salut.c create mode 100644 libempathy-gtk/empathy-account-widget-salut.glade create mode 100644 libempathy-gtk/empathy-account-widget-salut.h diff --git a/ChangeLog b/ChangeLog index 57b5fde0..bfb4426f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-08-23 Xavier Claessens + + * libempathy-gtk/empathy-account-widget-salut.glade: + * libempathy-gtk/empathy-account-widget-salut.c: + * libempathy-gtk/empathy-account-widget-salut.h: + * libempathy-gtk/empathy-preferences.h: + * libempathy-gtk/empathy-accounts-dialog.c: + * libempathy-gtk/Makefile.am: + * src/empathy.c: + * configure.ac: + * data/empathy.schemas.in: Add specialised UI for salut settings. + Configure a Salut account first time empathy is started with + salut CM installed using gnome-about-me information. Fixes bug #447467 + (Cosimo Cecchi, Xavier Claessens). + 2007-08-19 Xavier Claessens * python/pyempathy/Makefile.am: diff --git a/configure.ac b/configure.ac index f582d2bd..9bc30b4e 100644 --- a/configure.ac +++ b/configure.ac @@ -96,6 +96,7 @@ PKG_CHECK_MODULES(EMPATHY, gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED libgnomeui-2.0 + libebook-1.2 ]) dnl ----------------------------------------------------------- diff --git a/data/empathy.schemas.in b/data/empathy.schemas.in index 103fdd2a..29a8bc99 100644 --- a/data/empathy.schemas.in +++ b/data/empathy.schemas.in @@ -245,6 +245,21 @@ + + /schemas/apps/empathy/accounts/salut_created + /apps/empathy/accounts/salut_created + empathy + bool + false + + Checks if Salut account is created + + Whether or not the Salut account has been created on the first + empathy run. + + + + diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index 7b0a9db2..f73966a3 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -20,6 +20,8 @@ libempathy_gtk_la_SOURCES = \ empathy-accounts-dialog.c \ empathy-account-widget-generic.c \ empathy-account-widget-jabber.c \ + empathy-account-widget-msn.c \ + empathy-account-widget-salut.c \ empathy-profile-chooser.c \ empathy-cell-renderer-expander.c \ empathy-cell-renderer-text.c \ @@ -43,8 +45,7 @@ libempathy_gtk_la_SOURCES = \ empathy-new-chatroom-dialog.c \ empathy-chatrooms-window.c \ empathy-log-window.c \ - empathy-ui-utils.c \ - empathy-account-widget-msn.c + empathy-ui-utils.c # do not distribute generated files nodist_libempathy_gtk_la_SOURCES =\ @@ -66,6 +67,8 @@ libempathy_gtk_headers = \ empathy-accounts-dialog.h \ empathy-account-widget-generic.h \ empathy-account-widget-jabber.h \ + empathy-account-widget-msn.h \ + empathy-account-widget-salut.h \ empathy-profile-chooser.h \ empathy-cell-renderer-expander.h \ empathy-cell-renderer-text.h \ @@ -89,8 +92,7 @@ libempathy_gtk_headers = \ empathy-new-chatroom-dialog.h \ empathy-chatrooms-window.h \ empathy-log-window.h \ - empathy-ui-utils.h \ - empathy-account-widget-msn.h + empathy-ui-utils.h libempathy_gtk_includedir = $(includedir)/libempathy-gtk/ libempathy_gtk_include_HEADERS = \ @@ -107,13 +109,14 @@ glade_DATA = \ empathy-presence-chooser.glade \ empathy-accounts-dialog.glade \ empathy-account-widget-jabber.glade \ + empathy-account-widget-msn.glade \ + empathy-account-widget-salut.glade \ empathy-new-chatroom-dialog.glade \ empathy-group-chat.glade \ empathy-chatrooms-window.glade \ empathy-spell-dialog.glade \ empathy-log-window.glade \ - empathy-chat.glade \ - empathy-account-widget-msn.glade + empathy-chat.glade empathy-gtk-enum-types.h: stamp-empathy-gtk-enum-types.h @true diff --git a/libempathy-gtk/empathy-account-widget-salut.c b/libempathy-gtk/empathy-account-widget-salut.c new file mode 100644 index 00000000..94da89e2 --- /dev/null +++ b/libempathy-gtk/empathy-account-widget-salut.c @@ -0,0 +1,184 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2007 Cosimo Cecchi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Cosimo Cecchi + */ + +#include "config.h" + +#include + +#include +#include +#include + +#include + +#include + +#include "empathy-account-widget-salut.h" +#include "empathy-ui-utils.h" + +typedef struct { + McAccount *account; + + GtkWidget *vbox_settings; + GtkWidget *entry_nickname; + GtkWidget *entry_published; + GtkWidget *entry_first_name; + GtkWidget *entry_last_name; + GtkWidget *entry_email; + GtkWidget *entry_jid; +} EmpathyAccountWidgetSalut; + +static gboolean account_widget_salut_entry_focus_cb (GtkWidget *widget, + GdkEventFocus *event, + EmpathyAccountWidgetSalut *settings); +static void account_widget_salut_destroy_cb (GtkWidget *widget, + EmpathyAccountWidgetSalut *settings); +static void account_widget_salut_setup (EmpathyAccountWidgetSalut *settings); + + + +static gboolean +account_widget_salut_entry_focus_cb (GtkWidget *widget, + GdkEventFocus *event, + EmpathyAccountWidgetSalut *settings) +{ + const gchar *param; + const gchar *str; + + if (widget == settings->entry_nickname) { + param = "nickname"; + } + else if (widget == settings->entry_published) { + param = "published-name"; + } + else if (widget == settings->entry_first_name) { + param = "first-name"; + } + else if (widget == settings->entry_last_name) { + param = "last-name"; + } + else if (widget == settings->entry_email) { + param = "email"; + } + else if (widget == settings->entry_jid) { + param = "jid"; + } + else { + return FALSE; + } + + str = gtk_entry_get_text (GTK_ENTRY (widget)); + + if (G_STR_EMPTY (str)) { + gchar *value = NULL; + + mc_account_get_param_string (settings->account, param, &value); + gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); + g_free (value); + } else { + mc_account_set_param_string (settings->account, param, str); + } + + return FALSE; +} + +static void +account_widget_salut_destroy_cb (GtkWidget *widget, + EmpathyAccountWidgetSalut *settings) +{ + g_object_unref (settings->account); + g_free (settings); +} + +static void +account_widget_salut_setup (EmpathyAccountWidgetSalut *settings) +{ + gchar *nickname = NULL; + gchar *published_name = NULL; + gchar *first_name = NULL; + gchar *last_name = NULL; + gchar *email = NULL; + gchar *jid = NULL; + + mc_account_get_param_string (settings->account, "nickname", &nickname); + mc_account_get_param_string (settings->account, "published-name", &published_name); + mc_account_get_param_string (settings->account, "first-name", &first_name); + mc_account_get_param_string (settings->account, "last-name", &last_name); + mc_account_get_param_string (settings->account, "email", &email); + mc_account_get_param_string (settings->account, "jid", &jid); + + gtk_entry_set_text (GTK_ENTRY (settings->entry_nickname), nickname ? nickname : ""); + gtk_entry_set_text (GTK_ENTRY (settings->entry_published), published_name ? published_name : ""); + gtk_entry_set_text (GTK_ENTRY (settings->entry_first_name), first_name ? first_name : ""); + gtk_entry_set_text (GTK_ENTRY (settings->entry_last_name), last_name ? last_name : ""); + gtk_entry_set_text (GTK_ENTRY (settings->entry_email), email ? email : ""); + gtk_entry_set_text (GTK_ENTRY (settings->entry_jid), jid ? jid : ""); + + g_free (nickname); + g_free (published_name); + g_free (first_name); + g_free (last_name); + g_free (email); + g_free (jid); +} + + +GtkWidget * +empathy_account_widget_salut_new (McAccount *account) +{ + EmpathyAccountWidgetSalut *settings; + GladeXML *glade; + + settings = g_new0 (EmpathyAccountWidgetSalut, 1); + settings->account = g_object_ref (account); + + glade = empathy_glade_get_file ("empathy-account-widget-salut.glade", + "vbox_salut_settings", + NULL, + "vbox_salut_settings", &settings->vbox_settings, + "entry_published", &settings->entry_published, + "entry_nickname", &settings->entry_nickname, + "entry_first_name", &settings->entry_first_name, + "entry_last_name", &settings->entry_last_name, + "entry_email", &settings->entry_email, + "entry_jid", &settings->entry_jid, + NULL); + + account_widget_salut_setup (settings); + + empathy_glade_connect (glade, + settings, + "vbox_salut_settings", "destroy", account_widget_salut_destroy_cb, + "entry_nickname", "focus-out-event", account_widget_salut_entry_focus_cb, + "entry_published", "focus-out-event", account_widget_salut_entry_focus_cb, + "entry_first_name", "focus-out-event", account_widget_salut_entry_focus_cb, + "entry_last_name", "focus-out-event", account_widget_salut_entry_focus_cb, + "entry_email", "focus-out-event", account_widget_salut_entry_focus_cb, + "entry_jid", "focus-out-event", account_widget_salut_entry_focus_cb, + NULL); + + g_object_unref (glade); + + gtk_widget_show (settings->vbox_settings); + + return settings->vbox_settings; +} diff --git a/libempathy-gtk/empathy-account-widget-salut.glade b/libempathy-gtk/empathy-account-widget-salut.glade new file mode 100644 index 00000000..14ede695 --- /dev/null +++ b/libempathy-gtk/empathy-account-widget-salut.glade @@ -0,0 +1,395 @@ + + + + + + + True + salut account settings + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + False + 6 + + + + True + 2 + 3 + False + 6 + 12 + + + + True + _First Name: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + entry_first_name + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _Last Name: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + entry_last_name + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 3 + 0 + 1 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 3 + 1 + 2 + + + + + + 0 + False + False + + + + + + True + True + False + 0 + + + + True + 4 + 3 + False + 6 + 12 + + + + True + _E-mail: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + entry_email + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + _Jabber ID: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + entry_jid + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 3 + 2 + 3 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 3 + 3 + 4 + + + + + + + True + _Nickname: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + entry_nickname + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _Published Name: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + entry_published + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 3 + 0 + 1 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 3 + 1 + 2 + + + + + + + + + True + <b>Advanced</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + False + False + + + + + + + diff --git a/libempathy-gtk/empathy-account-widget-salut.h b/libempathy-gtk/empathy-account-widget-salut.h new file mode 100644 index 00000000..57427187 --- /dev/null +++ b/libempathy-gtk/empathy-account-widget-salut.h @@ -0,0 +1,34 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2007 Cosimo Cecchi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Cosimo Cecchi + */ + +#ifndef __EMPATHY_ACCOUNT_WIDGET_SALUT_H__ +#define __EMPATHY_ACCOUNT_WIDGET_SALUT_H__ + +#include + +G_BEGIN_DECLS + +GtkWidget *empathy_account_widget_salut_new (McAccount *account); + +G_END_DECLS + +#endif /* __EMPATHY_ACCOUNT_WIDGET_SALUT_H__ */ diff --git a/libempathy-gtk/empathy-accounts-dialog.c b/libempathy-gtk/empathy-accounts-dialog.c index 2a12eb1d..3f291197 100644 --- a/libempathy-gtk/empathy-accounts-dialog.c +++ b/libempathy-gtk/empathy-accounts-dialog.c @@ -47,6 +47,7 @@ #include "empathy-account-widget-generic.h" #include "empathy-account-widget-jabber.h" #include "empathy-account-widget-msn.h" +#include "empathy-account-widget-salut.h" #define DEBUG_DOMAIN "AccountDialog" @@ -287,6 +288,10 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog, dialog ->settings_widget = empathy_account_widget_msn_new (account); } + else if (!empathy_strdiff (config_ui, "salut")) { + dialog->settings_widget = + empathy_account_widget_salut_new (account); + } else { dialog->settings_widget = empathy_account_widget_generic_new (account); diff --git a/libempathy-gtk/empathy-preferences.h b/libempathy-gtk/empathy-preferences.h index dc058d7e..c787c814 100644 --- a/libempathy-gtk/empathy-preferences.h +++ b/libempathy-gtk/empathy-preferences.h @@ -48,6 +48,7 @@ G_BEGIN_DECLS #define EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE EMPATHY_PREFS_PATH "/contacts/show_offline" #define EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM EMPATHY_PREFS_PATH "/contacts/sort_criterium" #define EMPATHY_PREFS_HINTS_CLOSE_MAIN_WINDOW EMPATHY_PREFS_PATH "/hints/close_main_window" +#define EMPATHY_PREFS_SALUT_ACCOUNT_CREATED EMPATHY_PREFS_PATH "/accounts/salut_created" GtkWidget * empathy_preferences_show (GtkWindow *parent); diff --git a/src/empathy.c b/src/empathy.c index c4ca5530..81fdf1e4 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -45,6 +46,8 @@ #include #include #include +#include +#include #include #include #include @@ -147,6 +150,85 @@ new_channel_cb (EmpathyChandler *chandler, g_object_unref (account); } +static void +create_salut_account (void) +{ + McProfile *profile; + McProtocol *protocol; + gboolean salut_created; + McAccount *account; + EBook *book; + EContact *contact; + gchar *nickname = NULL; + gchar *published_name = NULL; + gchar *first_name = NULL; + gchar *last_name = NULL; + gchar *email = NULL; + gchar *jid = NULL; + + if (!empathy_conf_get_bool (empathy_conf_get(), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + &salut_created)) { + return; + } + if (salut_created) { + return; + } + + profile = mc_profile_lookup ("salut"); + protocol = mc_profile_get_protocol (profile); + if (!protocol) { + g_object_unref (profile); + return; + } + g_object_unref (protocol); + + if (!e_book_get_self (&contact, &book, NULL)) { + return; + } + + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_SALUT_ACCOUNT_CREATED, + TRUE); + + account = mc_account_create (profile); + mc_account_set_display_name (account, _("People nearby")); + + nickname = e_contact_get (contact, E_CONTACT_NICKNAME); + published_name = e_contact_get (contact, E_CONTACT_FULL_NAME); + first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME); + last_name = e_contact_get (contact, E_CONTACT_FAMILY_NAME); + email = e_contact_get (contact, E_CONTACT_EMAIL_1); + jid = e_contact_get (contact, E_CONTACT_IM_JABBER_HOME_1); + + if (G_STR_EMPTY (nickname) || !empathy_strdiff (nickname, "nickname")) { + g_free (nickname); + nickname = g_strdup (g_get_user_name ()); + } + if (G_STR_EMPTY (published_name)) { + g_free (published_name); + published_name = g_strdup (g_get_real_name ()); + } + + mc_account_set_param_string (account, "nickname", nickname ? nickname : ""); + mc_account_set_param_string (account, "published-name", published_name ? published_name : ""); + mc_account_set_param_string (account, "first-name", first_name ? first_name : ""); + mc_account_set_param_string (account, "last-name", last_name ? last_name : ""); + mc_account_set_param_string (account, "email", email ? email : ""); + mc_account_set_param_string (account, "jid", jid ? jid : ""); + + g_free (nickname); + g_free (published_name); + g_free (first_name); + g_free (last_name); + g_free (email); + g_free (jid); + g_object_unref (account); + g_object_unref (profile); + g_object_unref (contact); + g_object_unref (book); +} + int main (int argc, char *argv[]) { @@ -208,6 +290,8 @@ main (int argc, char *argv[]) if (!no_connect) { start_mission_control (idle); } + + create_salut_account (); /* Setting up UI */ window = empathy_main_window_show (); -- 2.39.2