From 31ffe0cd7670a9c31402443587dbe7d12f8561e0 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 12 Nov 2009 12:46:42 +0000 Subject: [PATCH] move empathy-misc to empathy-notify-manager All its code was related to notifications. --- libempathy-gtk/empathy-notify-manager.c | 44 ++++++++++++++ libempathy-gtk/empathy-notify-manager.h | 14 +++++ src/Makefile.am | 1 - src/empathy-chat-window.c | 2 +- src/empathy-misc.c | 77 ------------------------- src/empathy-misc.h | 49 ---------------- src/empathy-status-icon.c | 1 - 7 files changed, 59 insertions(+), 129 deletions(-) delete mode 100644 src/empathy-misc.c delete mode 100644 src/empathy-misc.h diff --git a/libempathy-gtk/empathy-notify-manager.c b/libempathy-gtk/empathy-notify-manager.c index 0bb6b856..44f77937 100644 --- a/libempathy-gtk/empathy-notify-manager.c +++ b/libempathy-gtk/empathy-notify-manager.c @@ -25,6 +25,9 @@ #include +#include +#include + #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include @@ -141,3 +144,44 @@ empathy_notify_manager_has_capability (EmpathyNotifyManager *self, return g_hash_table_lookup (priv->capabilities, capa) != NULL; } + +GdkPixbuf * +empathy_misc_get_pixbuf_for_notification (EmpathyContact *contact, + const char *icon_name) +{ + GdkPixbuf *pixbuf = NULL; + + if (contact != NULL) + pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, 48, 48); + + if (pixbuf == NULL) + pixbuf = empathy_pixbuf_from_icon_name_sized (icon_name, 48); + + return pixbuf; +} + +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/libempathy-gtk/empathy-notify-manager.h b/libempathy-gtk/empathy-notify-manager.h index 951bd4d9..d56e5085 100644 --- a/libempathy-gtk/empathy-notify-manager.h +++ b/libempathy-gtk/empathy-notify-manager.h @@ -51,6 +51,15 @@ G_BEGIN_DECLS #define EMPATHY_IS_NOTIFY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_NOTIFY_MANAGER)) #define EMPATHY_NOTIFY_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_NOTIFY_MANAGER, EmpathyNotifyManagerClass)) +/* FIXME: this should *really* belong to libnotify. */ +typedef enum { + EMPATHY_NOTIFICATION_CLOSED_INVALID = 0, + EMPATHY_NOTIFICATION_CLOSED_EXPIRED = 1, + EMPATHY_NOTIFICATION_CLOSED_DISMISSED = 2, + EMPATHY_NOTIFICATION_CLOSED_PROGRAMMATICALY = 3, + EMPATHY_NOTIFICATION_CLOSED_RESERVED = 4 +} EmpathyNotificationClosedReason; + typedef struct _EmpathyNotifyManager EmpathyNotifyManager; typedef struct _EmpathyNotifyManagerClass EmpathyNotifyManagerClass; @@ -73,6 +82,11 @@ EmpathyNotifyManager * empathy_notify_manager_dup_singleton (void); gboolean empathy_notify_manager_has_capability (EmpathyNotifyManager *self, const gchar *capa); +gboolean empathy_notification_is_enabled (void); +GdkPixbuf * empathy_misc_get_pixbuf_for_notification (EmpathyContact *contact, + const char *icon_name); + + G_END_DECLS #endif /* __EMPATHY_NOTIFY_MANAGER_H__ */ diff --git a/src/Makefile.am b/src/Makefile.am index cfd75137..b61f9d34 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,6 @@ empathy_handwritten_source = \ empathy-import-utils.c empathy-import-utils.h \ empathy-import-widget.c empathy-import-widget.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-sidebar.c empathy-sidebar.h \ diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index ccbfff67..6d69235a 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -52,10 +52,10 @@ #include #include #include +#include #include "empathy-chat-window.h" #include "empathy-about-dialog.h" -#include "empathy-misc.h" #define DEBUG_FLAG EMPATHY_DEBUG_CHAT #include diff --git a/src/empathy-misc.c b/src/empathy-misc.c deleted file mode 100644 index a1a08474..00000000 --- a/src/empathy-misc.c +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Author: Cosimo Cecchi - * - */ - -#include "empathy-misc.h" - -#include -#include -#include - -/* public methods */ - -GdkPixbuf * -empathy_misc_get_pixbuf_for_notification (EmpathyContact *contact, - const char *icon_name) -{ - GdkPixbuf *pixbuf = NULL; - - if (contact != NULL) { - pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, - 48, 48); - } - - if (!pixbuf) { - pixbuf = empathy_pixbuf_from_icon_name_sized - (icon_name, 48); - } - - return pixbuf; -} - -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 deleted file mode 100644 index b3fe8fdb..00000000 --- a/src/empathy-misc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * Author: Cosimo Cecchi - * - */ - -#ifndef __EMPATHY_MISC_H__ -#define __EMPATHY_MISC_H__ - -#include -#include - -#include - -G_BEGIN_DECLS - -/* FIXME: this should *really* belong to libnotify. */ -typedef enum { - EMPATHY_NOTIFICATION_CLOSED_INVALID = 0, - EMPATHY_NOTIFICATION_CLOSED_EXPIRED = 1, - EMPATHY_NOTIFICATION_CLOSED_DISMISSED = 2, - EMPATHY_NOTIFICATION_CLOSED_PROGRAMMATICALY = 3, - EMPATHY_NOTIFICATION_CLOSED_RESERVED = 4 -} EmpathyNotificationClosedReason; - -gboolean empathy_notification_is_enabled (void); -GdkPixbuf * empathy_misc_get_pixbuf_for_notification (EmpathyContact *contact, - const char *icon_name); - -G_END_DECLS - -#endif /* __EMPATHY_MISC_H__ */ diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c index 000100f7..aaf827dc 100644 --- a/src/empathy-status-icon.c +++ b/src/empathy-status-icon.c @@ -49,7 +49,6 @@ #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 -- 2.39.2