[ekiga] Added a few notifications.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Added a few notifications.
- Date: Thu, 19 Apr 2012 16:03:17 +0000 (UTC)
commit f6327faec06ab1e1579e2753923ebf848063b673
Author: Damien Sandras <dsandras beip be>
Date: Sun Apr 15 16:16:05 2012 +0200
Added a few notifications.
They will be moved to the NotificationCore.
src/gui/notify.cpp | 113 ++++++++++++++++++++++++---------------------------
1 files changed, 53 insertions(+), 60 deletions(-)
---
diff --git a/src/gui/notify.cpp b/src/gui/notify.cpp
index 6975707..f0c7f31 100644
--- a/src/gui/notify.cpp
+++ b/src/gui/notify.cpp
@@ -59,6 +59,13 @@ struct CallNotificationInfo
boost::shared_ptr<Ekiga::Call> call;
};
+struct _Notify
+{
+ NotifyNotification *missed_call_notification;
+ gchar *missed_call_body;
+
+};
+
// return if the notify server accepts actions (i.e. buttons)
// taken from https://wiki.ubuntu.com/NotificationDevelopmentGuidelines#Avoiding%20actions
static int
@@ -105,18 +112,28 @@ notify_action_cb (NotifyNotification *notification,
}
static void
-notify_missed_call_action_cb (NotifyNotification *notification,
- G_GNUC_UNUSED gchar *action,
+notify_missed_call_action_cb (G_GNUC_UNUSED NotifyNotification *notification,
+ gchar *action,
gpointer data)
{
- GtkWidget *window = GTK_WIDGET (data);
+ GtkWidget *window = GnomeMeeting::Process ()->GetMainWindow (); //FIXME when GOBJECT
+ _Notify *notifications = (_Notify*) (data);
- gm_conf_set_int (USER_INTERFACE_KEY "main_window/panel_section", CALL);
- if (!gtk_widget_get_visible (window)
- || (gdk_window_get_state (GDK_WINDOW (window->window)) & GDK_WINDOW_STATE_ICONIFIED))
- gtk_widget_show (window);
+ if (!strcmp (action, "show")) {
+ gm_conf_set_int (USER_INTERFACE_KEY "main_window/panel_section", CALL);
- notify_notification_close (notification, NULL);
+ if (!gtk_widget_get_visible (window)
+ || (gdk_window_get_state (GDK_WINDOW (window->window)) & GDK_WINDOW_STATE_ICONIFIED))
+ gtk_widget_show (window);
+
+ g_free (notifications->missed_call_body);
+ notifications->missed_call_body = NULL;
+
+ notify_notification_close (notifications->missed_call_notification, NULL);
+ notifications->missed_call_notification = NULL;
+ }
+ else
+ notify_notification_close (notifications->missed_call_notification, NULL);
}
static void
@@ -148,26 +165,29 @@ on_missed_call_cb (boost::shared_ptr<Ekiga::CallManager> /*manager*/,
boost::shared_ptr<Ekiga::Call> call,
gpointer data)
{
- NotifyNotification *notify = NULL;
- gchar *body = g_strdup_printf (_("Missed call from %s"), (const char*) call->get_remote_party_name ().c_str ());
-
- notify = notify_notification_new (_("Missed call"), body, GM_ICON_LOGO
-// NOTIFY_CHECK_VERSION appeared in 0.5.2 only
-#ifndef NOTIFY_CHECK_VERSION
- , NULL
-#else
-#if !NOTIFY_CHECK_VERSION(0,7,0)
- , NULL
-#endif
-#endif
- );
-
- notify_notification_set_urgency (notify, NOTIFY_URGENCY_NORMAL);
- notify_notification_set_timeout (notify, NOTIFY_EXPIRES_NEVER);
- notify_notification_add_action (notify, "default", _("Show"), notify_missed_call_action_cb, data, NULL);
- notify_notification_show (notify, NULL);
+ _Notify *notifications = (_Notify *) (data);
+
+ if (notifications->missed_call_body == NULL)
+ notifications->missed_call_body = g_strdup_printf (_("Missed call from %s"),
+ (const char*) call->get_remote_party_name ().c_str ());
+ else
+ notifications->missed_call_body = g_strdup_printf (_("Missed call from %s\n%s"),
+ (const char*) call->get_remote_party_name ().c_str (),
+ (const char*) notifications->missed_call_body);
+
+ if (notifications->missed_call_notification == NULL) {
+ notifications->missed_call_notification = notify_notification_new (_("Missed Call"),
+ notifications->missed_call_body,
+ GM_ICON_LOGO);
+ notify_notification_add_action (notifications->missed_call_notification, "default", _("Show"),
+ notify_missed_call_action_cb, data, NULL);
+ }
+ else
+ notify_notification_update (notifications->missed_call_notification, _("Missed Calls"),
+ notifications->missed_call_body, GM_ICON_LOGO);
- g_free (body);
+ notify_notification_set_timeout (notifications->missed_call_notification, 0);
+ notify_notification_show (notifications->missed_call_notification, NULL);
}
static void
@@ -197,6 +217,7 @@ on_unread_count_cb (G_GNUC_UNUSED GtkWidget *widget,
notify_notification_set_urgency (notify, NOTIFY_URGENCY_NORMAL);
notify_notification_set_timeout (notify, NOTIFY_EXPIRES_NEVER);
+ notify_notification_add_action (notify, "ignore", _("Ignore"), notify_show_window_action_cb, data, NULL);
notify_notification_add_action (notify, "default", _("Show"), notify_show_window_action_cb, data, NULL);
notify_notification_show (notify, NULL);
}
@@ -259,35 +280,6 @@ static void on_setup_call_cb (boost::shared_ptr<Ekiga::CallManager> manager,
ekiga_incoming_call_notify (call);
}
-static void on_account_updated (Ekiga::BankPtr /*bank*/,
- Ekiga::AccountPtr account,
- gpointer data)
-{
- NotifyNotification *notify = NULL;
- gchar *title = NULL;
-
- if (account->is_failed ()) {
-
- title = g_strdup_printf (_("%s account"), (const char*) account->get_name ().c_str ());
-
- notify = notify_notification_new (title, _("Failure to register"), GM_ICON_LOGO
- // NOTIFY_CHECK_VERSION appeared in 0.5.2 only
-#ifndef NOTIFY_CHECK_VERSION
- , NULL
-#else
-#if !NOTIFY_CHECK_VERSION(0,7,0)
- , NULL
-#endif
-#endif
- );
- notify_notification_set_timeout (notify, NOTIFY_EXPIRES_DEFAULT);
- notify_notification_set_urgency (notify, NOTIFY_URGENCY_CRITICAL);
- notify_notification_add_action (notify, "default", _("Show"), notify_show_window_action_cb, data, NULL);
-
- notify_notification_show (notify, NULL);
- }
-}
-
/*
* Public API
@@ -295,18 +287,19 @@ static void on_account_updated (Ekiga::BankPtr /*bank*/,
void
notify_start (Ekiga::ServiceCore & core)
{
+ _Notify *notifications = new _Notify ();
+ notifications->missed_call_notification = NULL;
+ notifications->missed_call_body = NULL;
+
boost::shared_ptr<GtkFrontend> frontend = core.get<GtkFrontend> ("gtk-frontend");
boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
boost::shared_ptr<Ekiga::AccountCore> account_core = core.get<Ekiga::AccountCore> ("account-core");
- GtkWidget *main_window = GnomeMeeting::Process ()->GetMainWindow (); //FIXME when GOBJECT
GtkWidget *accounts_window = GnomeMeeting::Process ()->GetAccountsWindow (); //FIXME when GOBJECT
GtkWidget *chat_window = GTK_WIDGET (frontend->get_chat_window ());
call_core->setup_call.connect (boost::bind (&on_setup_call_cb, _1, _2));
- call_core->missed_call.connect (boost::bind (&on_missed_call_cb, _1, _2, (gpointer) main_window));
-
- account_core->account_updated.connect (boost::bind (&on_account_updated, _1, _2, (gpointer) accounts_window));
+ call_core->missed_call.connect (boost::bind (&on_missed_call_cb, _1, _2, (gpointer) notifications));
g_signal_connect (chat_window, "unread-count", G_CALLBACK (on_unread_count_cb), chat_window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]