#include <glib/gi18n.h>
#include <libtelepathy/tp-helpers.h>
-#include <libmissioncontrol/mission-control.h>
#include <libempathy/gossip-conf.h>
#include <libempathy/gossip-contact.h>
#include <libempathy/gossip-debug.h>
+#include <libempathy/gossip-utils.h>
#include "empathy-main-window.h"
#include "ephy-spinner.h"
/* Accels (menu shortcuts) can be configured and saved */
#define ACCELS_FILENAME "accels.txt"
-/* Flashing delay for icons (milliseconds). */
-#define FLASH_TIMEOUT 500
-
/* Name in the geometry file */
#define GEOMETRY_NAME "main-window"
typedef struct {
GossipContactList *contact_list;
- MissionControl *mc;
/* Main widgets */
GtkWidget *window;
static void main_window_accels_save (void);
static void main_window_connection_items_setup (EmpathyMainWindow *window,
GladeXML *glade);
-//static void main_window_connection_items_update (void);
-static void main_window_presence_changed_cb (DBusGProxy *proxy,
- McPresence state,
- EmpathyMainWindow *window);
-static void main_window_presence_chooser_changed_cb (GtkWidget *chooser,
- McPresence state,
- const gchar *status,
- EmpathyMainWindow *window);
static gboolean main_window_configure_event_timeout_cb (EmpathyMainWindow *window);
static gboolean main_window_configure_event_cb (GtkWidget *widget,
GdkEventConfigure *event,
static void main_window_notify_compact_contact_list_cb (GossipConf *conf,
const gchar *key,
EmpathyMainWindow *window);
+static void main_window_notify_sort_criterium_cb (GossipConf *conf,
+ const gchar *key,
+ EmpathyMainWindow *window);
GtkWidget *
empathy_main_window_show (void)
GtkWidget *ebox;
GtkToolItem *item;
gchar *str;
- McPresence state;
gboolean show_offline;
gboolean show_avatars;
gboolean compact_contact_list;
gtk_widget_hide (window->edit_context);
gtk_widget_hide (window->edit_context_separator);
- /* Set up presence chooser
- * FIXME: Update status message not yet supported by MC
- */
- window->mc = mission_control_new (tp_get_bus ());
+ /* Set up presence chooser */
window->presence_chooser = gossip_presence_chooser_new ();
gtk_widget_show (window->presence_chooser);
- gossip_presence_chooser_set_flash_interval (GOSSIP_PRESENCE_CHOOSER (window->presence_chooser),
- FLASH_TIMEOUT);
- state = mission_control_get_presence (window->mc, NULL);
- gossip_presence_chooser_set_state (GOSSIP_PRESENCE_CHOOSER (window->presence_chooser),
- state);
- dbus_g_proxy_connect_signal (DBUS_G_PROXY (window->mc),
- "PresenceStatusRequested",
- G_CALLBACK (main_window_presence_changed_cb),
- window, NULL);
- g_signal_connect (window->presence_chooser,
- "changed",
- G_CALLBACK (main_window_presence_chooser_changed_cb),
- window);
-
-
item = gtk_tool_item_new ();
gtk_widget_show (GTK_WIDGET (item));
gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
window->widgets_connected = g_list_prepend (window->widgets_connected,
- window->presence_chooser);
+ window->presence_chooser);
/* Set up the throbber */
ebox = gtk_event_box_new ();
gtk_window_move (GTK_WINDOW (window->window), x, y);
}
- /* Get preferences */
conf = gossip_conf_get ();
+
+ /* Show offline ? */
gossip_conf_get_bool (conf,
GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
&show_offline);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_offline_widget),
show_offline);
+ /* Show avatars ? */
gossip_conf_get_bool (conf,
GOSSIP_PREFS_UI_SHOW_AVATARS,
&show_avatars);
GOSSIP_PREFS_UI_SHOW_AVATARS,
(GossipConfNotifyFunc) main_window_notify_show_avatars_cb,
window);
+ gossip_contact_list_set_show_avatars (window->contact_list, show_avatars);
+
+ /* Is compact ? */
gossip_conf_get_bool (conf,
GOSSIP_PREFS_UI_COMPACT_CONTACT_LIST,
&compact_contact_list);
GOSSIP_PREFS_UI_COMPACT_CONTACT_LIST,
(GossipConfNotifyFunc) main_window_notify_compact_contact_list_cb,
window);
+ gossip_contact_list_set_is_compact (window->contact_list, compact_contact_list);
- g_object_set (window->contact_list,
- "show-avatars", show_avatars,
- "is-compact", compact_contact_list,
- NULL);
+ /* Sort criterium */
+ gossip_conf_notify_add (conf,
+ GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM,
+ (GossipConfNotifyFunc) main_window_notify_sort_criterium_cb,
+ window);
+ main_window_notify_sort_criterium_cb (conf,
+ GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM,
+ window);
gtk_widget_show (window->window);
g_list_free (window->widgets_disconnected);
g_object_unref (window->tooltips);
- g_object_unref (window->mc);
g_free (window);
}
main_window_chat_quit_cb (GtkWidget *widget,
EmpathyMainWindow *window)
{
- gtk_widget_destroy (window->window);
+ gtk_main_quit ();
}
static void
window->widgets_disconnected = list;
}
-#if 0
-FIXME:
-static void
-main_window_connection_items_update (void)
-{
- GList *l;
- guint connected = 0;
- guint disconnected = 0;
-
- /* Get account count for:
- * - connected and disabled,
- * - connected and enabled
- * - disabled and enabled
- */
- gossip_session_count_accounts (window->session,
- &connected,
- NULL,
- &disconnected);
-
- for (l = window->widgets_connected; l; l = l->next) {
- gtk_widget_set_sensitive (l->data, (connected > 0));
- }
-
- for (l = window->widgets_disconnected; l; l = l->next) {
- gtk_widget_set_sensitive (l->data, (disconnected > 0));
- }
-}
-#endif
-
-static void
-main_window_presence_changed_cb (DBusGProxy *proxy,
- McPresence state,
- EmpathyMainWindow *window)
-{
- gossip_debug (DEBUG_DOMAIN, "presence changed to %d", state);
- gossip_presence_chooser_set_state (GOSSIP_PRESENCE_CHOOSER (window->presence_chooser),
- state);
-}
-
-static void
-main_window_presence_chooser_changed_cb (GtkWidget *chooser,
- McPresence state,
- const gchar *status,
- EmpathyMainWindow *window)
-{
- gossip_status_presets_set_default (state, status);
- mission_control_set_presence (window->mc, state, status, NULL, NULL);
-}
-
static gboolean
main_window_configure_event_timeout_cb (EmpathyMainWindow *window)
{
}
}
+static void
+main_window_notify_sort_criterium_cb (GossipConf *conf,
+ const gchar *key,
+ EmpathyMainWindow *window)
+{
+ gchar *str = NULL;
+
+ if (gossip_conf_get_string (conf, key, &str)) {
+ GType type;
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ type = gossip_contact_list_sort_get_type ();
+ enum_class = G_ENUM_CLASS (g_type_class_peek (type));
+ enum_value = g_enum_get_value_by_nick (enum_class, str);
+
+ if (enum_value) {
+ gossip_contact_list_set_sort_criterium (window->contact_list,
+ enum_value->value);
+ }
+ }
+}
+