Logo Search packages:      
Sourcecode: pan version File versions  Download package

GtkTreePath * GroupPane::find_next_subscribed_group ( bool  unread_only ) [private]

Walk circularly through the subscribed groups, looking for the next one after our current selection, possibly only ones with unread messages.

Definition at line 687 of file group-pane.cc.

References PanTreeStore::get_row().

{
  GtkTreeView * view (GTK_TREE_VIEW(_tree_view));
  GtkTreeModel * model (gtk_tree_view_get_model (view));

  // find how many subscribed groups the tree's got
  GtkTreeIter sub_iter;
  gtk_tree_model_iter_nth_child (model, &sub_iter, 0, 0); // 'sub' node
  const int n_groups = gtk_tree_model_iter_n_children (model, &sub_iter);
  if (n_groups < 1)
    return 0;

  // find the index of the current selection
  // (or -1 if no subscribed groups are selected)
  int start_pos = -1;
  GtkTreeIter sel_iter;
  const Quark group = get_first_selection ();
  if (!group.empty()) {
    const MyRow* row = find_row (group);
    sel_iter = PAN_TREE_STORE(model)->get_iter (row);
    GtkTreePath * path = gtk_tree_model_get_path (model, &sel_iter);
    gint depth = gtk_tree_path_get_depth (path);
    gint* indices = gtk_tree_path_get_indices (path);
    if (depth==2 && indices[0]==0) // a subscribed group is selected
      start_pos = indices[1];
    gtk_tree_path_free (path);
  }

  // loop through the `sub' node's children looking for
  // groups that match our criteria.
  int n = start_pos;
  for (;;)
  {
    if (++n == n_groups) {
      if (start_pos == -1)
        return 0;
      n = 0;
    }
    if (n == start_pos)
      return 0;

    GtkTreeIter group_iter;
    gtk_tree_model_iter_nth_child (model, &group_iter, &sub_iter, n);
    const MyRow * row (dynamic_cast<MyRow*>(_tree_store->get_row (&group_iter)));
    if (!unread_only || row->unread)
      return gtk_tree_model_get_path (model, &group_iter);
  }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index