mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Use the new account tree view widget.src/gnome/druid-stock-split.c
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9158 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "gnc-gui-query.h"
|
||||
#include "gnc-session.h"
|
||||
#include "gnc-tree-model-account.h"
|
||||
#include "gnc-tree-view-account.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "messages.h"
|
||||
@@ -105,7 +106,7 @@ struct _AccountWindow
|
||||
|
||||
|
||||
/** Static Globals *******************************************************/
|
||||
static short module = MOD_GUI;
|
||||
static short module = MOD_TEST;
|
||||
|
||||
static gint last_width = 0;
|
||||
static gint last_height = 0;
|
||||
@@ -175,6 +176,8 @@ gnc_account_to_ui(AccountWindow *aw)
|
||||
const char *string;
|
||||
gboolean tax_related, placeholder, nonstd_scu;
|
||||
gint index;
|
||||
GtkTreePath *tree_path;
|
||||
GncTreeModelAccount *tree_model;
|
||||
|
||||
if (!account)
|
||||
return;
|
||||
@@ -217,6 +220,14 @@ gnc_account_to_ui(AccountWindow *aw)
|
||||
placeholder = xaccAccountGetPlaceholder (account);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->placeholder_button),
|
||||
placeholder);
|
||||
|
||||
tree_model = GNC_TREE_MODEL_ACCOUNT (gtk_tree_view_get_model (aw->parent_tree));
|
||||
gtk_tree_view_collapse_all (aw->parent_tree);
|
||||
tree_path = gnc_tree_model_account_get_path_from_account (GNC_TREE_MODEL_ACCOUNT(tree_model), account);
|
||||
if (tree_path) {
|
||||
gtk_tree_view_expand_to_path (aw->parent_tree, tree_path);
|
||||
gtk_tree_path_free(tree_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -396,10 +407,16 @@ gnc_ui_to_account(AccountWindow *aw)
|
||||
}
|
||||
else
|
||||
{
|
||||
Account *transfer;
|
||||
Account *transfer = NULL;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
transfer = gnc_account_tree_get_current_account
|
||||
(GNC_ACCOUNT_TREE (aw->transfer_tree));
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->transfer_tree));
|
||||
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
|
||||
transfer = gnc_tree_model_account_get_account (GNC_TREE_MODEL_ACCOUNT (model),
|
||||
&iter);
|
||||
}
|
||||
if (!transfer)
|
||||
return;
|
||||
|
||||
@@ -989,11 +1006,16 @@ gnc_new_account_ok (AccountWindow *aw)
|
||||
|
||||
if (!use_equity)
|
||||
{
|
||||
Account *transfer;
|
||||
|
||||
transfer = gnc_account_tree_get_current_account
|
||||
(GNC_ACCOUNT_TREE (aw->transfer_tree));
|
||||
Account *transfer = NULL;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->transfer_tree));
|
||||
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
|
||||
transfer = gnc_tree_model_account_get_account (GNC_TREE_MODEL_ACCOUNT (model),
|
||||
&iter);
|
||||
}
|
||||
if (!transfer)
|
||||
{
|
||||
const char *message = _("You must select a transfer account or choose"
|
||||
@@ -1335,6 +1357,7 @@ commodity_changed_cb (GNCGeneralSelect *gsl, gpointer data)
|
||||
{
|
||||
AccountWindow *aw = data;
|
||||
gnc_commodity *currency;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
currency = (gnc_commodity *) gnc_general_select_get_selected (gsl);
|
||||
if (!currency)
|
||||
@@ -1345,17 +1368,40 @@ commodity_changed_cb (GNCGeneralSelect *gsl, gpointer data)
|
||||
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (aw->opening_balance_edit),
|
||||
gnc_commodity_print_info (currency, FALSE));
|
||||
|
||||
gnc_account_tree_refresh (GNC_ACCOUNT_TREE (aw->transfer_tree));
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->transfer_tree));
|
||||
gtk_tree_selection_unselect_all (selection);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
account_commodity_filter (Account *account, gpointer user_data)
|
||||
account_commodity_filter (GtkTreeSelection *selection,
|
||||
GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
gboolean path_currently_selected,
|
||||
gpointer user_data)
|
||||
{
|
||||
AccountWindow *aw = user_data;
|
||||
gnc_commodity *commodity;
|
||||
AccountWindow *aw;
|
||||
Account *account;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (!account)
|
||||
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), FALSE);
|
||||
aw = user_data;
|
||||
|
||||
if (path_currently_selected) {
|
||||
/* already selected, don't waste time. */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!gtk_tree_model_get_iter (model, &iter, path)) {
|
||||
/* Can't convert path to iter? Bad! */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
account = gnc_tree_model_account_get_account (GNC_TREE_MODEL_ACCOUNT (model), &iter);
|
||||
if (!account) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
commodity = (gnc_commodity *)
|
||||
gnc_general_select_get_selected (GNC_GENERAL_SELECT (aw->commodity_edit));
|
||||
@@ -1389,10 +1435,11 @@ gnc_account_window_create(AccountWindow *aw)
|
||||
GObject *awo;
|
||||
GtkWidget *box;
|
||||
GladeXML *xml;
|
||||
AccountGroup *group;
|
||||
GtkTreeModel *model;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
// AccountGroup *group;
|
||||
// GtkTreeModel *model;
|
||||
// GtkCellRenderer *renderer;
|
||||
// GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
xml = gnc_glade_xml_new ("account.glade", "Account Dialog");
|
||||
|
||||
@@ -1441,22 +1488,11 @@ gnc_account_window_create(AccountWindow *aw)
|
||||
xaccAccountBeginEdit (aw->top_level_account);
|
||||
xaccAccountSetName(aw->top_level_account, _("New top level account"));
|
||||
|
||||
group = gnc_book_get_group (gnc_get_current_book ());
|
||||
|
||||
aw->parent_tree = GTK_TREE_VIEW (glade_xml_get_widget (xml, "parent_tree_view"));
|
||||
model = gnc_tree_model_account_new (group);
|
||||
gnc_tree_model_account_set_toplevel (GNC_TREE_MODEL_ACCOUNT (model), aw->top_level_account);
|
||||
gtk_tree_view_set_model (aw->parent_tree, model);
|
||||
g_object_unref (model);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("",
|
||||
renderer,
|
||||
"text", GNC_TREE_MODEL_ACCOUNT_COL_NAME,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (aw->parent_tree, column);
|
||||
gtk_tree_view_set_headers_visible (aw->parent_tree, FALSE);
|
||||
gtk_tree_view_expand_all (aw->parent_tree);
|
||||
// group = gnc_book_get_group (gnc_get_current_book ());
|
||||
aw->parent_tree = gnc_tree_view_account_new();
|
||||
gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(aw->parent_tree));
|
||||
gnc_tree_view_account_configure_columns (GNC_TREE_VIEW_ACCOUNT(aw->parent_tree), NULL);
|
||||
gtk_widget_show(GTK_WIDGET(aw->parent_tree));
|
||||
|
||||
aw->tax_related_button = glade_xml_get_widget (xml, "tax_related_button");
|
||||
aw->placeholder_button = glade_xml_get_widget (xml, "placeholder_button");
|
||||
@@ -1484,12 +1520,9 @@ gnc_account_window_create(AccountWindow *aw)
|
||||
|
||||
box = glade_xml_get_widget (xml, "transfer_account_scroll");
|
||||
|
||||
aw->transfer_tree = gnc_account_tree_new ();
|
||||
gtk_clist_column_titles_hide (GTK_CLIST (aw->transfer_tree));
|
||||
/* gnc_account_tree_hide_all_but_name(GNC_ACCOUNT_TREE(aw->parent_tree)); */
|
||||
|
||||
gnc_account_tree_set_selectable_filter (GNC_ACCOUNT_TREE (aw->transfer_tree),
|
||||
account_commodity_filter, aw);
|
||||
aw->transfer_tree = GTK_WIDGET(gnc_tree_view_account_new());
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(aw->transfer_tree));
|
||||
gtk_tree_selection_set_select_function(selection, account_commodity_filter, aw, NULL);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(aw->transfer_tree));
|
||||
gtk_widget_show (GTK_WIDGET(aw->transfer_tree));
|
||||
@@ -1641,6 +1674,7 @@ gnc_ui_new_account_window_internal (Account *base_account,
|
||||
GncTreeModelAccount *model;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *tree_path;
|
||||
|
||||
aw = g_new0 (AccountWindow, 1);
|
||||
|
||||
@@ -1690,9 +1724,14 @@ gnc_ui_new_account_window_internal (Account *base_account,
|
||||
base_account = aw->top_level_account;
|
||||
}
|
||||
|
||||
gtk_tree_view_expand_all (GTK_TREE_VIEW (aw->parent_tree));
|
||||
model = GNC_TREE_MODEL_ACCOUNT (gtk_tree_view_get_model (GTK_TREE_VIEW (aw->parent_tree)));
|
||||
model = GNC_TREE_MODEL_ACCOUNT (gtk_tree_view_get_model (aw->parent_tree));
|
||||
gnc_tree_model_account_get_iter_from_account (model, base_account, &iter);
|
||||
gtk_tree_view_collapse_all (aw->parent_tree);
|
||||
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &iter);
|
||||
if (tree_path) {
|
||||
gtk_tree_view_expand_to_path (aw->parent_tree, tree_path);
|
||||
gtk_tree_path_free(tree_path);
|
||||
}
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aw->parent_tree));
|
||||
gtk_tree_selection_select_iter (selection, &iter);
|
||||
|
||||
@@ -1937,7 +1976,6 @@ gnc_ui_edit_account_window(Account *account)
|
||||
if (parent == NULL)
|
||||
parent = aw->top_level_account;
|
||||
|
||||
gtk_tree_view_expand_all (aw->parent_tree);
|
||||
model = GNC_TREE_MODEL_ACCOUNT (gtk_tree_view_get_model (aw->parent_tree));
|
||||
gnc_tree_model_account_get_iter_from_account (model, parent, &iter);
|
||||
selection = gtk_tree_view_get_selection (aw->parent_tree);
|
||||
|
||||
@@ -513,14 +513,7 @@
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="parent_tree_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
</widget>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
@@ -12,12 +12,14 @@
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<signal name="destroy" handler="gnc_stock_split_druid_window_destroy_cb" last_modification_time="Sat, 23 Aug 2003 22:43:04 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruid" id="stock_split_druid">
|
||||
<property name="border_width">4</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="show_help">False</property>
|
||||
<signal name="cancel" handler="gnc_stock_split_druid_cancel_druid" last_modification_time="Sat, 23 Aug 2003 22:42:56 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruidPageEdge" id="start_page">
|
||||
@@ -37,9 +39,10 @@
|
||||
<widget class="GnomeDruidPageStandard" id="account_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Stock Account</property>
|
||||
<property name="title_foreground">#df20083dceb8</property>
|
||||
<property name="background">#df180834e9eb</property>
|
||||
<property name="logo_background">#1df0081d0001</property>
|
||||
<property name="title_foreground">#1258082cd158</property>
|
||||
<property name="background">#b618082be9eb</property>
|
||||
<property name="logo_background">#1e10081d0001</property>
|
||||
<signal name="next" handler="gnc_stock_split_druid_account_next" last_modification_time="Sat, 23 Aug 2003 22:43:13 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="vbox98">
|
||||
@@ -79,21 +82,67 @@
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow21">
|
||||
<property name="border_width">10</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="account_clist">
|
||||
<widget class="GtkCList" id="account_clist">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
<property name="n_columns">3</property>
|
||||
<property name="column_widths">80,80,80</property>
|
||||
<property name="selection_mode">GTK_SELECTION_SINGLE</property>
|
||||
<property name="show_titles">True</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label847718">
|
||||
<property name="label" translatable="yes">Account</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label847719">
|
||||
<property name="label" translatable="yes">Symbol</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label847720">
|
||||
<property name="label" translatable="yes">Shares</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_RIGHT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
@@ -114,9 +163,11 @@
|
||||
<widget class="GnomeDruidPageStandard" id="details_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Stock Split Details</property>
|
||||
<property name="title_foreground">#51600840ceb8</property>
|
||||
<property name="background">#f0380835e9eb</property>
|
||||
<property name="logo_background">#1df0081d0001</property>
|
||||
<property name="title_foreground">#c7f0082cd158</property>
|
||||
<property name="background">#d678082ce9eb</property>
|
||||
<property name="logo_background">#1e10081d0001</property>
|
||||
<signal name="prepare" handler="gnc_stock_split_druid_details_prepare" last_modification_time="Sat, 23 Aug 2003 22:44:51 GMT"/>
|
||||
<signal name="next" handler="gnc_stock_split_druid_details_next" last_modification_time="Sat, 23 Aug 2003 22:45:27 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="druid-vbox32">
|
||||
@@ -462,9 +513,11 @@ You may safely leave it blank.</property>
|
||||
<widget class="GnomeDruidPageStandard" id="cash_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Cash In Lieu</property>
|
||||
<property name="title_foreground">#4868083bceb8</property>
|
||||
<property name="background">#33e80832e9eb</property>
|
||||
<property name="logo_background">#1df0081d0001</property>
|
||||
<property name="title_foreground">#b030082ed158</property>
|
||||
<property name="background">#af98082ee9eb</property>
|
||||
<property name="logo_background">#1e10081d0001</property>
|
||||
<signal name="prepare" handler="gnc_stock_split_druid_cash_prepare" last_modification_time="Sat, 23 Aug 2003 22:55:18 GMT"/>
|
||||
<signal name="next" handler="gnc_stock_split_druid_cash_next" last_modification_time="Sat, 23 Aug 2003 22:55:44 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="druid-vbox33">
|
||||
@@ -752,6 +805,7 @@ quit without making any changes.</property>
|
||||
<property name="background_color">#666666669999</property>
|
||||
<property name="logo_background_color">#666666669999</property>
|
||||
<property name="textbox_color">#ffffffffffff</property>
|
||||
<signal name="finish" handler="gnc_stock_split_druid_finish" last_modification_time="Sat, 23 Aug 2003 22:56:22 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user