Example #1
0
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);
}
Example #2
0
static void
established_call_cb (boost::shared_ptr<Ekiga::CallManager>  /*manager*/,
                     boost::shared_ptr<Ekiga::Call>  /*call*/,
                     gpointer self)
{
  statusicon_set_inacall (STATUSICON (self), true);
}
Example #3
0
static void
unread_count_cb (G_GNUC_UNUSED GtkWidget *widget,
		 guint messages,
		 gpointer data)
{
  StatusIcon *self = STATUSICON (data);

  gchar *message = NULL;

  if (messages > 0)
    statusicon_start_blinking (self, "im-message");
  else
    statusicon_stop_blinking (self);

  if (messages > 0) {

    message = g_strdup_printf (ngettext ("You have %d message",
					 "You have %d messages",
					 messages), messages);
    gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON (self), message);
    g_free (message);
  }
  else
    gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON (self), NULL);

  self->priv->unread_messages = (messages > 0);
}
Example #4
0
static void
cleared_call_cb (boost::shared_ptr<Ekiga::Call> /*call*/,
                 std::string /*reason*/,
                 gpointer self)
{
  statusicon_set_inacall (STATUSICON (self), false);
}
Example #5
0
/*
 * 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;
}
Example #6
0
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);
}
Example #7
0
static void
statusicon_finalize (GObject *obj)
{
  StatusIcon *self = NULL;

  self = STATUSICON (obj);

  if (self->priv->blink_image)
    g_free (self->priv->blink_image);

  delete self->priv;

  parent_class->finalize (obj);
}
Example #8
0
/*
 * GObject stuff
 */
static void
statusicon_dispose (GObject *obj)
{
  StatusIcon *icon = NULL;

  icon = STATUSICON (obj);

  if (icon->priv->blink_image) {

    g_free (icon->priv->blink_image);
    icon->priv->blink_image = NULL;
  }

  parent_class->dispose (obj);
}
Example #9
0
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;
}
Example #10
0
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);
}
Example #11
0
static void
status_icon_clicked_cb (G_GNUC_UNUSED GtkWidget* widget,
                        gpointer data)
{
  StatusIcon *self = STATUSICON (data);
  GtkWidget *window = gm_application_get_ekiga_window (GM_APPLICATION (self->priv->app));

  if (!gtk_widget_get_visible (window)
      || (gdk_window_get_state (GDK_WINDOW (gtk_widget_get_window (window)))
          & GDK_WINDOW_STATE_ICONIFIED)) {
    gtk_widget_show (window);
  }
  else {

    if (gtk_window_has_toplevel_focus (GTK_WINDOW (window)))
      gtk_widget_hide (window);
    else
      gtk_window_present (GTK_WINDOW (window));
  }
}
Example #12
0
static void
statusicon_on_notification_added (boost::shared_ptr<Ekiga::Notification> notification,
                                  gpointer data)
{
  StatusIcon *self = STATUSICON (data);
  GdkPixbuf* pixbuf = gtk_widget_render_icon_pixbuf (self->priv->chat_window,
						     GTK_STOCK_DIALOG_WARNING,
						     GTK_ICON_SIZE_MENU);

  gchar *current_tooltip = gtk_status_icon_get_tooltip_text (GTK_STATUS_ICON (self));
  gchar *tooltip = NULL;
  if (current_tooltip != NULL)
    tooltip = g_strdup_printf ("%s\n%s", current_tooltip, notification->get_title ().c_str ());
  else
    tooltip = g_strdup (notification->get_title ().c_str ());

  gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON (self), pixbuf);
  gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON (self), tooltip);
  g_object_unref (pixbuf);

  g_free (current_tooltip);
  g_free (tooltip);
}
Example #13
0
/*
 * 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;
}