[Cruft Reduction] Remove unused functions from src/gnome-utils.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21578 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls 2011-11-18 21:03:40 +00:00
parent 921bba1ad2
commit e1ce730560
22 changed files with 12 additions and 1594 deletions

View File

@ -32,37 +32,6 @@
#include "qof.h"
#include "gnc-gnome-utils.h"
void
gnc_assistant_set_watermark_images (GtkAssistant *assistant,
const char *top_path,
const char *side_path)
{
GdkPixbuf *top_pixbuf, *side_pixbuf;
GList *page_list, *item;
GtkWidget *page;
GtkAssistantPageType page_type;
page_list = gtk_container_get_children(GTK_CONTAINER(assistant));
top_pixbuf = gnc_gnome_get_gdkpixbuf(top_path);
side_pixbuf = gnc_gnome_get_gdkpixbuf(side_path);
for (item = page_list; item; item = g_list_next(item))
{
page = item->data;
page_type = gtk_assistant_get_page_type(assistant, page);
gtk_assistant_set_page_header_image (assistant, page, top_pixbuf);
if ( (page_type == GTK_ASSISTANT_PAGE_INTRO) ||
(page_type == GTK_ASSISTANT_PAGE_SUMMARY) ||
(page_type == GTK_ASSISTANT_PAGE_CONFIRM) )
gtk_assistant_set_page_side_image (assistant, page, side_pixbuf);
}
g_object_unref (G_OBJECT(side_pixbuf));
g_object_unref (G_OBJECT(top_pixbuf));
g_list_free(page_list);
}
void
gnc_assistant_set_colors (GtkAssistant *assistant)
{

View File

@ -27,9 +27,6 @@
#include <gtk/gtk.h>
void gnc_assistant_set_watermark_images (GtkAssistant *assistant,
const char *top_path,
const char *side_path);
void gnc_assistant_set_colors (GtkAssistant *assistant);
#endif

View File

@ -189,19 +189,6 @@ gnc_gnome_locate_pixmap (const char *name)
return fullname;
}
char *
gnc_gnome_locate_file (GnomeFileDomain domain, const char *name)
{
char *fullname;
g_return_val_if_fail(name, NULL);
fullname = gnome_program_locate_file(gnucash_program,
domain, name, TRUE, NULL);
if (!fullname)
PERR ("Could not locate file %s", name);
return fullname;
}
char *
gnc_gnome_locate_data_file (const char *name)
{

View File

@ -82,21 +82,6 @@ char *gnc_gnome_locate_data_file (const char *name);
*/
char *gnc_gnome_locate_ui_file (const char *name);
/** Given a file name, find the file in the directories associated
* with the given file domain. This routine will display an error
* message if it can't find the file.
*
* @param domain The GnomeFileDomain, e.g. GNOME_FILE_DOMAIN_APP_HELP
*
* @param name The name of the file to be found.
*
* @return the full path name of the file, or NULL of the file can't
* be found.
*
* @note It is the caller's responsibility to free the returned string.
*/
char *gnc_gnome_locate_file (GnomeFileDomain domain, const char *name);
/** Launch the default gnome help browser and open to a given link
* within a given file. This routine will display an error message
* if it can't find the help file or can't open the help browser.

View File

@ -172,13 +172,6 @@ gnc_tree_model_account_types_is_valid (GtkTreeModel *model,
return (valid_types & (1 << type)) ? TRUE : FALSE;
}
GtkTreeModel *
gnc_tree_model_account_types_valid (void)
{
return gnc_tree_model_account_types_filter_using_mask(
xaccAccountTypesValid());
}
GtkTreeModel *
gnc_tree_model_account_types_filter_using_mask (guint32 types)
{
@ -212,29 +205,6 @@ gnc_tree_model_account_types_get_mask (GtkTreeModel *f_model)
return GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (f_model), TYPE_MASK));
}
guint32
gnc_tree_model_account_types_get_selected (GncTreeModelAccountTypes * model)
{
GncTreeModelAccountTypesPrivate *priv;
g_return_val_if_fail (model != NULL, 0);
priv = GNC_TREE_MODEL_ACCOUNT_TYPES_GET_PRIVATE(model);
return priv->selected;
}
void
gnc_tree_model_account_types_set_selected (GncTreeModelAccountTypes * model,
guint32 selected)
{
GncTreeModelAccountTypesPrivate *priv;
g_return_if_fail (model != NULL);
priv = GNC_TREE_MODEL_ACCOUNT_TYPES_GET_PRIVATE(model);
priv->selected = selected;
}
guint32
gnc_tree_model_account_types_get_selection (GtkTreeSelection *sel)
{

View File

@ -97,11 +97,6 @@ GType gnc_tree_model_account_types_get_type (void);
/*************** Method 1 functions ***************/
/* Returns a GtkTreeModelFilter that wraps the model. Deprecated and root
account types will be filtered. Caller is responsible for
ref/unref. */
GtkTreeModel * gnc_tree_model_account_types_valid (void);
/* Returns a GtkTreeModelFilter that wraps the model. Only account
types specified by the 'types' bitmask are visible. To force the
visibility of deprecated account types, pass
@ -147,12 +142,6 @@ void gnc_tree_model_account_types_set_selection(GtkTreeSelection *sel,
GtkTreeModel *gnc_tree_model_account_types_new(guint32 selected);
guint32 gnc_tree_model_account_types_get_selected(
GncTreeModelAccountTypes * model);
void gnc_tree_model_account_types_set_selected(
GncTreeModelAccountTypes * model, guint32 selected);
G_END_DECLS

View File

@ -1070,41 +1070,6 @@ gnc_tree_model_commodity_get_iter_from_namespace (GncTreeModelCommodity *model,
return TRUE;
}
/*
* Convert a model/namespace pair into a gtk_tree_model_path. This
* routine should only be called from the file
* gnc-tree-view-commodity.c.
*/
GtkTreePath *
gnc_tree_model_commodity_get_path_from_namespace (GncTreeModelCommodity *model,
gnc_commodity_namespace *namespace)
{
GtkTreeIter tree_iter;
GtkTreePath *tree_path;
ENTER("model %p, namespace %p", model, namespace);
g_return_val_if_fail (GNC_IS_TREE_MODEL_COMMODITY (model), NULL);
g_return_val_if_fail (namespace != NULL, NULL);
if (!gnc_tree_model_commodity_get_iter_from_namespace (model, namespace, &tree_iter))
{
LEAVE("no iter");
return NULL;
}
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
if (tree_path)
{
gchar *path_string = gtk_tree_path_to_string(tree_path);
LEAVE("path (2) %s", path_string);
g_free(path_string);
}
else
{
LEAVE("no path");
}
return tree_path;
}
/************************************************************/
/* Commodity Tree Model - Engine Event Handling Functions */

View File

@ -209,19 +209,6 @@ gboolean gnc_tree_model_commodity_get_iter_from_commodity (GncTreeModelCommodity
gnc_commodity *commodity,
GtkTreeIter *iter);
/** Convert a commodity namespace pointer into a GtkTreePath.
*
* @param model A pointer to the commodity tree model.
*
* @param namespace A pointer to the gnucash commodity namespace.
*
* @return A pointer to a GtkTreePath describing the location of this
* namespace. This pointer must be freed by the caller when no
* longer needed. This routine will return NULL if the namespace
* does not exist in the tree. */
GtkTreePath *gnc_tree_model_commodity_get_path_from_namespace (GncTreeModelCommodity *model,
gnc_commodity_namespace *namespace);
/** Convert a commodity pointer into a GtkTreePath.
*
* @param model A pointer to the commodity tree model.

View File

@ -1296,42 +1296,6 @@ gnc_tree_model_price_get_iter_from_commodity (GncTreeModelPrice *model,
return TRUE;
}
/*
* Convert a model/commodity pair into a gtk_tree_model_path. This
* routine should only be called from the file
* gnc-tree-view-price.c.
*/
GtkTreePath *
gnc_tree_model_price_get_path_from_commodity (GncTreeModelPrice *model,
gnc_commodity *commodity)
{
GtkTreeIter tree_iter;
GtkTreePath *tree_path;
ENTER("model %p, commodity %p", model, commodity);
g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
g_return_val_if_fail (commodity != NULL, NULL);
if (!gnc_tree_model_price_get_iter_from_commodity (model, commodity, &tree_iter))
{
LEAVE("no iter");
return NULL;
}
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
if (tree_path)
{
gchar *path_string = gtk_tree_path_to_string(tree_path);
LEAVE("path (2) %s", path_string);
g_free(path_string);
}
else
{
LEAVE("no path");
}
return tree_path;
}
/*
* Convert a model/namespace pair into a gtk_tree_model_iter. This
* routine should only be called from the file
@ -1370,42 +1334,6 @@ gnc_tree_model_price_get_iter_from_namespace (GncTreeModelPrice *model,
return TRUE;
}
/*
* Convert a model/namespace pair into a gtk_tree_model_path. This
* routine should only be called from the file
* gnc-tree-view-price.c.
*/
GtkTreePath *
gnc_tree_model_price_get_path_from_namespace (GncTreeModelPrice *model,
gnc_commodity_namespace *namespace)
{
GtkTreeIter tree_iter;
GtkTreePath *tree_path;
ENTER("model %p, namespace %p", model, namespace);
g_return_val_if_fail (GNC_IS_TREE_MODEL_PRICE (model), NULL);
g_return_val_if_fail (namespace != NULL, NULL);
if (!gnc_tree_model_price_get_iter_from_namespace (model, namespace, &tree_iter))
{
LEAVE("no iter");
return NULL;
}
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
if (tree_path)
{
gchar *path_string = gtk_tree_path_to_string(tree_path);
LEAVE("path (2) %s", path_string);
g_free(path_string);
}
else
{
LEAVE("no path");
}
return tree_path;
}
/************************************************************/
/* Price Tree Model - Engine Event Handling Functions */
/************************************************************/

View File

@ -251,32 +251,6 @@ gboolean gnc_tree_model_price_get_iter_from_price (GncTreeModelPrice *model,
GNCPrice *price,
GtkTreeIter *iter);
/** Convert a commodity namespace pointer into a GtkTreePath.
*
* @param model A pointer to the price tree model.
*
* @param namespace A pointer to the gnucash commodity namespace.
*
* @return A pointer to a GtkTreePath describing the location of this
* namespace. This pointer must be freed by the caller when no
* longer needed. This routine will return NULL if the namespace
* does not exist in the tree. */
GtkTreePath *gnc_tree_model_price_get_path_from_namespace (GncTreeModelPrice *model,
gnc_commodity_namespace *namespace);
/** Convert a commodity pointer into a GtkTreePath.
*
* @param model A pointer to the price tree model.
*
* @param commodity A pointer to the gnucash commodity.
*
* @return A pointer to a GtkTreePath describing the location of this
* commodity. This pointer must be freed by the caller when no
* longer needed. This routine will return NULL if the commodity
* does not exist in the tree. */
GtkTreePath *gnc_tree_model_price_get_path_from_commodity (GncTreeModelPrice *model,
gnc_commodity *commodity);
/** Convert a price pointer into a GtkTreePath.
*
* @param model A pointer to the price tree model.

View File

@ -209,17 +209,6 @@ gnc_tree_model_selection_new (GtkTreeModel *child_model)
return GTK_TREE_MODEL (model);
}
GtkTreeModel *
gnc_tree_model_selection_get_model (GncTreeModelSelection *model)
{
GncTreeModelSelectionPrivate *priv;
g_return_val_if_fail (GNC_IS_TREE_MODEL_SELECTION (model), NULL);
priv = GNC_TREE_MODEL_SELECTION_GET_PRIVATE(model);
return priv->child_model;
}
void
gnc_tree_model_selection_convert_child_iter_to_iter (GncTreeModelSelection *model,
GtkTreeIter *selection_iter,
@ -251,53 +240,6 @@ gnc_tree_model_selection_convert_iter_to_child_iter (GncTreeModelSelection *mode
child_iter->user_data3 = ((GtkTreeIter *) selection_iter->user_data)->user_data3;
}
gint
gnc_tree_model_selection_get_selection_column (GncTreeModelSelection *model)
{
GncTreeModelSelectionPrivate *priv;
g_return_val_if_fail (GNC_IS_TREE_MODEL_SELECTION (model), 0);
priv = GNC_TREE_MODEL_SELECTION_GET_PRIVATE(model);
return gtk_tree_model_get_n_columns (priv->child_model);
}
GtkTreeViewColumn *
gnc_tree_model_selection_create_tree_view_column (GncTreeModelSelection *model,
const gchar *title)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
renderer = gtk_cell_renderer_toggle_new ();
g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
g_signal_connect (G_OBJECT (renderer), "toggled",
G_CALLBACK (gnc_tree_model_selection_toggled), model);
column = gtk_tree_view_column_new_with_attributes (title,
renderer,
"active",
gnc_tree_model_selection_get_selection_row (model),
NULL);
return column;
}
gboolean
gnc_tree_model_selection_is_selected (GncTreeModelSelection *model,
GtkTreeIter *iter)
{
GncTreeModelSelectionPrivate *priv;
gchar *path;
gboolean selected;
priv = GNC_TREE_MODEL_SELECTION_GET_PRIVATE(model);
path = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL (model), iter);
selected = g_hash_table_lookup (priv->selections, path) != NULL;
g_free (path);
return selected;
}
void
gnc_tree_model_selection_set_selected (GncTreeModelSelection *model,

View File

@ -66,7 +66,6 @@ GType gnc_tree_model_selection_get_type (void);
GtkTreeModel *gnc_tree_model_selection_new (GtkTreeModel *child_model);
GtkTreeModel *gnc_tree_model_selection_get_model (GncTreeModelSelection *model);
void gnc_tree_model_selection_convert_child_iter_to_iter (GncTreeModelSelection *model,
GtkTreeIter *selection_iter,
GtkTreeIter *child_iter);
@ -74,12 +73,6 @@ void gnc_tree_model_selection_convert_iter_to_child_iter (GncTreeM
GtkTreeIter *child_iter,
GtkTreeIter *selection_iter);
gint gnc_tree_model_selection_get_selection_column (GncTreeModelSelection *model);
GtkTreeViewColumn *gnc_tree_model_selection_create_tree_view_column (GncTreeModelSelection *model,
const gchar *title);
gboolean gnc_tree_model_selection_is_selected (GncTreeModelSelection *model,
GtkTreeIter *iter);
void gnc_tree_model_selection_set_selected (GncTreeModelSelection *model,
GtkTreeIter *iter,
gboolean selected);

View File

@ -1026,20 +1026,6 @@ gnc_tree_view_account_refilter (GncTreeViewAccount *view)
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
}
gboolean
gnc_tree_view_account_filter_by_type_selection(Account* acct, gpointer data)
{
GNCAccountType acct_type;
guint sel_bits = GPOINTER_TO_UINT(data);
g_return_val_if_fail(GNC_IS_ACCOUNT(acct), FALSE);
acct_type = xaccAccountGetType(acct);
/* Because of some silly '== TRUE' comparisons in treemodelfilter,
we have to return exactly TRUE */
return (sel_bits & (1 << acct_type)) ? TRUE : FALSE;
}
gboolean
gnc_tree_view_account_filter_by_view_info(Account* acct, gpointer data)
{
@ -1772,7 +1758,8 @@ gnc_plugin_page_account_tree_filter_accounts (Account *account,
*
* @param button The GtkCheckButton that was toggled.
*
* @param fd A pointer to the account filter dialog struct. */
* @param fd A pointer to the account filter dialog struct.
*/
void
gppat_filter_show_hidden_toggled_cb (GtkToggleButton *button,
AccountFilterDialog *fd)
@ -1790,7 +1777,8 @@ gppat_filter_show_hidden_toggled_cb (GtkToggleButton *button,
*
* @param button The GtkCheckButton that was toggled.
*
* @param fd A pointer to the account filter dialog struct. */
* @param fd A pointer to the account filter dialog struct.
*/
void
gppat_filter_show_zero_toggled_cb (GtkToggleButton *button,
AccountFilterDialog *fd)
@ -1809,7 +1797,8 @@ gppat_filter_show_zero_toggled_cb (GtkToggleButton *button,
*
* @param button The button that was clicked.
*
* @param fd A pointer to the account filter dialog struct. */
* @param fd A pointer to the account filter dialog struct.
*/
void
gppat_filter_clear_all_cb (GtkWidget *button,
AccountFilterDialog *fd)
@ -1848,7 +1837,8 @@ gppat_filter_select_all_cb (GtkWidget *button,
*
* @param button The button that was clicked.
*
* @param fd A pointer to the account filter dialog struct. */
* @param fd A pointer to the account filter dialog struct.
*
void
gppat_filter_select_default_cb (GtkWidget *button,
AccountFilterDialog *fd)
@ -1857,7 +1847,7 @@ gppat_filter_select_default_cb (GtkWidget *button,
gppat_filter_select_all_cb(button, fd);
LEAVE(" ");
}
*/
/** Set the renderer's properties.
*
* @param column A GtkTreeColumn
@ -1922,7 +1912,8 @@ gppat_filter_visible_toggled_cb (GtkCellRendererToggle *renderer,
*
* @param response The response code from closing the dialog.
*
* @param fd A pointer to the account filter dialog struct. */
* @param fd A pointer to the account filter dialog struct.
*/
void
gppat_filter_response_cb (GtkWidget *dialog,
gint response,

View File

@ -287,26 +287,6 @@ void gnc_tree_view_account_set_filter (GncTreeViewAccount *account_view,
gpointer data,
GtkFunction destroy);
/* This is a convenient filter function for use with
* gnc_tree_view_account_set_filter() and the functions in
* gnc-tree-model-account-types.h. If you have some view that is
* backed by the "account types" tree model, you can get a guint32
* from that view's tree selection. Then, you can use that account
* type selection as a filter for the account tree view. For
* example:
*
* guint sel_mask;
*
* sel_mask = gnc_tree_model_account_types_get_selection(view);
*
* gnc_tree_view_account_set_filter(account_view,
* gnc_tree_view_account_filter_by_type_selection,
* GUINT_TO_POINTER(sel_mask), NULL);
*
*/
gboolean gnc_tree_view_account_filter_by_type_selection(
Account* acct, gpointer data);
/* This is a convenient filter function for use with
* gnc_tree_view_account_set_filter() and the functions in
* gnc-tree-model-account-types.h. If you have some view that is

View File

@ -487,50 +487,6 @@ gnc_tree_view_commodity_new (QofBook *book,
g_free(path_string); \
}
#if 0
static GtkTreePath *
gnc_tree_view_commodity_get_path_from_commodity (GncTreeViewCommodity *view,
gnc_commodity *commodity)
{
GtkTreeModel *model, *f_model, *s_model;
GtkTreePath *path, *f_path, *s_path;
ENTER("view %p, commodity %p (%s)", view, commodity, gnc_commodity_get_name(commodity));
if (commodity == NULL)
{
LEAVE("no commodity");
return NULL;
}
/* Reach down to the real model and get a path for this commodity */
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
path = gnc_tree_model_commodity_get_path_from_commodity (GNC_TREE_MODEL_COMMODITY(model), commodity);
if (path == NULL)
{
LEAVE("no path");
return NULL;
}
/* convert back to a filtered path */
f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model), path);
gtk_tree_path_free(path);
if (!f_path)
{
LEAVE("no filter path");
return NULL;
}
/* convert back to a sorted path */
s_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model), f_path);
gtk_tree_path_free(f_path);
debug_path(LEAVE, s_path);
return s_path;
}
#endif
static gboolean
gnc_tree_view_commodity_get_iter_from_commodity (GncTreeViewCommodity *view,
gnc_commodity *commodity,
@ -564,98 +520,6 @@ gnc_tree_view_commodity_get_iter_from_commodity (GncTreeViewCommodity *view,
return TRUE;
}
gint
gnc_tree_view_commodity_count_children (GncTreeViewCommodity *view,
gnc_commodity *commodity)
{
GtkTreeModel *s_model;
GtkTreeIter s_iter;
gint num_children;
ENTER("view %p, commodity %p (%s)", view, commodity, gnc_commodity_get_mnemonic(commodity));
if (commodity == NULL)
{
LEAVE("no commodity");
return 0;
}
if (!gnc_tree_view_commodity_get_iter_from_commodity (view, commodity, &s_iter))
{
LEAVE("view_get_iter_from_commodity failed");
return 0;
}
/* Any children? */
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
num_children = gtk_tree_model_iter_n_children(s_model, &s_iter);
LEAVE("%d children", num_children);
return num_children;
}
gnc_commodity *
gnc_tree_view_commodity_get_commodity_from_column (GtkTreeViewColumn *column,
GtkTreeModel *s_model,
GtkTreeIter *s_iter)
{
GtkTreeModel *model, *f_model;
GtkTreeIter iter, f_iter;
gnc_commodity *commodity;
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN(column), NULL);
g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
g_return_val_if_fail (s_iter != NULL, NULL);
ENTER("column %p, model %p, iter %p", column, s_model, s_iter);
gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
&f_iter,
s_iter);
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
&iter,
&f_iter);
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
commodity = gnc_tree_model_commodity_get_commodity (GNC_TREE_MODEL_COMMODITY(model), &iter);
LEAVE("commodity %p (%s)", commodity, gnc_commodity_get_mnemonic (commodity));
return commodity;
}
/************************************************************/
/* Commodity Tree View Filter Functions */
/************************************************************/
/*
* Set the list of columns that will be visible in an commodity tree view.
*/
void
gnc_tree_view_commodity_configure_columns (GncTreeViewCommodity *view,
GSList *column_names)
{
GtkTreeViewColumn *column;
GSList *node;
int i;
ENTER(" ");
for (i = 1; i < GNC_TREE_MODEL_COMMODITY_NUM_COLUMNS; i++)
{
column = gtk_tree_view_get_column (GTK_TREE_VIEW(view), i);
gtk_tree_view_column_set_visible (column, FALSE);
}
for (node = column_names; node != NULL; node = node->next)
{
for (i = 0; i < GNC_TREE_MODEL_COMMODITY_NUM_COLUMNS; i++)
{
column = gtk_tree_view_get_column (GTK_TREE_VIEW(view), i);
gtk_tree_view_column_set_visible (column, TRUE);
}
}
LEAVE(" ");
}
/************************************************************/
/* Commodity Tree View Visibility Filter */
/************************************************************/
@ -775,54 +639,6 @@ gnc_tree_view_commodity_refilter (GncTreeViewCommodity *view)
/* Commodity Tree View Get/Set Functions */
/************************************************************/
/*
* Retrieve the selected commodity from an commodity tree view. The
* commodity tree must be in single selection mode.
*/
gnc_commodity *
gnc_tree_view_commodity_get_commodity_from_path (GncTreeViewCommodity *view,
GtkTreePath *s_path)
{
GtkTreeModel *model, *f_model, *s_model;
GtkTreePath *path, *f_path;
GtkTreeIter iter;
gnc_commodity *commodity;
g_return_val_if_fail (GNC_IS_TREE_VIEW_COMMODITY (view), NULL);
g_return_val_if_fail (s_path != NULL, NULL);
ENTER("view %p", view);
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
f_path = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (s_model), s_path);
if (!f_path)
{
LEAVE("no filter path");
return NULL;
}
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
path = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (f_model), f_path);
gtk_tree_path_free(f_path);
if (!path)
{
LEAVE("no path");
return NULL;
}
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
if (!gtk_tree_model_get_iter (model, &iter, path))
{
LEAVE("no iter");
return NULL;
}
commodity = gnc_tree_model_commodity_get_commodity (GNC_TREE_MODEL_COMMODITY(model),
&iter);
gtk_tree_path_free(path);
LEAVE("commodity %p (%s)", commodity, gnc_commodity_get_mnemonic (commodity));
return commodity;
}
/*
* Retrieve the selected commodity from an commodity tree view. The
* commodity tree must be in single selection mode.
@ -861,78 +677,6 @@ gnc_tree_view_commodity_get_selected_commodity (GncTreeViewCommodity *view)
return commodity;
}
/*
* Selects a single commodity in the commodity tree view. The commodity
* tree must be in single selection mode.
*/
void
gnc_tree_view_commodity_set_selected_commodity (GncTreeViewCommodity *view,
gnc_commodity *commodity)
{
GtkTreeModel *model, *f_model, *s_model;
GtkTreePath *path, *f_path, *s_path, *parent_path;
GtkTreeSelection *selection;
ENTER("view %p, commodity %p (%s)", view,
commodity, gnc_commodity_get_mnemonic (commodity));
/* Clear any existing selection. */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
gtk_tree_selection_unselect_all (selection);
if (commodity == NULL)
{
LEAVE("");
return;
}
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (f_model));
path = gnc_tree_model_commodity_get_path_from_commodity (GNC_TREE_MODEL_COMMODITY(model), commodity);
if (path == NULL)
{
LEAVE("get_path_from_commodity failed");
return;
}
debug_path(DEBUG, path);
f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
path);
gtk_tree_path_free(path);
if (f_path == NULL)
{
LEAVE("no filter path");
return;
}
debug_path(DEBUG, f_path);
s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
f_path);
gtk_tree_path_free(f_path);
if (s_path == NULL)
{
LEAVE("no sort path");
return;
}
/* gtk_tree_view requires that a row be visible before it can be selected */
parent_path = gtk_tree_path_copy (s_path);
if (gtk_tree_path_up (parent_path))
{
/* This function is misnamed. It expands the actual item
* specified, not the path to the item specified. I.E. It expands
* one level too many, thus the get of the parent. */
gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
}
gtk_tree_path_free(parent_path);
gtk_tree_selection_select_path (selection, s_path);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
debug_path(LEAVE, s_path);
gtk_tree_path_free(s_path);
}
/*
* This helper function is called once for each row in the tree view
@ -962,121 +706,3 @@ get_selected_commodities_helper (GtkTreeModel *s_model,
&iter);
*return_list = g_list_append(*return_list, commodity);
}
/*
* Given an commodity tree view, return a list of the selected commodities. The
* commodity tree must be in multiple selection mode.
*
* Note: It is the responsibility of the caller to free the returned
* list.
*/
GList *
gnc_tree_view_commodity_get_selected_commodities (GncTreeViewCommodity *view)
{
GtkTreeSelection *selection;
GList *return_list = NULL;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
gtk_tree_selection_selected_foreach(selection, get_selected_commodities_helper, &return_list);
return return_list;
}
/*
* Given an commodity tree view and a list of commodities, select those
* commodities in the tree view.
*/
void
gnc_tree_view_commodity_set_selected_commodities (GncTreeViewCommodity *view,
GList *commodity_list,
gboolean show_last)
{
GtkTreeModel *model, *f_model, *s_model;
GtkTreePath *path, *f_path, *s_path, *parent_path;
GtkTreeSelection *selection;
GList *element;
gnc_commodity *commodity;
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
/* Clear any existing selection. */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
gtk_tree_selection_unselect_all (selection);
gtk_tree_view_collapse_all (GTK_TREE_VIEW(view));
/* Now go select what the user requested. */
for (element = commodity_list; element; )
{
commodity = element->data;
element = g_list_next(element);
path = gnc_tree_model_commodity_get_path_from_commodity (GNC_TREE_MODEL_COMMODITY(model), commodity);
if (path == NULL)
{
/*
* Oops. Someone must have deleted this commodity and not cleaned
* up all references to it.
*/
continue;
}
f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
path);
gtk_tree_path_free(path);
if (f_path == NULL)
continue;
s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
f_path);
gtk_tree_path_free(f_path);
if (s_path == NULL)
continue;
/* gtk_tree_view requires that a row be visible before it can be selected */
parent_path = gtk_tree_path_copy (s_path);
if (gtk_tree_path_up (parent_path))
{
/* This function is misnamed. It expands the actual item
* specified, not the path to the item specified. I.E. It
* expands one level too many, thus the get of the parent. */
gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
}
gtk_tree_path_free(parent_path);
gtk_tree_selection_select_path (selection, s_path);
if (show_last && (element == NULL))
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
gtk_tree_path_free(s_path);
}
}
#ifdef NEEDED
/*
* Retrieve the commodity currently under the cursor.
*/
gnc_commodity *
gnc_tree_view_commodity_get_cursor_account (GncTreeViewCommodity *view)
{
GtkTreeModel *s_model;
GtkTreePath *s_path;
gnc_commodity *commodity;
g_return_val_if_fail (GNC_IS_TREE_VIEW_COMMODITY (view), NULL);
ENTER("view %p", view);
s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
if (s_path)
{
account = gnc_tree_view_commodity_get_account_from_path (view, s_path);
gtk_tree_path_free(s_path);
}
else
{
account = NULL;
}
LEAVE("account %p (%s)", account, gnc_commodity_get_mnemonic (account));
return account;
}
#endif

View File

@ -179,53 +179,6 @@ void gnc_tree_view_commodity_refilter (GncTreeViewCommodity *view);
/** @name Commodity Tree View Get/Set Functions
@{ */
/** This function determines if an commodity in the commodity tree view
* has any visible children.
*
* @param view A pointer to an commodity tree view.
*
* @param commodity A pointer to the commodity to check.
*
* @return The number of children of the specified commodity. Returns 0
* on error.
*/
gint gnc_tree_view_commodity_count_children (GncTreeViewCommodity *view,
gnc_commodity *commodity);
/** This function retrieves a pointer to a commodity based upon the
* model and iter passed into it. It should only be used by callback
* functions that have had the model/iter passed to them.
*
* @param column A pointer to a tree view column from a commodity view.
*
* @param f_model A pointer to the filter model for the view.
*
* @param f_iter A pointer to the iter for a particular row in the view.
*
* @return The commodity associated with the spcified row in the view.
*/
gnc_commodity * gnc_tree_view_commodity_get_commodity_from_column (GtkTreeViewColumn *column,
GtkTreeModel *f_model,
GtkTreeIter *f_iter);
/** This function returns the commodity associated with the specified
* path. This function is useful in selection callbacks on an
* commodity tree widget.
*
* @param view A pointer to an commodity tree view.
*
* @param path A path specifying a node in the commodity tree.
*
* @return The commodity associated with this path.
*/
gnc_commodity * gnc_tree_view_commodity_get_commodity_from_path (GncTreeViewCommodity *view,
GtkTreePath *path);
/** This function returns the commodity in the commodity tree view at the
* current location of the cursor. (The outline frame. Usually is
* selected and therefore filled in, but not always.)
@ -248,67 +201,7 @@ gnc_commodity * gnc_tree_view_commodity_get_cursor_commodity (GncTreeViewCommodi
*
* @return The selected commodity, or NULL if no commodity was selected.
*/
gnc_commodity * gnc_tree_view_commodity_get_selected_commodity (GncTreeViewCommodity *view);
/** This function selects an commodity in the commodity tree view. All
* other commodities will be unselected. In addition, this function
* collapses the entitre tree and then expands only the path to the
* selected commodity, making the item easy to find. In general, this
* routine only need be called when initially putting up a window
* containing an commodity tree view widget.
*
* @note It only makes sense to call this function when the commodity
* tree is set to select a single item. There is a different
* function to use when the tree supports multiple selections.
*
* @param view A pointer to an commodity tree view.
*
* @param commodity A pointer to the commodity to select.
*/
void gnc_tree_view_commodity_set_selected_commodity (GncTreeViewCommodity *view,
gnc_commodity *commodity);
/** This function returns a list of the commodities associated with the
* selected items in the commodity tree view.
*
* @note It only makes sense to call this function when the commodity
* tree is set to select multiple items. There is a different
* function to use when the tree supports single selection.
*
* @param view A pointer to an commodity tree view.
*
* @return A list of commodities, or NULL if no commodity was selected.
*/
GList * gnc_tree_view_commodity_get_selected_commodities (GncTreeViewCommodity *view);
/** This function selects a set of commodities in the commodity tree view.
* All other commodities will be unselected. In addition, this function
* collapses the entitre tree and then expands only the path to the
* selected commodities, making them easy to find. In general, this
* routine only need be called when initially putting up a window
* containing an commodity tree view widget.
*
* @note It only makes sense to call this function when the commodity
* tree is set to select a single item. There is a different
* function to use when the tree supports multiple selections.
*
* @note It is the responsibility of the caller to free the returned
* list.
*
* @param view A pointer to an commodity tree view.
*
* @param commodity_list A list of commodities to select.
*
* @param show_last Force the window to scroll to the last commodity
* selected.
*/
void gnc_tree_view_commodity_set_selected_commodities (GncTreeViewCommodity *view,
GList *commodity_list,
gboolean show_last);
gnc_commodity * gnc_tree_view_commodity_get_selected_commodity (GncTreeViewCommodity *view);
/** This function selects all sub-commodities of an commodity in the
* commodity tree view. All other commodities will be unselected.

View File

@ -597,56 +597,6 @@ gnc_tree_view_owner_get_iter_from_owner (GncTreeViewOwner *view,
/* Owner Tree View Filter Functions */
/************************************************************/
/*
* Get a copy of the owner view info structure in use by the
* specified tree.
*/
void
gnc_tree_view_owner_get_view_info (GncTreeViewOwner *owner_view,
OwnerViewInfo *ovi)
{
GncTreeViewOwnerPrivate *priv;
g_return_if_fail(GNC_IS_TREE_VIEW_OWNER(owner_view));
g_return_if_fail(ovi != NULL);
priv = GNC_TREE_VIEW_OWNER_GET_PRIVATE(owner_view);
*ovi = priv->ovi;
}
/*
* Set the owner view info data in use by the specified tree to
* match the callers request.
*
* DRH - COMPATIBILITY WARNING
*
* This function does not do anything with the 'include_type' field.
* Should there be a automatic filter for backward compatibility
* that uses these flags, or should all uses of this be converted to
* a GtkTreeModelFilter?
*
* CAS - For now, I'll try the automatic filter approach by making
* this function use GtkTreeModelFilter.
*/
void
gnc_tree_view_owner_set_view_info (GncTreeViewOwner *owner_view,
OwnerViewInfo *ovi)
{
GncTreeViewOwnerPrivate *priv;
gint i;
guint sel_bits = 0;
ENTER("%p", owner_view);
g_return_if_fail(GNC_IS_TREE_VIEW_OWNER(owner_view));
g_return_if_fail(ovi != NULL);
priv = GNC_TREE_VIEW_OWNER_GET_PRIVATE(owner_view);
priv->ovi = *ovi;
LEAVE(" ");
}
static gboolean
gnc_tree_view_owner_filter_helper (GtkTreeModel *model,
GtkTreeIter *iter,
@ -941,117 +891,6 @@ get_selected_owners_helper (GtkTreeModel *s_model,
}
}
/*
* Given an owner tree view, return a list of the selected owners. The
* owner tree must be in multiple selection mode.
*
* Note: It is the responsibility of the caller to free the returned
* list.
*/
GList *
gnc_tree_view_owner_get_selected_owners (GncTreeViewOwner *view)
{
GtkTreeSelection *selection;
GncTreeViewSelectionInfo info;
g_return_val_if_fail (GNC_IS_TREE_VIEW_OWNER (view), NULL);
info.return_list = NULL;
info.priv = GNC_TREE_VIEW_OWNER_GET_PRIVATE(view);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
gtk_tree_selection_selected_foreach(selection, get_selected_owners_helper, &info);
return info.return_list;
}
/*
* Given an owner tree view and a list of owners, select those
* owners in the tree view.
*/
void
gnc_tree_view_owner_set_selected_owners (GncTreeViewOwner *view,
GList *owner_list,
gboolean show_last)
{
GtkTreeModel *model, *f_model, *s_model;
GtkTreePath *path, *f_path, *s_path, *parent_path;
GtkTreeSelection *selection;
GList *element;
GncOwner *owner;
g_return_if_fail (GNC_IS_TREE_VIEW_OWNER (view));
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
/* Clear any existing selection. */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
gtk_tree_selection_unselect_all (selection);
/* Now go select what the user requested. */
for (element = owner_list; element; )
{
owner = element->data;
element = g_list_next(element);
path = gnc_tree_model_owner_get_path_from_owner (GNC_TREE_MODEL_OWNER(model), owner);
if (path == NULL)
{
/*
* Oops. Someone must have deleted this owner and not cleaned
* up all references to it.
*/
continue;
}
f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
path);
gtk_tree_path_free(path);
if (f_path == NULL)
continue;
s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
f_path);
gtk_tree_path_free(f_path);
if (s_path == NULL)
continue;
gtk_tree_selection_select_path (selection, s_path);
if (show_last && (element == NULL))
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
gtk_tree_path_free(s_path);
}
}
/*
* Retrieve the owner currently under the cursor.
*/
GncOwner *
gnc_tree_view_owner_get_cursor_owner (GncTreeViewOwner *view)
{
GtkTreeModel *s_model;
GtkTreePath *s_path;
GncOwner *owner;
ENTER("view %p", view);
g_return_val_if_fail (GNC_IS_TREE_VIEW_OWNER (view), NULL);
s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
if (!s_path)
{
LEAVE("no owner");
return NULL;
}
owner = gnc_tree_view_owner_get_owner_from_path (view, s_path);
gtk_tree_path_free(s_path);
LEAVE("owner %p (%s)", owner, gncOwnerGetName (owner));
return owner;
}
/************************************************************/
/* Owner Tree View Add Column Functions */
/************************************************************/
@ -1122,33 +961,6 @@ owner_cell_kvp_data_func (GtkTreeViewColumn *tree_column,
}
GtkTreeViewColumn *
gnc_tree_view_owner_add_kvp_column (GncTreeViewOwner *view,
const gchar *column_title,
const gchar *kvp_key)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
g_return_val_if_fail (GNC_IS_TREE_VIEW_OWNER (view), NULL);
g_return_val_if_fail (kvp_key != NULL, NULL);
column = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), column_title,
kvp_key, NULL, "Sample text",
-1, -1, NULL);
/* This new kvp column has only had one renderer added to it so
* far. Find that renderer. */
renderer = gnc_tree_view_column_get_renderer(column);
g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
gtk_tree_view_column_set_cell_data_func (column, renderer,
owner_cell_kvp_data_func,
g_strdup(kvp_key), g_free);
return column;
}
static void col_edited_helper(GtkCellRendererText *cell, gchar *path_string,
gchar *new_text, gpointer _s_model)
{
@ -1219,37 +1031,6 @@ gtvo_setup_column_renderer_edited_cb(GncTreeViewOwner *owner_view,
}
}
GtkTreeViewColumn *
gnc_tree_view_owner_add_custom_column(GncTreeViewOwner *owner_view,
const gchar *column_title,
GncTreeViewOwnerColumnSource
col_source_cb,
GncTreeViewOwnerColumnTextEdited
col_edited_cb)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
g_return_val_if_fail (GNC_IS_TREE_VIEW_OWNER (owner_view), NULL);
renderer = gtk_cell_renderer_text_new ();
g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
column = gtk_tree_view_column_new_with_attributes (column_title,
renderer, NULL);
if (col_edited_cb)
{
gtvo_setup_column_renderer_edited_cb(owner_view, column,
renderer, col_edited_cb);
}
gtk_tree_view_column_set_cell_data_func (column, renderer,
col_source_helper,
col_source_cb, NULL);
gnc_tree_view_append_column (GNC_TREE_VIEW(owner_view), column);
return column;
}
/* BEGIN FILTER FUNCTIONS */
#define FILTER_TREE_VIEW "types_tree_view"
@ -1554,14 +1335,6 @@ gnc_tree_view_owner_restore(GncTreeViewOwner *view,
gnc_tree_view_owner_refilter(view);
}
void
gnc_tree_view_owner_name_edited_cb(GncOwner *owner, GtkTreeViewColumn *col, const gchar *new_name)
{
if (safe_strcmp(gncOwnerGetName(owner), new_name) == 0)
return;
gncOwnerSetName(owner, new_name);
}
static void
gtvo_set_column_editor(GncTreeViewOwner *view,
GtkTreeViewColumn *column,
@ -1580,12 +1353,3 @@ gtvo_set_column_editor(GncTreeViewOwner *view,
g_return_if_fail(renderer != NULL);
gtvo_setup_column_renderer_edited_cb(GNC_TREE_VIEW_OWNER(view), column, renderer, edited_cb);
}
void
gnc_tree_view_owner_set_name_edited(GncTreeViewOwner *view,
GncTreeViewOwnerColumnTextEdited edited_cb)
{
GncTreeViewOwnerPrivate *priv;
priv = GNC_TREE_VIEW_OWNER_GET_PRIVATE(view);
gtvo_set_column_editor(view, priv->name_column, edited_cb);
}

View File

@ -156,83 +156,12 @@ typedef void (*GncTreeViewOwnerColumnTextEdited) (GncOwner *owner,
GtkTreeViewColumn *col,
const gchar *new_text);
/** Add a new custom column to the set of columns in an owner tree
* view. This column will be visible as soon as it is added and will
* query the provided functions to determine what data to display.
* The TreeView will own the resulting TreeViewColumn, but caller may
* set any additional properties they wish.
*
* @param view A pointer to an owner tree view.
*
* @param column_title The title for this new column.
*
* @param source_cb A callback function that is expected to provide
* the data to be displayed.
*
* @param edited_cb A callback function that will be called if the
* user edits the displayed data.
*/
GtkTreeViewColumn * gnc_tree_view_owner_add_custom_column(
GncTreeViewOwner *view, const gchar *column_title,
GncTreeViewOwnerColumnSource source_cb,
GncTreeViewOwnerColumnTextEdited edited_cb);
void gnc_tree_view_owner_set_name_edited(GncTreeViewOwner *view,
GncTreeViewOwnerColumnTextEdited edited_cb);
void gnc_tree_view_owner_name_edited_cb(GncOwner *owner, GtkTreeViewColumn *col, const gchar *new_name);
/** Add a new column to the set of columns in an owner tree view.
* This column will be visible as soon as it is added and will
* display the contents of the specified KVP slot.
*
* @param view A pointer to an owner tree view.
*
* @param column_title The title for this new column.
*
* @param kvp_key The lookup key to use for looking up data in the
* owner KVP structures. The value associated with this key is what
* will be displayed in the column.
*/
GtkTreeViewColumn *
gnc_tree_view_owner_add_kvp_column (GncTreeViewOwner *view,
const gchar *column_title,
const gchar *kvp_key);
/** @} */
/** @name Owner Tree View Filtering
@{ */
/** Given pointers to an owner tree and old style filter block, this
* function will copy the current configuration of the owner tree
* widget into the data block. This may be used in conjunction with
* the gnc_tree_view_owner_set_view_info function to modify the
* filters on an existing owner tree.
*
* @param owner_view A pointer to an owner tree view.
*
* @param avi A pointer to an old style filter block to fill in.
*/
void gnc_tree_view_owner_get_view_info (GncTreeViewOwner *owner_view,
OwnerViewInfo *avi);
/** Given pointers to an owner tree and old style filter block, this
* function will applies the settings specified to the current
* configuration of the owner tree widget. This may be used in
* conjunction with the gnc_tree_view_owner_get_view_info function
* to modify the filters on an existing owner tree.
*
* @param owner_view A pointer to an owner tree view.
*
* @param avi A pointer to an old style filter block to apply to the
* view.
*/
void gnc_tree_view_owner_set_view_info (GncTreeViewOwner *owner_view,
OwnerViewInfo *avi);
/** This is the description of a filter function used by the owner tree.
*
* @param owner The owner to be tested.
@ -313,18 +242,6 @@ GncOwner * gnc_tree_view_owner_get_owner_from_path (GncTreeViewOwner *view,
GncOwner * gnc_tree_view_owner_get_owner_from_iter (GtkTreeModel *model,
GtkTreeIter *iter);
/** This function returns the owner in the owner tree view at the
* current location of the cursor. (The outline frame. Usually is
* selected and therefore filled in, but not always.)
*
* @param view A pointer to an owner tree view.
*
* @return The owner at the cursor.
*/
GncOwner * gnc_tree_view_owner_get_cursor_owner (GncTreeViewOwner *view);
/** This function returns the owner associated with the selected
* item in the owner tree view.
*
@ -358,45 +275,6 @@ void gnc_tree_view_owner_set_selected_owner (GncTreeViewOwner *view,
GncOwner *owner);
/** This function returns a list of the owners associated with the
* selected items in the owner tree view.
*
* @note It only makes sense to call this function when the owner
* tree is set to select multiple items. There is a different
* function to use when the tree supports single selection.
*
* @param view A pointer to an owner tree view.
*
* @return A list of owners, or NULL if no owner was selected.
*/
GList * gnc_tree_view_owner_get_selected_owners (GncTreeViewOwner *view);
/** This function selects a set of owners in the owner tree view.
* All other owners will be unselected. In addition, this function
* collapses the entitre tree and then expands only the path to the
* selected owners, making them easy to find. In general, this
* routine only need be called when initially putting up a window
* containing an owner tree view widget.
*
* @note It only makes sense to call this function when the owner
* tree is set to select a single item. There is a different
* function to use when the tree supports multiple selections.
*
* @note It is the responsibility of the caller to free the returned
* list.
*
* @param view A pointer to an owner tree view.
*
* @param owner_list A list of owners to select.
*
* @param show_last Force the window to scroll to the last owner
* selected.
*/
void gnc_tree_view_owner_set_selected_owners (GncTreeViewOwner *view,
GList *owner_list,
gboolean show_last);
G_END_DECLS
#endif /* __GNC_TREE_VIEW_OWNER_H */

View File

@ -502,50 +502,6 @@ gnc_tree_view_price_new (QofBook *book,
g_free(path_string); \
}
#if 0
static GtkTreePath *
gnc_tree_view_price_get_path_from_price (GncTreeViewPrice *view,
GNCPrice *price)
{
GtkTreeModel *model, *f_model, *s_model;
GtkTreePath *path, *f_path, *s_path;
ENTER("view %p, price %p (%s)", view, price, gnc_price_get_name(price));
if (price == NULL)
{
LEAVE("no price");
return NULL;
}
/* Reach down to the real model and get a path for this price */
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
path = gnc_tree_model_price_get_path_from_price (GNC_TREE_MODEL_PRICE(model), price);
if (path == NULL)
{
LEAVE("no path");
return NULL;
}
/* convert back to a filtered path */
f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model), path);
gtk_tree_path_free(path);
if (!f_path)
{
LEAVE("no filter path");
return NULL;
}
/* convert back to a sorted path */
s_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model), f_path);
gtk_tree_path_free(f_path);
debug_path(LEAVE, s_path);
return s_path;
}
#endif
static gboolean
gnc_tree_view_price_get_iter_from_price (GncTreeViewPrice *view,
GNCPrice *price,
@ -579,98 +535,10 @@ gnc_tree_view_price_get_iter_from_price (GncTreeViewPrice *view,
return TRUE;
}
gint
gnc_tree_view_price_count_children (GncTreeViewPrice *view,
GNCPrice *price)
{
GtkTreeModel *s_model;
GtkTreeIter s_iter;
gint num_children;
ENTER("view %p, price %p", view, price);
if (price == NULL)
{
LEAVE("no price");
return 0;
}
if (!gnc_tree_view_price_get_iter_from_price (view, price, &s_iter))
{
LEAVE("view_get_iter_from_price failed");
return 0;
}
/* Any children? */
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
num_children = gtk_tree_model_iter_n_children(s_model, &s_iter);
LEAVE("%d children", num_children);
return num_children;
}
GNCPrice *
gnc_tree_view_price_get_price_from_column (GtkTreeViewColumn *column,
GtkTreeModel *s_model,
GtkTreeIter *s_iter)
{
GtkTreeModel *model, *f_model;
GtkTreeIter iter, f_iter;
GNCPrice *price;
g_return_val_if_fail (GTK_IS_TREE_VIEW_COLUMN(column), NULL);
g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT(s_model), NULL);
g_return_val_if_fail (s_iter != NULL, NULL);
ENTER("column %p, model %p, iter %p", column, s_model, s_iter);
gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT(s_model),
&f_iter,
s_iter);
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
&iter,
&f_iter);
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
price = gnc_tree_model_price_get_price (GNC_TREE_MODEL_PRICE(model), &iter);
LEAVE("price %p", price);
return price;
}
/************************************************************/
/* Price Tree View Filter Functions */
/************************************************************/
/*
* Set the list of columns that will be visible in an price tree view.
*/
void
gnc_tree_view_price_configure_columns (GncTreeViewPrice *view,
GSList *column_names)
{
GtkTreeViewColumn *column;
GSList *node;
int i;
ENTER(" ");
for (i = 1; i < GNC_TREE_MODEL_PRICE_NUM_COLUMNS; i++)
{
column = gtk_tree_view_get_column (GTK_TREE_VIEW(view), i);
gtk_tree_view_column_set_visible (column, FALSE);
}
for (node = column_names; node != NULL; node = node->next)
{
for (i = 0; i < GNC_TREE_MODEL_PRICE_NUM_COLUMNS; i++)
{
column = gtk_tree_view_get_column (GTK_TREE_VIEW(view), i);
gtk_tree_view_column_set_visible (column, TRUE);
}
}
LEAVE(" ");
}
/************************************************************/
/* Price Tree View Visibility Filter */
/************************************************************/
@ -786,76 +654,10 @@ gnc_tree_view_price_set_filter (GncTreeViewPrice *view,
LEAVE(" ");
}
/*
* Forces the entire price tree to be re-evaluated for visibility.
*/
void
gnc_tree_view_price_refilter (GncTreeViewPrice *view)
{
GtkTreeModel *f_model, *s_model;
ENTER("view %p", view);
g_return_if_fail(GNC_IS_TREE_VIEW_PRICE(view));
s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
LEAVE(" ");
}
/************************************************************/
/* Price Tree View Get/Set Functions */
/************************************************************/
/*
* Retrieve the selected price from an price tree view. The
* price tree must be in single selection mode.
*/
GNCPrice *
gnc_tree_view_price_get_price_from_path (GncTreeViewPrice *view,
GtkTreePath *s_path)
{
GtkTreeModel *model, *f_model, *s_model;
GtkTreePath *path, *f_path;
GtkTreeIter iter;
GNCPrice *price;
ENTER("view %p", view);
g_return_val_if_fail (GNC_IS_TREE_VIEW_PRICE (view), NULL);
g_return_val_if_fail (s_path != NULL, NULL);
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
f_path = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (s_model), s_path);
if (!f_path)
{
LEAVE("no filter path");
return NULL;
}
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
path = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (f_model), f_path);
gtk_tree_path_free(f_path);
if (!path)
{
LEAVE("no path");
return NULL;
}
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
if (!gtk_tree_model_get_iter (model, &iter, path))
{
LEAVE("no iter");
return NULL;
}
price = gnc_tree_model_price_get_price (GNC_TREE_MODEL_PRICE(model),
&iter);
gtk_tree_path_free(path);
LEAVE("price %p", price);
return price;
}
/*
* Retrieve the selected price from an price tree view. The
* price tree must be in single selection mode.
@ -1008,103 +810,3 @@ gnc_tree_view_price_get_selected_prices (GncTreeViewPrice *view)
gtk_tree_selection_selected_foreach(selection, get_selected_prices_helper, &return_list);
return return_list;
}
/*
* Given an price tree view and a list of commodities, select those
* commodities in the tree view.
*/
void
gnc_tree_view_price_set_selected_prices (GncTreeViewPrice *view,
GList *price_list,
gboolean show_last)
{
GtkTreeModel *model, *f_model, *s_model;
GtkTreePath *path, *f_path, *s_path, *parent_path;
GtkTreeSelection *selection;
GList *element;
GNCPrice *price;
s_model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
/* Clear any existing selection. */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
gtk_tree_selection_unselect_all (selection);
gtk_tree_view_collapse_all (GTK_TREE_VIEW(view));
/* Now go select what the user requested. */
for (element = price_list; element; )
{
price = element->data;
element = g_list_next(element);
path = gnc_tree_model_price_get_path_from_price (GNC_TREE_MODEL_PRICE(model), price);
if (path == NULL)
{
/*
* Oops. Someone must have deleted this price and not cleaned
* up all references to it.
*/
continue;
}
f_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model),
path);
gtk_tree_path_free(path);
if (f_path == NULL)
continue;
s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model),
f_path);
gtk_tree_path_free(f_path);
if (s_path == NULL)
continue;
/* gtk_tree_view requires that a row be visible before it can be selected */
parent_path = gtk_tree_path_copy (s_path);
if (gtk_tree_path_up (parent_path))
{
/* This function is misnamed. It expands the actual item
* specified, not the path to the item specified. I.E. It
* expands one level too many, thus the get of the parent. */
gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), parent_path);
}
gtk_tree_path_free(parent_path);
gtk_tree_selection_select_path (selection, s_path);
if (show_last && (element == NULL))
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
gtk_tree_path_free(s_path);
}
}
#ifdef NEEDED
/*
* Retrieve the price currently under the cursor.
*/
GNCPrice *
gnc_tree_view_price_get_cursor_account (GncTreeViewPrice *view)
{
GtkTreeModel *s_model;
GtkTreePath *s_path;
GNCPrice *price;
ENTER("view %p", view);
g_return_val_if_fail (GNC_IS_TREE_VIEW_PRICE (view), NULL);
s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
gtk_tree_view_get_cursor (GTK_TREE_VIEW(view), &s_path, NULL);
if (s_path)
{
account = gnc_tree_view_price_get_account_from_path (view, s_path);
gtk_tree_path_free(s_path);
}
else
{
account = NULL;
}
LEAVE("account %p (%s)", account, gnc_price_get_mnemonic (account));
return account;
}
#endif

View File

@ -94,18 +94,6 @@ GtkTreeView *gnc_tree_view_price_new (QofBook *book,
/** @name Price Tree View Configuration
@{ */
/** Configure (by name) the set of visible columns in an price tree
* view. By default, only the price name column is show. The
* avalible list of columns can be found in the file
* gnc-tree-view-price.c
*
* @param price_view A pointer to an price tree view.
*
* @param column_names A list of column names to make visible.
*/
void gnc_tree_view_price_configure_columns (GncTreeViewPrice *price_view,
GSList *column_names);
#ifdef OLD
/** Add a new column to the set of columns in an price tree view.
* This column will display the contents of a specified KVP slot.
@ -156,59 +144,12 @@ void gnc_tree_view_price_set_filter (GncTreeViewPrice *view,
gnc_tree_view_price_pc_filter_func pc_func,
gpointer data,
GtkDestroyNotify destroy);
/** This function forces the price tree filter to be evaluated. It
* may be necessary to call this function if the initial state of the
* view is incorrect. This appears to only be necessary if the
* filter affects one of the top level prices in gnucash.
*
* @note This calls a function in gtk that is annotated in the
* sources as being slow. You have been warned.
*
* @param view A pointer to an price tree view.
*/
void gnc_tree_view_price_refilter (GncTreeViewPrice *view);
/** @} */
/** @name Price Tree View Get/Set Functions
@{ */
/** This function determines if an price in the price tree view
* has any visible children.
*
* @param view A pointer to an price tree view.
*
* @param price A pointer to the price to check.
*
* @return The number of children of the specified price. Returns 0
* on error.
*/
gint gnc_tree_view_price_count_children (GncTreeViewPrice *view,
GNCPrice *price);
GNCPrice * gnc_tree_view_price_get_price_from_column (GtkTreeViewColumn *column,
GtkTreeModel *f_model,
GtkTreeIter *f_iter);
/** This function returns the price associated with the specified
* path. This function is useful in selection callbacks on an
* price tree widget.
*
* @param view A pointer to an price tree view.
*
* @param path A path specifying a node in the price tree.
*
* @return The price associated with this path.
*/
GNCPrice * gnc_tree_view_price_get_price_from_path (GncTreeViewPrice *view,
GtkTreePath *path);
/** This function returns the price in the price tree view at the
* current location of the cursor. (The outline frame. Usually is
* selected and therefore filled in, but not always.)
@ -267,30 +208,6 @@ void gnc_tree_view_price_set_selected_price (GncTreeViewPrice *view,
GList * gnc_tree_view_price_get_selected_prices (GncTreeViewPrice *view);
/** This function selects a set of prices in the price tree view.
* All other prices will be unselected. In addition, this function
* collapses the entitre tree and then expands only the path to the
* selected prices, making them easy to find. In general, this
* routine only need be called when initially putting up a window
* containing an price tree view widget.
*
* @note It only makes sense to call this function when the price
* tree is set to select a single item. There is a different
* function to use when the tree supports multiple selections.
*
* @note It is the responsibility of the caller to free the returned
* list.
*
* @param view A pointer to an price tree view.
*
* @param price_list A pointer to the list of prices to select.
*
* @param show_last Force the window to scroll to the last price
* selected.
*/
void gnc_tree_view_price_set_selected_prices (GncTreeViewPrice *view,
GList *price_list,
gboolean show_last);
/** @} */
G_END_DECLS

View File

@ -142,24 +142,6 @@ gnc_search_param_new (void)
return o;
}
GNCSearchParam *
gnc_search_param_clone (GNCSearchParam *param)
{
GNCSearchParam *n;
GNCSearchParamPrivate *priv, *n_priv;
g_return_val_if_fail (GNC_IS_SEARCH_PARAM (param), NULL);
priv = GNC_SEARCH_PARAM_GET_PRIVATE(param);
n = gnc_search_param_new ();
n_priv = GNC_SEARCH_PARAM_GET_PRIVATE(n);
n->title = param->title;
n_priv->param_path = g_slist_copy (priv->param_path);
n_priv->type = priv->type;
return n;
}
void
gnc_search_param_set_param_path (GNCSearchParam *param,
QofIdTypeConst search_type,

View File

@ -57,7 +57,6 @@ GType gnc_search_param_get_type (void);
/* Create a new search param */
GNCSearchParam * gnc_search_param_new (void);
GNCSearchParam * gnc_search_param_clone (GNCSearchParam *param);
/* use the param_path for this parameter. This will automatically
* compute the parameter type and the converter functions.