Ejemplo n.º 1
0
/* is the user looking at the latest messages? */
static gboolean
is_pinned_to_new (struct MsgData * data)
{
  gboolean pinned_to_new = FALSE;

  if (data->view == NULL)
    {
      pinned_to_new = TRUE;
    }
  else
    {
      GtkTreePath * last_visible;
      if (gtk_tree_view_get_visible_range (data->view, NULL, &last_visible))
        {
          GtkTreeIter iter;
          const int row_count = gtk_tree_model_iter_n_children (data->sort, NULL);
          if (gtk_tree_model_iter_nth_child (data->sort, &iter, NULL, row_count-1))
            {
              GtkTreePath * last_row = gtk_tree_model_get_path (data->sort, &iter);
              pinned_to_new = !gtk_tree_path_compare (last_visible, last_row);
              gtk_tree_path_free (last_row);
            }
          gtk_tree_path_free (last_visible);
        }
    }

  return pinned_to_new;
}
Ejemplo n.º 2
0
static void changed(GtkTreeSelection *treeselection, gpointer user_data) {
  GtkWidget *list = static_cast<GtkWidget *>(user_data);
  list_priv_t *priv = static_cast<list_priv_t *>(g_object_get_data(G_OBJECT(list), "priv"));

  GtkTreeModel *model;
  GtkTreeIter iter;
  bool selected = list_get_selected(list, &model, &iter);

  /* scroll to selected entry if exactly one is selected */
  if(selected) {
    /* check if the entry isn't already visible */
    GtkTreePath *start = nullptr, *end = nullptr;
    tree_path_guard path(gtk_tree_model_get_path(model, &iter));

    gtk_tree_view_get_visible_range(priv->view, &start, &end);
    tree_path_guard sguard(start), eguard(end);

    /* check if path is before start of visible area or behin end of it */
    if((sguard && (gtk_tree_path_compare(path.get(), sguard.get())) < 0) ||
       (eguard && (gtk_tree_path_compare(path.get(), eguard.get()) > 0)))
      gtk_tree_view_scroll_to_cell(priv->view, path.get(), nullptr, TRUE, 0.5, 0.5);
  }

  /* the change event handler is overridden */
  priv->change(treeselection, priv->callback_context);
}
Ejemplo n.º 3
0
static gboolean
fm_list_view_get_visible_range (FMDirectoryView *view, 
                                GtkTreePath     **start_path,
                                GtkTreePath     **end_path)

{
    g_return_if_fail (FM_IS_LIST_VIEW (view));
    return gtk_tree_view_get_visible_range (FM_LIST_VIEW (view)->tree,
                                            start_path, end_path);
}
Ejemplo n.º 4
0
static VALUE
rg_visible_range(VALUE self)
{
    GtkTreePath* start_path;
    GtkTreePath* end_path;

    gboolean valid_paths = gtk_tree_view_get_visible_range(_SELF(self), &start_path, &end_path);

    return valid_paths ? rb_assoc_new(GTKTREEPATH2RVAL(start_path),
                                      GTKTREEPATH2RVAL(end_path)) : Qnil;
}
Ejemplo n.º 5
0
int wxListBox::GetTopItem() const
{
    int idx = wxNOT_FOUND;

#if GTK_CHECK_VERSION(2,8,0)
    wxGtkTreePath start;
    if (
        wx_is_at_least_gtk2(8) &&
        gtk_tree_view_get_visible_range(m_treeview, start.ByRef(), NULL))
    {
        gint *ptr = gtk_tree_path_get_indices(start);

        if ( ptr )
            idx = *ptr;
    }
#endif

    return idx;
}
Ejemplo n.º 6
0
int wxListBox::GetTopItem() const
{
    int idx = wxNOT_FOUND;

#if GTK_CHECK_VERSION(2,8,0)
    wxGtkTreePath start;
    if (
#ifndef __WXGTK3__
        gtk_check_version(2,8,0) == NULL &&
#endif
        gtk_tree_view_get_visible_range(m_treeview, start.ByRef(), NULL))
    {
        gint *ptr = gtk_tree_path_get_indices(start);

        if ( ptr )
            idx = *ptr;
    }
#endif

    return idx;
}
Ejemplo n.º 7
0
/**
 * move down the selection
 * this doesn't change the selection in the account, only on the model,
 * so need to update the account
 *
 * \param into_children		if TRUE and the current selection has children and is opened,
 * 				the selection goes on the first child of that transaction
 * 				else it goes directly on the next mother
 *
 * \return TRUE : done, FALSE : no change
 * */
gboolean transaction_list_select_down ( gboolean into_children )
{
    CustomRecord *record;
    GtkTreePath *end_path_list;
    GtkTreePath *path;
    CustomList *custom_list;

    custom_list = transaction_model_get_model ();

    g_return_val_if_fail ( custom_list != NULL, FALSE );

    /* the only way to forbid the move is if we are on the white line */
    record = custom_list -> selected_row;
    if (!record)
	/* there is no selection, should not happen
	 * to avoid to block grisbi, set on the white line */
	return transaction_list_select (-1);

    /* the way is different between the selected transaction is a child or a mother */
    if (record -> mother_row)
    {
	/* we are on a child, go to the next child or to the next mother */
	if (record -> pos == (record -> mother_row -> number_of_children - 1))
	    /* go to the next mother */
	    record = custom_list -> visibles_rows[record -> mother_row -> filtered_pos + 1];
	else
	    /* go to the next child */
	    record = record -> mother_row -> children_rows[record -> pos + 1];
    }
    else
    {
	/* we are on a mother, go into the first child or the next mother */

	/* if we are on the white line, go away */
	if (gsb_data_transaction_get_transaction_number (record -> transaction_pointer) == -1)
	    return FALSE;

	/* if we are on a split, and it is opened, and into_children i set, go
	 * to the first child */
	if (record -> number_of_children && into_children)
	{
	    path = gtk_tree_path_new ();
	    /* set the path on the mother row which have the expander */
	    gtk_tree_path_append_index (path, record -> children_rows[0] -> mother_row -> filtered_pos);
	}
	else
	    path = NULL;

	if (path
	    &&
	    gtk_tree_view_row_expanded (GTK_TREE_VIEW (gsb_transactions_list_get_tree_view ()), path))
	{
	    /* go to the first child */
	    record = record -> children_rows[0];
	    gtk_tree_path_free (path);
	}
	else
	    /* go to the next transaction mother */
	    record = custom_list -> visibles_rows[record -> filtered_pos + custom_list -> nb_rows_by_transaction];
    }

    /* now can remove the selection and select the new one */
    transaction_list_select_unselect ();
    transaction_list_select_record (record);

    /* move the tree view to the selection, we need to check the visible range and
     * all that stuff because gtk_tree_view_scroll_to_cell set the rows at the upper of the tree view
     * instead of keeping them at the bottom, when transaction goes down beside the bottom of the tree view */
    if ( gtk_tree_view_get_visible_range ( GTK_TREE_VIEW (gsb_transactions_list_get_tree_view ()),
					   NULL,
					   &end_path_list ))
    {
	path = gtk_tree_path_new ();

	if (record -> mother_row)
	{
	    gtk_tree_path_append_index (path, record -> mother_row -> filtered_pos);
	    gtk_tree_path_append_index (path, record -> filtered_pos);
	}
	else
	    /* check with the last visible line of the transaction */
	    gtk_tree_path_append_index (path, record -> transaction_records[custom_list -> nb_rows_by_transaction - 1] -> filtered_pos);

	if (gtk_tree_path_compare (end_path_list, path) == -1)
	    /* the last line of the transaction is above the last visible row */
	    gtk_tree_view_scroll_to_cell ( GTK_TREE_VIEW (gsb_transactions_list_get_tree_view ()),
					   path, NULL,
					   TRUE, 1.0, 0.0 );

	gtk_tree_path_free (path);
	gtk_tree_path_free (end_path_list);
    }
    return TRUE;
}
static gboolean
maybe_expand_container (RBGriloSource *source)
{
	GtkTreePath *path;
	GtkTreePath *end;
	GtkTreeIter iter;
	GtkTreeIter end_iter;
	GtkTreeIter next;
	GrlMedia *container;
	gboolean last;

	source->priv->maybe_expand_idle = 0;

	if (source->priv->browse_op != 0) {
		rb_debug ("not expanding, already browsing");
		return FALSE;
	}

	/* if we find a visible marker row, find more results */
	if (gtk_tree_view_get_visible_range (GTK_TREE_VIEW (source->priv->browser_view), &path, &end) == FALSE) {
		rb_debug ("not expanding, nothing to expand");
		return FALSE;
	}

	gtk_tree_model_get_iter (GTK_TREE_MODEL (source->priv->browser_model), &iter, path);
	gtk_tree_model_get_iter (GTK_TREE_MODEL (source->priv->browser_model), &end_iter, end);

	do {
		gtk_tree_path_free (path);
		path = gtk_tree_model_get_path (GTK_TREE_MODEL (source->priv->browser_model), &iter);
		last = (gtk_tree_path_compare (path, end) >= 0);
		gtk_tree_model_get (GTK_TREE_MODEL (source->priv->browser_model), &iter,
				    0, &container,
				    -1);
		if (container == NULL) {
			if (expand_from_marker (source, &iter)) {
				rb_debug ("expanding");
				break;
			}
		}

		next = iter;
		if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (source->priv->browser_view), path) &&
		    gtk_tree_model_iter_has_child (GTK_TREE_MODEL (source->priv->browser_model), &iter)) {
			gtk_tree_model_iter_children (GTK_TREE_MODEL (source->priv->browser_model), &iter, &next);
		} else if (gtk_tree_model_iter_next (GTK_TREE_MODEL (source->priv->browser_model), &next)) {
			iter = next;
		} else {
			if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (source->priv->browser_model), &next, &iter) == FALSE) {
				break;
			}
			iter = next;
			if (gtk_tree_model_iter_next (GTK_TREE_MODEL (source->priv->browser_model), &iter) == FALSE) {
				break;
			}
		}
	} while (last == FALSE);

	gtk_tree_path_free (path);
	gtk_tree_path_free (end);
	return FALSE;
}