aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--libempathy-gtk/Makefile.am1
-rw-r--r--libempathy-gtk/empathy-main-window.c32
-rw-r--r--libempathy-gtk/empathy-status-icon.c166
-rw-r--r--libempathy-gtk/empathy-status-icon.h54
-rw-r--r--libempathy/gossip-presence.c4
-rw-r--r--src/empathy-main.c45
7 files changed, 266 insertions, 37 deletions
diff --git a/TODO b/TODO
index 989f1825e..40c8eb2c9 100644
--- a/TODO
+++ b/TODO
@@ -8,6 +8,7 @@ Things you can do if you want to help:
- Set up the translation system and import po files from gossip? Or re-translate everything?
- Fix setting subscription for contacts in EmpathyContactList.
- Write a MC plugin to filter channels before dispatching them. For example we need a GtkStatusIcon that blink when an event arrives (text/voip/ft channel) and tells the MC to dispatch the channel only when the user clicked the icon. Like in gossip.
+ - Make use of NetworkManager and gnome-screensaver to set the presence
- Testing and Bugfixing.
SoC projects:
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index bd8abcc2b..d6d64905f 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -10,6 +10,7 @@ libempathy_gtk_la_SOURCES = \
ephy-spinner.c ephy-spinner.h \
empathy-images.h \
empathy-main-window.c empathy-main-window.h \
+ empathy-status-icon.c empathy-status-icon.h \
gossip-accounts-dialog.c gossip-accounts-dialog.h \
gossip-account-widget-generic.c gossip-account-widget-generic.h \
gossip-account-widget-jabber.c gossip-account-widget-jabber.h \
diff --git a/libempathy-gtk/empathy-main-window.c b/libempathy-gtk/empathy-main-window.c
index a34ad5bff..6394a6498 100644
--- a/libempathy-gtk/empathy-main-window.c
+++ b/libempathy-gtk/empathy-main-window.c
@@ -33,6 +33,7 @@
#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"
@@ -132,7 +133,7 @@ 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,
+static void main_window_presence_changed_cb (MissionControl *mc,
McPresence state,
EmpathyMainWindow *window);
static void main_window_presence_chooser_changed_cb (GtkWidget *chooser,
@@ -228,26 +229,22 @@ empathy_main_window_show (void)
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
- */
+ /* Set up presence chooser */
window->mc = mission_control_new (tp_get_bus ());
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",
+ "PresenceStatusActual",
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);
-
+ state = mission_control_get_presence_actual (window->mc, NULL);
+ main_window_presence_changed_cb (window->mc, state, window);
+ gtk_widget_show (window->presence_chooser);
item = gtk_tool_item_new ();
gtk_widget_show (GTK_WIDGET (item));
@@ -762,13 +759,26 @@ main_window_connection_items_update (void)
#endif
static void
-main_window_presence_changed_cb (DBusGProxy *proxy,
+main_window_presence_changed_cb (MissionControl *mc,
McPresence state,
EmpathyMainWindow *window)
{
+ gchar *status;
+
gossip_debug (DEBUG_DOMAIN, "presence changed to %d", state);
+
+ status = mission_control_get_presence_message_actual (window->mc, NULL);
+
+ if (G_STR_EMPTY (status)) {
+ g_free (status);
+ status = g_strdup (gossip_presence_state_get_default_status (state));
+ }
+
gossip_presence_chooser_set_state (GOSSIP_PRESENCE_CHOOSER (window->presence_chooser),
state);
+ gossip_presence_chooser_set_status (GOSSIP_PRESENCE_CHOOSER (window->presence_chooser),
+ status);
+ g_free (status);
}
static void
diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c
new file mode 100644
index 000000000..e46944e5b
--- /dev/null
+++ b/libempathy-gtk/empathy-status-icon.c
@@ -0,0 +1,166 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 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 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: Xavier Claessens <xclaesse@gmail.com>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include <libtelepathy/tp-helpers.h>
+
+#include <libmissioncontrol/mission-control.h>
+
+#include <libempathy/gossip-debug.h>
+#include <libempathy/gossip-utils.h>
+
+#include "empathy-status-icon.h"
+#include "gossip-ui-utils.h"
+
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+ EMPATHY_TYPE_STATUS_ICON, EmpathyStatusIconPriv))
+
+#define DEBUG_DOMAIN "StatusIcon"
+
+struct _EmpathyStatusIconPriv {
+ MissionControl *mc;
+ GtkStatusIcon *icon;
+};
+
+static void empathy_status_icon_class_init (EmpathyStatusIconClass *klass);
+static void empathy_status_icon_init (EmpathyStatusIcon *icon);
+static void status_icon_finalize (GObject *object);
+static void status_icon_presence_changed_cb (MissionControl *mc,
+ McPresence state,
+ EmpathyStatusIcon *icon);
+static void status_icon_activate_cb (GtkStatusIcon *status_icon,
+ EmpathyStatusIcon *icon);
+
+enum {
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+G_DEFINE_TYPE (EmpathyStatusIcon, empathy_status_icon, G_TYPE_OBJECT);
+
+static void
+empathy_status_icon_class_init (EmpathyStatusIconClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = status_icon_finalize;
+
+ signals[ACTIVATE] =
+ g_signal_new ("activate",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_type_class_add_private (object_class, sizeof (EmpathyStatusIconPriv));
+}
+
+static void
+empathy_status_icon_init (EmpathyStatusIcon *icon)
+{
+ EmpathyStatusIconPriv *priv;
+ McPresence state;
+
+ priv = GET_PRIV (icon);
+
+ priv->mc = mission_control_new (tp_get_bus ());
+ priv->icon = gtk_status_icon_new ();
+
+ dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->mc),
+ "PresenceStatusActual",
+ G_CALLBACK (status_icon_presence_changed_cb),
+ icon, NULL);
+ g_signal_connect (priv->icon, "activate",
+ G_CALLBACK (status_icon_activate_cb),
+ icon);
+
+ state = mission_control_get_presence_actual (priv->mc, NULL);
+ status_icon_presence_changed_cb (priv->mc, state, icon);
+}
+
+static void
+status_icon_finalize (GObject *object)
+{
+ EmpathyStatusIconPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc),
+ "PresenceStatusActual",
+ G_CALLBACK (status_icon_presence_changed_cb),
+ object);
+ g_signal_handlers_disconnect_by_func (priv->icon,
+ status_icon_activate_cb,
+ object);
+
+ g_object_unref (priv->mc);
+ g_object_unref (priv->icon);
+}
+
+EmpathyStatusIcon *
+empathy_status_icon_new (void)
+{
+ return g_object_new (EMPATHY_TYPE_STATUS_ICON, NULL);
+}
+
+static void
+status_icon_presence_changed_cb (MissionControl *mc,
+ McPresence state,
+ EmpathyStatusIcon *icon)
+{
+ EmpathyStatusIconPriv *priv;
+ const gchar *icon_name;
+ gchar *status;
+
+ priv = GET_PRIV (icon);
+
+ icon_name = gossip_icon_name_for_presence_state (state);
+ status = mission_control_get_presence_message_actual (priv->mc, NULL);
+ if (G_STR_EMPTY (status)) {
+ g_free (status);
+ status = g_strdup (gossip_presence_state_get_default_status (state));
+ }
+
+ gtk_status_icon_set_from_icon_name (priv->icon, icon_name);
+ gtk_status_icon_set_tooltip (priv->icon, status);
+
+ g_free (status);
+}
+
+static void
+status_icon_activate_cb (GtkStatusIcon *status_icon,
+ EmpathyStatusIcon *icon)
+{
+ g_signal_emit (icon, signals[ACTIVATE], 0);
+}
+
diff --git a/libempathy-gtk/empathy-status-icon.h b/libempathy-gtk/empathy-status-icon.h
new file mode 100644
index 000000000..898e3514a
--- /dev/null
+++ b/libempathy-gtk/empathy-status-icon.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 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 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: Xavier Claessens <xclaesse@gmail.com>
+ */
+
+#ifndef __EMPATHY_STATUS_ICON_H__
+#define __EMPATHY_STATUS_ICON_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define EMPATHY_TYPE_STATUS_ICON (empathy_status_icon_get_type ())
+#define EMPATHY_STATUS_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_STATUS_ICON, EmpathyStatusIcon))
+#define EMPATHY_STATUS_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_STATUS_ICON, EmpathyStatusIconClass))
+#define EMPATHY_IS_STATUS_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_STATUS_ICON))
+#define EMPATHY_IS_STATUS_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_STATUS_ICON))
+#define EMPATHY_STATUS_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_STATUS_ICON, EmpathyStatusIconClass))
+
+typedef struct _EmpathyStatusIcon EmpathyStatusIcon;
+typedef struct _EmpathyStatusIconClass EmpathyStatusIconClass;
+typedef struct _EmpathyStatusIconPriv EmpathyStatusIconPriv;
+
+struct _EmpathyStatusIcon {
+ GObject parent;
+};
+
+struct _EmpathyStatusIconClass {
+ GObjectClass parent_class;
+};
+
+GType empathy_status_icon_get_type (void) G_GNUC_CONST;
+EmpathyStatusIcon *empathy_status_icon_new (void);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_STATUS_ICON_H__ */
diff --git a/libempathy/gossip-presence.c b/libempathy/gossip-presence.c
index e78c11b2f..7add39669 100644
--- a/libempathy/gossip-presence.c
+++ b/libempathy/gossip-presence.c
@@ -278,11 +278,9 @@ gossip_presence_state_get_default_status (McPresence state)
case MC_PRESENCE_EXTENDED_AWAY:
return _("Away");
case MC_PRESENCE_HIDDEN:
- return _("Unavailable");
case MC_PRESENCE_OFFLINE:
- return _("Offline");
case MC_PRESENCE_UNSET:
- return _("Unset");
+ return _("Offline");
default:
g_assert_not_reached ();
}
diff --git a/src/empathy-main.c b/src/empathy-main.c
index 47f2c566f..0815e1216 100644
--- a/src/empathy-main.c
+++ b/src/empathy-main.c
@@ -34,24 +34,25 @@
#include <libmissioncontrol/mission-control.h>
#include <libempathy/gossip-debug.h>
+#include <libempathy/gossip-presence.h>
#include <libempathy-gtk/empathy-main-window.h>
-#include <libempathy-gtk/empathy-images.h>
+#include <libempathy-gtk/empathy-status-icon.h>
#include <libempathy-gtk/gossip-accounts-dialog.h>
#include "empathy-filter.h"
#define DEBUG_DOMAIN "EmpathyMain"
-static void error_cb (MissionControl *mc,
- GError *error,
- gpointer data);
-static void service_ended_cb (MissionControl *mc,
- gpointer user_data);
-static void start_mission_control (MissionControl *mc);
-static void destroy_cb (GtkWidget *window,
- MissionControl *mc);
-static void icon_activate_cb (GtkStatusIcon *status_icon,
- GtkWidget *window);
+static void error_cb (MissionControl *mc,
+ GError *error,
+ gpointer data);
+static void service_ended_cb (MissionControl *mc,
+ gpointer user_data);
+static void start_mission_control (MissionControl *mc);
+static void destroy_cb (GtkWidget *window,
+ MissionControl *mc);
+static void icon_activate_cb (EmpathyStatusIcon *icon,
+ GtkWidget *window);
static void
error_cb (MissionControl *mc,
@@ -112,8 +113,8 @@ destroy_cb (GtkWidget *window,
}
static void
-icon_activate_cb (GtkStatusIcon *status_icon,
- GtkWidget *window)
+icon_activate_cb (EmpathyStatusIcon *icon,
+ GtkWidget *window)
{
if (GTK_WIDGET_VISIBLE (window)) {
gtk_widget_hide (window);
@@ -137,12 +138,12 @@ new_channel_cb (EmpathyFilter *filter,
int
main (int argc, char *argv[])
{
- GList *accounts;
- GtkStatusIcon *icon;
- GtkWidget *window;
- MissionControl *mc;
- McAccountMonitor *monitor;
- EmpathyFilter *filter;
+ GList *accounts;
+ EmpathyStatusIcon *icon;
+ GtkWidget *window;
+ MissionControl *mc;
+ McAccountMonitor *monitor;
+ EmpathyFilter *filter;
gtk_init (&argc, &argv);
@@ -172,10 +173,8 @@ main (int argc, char *argv[])
G_CALLBACK (gtk_widget_hide_on_delete),
NULL);
- /* Setting up the tray icon */
- icon = gtk_status_icon_new_from_icon_name (EMPATHY_IMAGE_MESSAGE);
- gtk_status_icon_set_tooltip (icon, "Empathy - click here to show/hide the main window");
- gtk_status_icon_set_visible (icon, TRUE);
+ /* Setting up the status icon */
+ icon = empathy_status_icon_new ();
g_signal_connect (icon, "activate",
G_CALLBACK (icon_activate_cb),
window);