Esempio n. 1
0
static gboolean
custom_list_get_iter (GtkTreeModel * tree_model,
							 GtkTreeIter * iter, GtkTreePath * path)
{
	CustomList *custom_list = CUSTOM_LIST (tree_model);
	chanlistrow *record;
	gint n;

	n = gtk_tree_path_get_indices (path)[0];
	if (n >= custom_list->num_rows || n < 0)
		return FALSE;

	record = custom_list->rows[n];

	/* We simply store a pointer to our custom record in the iter */
	iter->user_data = record;

	return TRUE;
}
Esempio n. 2
0
static gboolean
custom_list_iter_children (GtkTreeModel * tree_model,
									GtkTreeIter * iter, GtkTreeIter * parent)
{
	CustomList *custom_list = CUSTOM_LIST (tree_model);

	/* this is a list, nodes have no children */
	if (parent)
		return FALSE;

	/* parent == NULL is a special case; we need to return the first top-level row */
	/* No rows => no first row */
	if (custom_list->num_rows == 0)
		return FALSE;

	/* Set iter to first item in list */
	iter->user_data = custom_list->rows[0];

	return TRUE;
}
static GtkTreePath *
custom_list_get_path (GtkTreeModel *tree_model,
                      GtkTreeIter  *iter)
{
  GtkTreePath  *path;
  CustomRecord *record;
  CustomList   *custom_list;
 
  g_return_val_if_fail (CUSTOM_IS_LIST(tree_model), NULL);
  g_return_val_if_fail (iter != NULL,               NULL);
  g_return_val_if_fail (iter->user_data != NULL,    NULL);
 
  custom_list = CUSTOM_LIST(tree_model);
 
  record = (CustomRecord*) iter->user_data;
 
  path = gtk_tree_path_new();
  gtk_tree_path_append_index(path, record->pos);
 
  return path;
}
Esempio n. 4
0
static gboolean
custom_list_iter_next (GtkTreeModel * tree_model, GtkTreeIter * iter)
{
	chanlistrow *record, *nextrecord;
	CustomList *custom_list = CUSTOM_LIST (tree_model);

	record = (chanlistrow *) iter->user_data;

	/* Is this the last record in the list? */
	if ((record->pos + 1) >= custom_list->num_rows)
		return FALSE;

	nextrecord = custom_list->rows[(record->pos + 1)];

	g_assert (nextrecord != NULL);
	g_assert (nextrecord->pos == (record->pos + 1));

	iter->user_data = nextrecord;

	return TRUE;
}
Esempio n. 5
0
static void
custom_list_sortable_set_sort_column_id (GtkTreeSortable * sortable,
													  gint sort_col_id, GtkSortType order)
{
	CustomList *custom_list = CUSTOM_LIST (sortable);

	if (custom_list->sort_id == sort_col_id
		 && custom_list->sort_order == order)
		return;

	custom_list->sort_id = sort_col_id;
	custom_list->sort_order = order;

	custom_list_resort (custom_list);

	/* emit "sort-column-changed" signal to tell any tree views
	 *  that the sort column has changed (so the little arrow
	 *  in the column header of the sort column is drawn
	 *  in the right column)                                     */

	gtk_tree_sortable_sort_column_changed (sortable);
}
static gboolean
custom_list_get_iter (GtkTreeModel *tree_model,
                      GtkTreeIter  *iter,
                      GtkTreePath  *path)
{
  CustomList    *custom_list;
  CustomRecord  *record;
  gint          *indices, n, depth;
 
  g_assert(CUSTOM_IS_LIST(tree_model));
  g_assert(path!=NULL);
 
  custom_list = CUSTOM_LIST(tree_model);
 
  indices = gtk_tree_path_get_indices(path);
  depth   = gtk_tree_path_get_depth(path);
 
  /* we do not allow children */
  g_assert(depth == 1); /* depth 1 = top level; a list only has top level nodes and no children */
 
  n = indices[0]; /* the n-th top level row */
 
  if ( n >= custom_list->num_rows || n < 0 )
    return FALSE;
 
  record = custom_list->rows[n];
 
  g_assert(record != NULL);
  g_assert(record->pos == n);
 
  /* We simply store a pointer to our custom record in the iter */
  iter->stamp      = custom_list->stamp;
  iter->user_data  = record;
  iter->user_data2 = NULL;   /* unused */
  iter->user_data3 = NULL;   /* unused */
 
  return TRUE;
}
Esempio n. 7
0
static GType
custom_list_get_column_type (GtkTreeModel * tree_model, gint index)
{
	return CUSTOM_LIST (tree_model)->column_types[index];
}
Esempio n. 8
0
/**
 * Places a data row into the gui GtkTreeView, if and only if the row matches
 * the user and regex/search requirements.
 */
static void
chanlist_place_row_in_gui (server *serv, chanlistrow *next_row, gboolean force)
{
	GtkTreeModel *model;

	/* First, update the 'found' counter values */
	serv->gui->chanlist_users_found_count += next_row->users;
	serv->gui->chanlist_channels_found_count++;

	if (serv->gui->chanlist_channels_shown_count == 1)
		/* join & save buttons become live */
		chanlist_update_buttons (serv);

	if (next_row->users < serv->gui->chanlist_minusers)
	{
		serv->gui->chanlist_caption_is_stale = TRUE;
		return;
	}

	if (next_row->users > serv->gui->chanlist_maxusers
		 && serv->gui->chanlist_maxusers > 0)
	{
		serv->gui->chanlist_caption_is_stale = TRUE;
		return;
	}

	if (GTK_ENTRY (serv->gui->chanlist_wild)->text[0])
	{
		/* Check what the user wants to match. If both buttons or _neither_
		 * button is checked, look for match in both by default. 
		 */
		if (serv->gui->chanlist_match_wants_channel ==
			 serv->gui->chanlist_match_wants_topic)
		{
			if (!chanlist_match (serv, GET_CHAN (next_row))
				 && !chanlist_match (serv, next_row->topic))
			{
				serv->gui->chanlist_caption_is_stale = TRUE;
				return;
			}
		}

		else if (serv->gui->chanlist_match_wants_channel)
		{
			if (!chanlist_match (serv, GET_CHAN (next_row)))
			{
				serv->gui->chanlist_caption_is_stale = TRUE;
				return;
			}
		}

		else if (serv->gui->chanlist_match_wants_topic)
		{
			if (!chanlist_match (serv, next_row->topic))
			{
				serv->gui->chanlist_caption_is_stale = TRUE;
				return;
			}
		}
	}

	if (force || serv->gui->chanlist_channels_shown_count < 20)
	{
		model = GET_MODEL (serv);
		/* makes it appear fast :) */
		custom_list_append (CUSTOM_LIST (model), next_row);
		chanlist_update_caption (serv);
	}
	else
		/* add it to GUI at the next update interval */
		serv->gui->chanlist_pending_rows = g_slist_prepend (serv->gui->chanlist_pending_rows, next_row);

	/* Update the 'shown' counter values */
	serv->gui->chanlist_users_shown_count += next_row->users;
	serv->gui->chanlist_channels_shown_count++;
}