Re: liststore manipulation question



Thanks.  That looks like what I want.


  // Wally

On Thu, 2010-07-08 at 20:50 +0200, Tadej Borovšak wrote:
Hi.

You'll probably want to do something like this in your functions (replace my
data parameter with whatever you're using to get widget's inside callback):

static void
move_up (GtkButton *button,
       Data      *data)
{
  GtkTreeIter   current,
              prev;
  GtkTreePath  *path;
  GtkTreeModel *model;

  if (!gtk_tree_selection_get_selected (data->sel, &model, &current))
    return;

  path = gtk_tree_model_get_path (model, &current);
  if (gtk_tree_path_prev (path))
    {
      gtk_tree_model_get_iter (model, &prev, path);

      /* Now current "points" to currently selected row and prev to row before.
       * Do number switch here now. */
    }
  gtk_tree_path_free (path);
}

static void
move_down (GtkButton *button,
         Data      *data)
{
  GtkTreeIter   current,
              next;
  GtkTreeModel *model;

  if (!gtk_tree_selection_get_selected (data->sel, &model, &current))
    return;

  next = current;
  if (gtk_tree_model_iter_next (&next))
    {
      /* Now current "points" to currently selected row and prev to row before.
       * Do number switch here now. */
    }
}

Hopefully this will help you a bit.

Tadej

-- 
Wallace Owen L-3Com com
Office: 619.278.2084
Cell:   619.990.2286




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]