Example #1
0
static void
roster_view_gtk_find_iter_for_presentity (RosterViewGtk *view,
                                          GtkTreeIter *group_iter,
                                          Ekiga::PresentityPtr presentity,
                                          GtkTreeIter *iter)
{
  GtkTreeModel *model = NULL;
  Ekiga::Presentity *iter_presentity = NULL;
  gboolean found = FALSE;

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

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

    do {

      gtk_tree_model_get (model, iter, COLUMN_PRESENTITY, &iter_presentity, -1);
      if (iter_presentity == presentity.get ())
        found = TRUE;
    } while (!found && gtk_tree_model_iter_next (model, iter));
  }

  if (!found)
    gtk_tree_store_append (view->priv->store, iter, group_iter);
}
Example #2
0
bool
Opal::Bank::populate_menu (Ekiga::PresentityPtr presentity,
			   const std::string uri,
			   Ekiga::MenuBuilder& builder)
{
  return populate_menu_helper (presentity->get_name (), uri, builder);
}
Example #3
0
  bool operator() (Ekiga::PresentityPtr presentity)
  {
    const std::list<std::string> presentity_groups = presentity->get_groups ();

    groups.push_back (presentity_groups.begin (),
		   presentity_groups.end ());

    return true;
  }
Example #4
0
static void
on_presentity_updated (RosterViewGtk* self,
		       Ekiga::ClusterPtr cluster,
		       Ekiga::HeapPtr heap,
		       Ekiga::PresentityPtr presentity)
{
  GtkTreeModel *model;
  GtkTreeIter heap_iter;
  GtkTreeIter group_iter;
  GtkTreeIter iter;
  gchar *group_name = NULL;
  int timeout = 0;
  std::set<std::string> groups = presentity->get_groups ();

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

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

  // This makes sure we are in all groups where we should
  on_presentity_added (self, cluster, heap, presentity);

  // Now let's remove from all the others
  roster_view_gtk_find_iter_for_heap (self, heap, &heap_iter);

  if (gtk_tree_model_iter_nth_child (model, &group_iter, &heap_iter, 0)) {

    do {

      gtk_tree_model_get (model, &group_iter,
                          COLUMN_GROUP_NAME, &group_name,
                          -1);
      if (group_name != NULL) {

        if (groups.find (group_name) == groups.end ()) {

          roster_view_gtk_find_iter_for_presentity (self, &group_iter, presentity, &iter);
          gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
                              COLUMN_TIMEOUT, &timeout,
                              -1);
          if (timeout > 0)
            g_source_remove (timeout);
          gtk_tree_store_remove (self->priv->store, &iter);
        }
        g_free (group_name);
      }
    } while (gtk_tree_model_iter_next (model, &group_iter));
  }

  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);
}
Example #5
0
static void
on_presentity_updated (HeapView* self,
		       Ekiga::PresentityPtr presentity)
{
  // first, make sure we are in all the groups we should be in, with up to date information
  on_presentity_added (self, presentity);

  // now, let's remove ourselves from the others
  GtkTreeModel* model;
  GtkTreeIter group_iter;
  GtkTreeIter iter;
  gchar* group_name = NULL;
  std::set<std::string> groups = presentity->get_groups ();

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

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

  if (gtk_tree_model_get_iter_first (model, &group_iter)) {

    do {

      gtk_tree_model_get (model, &group_iter, COLUMN_NAME, &group_name, -1);

      if (group_name != NULL) {

	if (groups.find (group_name) == groups.end ()) {

	  find_iter_for_presentity (self, presentity.get (), &group_iter, &iter);
	  gtk_tree_store_remove (self->priv->store, &iter);
	}
	g_free (group_name);
      }

    } while (gtk_tree_model_iter_next (model, &group_iter));
  }

  clear_empty_groups (self);
}
Example #6
0
static void
on_presentity_added (HeapView* self,
		     Ekiga::PresentityPtr presentity)
{
  GtkTreeIter group_iter;
  GtkTreeIter iter;
  std::set<std::string> groups = presentity->get_groups ();
  GtkTreeSelection* selection = gtk_tree_view_get_selection (self->priv->view);
  bool should_emit = false;

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

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

    find_iter_for_group (self, group->c_str (), &group_iter);
    find_iter_for_presentity (self, presentity.get (), &group_iter, &iter);

    if (gtk_tree_selection_iter_is_selected (selection, &iter))
      should_emit = true;

    gtk_tree_store_set (self->priv->store, &iter,
			COLUMN_TYPE, TYPE_PRESENTITY,
			COLUMN_PRESENTITY, presentity.get (),
			COLUMN_NAME, presentity->get_name ().c_str (),
			COLUMN_PRESENCE, presentity->get_presence ().c_str (),
			COLUMN_STATUS, presentity->get_status ().c_str (),
			-1);
  }

  if (should_emit)
    g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
}
Example #7
0
static void
on_presentity_removed (HeapView* self,
		       Ekiga::PresentityPtr presentity)
{
  GtkTreeModel* model;
  GtkTreeIter group_iter;
  GtkTreeIter iter;

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

  if (gtk_tree_model_get_iter_first (model, &group_iter)) {

    do {

      find_iter_for_presentity (self, presentity.get (), &group_iter, &iter);
      gtk_tree_store_remove (self->priv->store, &iter);
    } while (gtk_tree_model_iter_next (model, &group_iter));
  }

  clear_empty_groups (self);
}
Example #8
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);
}