Esempio n. 1
0
static void
on_heap_updated (RosterViewGtk* self,
		 G_GNUC_UNUSED Ekiga::ClusterPtr cluster,
		 Ekiga::HeapPtr heap)
{
  GtkTreeIter iter;
  GtkTreeIter filtered_iter;
  GtkTreeSelection* selection = NULL;
  gboolean should_emit = FALSE;

  roster_view_gtk_find_iter_for_heap (self, heap, &iter);

  selection = gtk_tree_view_get_selection (self->priv->tree_view);
  GtkTreeModelFilter* model = GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (self->priv->tree_view));

  if (gtk_tree_model_filter_convert_child_iter_to_iter (model, &filtered_iter, &iter))
    if (gtk_tree_selection_iter_is_selected (selection, &filtered_iter))
      should_emit = TRUE;

  gtk_tree_store_set (self->priv->store, &iter,
		      COLUMN_TYPE, TYPE_HEAP,
		      COLUMN_HEAP, heap.get (),
		      COLUMN_NAME, heap->get_name ().c_str (), -1);

  if (should_emit)
    g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
}
Esempio n. 2
0
static void
on_heap_added (RosterViewGtk* self,
	       Ekiga::ClusterPtr cluster,
	       Ekiga::HeapPtr heap)
{
  on_heap_updated (self, cluster, heap);
  heap->visit_presentities (boost::bind (&visit_presentities, self, cluster, heap, _1));
}
Esempio n. 3
0
static bool
visit_heaps (RosterViewGtk* self,
	     Ekiga::ClusterPtr cluster,
	     Ekiga::HeapPtr heap)
{
  on_heap_updated (self, cluster, heap);
  heap->visit_presentities (boost::bind (&visit_presentities, self, cluster, heap, _1));

  return true;
}
Esempio n. 4
0
static void
roster_view_gtk_find_iter_for_group (RosterViewGtk *view,
				     Ekiga::HeapPtr heap,
                                     GtkTreeIter *heap_iter,
                                     const std::string name,
                                     GtkTreeIter *iter)
{
  GtkTreeModel *model = NULL;
  gchar *group_name = NULL;
  gboolean found = FALSE;

  model = GTK_TREE_MODEL (view->priv->store);

  if (gtk_tree_model_iter_nth_child (model, iter, heap_iter, 0)) {

    do {

      gtk_tree_model_get (model, iter, COLUMN_GROUP_NAME, &group_name, -1);
      if (group_name != NULL && name == group_name)
        found = TRUE;
      if (group_name != NULL)
        g_free (group_name);
    } while (!found && gtk_tree_model_iter_next (model, iter));
  }

  if (!found) {

    gtk_tree_store_append (view->priv->store, iter, heap_iter);
    gtk_tree_store_set (view->priv->store, iter,
                        COLUMN_TYPE, TYPE_GROUP,
                        COLUMN_HEAP, heap.get (),
                        COLUMN_NAME, name.c_str (),
                        COLUMN_GROUP_NAME, name.c_str (),
                        -1);
  }
}
Esempio n. 5
0
/*
 * Implementation of the static helpers.
 */
static void
roster_view_gtk_find_iter_for_heap (RosterViewGtk *view,
                                    Ekiga::HeapPtr heap,
                                    GtkTreeIter *iter)
{
  GtkTreeModel *model = NULL;
  Ekiga::Heap *iter_heap = NULL;
  gboolean found = FALSE;

  model = GTK_TREE_MODEL (view->priv->store);

  if (gtk_tree_model_get_iter_first (model, iter)) {

    do {

      gtk_tree_model_get (model, iter, COLUMN_HEAP, &iter_heap, -1);
      if (iter_heap == heap.get ())
        found = TRUE;
    } while (!found && gtk_tree_model_iter_next (model, iter));
  }

  if (!found)
    gtk_tree_store_append (view->priv->store, iter, NULL);
}
Esempio n. 6
0
static void
heap_view_set_heap (HeapView* self,
		    Ekiga::HeapPtr heap)
{
  if (self->priv->heap) {

    for (std::vector<boost::signals::connection>::iterator iter
	   = self->priv->connections.begin ();
	 iter != self->priv->connections.end ();
	 iter++)
      iter->disconnect ();

    self->priv->connections.clear ();
  }

  if (heap) {

    boost::signals::connection conn;

    conn = heap->removed.connect (boost::bind (&on_heap_removed, self));
    self->priv->connections.push_back (conn);
    conn = heap->presentity_added.connect (boost::bind (&on_presentity_added, self, _1));
    self->priv->connections.push_back (conn);
    conn = heap->presentity_updated.connect (boost::bind (&on_presentity_updated, self, _1));
    self->priv->connections.push_back (conn);
    conn = heap->presentity_removed.connect (boost::bind (&on_presentity_removed, self, _1));
    self->priv->connections.push_back (conn);
    conn = heap->questions.connect (boost::bind (&on_questions, self, _1));
  }

  gtk_tree_store_clear (self->priv->store);
  self->priv->heap = heap;

  if (self->priv->heap)
    heap->visit_presentities (boost::bind (&visit_presentities, self, _1));
}
Esempio n. 7
0
static void
on_presentity_added (RosterViewGtk* self,
		     G_GNUC_UNUSED Ekiga::ClusterPtr cluster,
		     Ekiga::HeapPtr heap,
		     Ekiga::PresentityPtr presentity)
{
  GtkTreeIter heap_iter;
  std::set<std::string> groups = presentity->get_groups ();
  GtkTreeSelection* selection = gtk_tree_view_get_selection (self->priv->tree_view);
  GtkTreeModelFilter* filtered_model = GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (self->priv->tree_view));
  GtkTreeIter group_iter;
  GtkTreeIter iter;
  GtkTreeIter filtered_iter;
  bool active = false;
  bool away = false;
  guint timeout = 0;
  std::string status;
  gchar *old_presence = NULL;
  gboolean should_emit = FALSE;

  roster_view_gtk_find_iter_for_heap (self, heap, &heap_iter);

  active = presentity->get_presence () != "offline";
  away = presentity->get_presence () == "away";

  if (groups.empty ())
    groups.insert (_("Unsorted"));

  for (std::set<std::string>::const_iterator group = groups.begin ();
       group != groups.end ();
       group++) {

    roster_view_gtk_find_iter_for_group (self, heap, &heap_iter,
					 *group, &group_iter);
    roster_view_gtk_find_iter_for_presentity (self, &group_iter, presentity, &iter);

    if (gtk_tree_model_filter_convert_child_iter_to_iter (filtered_model, &filtered_iter, &iter))
      if (gtk_tree_selection_iter_is_selected (selection, &filtered_iter))
	should_emit = TRUE;

    // Find out what our presence was
    gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
                        COLUMN_PRESENCE, &old_presence, -1);

    if (old_presence && presentity->get_presence () != old_presence
        && presentity->get_presence () != "unknown" && presentity->get_presence () != "offline"
        && (!g_strcmp0 (old_presence, "unknown") || !g_strcmp0 (old_presence, "offline"))) {

      StatusIconInfo *info = new StatusIconInfo ();
      info->model = GTK_TREE_MODEL (self->priv->store);
      info->iter = gtk_tree_iter_copy (&iter);
      info->cpt = 0;

      timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 1, roster_view_gtk_icon_blink_cb,
                                            (gpointer) info, (GDestroyNotify) status_icon_info_delete);
      gtk_tree_store_set (self->priv->store, &iter,
                          COLUMN_TIMEOUT, timeout, -1);
    }
    else {

      std::string icon = "avatar-default";
      if (!old_presence) {
        gtk_tree_store_set (self->priv->store, &iter,
                            COLUMN_PRESENCE_ICON, icon.c_str (),
                            -1);
      }
      else if (old_presence != presentity->get_presence ()) {
        if (presentity->get_presence () != "unknown")
          icon = "user-" + presentity->get_presence ();
        gtk_tree_store_set (self->priv->store, &iter,
                            COLUMN_PRESENCE_ICON, icon.c_str (),
                            -1);
      }
    }
    status = presentity->get_status ();
    if (status.empty ()) {
      if (presentity->get_presence () == "away")
        status = _("Away");
      else if (presentity->get_presence () == "available")
        status = _("Available");
      else if (presentity->get_presence () == "offline")
        status = _("Offline");
      else if (presentity->get_presence () == "busy")
        status = _("Busy");
    }
    gtk_tree_store_set (self->priv->store, &iter,
                        COLUMN_TYPE, TYPE_PRESENTITY,
                        COLUMN_OFFLINE, active,
                        COLUMN_HEAP, heap.get (),
                        COLUMN_PRESENTITY, presentity.get (),
                        COLUMN_NAME, presentity->get_name ().c_str (),
                        COLUMN_STATUS, status.c_str (),
                        COLUMN_PRESENCE, presentity->get_presence ().c_str (),
                        COLUMN_ACTIVE, (!active || away) ? "gray" : "black", -1);
    gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
                        COLUMN_TIMEOUT, &timeout,
                        -1);

    g_free (old_presence);
  }

  GtkTreeModel* model = gtk_tree_view_get_model (self->priv->tree_view);
  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));

  roster_view_gtk_update_groups (self, &heap_iter);

  if (should_emit)
    g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
}