]> git.0d.be Git - empathy.git/commitdiff
Move empathy_notification_is_enabled () to src/
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:08:04 +0000 (17:08 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:08:04 +0000 (17:08 +0000)
svn path=/trunk/; revision=2294

libempathy-gtk/empathy-ui-utils.c
libempathy-gtk/empathy-ui-utils.h
libempathy/empathy-utils.c
libempathy/empathy-utils.h
src/Makefile.am
src/empathy-chat-window.c
src/empathy-misc.c [new file with mode: 0644]
src/empathy-misc.h [new file with mode: 0644]
src/empathy-status-icon.c

index d7d314082d08c977ab4ed319aed5a6f067295705..91362da5e88ab016d28ae6533d19aef23f0c8dd8 100644 (file)
@@ -1584,23 +1584,6 @@ static EmpathySoundEntry sound_entries[LAST_EMPATHY_SOUND] = {
          N_("Voice call ended"), NULL },
 };
 
-static gboolean
-check_available (void)
-{
-       McPresence presence;
-       EmpathyIdle *idle;
-
-       idle = empathy_idle_dup_singleton ();
-       presence = empathy_idle_get_state (idle);
-       g_object_unref (idle);
-
-       if (presence != MC_PRESENCE_AVAILABLE &&
-           presence != MC_PRESENCE_UNSET) {
-               return FALSE;    
-       }
-
-       return TRUE;
-}
 
 static gboolean
 empathy_sound_pref_is_enabled (const char *key)
@@ -1617,7 +1600,7 @@ empathy_sound_pref_is_enabled (const char *key)
                return FALSE;
        }
 
-       if (!check_available ()) {
+       if (!empathy_check_available_state ()) {
                empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
                                       &res);
                if (res) {
@@ -1658,36 +1641,3 @@ empathy_sound_play (GtkWidget *widget,
        }
 }
 
-gboolean
-empathy_notification_should_show (gboolean check_focus)
-{
-       EmpathyConf *conf;
-       gboolean res;
-
-       conf = empathy_conf_get ();
-       res = FALSE;
-
-       empathy_conf_get_bool (conf, EMPATHY_PREFS_NOTIFICATIONS_ENABLED, &res);
-
-       if (!res) {
-               return FALSE;
-       }
-
-       if (!check_available ()) {
-               empathy_conf_get_bool (conf,
-                                      EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
-                                      &res);
-               if (res) {
-                       return FALSE;
-               }
-       }
-
-       if (check_focus) {
-               empathy_conf_get_bool (conf,
-                                      EMPATHY_PREFS_NOTIFICATIONS_FOCUS, &res);
-               return res;
-       } else {
-               return TRUE;
-       }
-}
-
index 6a52ff111b6ffe31f179d0b4e14db5652eeadf80..f7ec6649cfafaa27c4253c21d62abc579f21a79a 100644 (file)
@@ -133,9 +133,6 @@ void        empathy_send_file_with_file_chooser         (EmpathyContact   *conta
 void        empathy_sound_play                          (GtkWidget        *widget,
                                                         EmpathySound      sound_id);
 
-/* Notifications */
-gboolean    empathy_notification_should_show            (gboolean          check_focus);
-
 G_END_DECLS
 
 #endif /*  __EMPATHY_UI_UTILS_H__ */
index e4ada9f806d50491698dc0c9d26696b16ed996dc..bda638dffc93ec88b3da0d4b84b425b3d67c27ad 100644 (file)
@@ -41,6 +41,7 @@
 #include "empathy-contact-manager.h"
 #include "empathy-dispatcher.h"
 #include "empathy-dispatch-operation.h"
+#include "empathy-idle.h"
 #include "empathy-tp-call.h"
 
 #include <extensions/extensions.h>
@@ -482,3 +483,22 @@ empathy_start_call_with_contact (EmpathyContact *contact)
   empathy_dispatcher_call_with_contact (contact, empathy_call_request_cb,
     contact);
 }
+
+gboolean
+empathy_check_available_state (void)
+{
+       McPresence presence;
+       EmpathyIdle *idle;
+
+       idle = empathy_idle_dup_singleton ();
+       presence = empathy_idle_get_state (idle);
+       g_object_unref (idle);
+
+       if (presence != MC_PRESENCE_AVAILABLE &&
+           presence != MC_PRESENCE_UNSET) {
+               return FALSE;    
+       }
+
+       return TRUE;
+}
+
index dc17353da04e464f7977b19a634c7be822f72412..46fa193c0a08c64bcd3d217e711844ac9064f82e 100644 (file)
@@ -87,7 +87,7 @@ McAccount *  empathy_channel_get_account            (TpChannel       *channel);
 gboolean     empathy_proxy_equal                    (gconstpointer    a,
                                                     gconstpointer    b);
 guint        empathy_proxy_hash                     (gconstpointer    key);
-
+gboolean     empathy_check_available_state          (void);
 /* Temporary utility function, should be replaces by better voip infrastructure
  * soon */
 void empathy_start_call_with_contact (EmpathyContact *contact);
index 5294eac0916ed7683620bfdaa2087294555d54d8..db6479ea9297af33d7163c3c07dcdd654fa73cdd 100644 (file)
@@ -32,6 +32,7 @@ empathy_SOURCES =                                                     \
        empathy-import-dialog.c empathy-import-dialog.h                 \
        empathy-import-pidgin.c empathy-import-pidgin.h                 \
        empathy-main-window.c empathy-main-window.h                     \
+       empathy-misc.c empathy-misc.h                                   \
        empathy-new-chatroom-dialog.c empathy-new-chatroom-dialog.h     \
        empathy-preferences.c empathy-preferences.h                     \
        empathy-status-icon.c empathy-status-icon.h                     \
index 31a2866a620de96196708dd7b5916f77d4beb55c..cbb6c085c4cac81bee447406116e104ace983c7d 100644 (file)
@@ -55,6 +55,7 @@
 
 #include "empathy-chat-window.h"
 #include "empathy-about-dialog.h"
+#include "empathy-misc.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_CHAT
 #include <libempathy/empathy-debug.h>
@@ -868,9 +869,16 @@ chat_window_show_or_update_notification (EmpathyMessage *message,
        const char *body;
        GdkPixbuf *pixbuf;
        EmpathyChatWindowPriv *priv = GET_PRIV (window);
+       gboolean res;
 
-       if (!empathy_notification_should_show (TRUE)) {
+       if (!empathy_notification_is_enabled ()) {
                return;
+       } else {
+               empathy_conf_get_bool (empathy_conf_get (),
+                                      EMPATHY_PREFS_NOTIFICATIONS_FOCUS, &res);
+               if (!res) {
+                       return;
+               }
        }
 
        sender = empathy_message_get_sender (message);
diff --git a/src/empathy-misc.c b/src/empathy-misc.c
new file mode 100644 (file)
index 0000000..eb4baf3
--- /dev/null
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 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.
+ * 
+ * Author: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
+ *
+ */
+
+#include "empathy-misc.h"
+
+#include <libempathy/empathy-utils.h>
+#include <libempathy-gtk/empathy-conf.h>
+
+/* public methods */
+gboolean
+empathy_notification_is_enabled (void)
+{
+       EmpathyConf *conf;
+       gboolean res;
+
+       conf = empathy_conf_get ();
+       res = FALSE;
+
+       empathy_conf_get_bool (conf, EMPATHY_PREFS_NOTIFICATIONS_ENABLED, &res);
+
+       if (!res) {
+               return FALSE;
+       }
+
+       if (!empathy_check_available_state ()) {
+               empathy_conf_get_bool (conf,
+                                      EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
+                                      &res);
+               if (res) {
+                       return FALSE;
+               }
+       }
+
+       return TRUE;
+}
+
diff --git a/src/empathy-misc.h b/src/empathy-misc.h
new file mode 100644 (file)
index 0000000..6bc3e2b
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 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.
+ * 
+ * Author: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
+ *
+ */
+
+#ifndef __EMPATHY_MISC_H__
+#define __EMPATHY_MISC_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gboolean    empathy_notification_is_enabled  (void);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_MISC_H__ */
index 08293de555ba02ca35a2b39a2156d1b514ca2445..07f8abf85daf532d9780599d3fb9ccbaa4a2a12c 100644 (file)
@@ -43,6 +43,7 @@
 #include "empathy-status-icon.h"
 #include "empathy-preferences.h"
 #include "empathy-event-manager.h"
+#include "empathy-misc.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
 #include <libempathy/empathy-debug.h>
@@ -225,7 +226,7 @@ status_icon_event_added_cb (EmpathyEventManager *manager,
        status_icon_update_icon (icon);
        status_icon_update_tooltip (icon);
 
-       if (empathy_notification_should_show (FALSE)) {
+       if (empathy_notification_is_enabled ()) {
                status_icon_update_notification (icon);
        }
 
@@ -274,7 +275,7 @@ status_icon_event_updated_cb (EmpathyEventManager *manager,
                return;
        }
 
-       if (empathy_notification_should_show (FALSE)) {
+       if (empathy_notification_is_enabled ()) {
                status_icon_update_notification (icon);
        }
 
@@ -342,7 +343,7 @@ status_icon_idle_notify_cb (EmpathyStatusIcon *icon)
        status_icon_update_icon (icon);
        status_icon_update_tooltip (icon);
 
-       if (!empathy_notification_should_show (FALSE)) {
+       if (!empathy_notification_is_enabled ()) {
                /* dismiss the outstanding notification if present */
 
                if (priv->notification) {