static void statusicon_activated_cb (G_GNUC_UNUSED GtkStatusIcon *icon, gpointer data) { StatusIcon *self = STATUSICON (data); // No unread messages => show ekiga if (!self->priv->unread_messages) { // FIXME: When the main_window will be a GtkFrontend component, // this signal will be useless g_signal_emit (self, signals, 0, NULL); } else { // Unread messages => show chat window boost::shared_ptr<GtkFrontend> frontend = self->priv->frontend.lock(); if (frontend) { GtkWidget *w = GTK_WIDGET (frontend->get_chat_window ()); gtk_widget_show (w); gtk_window_present (GTK_WINDOW (w)); } } // Remove warnings from statusicon statusicon_set_status (STATUSICON (data), STATUSICON (data)->priv->status); gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON (self), NULL); }
static void statusicon_set_inacall (StatusIcon *statusicon, bool inacall) { g_return_if_fail (statusicon != NULL); /* Update the status icon */ if (inacall) gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (statusicon), "user-inacall"); else statusicon_set_status (statusicon, statusicon->priv->status); }
/* * Public API */ StatusIcon * status_icon_new (Ekiga::ServiceCore & core) { StatusIcon *self = NULL; if (!statusicon_should_run ()) return self; boost::signals::connection conn; self = STATUSICON (g_object_new (STATUSICON_TYPE, NULL)); self->priv = new StatusIconPrivate; self->priv->popup_menu = statusicon_build_menu (); g_object_ref_sink (self->priv->popup_menu); self->priv->has_message = FALSE; self->priv->blink_id = -1; self->priv->blinking = false; self->priv->blink_image = NULL; self->priv->unread_messages = false; boost::shared_ptr<Ekiga::PersonalDetails> details = core.get<Ekiga::PersonalDetails> ("personal-details"); boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core"); boost::shared_ptr<Ekiga::NotificationCore> notification_core = core.get<Ekiga::NotificationCore> ("notification-core"); boost::shared_ptr<GtkFrontend> frontend = core.get<GtkFrontend> ("gtk-frontend"); self->priv->frontend = frontend; GtkWidget *chat_window = GTK_WIDGET (frontend->get_chat_window ()); statusicon_set_status (self, details->get_presence ()); notification_core->notification_added.connect (boost::bind (statusicon_on_notification_added, _1, (gpointer) self)); conn = details->updated.connect (boost::bind (&personal_details_updated_cb, self, details)); self->priv->connections.add (conn); conn = call_core->established_call.connect (boost::bind (&established_call_cb, _1, _2, (gpointer) self)); self->priv->connections.add (conn); conn = call_core->cleared_call.connect (boost::bind (&cleared_call_cb, _1, _2, _3, (gpointer) self)); self->priv->connections.add (conn); g_signal_connect (self, "popup-menu", G_CALLBACK (show_popup_menu_cb), self->priv->popup_menu); g_signal_connect (self, "activate", G_CALLBACK (statusicon_activated_cb), self); g_signal_connect (chat_window, "unread-count", G_CALLBACK (unread_count_cb), self); return self; }
static gboolean statusicon_blink_cb (gpointer data) { StatusIcon *statusicon = STATUSICON (data); g_return_val_if_fail (data != NULL, false); if (statusicon->priv->blinking) gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (statusicon), "im-message"); else statusicon_set_status (statusicon, statusicon->priv->status); statusicon->priv->blinking = !statusicon->priv->blinking; return true; }
static void statusicon_stop_blinking (StatusIcon *self) { if (self->priv->blink_image) { g_free (self->priv->blink_image); self->priv->blink_image = NULL; } if (self->priv->blink_id != -1) { g_source_remove (self->priv->blink_id); self->priv->blink_id = -1; self->priv->blinking = false; } statusicon_set_status (STATUSICON (self), self->priv->status); }
static void statusicon_activated_cb (G_GNUC_UNUSED GtkStatusIcon *icon, gpointer data) { StatusIcon *self = STATUSICON (data); // No unread messages => signal the gtk+ frontend // (should hide/present the main window) if (!self->priv->unread_messages) { g_signal_emit (self, signals, 0, NULL); } else { // Unread messages => show chat window gtk_window_present (GTK_WINDOW (self->priv->chat_window)); } // Remove warnings from statusicon statusicon_set_status (STATUSICON (data), STATUSICON (data)->priv->status); gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON (self), NULL); }
static void personal_details_updated_cb (StatusIcon* self, boost::shared_ptr<Ekiga::PersonalDetails> details) { statusicon_set_status (self, details->get_presence ()); }
/* * Public API */ StatusIcon * status_icon_new (GmApplication *app) { StatusIcon *self = NULL; g_return_val_if_fail (GM_IS_APPLICATION (app), NULL); if (!statusicon_should_run ()) return self; Ekiga::ServiceCore& core = gm_application_get_core (app); boost::signals2::connection conn; self = STATUSICON (g_object_new (STATUSICON_TYPE, NULL)); self->priv = new StatusIconPrivate; self->priv->has_message = FALSE; self->priv->blink_id = -1; self->priv->blinking = false; self->priv->blink_image = NULL; self->priv->unread_messages = false; self->priv->app = app; boost::shared_ptr<Ekiga::PersonalDetails> details = core.get<Ekiga::PersonalDetails> ("personal-details"); boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core"); boost::shared_ptr<Ekiga::NotificationCore> notification_core = core.get<Ekiga::NotificationCore> ("notification-core"); self->priv->chat_window = gm_application_get_chat_window (app); statusicon_set_status (self, details->get_presence ()); notification_core->notification_added.connect (boost::bind (statusicon_on_notification_added, _1, (gpointer) self)); conn = details->updated.connect (boost::bind (&personal_details_updated_cb, self, details)); self->priv->connections.add (conn); conn = call_core->established_call.connect (boost::bind (&established_call_cb, _1, (gpointer) self)); self->priv->connections.add (conn); conn = call_core->cleared_call.connect (boost::bind (&cleared_call_cb, _1, _2, (gpointer) self)); self->priv->connections.add (conn); g_signal_connect (self, "activate", G_CALLBACK (statusicon_activated_cb), self); if (self->priv->chat_window) g_signal_connect (self->priv->chat_window, "unread-count", G_CALLBACK (unread_count_cb), self); g_signal_connect (self, "clicked", G_CALLBACK (status_icon_clicked_cb), self); return self; }