/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2007 Collabora Ltd.
+ * Copyright (C) 2007-2008 Collabora Ltd.
*
- * 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 library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library 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.
+ * Lesser 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.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: Xavier Claessens <xclaesse@gmail.com>
*/
#include <stdlib.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <libmissioncontrol/mission-control.h>
#include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-utils.h>
contact_widget = g_object_get_data (G_OBJECT (dialog), "contact_widget");
this_contact = empathy_contact_widget_get_contact (contact_widget);
- return !empathy_contact_equal (contact, this_contact);
+ return contact != this_contact;
}
/*
EmpathyContactManager *manager;
EmpathyContact *contact;
- manager = empathy_contact_manager_new ();
+ manager = empathy_contact_manager_dup_singleton ();
contact = empathy_contact_widget_get_contact (contact_widget);
if (response == GTK_RESPONSE_YES) {
empathy_subscription_dialog_show (EmpathyContact *contact,
GtkWindow *parent)
{
+ GtkBuilder *gui;
GtkWidget *dialog;
GtkWidget *hbox_subscription;
GtkWidget *contact_widget;
GList *l;
+ gchar *filename;
g_return_if_fail (EMPATHY_IS_CONTACT (contact));
return;
}
- empathy_glade_get_file_simple ("empathy-contact-dialogs.glade",
- "subscription_request_dialog",
- NULL,
+ filename = empathy_file_lookup ("empathy-contact-dialogs.ui",
+ "libempathy-gtk");
+ gui = empathy_builder_get_file (filename,
"subscription_request_dialog", &dialog,
"hbox_subscription", &hbox_subscription,
NULL);
+ g_free (filename);
+ g_object_unref (gui);
contact_widget = empathy_contact_widget_new (contact,
EMPATHY_CONTACT_WIDGET_EDIT_ALIAS |
contact_widget,
TRUE, TRUE,
0);
+ gtk_widget_show (contact_widget);
+
g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget);
subscription_dialogs = g_list_prepend (subscription_dialogs, dialog);
empathy_contact_information_dialog_show (EmpathyContact *contact,
GtkWindow *parent,
gboolean edit,
- gboolean edit_groups)
+ gboolean is_user)
{
GtkWidget *dialog;
GtkWidget *button;
dialog = gtk_dialog_new ();
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_window_set_title (GTK_WINDOW (dialog), _("Contact information"));
+ if (is_user) {
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Personal Information"));
+ }
+ else if (edit) {
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Contact Information"));
+ }
+ else {
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Contact Information"));
+ }
/* Close button */
button = gtk_button_new_with_label (GTK_STOCK_CLOSE);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
button,
GTK_RESPONSE_CLOSE);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_window_set_default (GTK_WINDOW (dialog), button);
gtk_widget_show (button);
/* Contact info widget */
if (edit) {
flags |= EMPATHY_CONTACT_WIDGET_EDIT_ALIAS;
- if (empathy_contact_is_user (contact)) {
- flags |= EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT |
- EMPATHY_CONTACT_WIDGET_EDIT_AVATAR;
- }
}
- if (edit_groups) {
+ if (is_user) {
+ flags |= EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT;
+ flags |= EMPATHY_CONTACT_WIDGET_EDIT_AVATAR;
+ }
+ if (!is_user && edit) {
flags |= EMPATHY_CONTACT_WIDGET_EDIT_GROUPS;
}
contact_widget = empathy_contact_widget_new (contact, flags);
+ gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
contact_widget,
TRUE, TRUE, 0);
empathy_account_chooser_filter_is_connected,
NULL);
}
+ gtk_widget_show (contact_widget);
g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget);
information_dialogs = g_list_prepend (information_dialogs, dialog);
can_add_contact_to_account (McAccount *account,
gpointer user_data)
{
- MissionControl *mc;
- TelepathyConnectionStatus status;
- McProfile *profile;
- const gchar *protocol_name;
-
- mc = empathy_mission_control_new ();
- status = mission_control_get_connection_status (mc, account, NULL);
- g_object_unref (mc);
- if (status != TP_CONN_STATUS_CONNECTED) {
- /* Account is disconnected */
+ EmpathyAccountManager *account_manager;
+ EmpathyContactManager *contact_manager;
+ TpConnection *connection;
+ gboolean result;
+
+ account_manager = empathy_account_manager_dup_singleton ();
+ connection = empathy_account_manager_get_connection (account_manager,
+ account);
+ if (!connection) {
+ g_object_unref (account_manager);
return FALSE;
}
- profile = mc_account_get_profile (account);
- protocol_name = mc_profile_get_protocol_name (profile);
- if (strcmp (protocol_name, "local-xmpp") == 0) {
- /* We can't add accounts to a XMPP LL connection
- * FIXME: We should inspect the flags of the contact list group interface
- */
- g_object_unref (profile);
- return FALSE;
- }
+ contact_manager = empathy_contact_manager_dup_singleton ();
+ result = empathy_contact_manager_can_add (contact_manager, connection);
+ g_object_unref (contact_manager);
+ g_object_unref (account_manager);
- g_object_unref (profile);
- return TRUE;
+ return result;
}
static void
EmpathyContactManager *manager;
EmpathyContact *contact;
- manager = empathy_contact_manager_new ();
+ manager = empathy_contact_manager_dup_singleton ();
contact = empathy_contact_widget_get_contact (contact_widget);
if (contact && response == GTK_RESPONSE_OK) {
dialog = gtk_dialog_new ();
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_window_set_title (GTK_WINDOW (dialog), _("New contact"));
+ gtk_window_set_title (GTK_WINDOW (dialog), _("New Contact"));
/* Cancel button */
button = gtk_button_new_with_label (GTK_STOCK_CANCEL);
empathy_contact_widget_set_account_filter (contact_widget,
can_add_contact_to_account,
NULL);
+ gtk_widget_show (contact_widget);
new_contact_dialog = dialog;