* Danielle Madeley <danielle.madeley@collabora.co.uk>
*/
-#include <config.h>
+#include "config.h"
+#include "empathy-roster-window.h"
#include <sys/stat.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
-#include <telepathy-glib/telepathy-glib.h>
-#include <folks/folks.h>
-
-#include <libempathy/empathy-contact.h>
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-request-util.h>
-#include <libempathy/empathy-chatroom-manager.h>
-#include <libempathy/empathy-chatroom.h>
-#include <libempathy/empathy-gsettings.h>
-#include <libempathy/empathy-individual-manager.h>
-#include <libempathy/empathy-gsettings.h>
-#include <libempathy/empathy-status-presets.h>
-#include <libempathy/empathy-presence-manager.h>
-
-#include <libempathy-gtk/empathy-live-search.h>
-#include <libempathy-gtk/empathy-contact-blocking-dialog.h>
-#include <libempathy-gtk/empathy-contact-search-dialog.h>
-#include <libempathy-gtk/empathy-geometry.h>
-#include <libempathy-gtk/empathy-gtk-enum-types.h>
-#include <libempathy-gtk/empathy-individual-dialogs.h>
-#include <libempathy-gtk/empathy-individual-store-manager.h>
-#include <libempathy-gtk/empathy-roster-model.h>
-#include <libempathy-gtk/empathy-roster-model-manager.h>
-#include <libempathy-gtk/empathy-roster-view.h>
-#include <libempathy-gtk/empathy-new-message-dialog.h>
-#include <libempathy-gtk/empathy-new-call-dialog.h>
-#include <libempathy-gtk/empathy-log-window.h>
-#include <libempathy-gtk/empathy-presence-chooser.h>
-#include <libempathy-gtk/empathy-sound-manager.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
-
+#include "empathy-about-dialog.h"
#include "empathy-accounts-dialog.h"
#include "empathy-call-observer.h"
#include "empathy-chat-manager.h"
-#include "empathy-roster-window.h"
-#include "empathy-preferences.h"
-#include "empathy-about-dialog.h"
-#include "empathy-debug-window.h"
-#include "empathy-new-chatroom-dialog.h"
+#include "empathy-chatroom-manager.h"
#include "empathy-chatrooms-window.h"
+#include "empathy-contact-blocking-dialog.h"
+#include "empathy-contact-search-dialog.h"
#include "empathy-event-manager.h"
#include "empathy-ft-manager.h"
+#include "empathy-geometry.h"
+#include "empathy-gsettings.h"
+#include "empathy-gsettings.h"
+#include "empathy-gtk-enum-types.h"
+#include "empathy-individual-dialogs.h"
+#include "empathy-log-window.h"
+#include "empathy-new-call-dialog.h"
+#include "empathy-new-chatroom-dialog.h"
+#include "empathy-new-message-dialog.h"
+#include "empathy-preferences.h"
+#include "empathy-presence-chooser.h"
+#include "empathy-presence-manager.h"
+#include "empathy-request-util.h"
+#include "empathy-roster-model-manager.h"
+#include "empathy-roster-view.h"
+#include "empathy-status-presets.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
/* Flashing delay for icons (milliseconds). */
#define FLASH_TIMEOUT 500
PAGE_MESSAGE_FLAG_ADD_CONTACT = 1 << 5,
} PageMessageFlags;
+static gboolean
+can_add_contact (EmpathyRosterWindow *self)
+{
+ GList *accounts, *l;
+ gboolean result = FALSE;
+
+ accounts = tp_account_manager_dup_valid_accounts (
+ self->priv->account_manager);
+ for (l = accounts; l != NULL && !result; l = g_list_next (l))
+ {
+ TpAccount *account = TP_ACCOUNT (l->data);
+ TpConnection *conn;
+
+ conn = tp_account_get_connection (account);
+ if (conn == NULL)
+ continue;
+
+ if (tp_connection_get_can_change_contact_list (conn))
+ result = TRUE;
+ }
+
+ g_list_free_full (accounts, g_object_unref);
+ return result;
+}
+
static void
display_page_message (EmpathyRosterWindow *self,
const gchar *msg,
gtk_widget_set_visible (self->priv->button_add_contact,
(flags & PAGE_MESSAGE_FLAG_ADD_CONTACT) != 0);
+ if ((flags & PAGE_MESSAGE_FLAG_ADD_CONTACT) != 0)
+ gtk_widget_set_sensitive (self->priv->button_add_contact,
+ can_add_contact (self));
+
gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook),
PAGE_MESSAGE);
}
display_page_no_account (EmpathyRosterWindow *self)
{
display_page_message (self,
- _("You need to setup an account to see contacts here."),
+ _("You need to set up an account to see contacts here."),
PAGE_MESSAGE_FLAG_ACCOUNTS);
}
label = gtk_label_new (message_markup);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_widget_show (label);
{
gboolean connected, connecting;
GList *l;
+ GAction *action;
connected = empathy_account_manager_get_accounts_connected (&connecting);
/* Update widgets sensibility */
for (l = self->priv->actions_connected; l; l = l->next)
g_simple_action_set_enabled (l->data, connected);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (self), "chat_add_contact");
+ if (!can_add_contact (self))
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
}
static void
static gboolean
roster_window_key_press_event_cb (GtkWidget *window,
GdkEventKey *event,
- gpointer user_data)
+ EmpathyRosterWindow *self)
{
if (event->keyval == GDK_KEY_T
&& event->state & GDK_SHIFT_MASK
&& event->state & GDK_CONTROL_MASK)
empathy_chat_manager_call_undo_closed_chat ();
+ if (event->keyval == GDK_KEY_f
+ && event->state & GDK_CONTROL_MASK)
+ gtk_widget_show (self->priv->search_bar);
+
return FALSE;
}
gtk_widget_show (self->priv->main_vbox);
g_signal_connect (self, "key-press-event",
- G_CALLBACK (roster_window_key_press_event_cb), NULL);
+ G_CALLBACK (roster_window_key_press_event_cb), self);
g_object_unref (gui);