Пример #1
0
static void
renderer_editing_canceled_cb (GtkCellRendererText *cell,
			      EphyNodeView *view)
{
	if (view->priv->remove_if_cancelled)
	{
		ephy_node_unref (view->priv->edited_node);
		view->priv->remove_if_cancelled = FALSE;
	}
}
Пример #2
0
/**
 * ephy_node_view_remove:
 * @view: an #EphyNodeView
 *
 * Remove the currently selected nodes from @view.
 **/
void
ephy_node_view_remove (EphyNodeView *view)
{
	EphyNodeViewPrivate *priv = view->priv;
	GList *list, *l;
	EphyNode *node;
	GtkTreeIter iter, iter2, iter3;
	GtkTreePath *path;
	GtkTreeRowReference *row_ref = NULL;
	GtkTreeSelection *selection;

	/* Before removing we try to get a reference to the next node in the view. If that is
	 * not available we try with the previous one, and if that is absent too,
	 * we will not select anything (which equals to select the topic "All")
	 */

	list = ephy_node_view_get_selection (view);
	if (list == NULL) return;

	node = g_list_first (list)->data;
	ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->priv->nodemodel),
					     node, &iter3);
	gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->priv->filtermodel),
							  &iter2, &iter3);
	gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->priv->sortmodel),
							&iter, &iter2);
	iter2 = iter;

	if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->priv->sortmodel), &iter))
	{
		path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->priv->sortmodel), &iter);
		row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->priv->sortmodel), path);
	}
	else
	{
		path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->priv->sortmodel), &iter2);
		if (gtk_tree_path_prev (path))
		{
			row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->priv->sortmodel), path);
		}
	}
	gtk_tree_path_free (path);

	/* Work around bug #346662 */
	priv->changing_selection = TRUE;
	for (l = list; l != NULL; l = l->next)
	{
		ephy_node_unref (l->data);
	}
	priv->changing_selection = FALSE;

	g_list_free (list);

	/* Fake a selection changed signal */
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
	g_signal_emit_by_name (selection, "changed");

	/* Select the "next" node */

	if (row_ref != NULL)
	{
		path = gtk_tree_row_reference_get_path (row_ref);

		if (path != NULL)
		{
			gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
			gtk_tree_path_free (path);
		}	

		gtk_tree_row_reference_free (row_ref);
	}
}
Пример #3
0
static void
ephy_node_db_free_func (EphyNode *node)
{
    if (node)
        ephy_node_unref (node);
}