/*
* 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 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 <libempathy/empathy-tp-chat.h>
#include <libempathy/empathy-debug.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-conf.h>
#include <libempathy/empathy-idle.h>
#include <libempathy/empathy-filter.h>
#include "empathy-status-icon.h"
#include "empathy-contact-dialogs.h"
#include "empathy-presence-chooser.h"
+#include "empathy-conf.h"
#include "empathy-preferences.h"
#include "empathy-ui-utils.h"
#include "empathy-accounts-dialog.h"
#include "empathy-images.h"
+#include "empathy-new-message-dialog.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
static void status_icon_update_tooltip (EmpathyStatusIcon *icon);
static void status_icon_set_from_state (EmpathyStatusIcon *icon);
static void status_icon_set_visibility (EmpathyStatusIcon *icon,
- gboolean visible);
+ gboolean visible,
+ gboolean store);
static void status_icon_toggle_visibility (EmpathyStatusIcon *icon);
static void status_icon_activate_cb (GtkStatusIcon *status_icon,
EmpathyStatusIcon *icon);
G_DEFINE_TYPE (EmpathyStatusIcon, empathy_status_icon, G_TYPE_OBJECT);
+static void
+status_icon_notify_use_nm_cb (EmpathyConf *conf,
+ const gchar *key,
+ gpointer user_data)
+{
+ EmpathyStatusIconPriv *priv = GET_PRIV (user_data);
+ gboolean use_nm;
+
+ if (empathy_conf_get_bool (conf, key, &use_nm)) {
+ empathy_idle_set_use_nm (priv->idle, use_nm);
+ }
+}
+
+static void
+status_icon_notify_visibility_cb (EmpathyConf *conf,
+ const gchar *key,
+ gpointer user_data)
+{
+ EmpathyStatusIcon *icon = user_data;
+ gboolean hidden = FALSE;
+
+ if (empathy_conf_get_bool (conf, key, &hidden)) {
+ status_icon_set_visibility (icon, !hidden, FALSE);
+ }
+}
+
static void
empathy_status_icon_class_init (EmpathyStatusIconClass *klass)
{
{
EmpathyStatusIconPriv *priv;
GList *pendings, *l;
+ gboolean use_nm;
priv = GET_PRIV (icon);
priv->icon = gtk_status_icon_new ();
- priv->idle = empathy_idle_new ();
- empathy_idle_set_auto_away (priv->idle, TRUE);
- empathy_idle_set_auto_disconnect (priv->idle, TRUE);
priv->manager = empathy_contact_manager_new ();
priv->mc = empathy_mission_control_new ();
- priv->text_filter = empathy_filter_new ("org.gnome.Empathy.Chat",
- "/org/freedesktop/Telepathy/Filter",
+ priv->text_filter = empathy_filter_new ("org.gnome.Empathy.ChatFilter",
+ "/org/gnome/Empathy/ChatFilter",
TP_IFACE_CHANNEL_TYPE_TEXT,
MC_FILTER_PRIORITY_DIALOG,
MC_FILTER_FLAG_INCOMING);
+ /* Setup EmpathyIdle */
+ priv->idle = empathy_idle_new ();
+ empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_USE_NM,
+ &use_nm);
+ empathy_conf_notify_add (empathy_conf_get (),
+ EMPATHY_PREFS_USE_NM,
+ status_icon_notify_use_nm_cb,
+ icon);
+ empathy_idle_set_auto_away (priv->idle, TRUE);
+ empathy_idle_set_use_nm (priv->idle, use_nm);
+
+ /* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */
+ empathy_conf_notify_add (empathy_conf_get (),
+ EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
+ status_icon_notify_visibility_cb,
+ icon);
+
status_icon_create_menu (icon);
status_icon_idle_notify_cb (icon);
EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
&should_hide);
- status_icon_set_visibility (icon, !should_hide);
+ if (gtk_window_is_active (priv->window) == should_hide) {
+ status_icon_set_visibility (icon, !should_hide, FALSE);
+ }
return icon;
}
static void
status_icon_set_visibility (EmpathyStatusIcon *icon,
- gboolean visible)
+ gboolean visible,
+ gboolean store)
{
EmpathyStatusIconPriv *priv;
priv = GET_PRIV (icon);
+ if (store) {
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible);
+ }
+
if (!visible) {
empathy_window_iconify (priv->window, priv->icon);
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, TRUE);
} else {
GList *accounts;
empathy_window_present (GTK_WINDOW (priv->window), TRUE);
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, FALSE);
/* Show the accounts dialog if there is no enabled accounts */
accounts = mc_accounts_list_by_enabled (TRUE);
gboolean visible;
visible = gtk_window_is_active (priv->window);
- status_icon_set_visibility (icon, !visible);
+ status_icon_set_visibility (icon, !visible, TRUE);
}
static void
GdkEvent *event,
EmpathyStatusIcon *icon)
{
- status_icon_set_visibility (icon, FALSE);
+ status_icon_set_visibility (icon, FALSE, TRUE);
return TRUE;
}
priv = GET_PRIV (icon);
- //empathy_new_message_dialog_show (GTK_WINDOW (priv->window));
+ empathy_new_message_dialog_show (NULL);
}
static void
gboolean visible;
visible = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
- status_icon_set_visibility (icon, visible);
+ status_icon_set_visibility (icon, visible, TRUE);
}
static void