Re: Can someone help me make the SLR dialog do what I want?

2007-11-15 Thread Josh Sled
Sorry for the delay in response.

Tim Wunder <[EMAIL PROTECTED]> writes:
> Ugh... I appreciate your responding to my plea for help, but I really need 
> more basic and fundamental help than that. Assume I know /nothing/ about C 
> programming, and especially gtk+ programming. 

I hope that you didn't find all this too discouraging, and if you did, you'll
feel motivated to try again.


> I did some messing around to see if I could grok even a little of what you 
> told me (and what I read). Without much success, as indicated by:
> dialog-sx-since-last-run.c:981: warning: ISO C90 forbids mixed declarations 
> and code
> dialog-sx-since-last-run.c:982: warning: passing argument 1 
> of 'gtk_tree_model_filter_set_visible_func' from incompatible pointe
>
> I did this: 
> _gnc_slr_filter(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
> {
> // just playing around with a function call
> gboolean SX_filter = 1;
> return !SX_filter;
> }
>
> and then...
> //gtk_tree_view_expand_all(dialog->instance_view);
> GtkTreeModel *filtered_model = 
> gtk_tree_model_filter_new(GTK_TREE_MODEL(dialog->editing_model), NULL);
> 
> gtk_tree_model_filter_set_visible_func(filtered_model,_gnc_slr_filter, 
> NULL, NULL);
>
> I'm sure what I've done isn't even close to what's supposed to be done, but 
> I'm old, so choose your clue bat with care. ;)  Don't I need to pass 
> variables when calling functions or something?

When you use a function pointer like this, you're not actually calling the
function ... you're just passing the pointer to the function for something
else (the GtkTreeModel, in this case) to invoke.  When it does eventually
call the function, it do need to pass arguments ... and it's going to pass
exactly the parameters that are expected of functions that fit the
"visible_func" signature.


> Also, how do I query the model (?) to determine its state (autocreate, 
> to-create, reminder, etc...)?

The filter function only has access to its parameters; its "model" param is
generically a GtkTreeModel, but you (and the code) can assume it's actually a
GncSxSlrTreeModelAdapter.  This class has the GncSxInstanceModel that it's
adapting as the field "instances".

From a GtkIter one can get a GtkPath, which has specific indices; these
indices can then be used as list indices into the GncSxInstanceModel (and its
contained objects), to get the specific GncSxInstance that the GtkIter for a
row in the tree model corresponds to.

There is a convenience method in this file to do just those steps, taking the
model and an iter and translating it into the instance :)

GncSxInstance*
gnc_sx_slr_model_get_instance(GncSxSlrTreeModelAdapter *model, GtkTreeIter 
*iter)


Once you have the relevant GncSxInstance*, the creation state is in the
fields:

GncSxInstanceState orig_state;
GncSxInstanceState state;

...on the GncSxInstance class/struct
(see src/app-util/gnc-sx-instance-model.h:98).

-- 
...jsled
http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo [EMAIL PROTECTED]


pgpllxl7jqJJ6.pgp
Description: PGP signature
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Can someone help me make the SLR dialog do what I want?

2007-08-28 Thread Derek Atkins
Quoting Tim Wunder <[EMAIL PROTECTED]>:

> I did some messing around to see if I could grok even a little of what you
> told me (and what I read). Without much success, as indicated by:
> dialog-sx-since-last-run.c:981: warning: ISO C90 forbids mixed declarations
> and code
> dialog-sx-since-last-run.c:982: warning: passing argument 1
> of 'gtk_tree_model_filter_set_visible_func' from incompatible pointe

This means that you declared a variable in the middle of the code.  E.g.
you did something like:

RetType fcn(FooType1 arg1, FooType2 arg2)
{
   FooType* var1;

   ... // some real code here

   BarType var2;<===  This is the error.

   ... //
}

The fix is to move the declaration of "BarType var2" to the top of the
function.

> I did this:
[snip]
> and then...
> //gtk_tree_view_expand_all(dialog->instance_view);
>GtkTreeModel *filtered_model =
> gtk_tree_model_filter_new(GTK_TREE_MODEL(dialog->editing_model), NULL);

This is probably your BarType...

-derek

-- 
   Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
   Member, MIT Student Information Processing Board  (SIPB)
   URL: http://web.mit.edu/warlord/PP-ASEL-IA N1NWH
   [EMAIL PROTECTED]PGP key available

___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Can someone help me make the SLR dialog do what I want?

2007-08-28 Thread Tim Wunder
On Friday 24 August 2007 7:57:00 pm Josh Sled wrote:

> GtkTreeModel *filtered_model =
> gtk_tree_model_filter_new(existing_model, NULL);
> gtk_tree_model_filter_set_visible_func(filtered_model,
> _gnc_sxslr_filter_func, NULL, NULL);
>
>
> This is very similar to the use of an Interface in object-oriented
> languages ... the function pointer can be thought of as a functional
> interface.

Ugh... I appreciate your responding to my plea for help, but I really need 
more basic and fundamental help than that. Assume I know /nothing/ about C 
programming, and especially gtk+ programming. 

I did some messing around to see if I could grok even a little of what you 
told me (and what I read). Without much success, as indicated by:
dialog-sx-since-last-run.c:981: warning: ISO C90 forbids mixed declarations 
and code
dialog-sx-since-last-run.c:982: warning: passing argument 1 
of 'gtk_tree_model_filter_set_visible_func' from incompatible pointe

I did this: 
_gnc_slr_filter(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
// just playing around with a function call
gboolean SX_filter = 1;
return !SX_filter;
}

and then...
//gtk_tree_view_expand_all(dialog->instance_view);
GtkTreeModel *filtered_model = 
gtk_tree_model_filter_new(GTK_TREE_MODEL(dialog->editing_model), NULL);
gtk_tree_model_filter_set_visible_func(filtered_model,_gnc_slr_filter, 
NULL, NULL);

I'm sure what I've done isn't even close to what's supposed to be done, but 
I'm old, so choose your clue bat with care. ;)  Don't I need to pass 
variables when calling functions or something?

Also, how do I query the model (?) to determine its state (autocreate, 
to-create, reminder, etc...)?

Thanks, 
Tim
-- 
Fedora Core release 6 (Zod), Linux 2.6.22.2-42.fc6
KDE: 3.5.7-9.fc6 Fedora
 21:05:01 up 9 days,  6:09,  3 users,  load average: 0.24, 0.18, 0.11
"It's what you learn after you know it all that counts" John Wooden


signature.asc
Description: This is a digitally signed message part.
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Can someone help me make the SLR dialog do what I want?

2007-08-24 Thread Josh Sled
Tim Wunder <[EMAIL PROTECTED]> writes:
> OK... So I :
> "Filter specific rows, based on data from a "visible column", a column 
> storing 
> booleans indicating whether the row should be filtered or not, or based on 
> the return value of a "visible function", which gets a model, iter and 
> user_data and returns a boolean indicating whether the row should be filtered 
> or not."
> Where do I do this filtering? I guess I'd need to create some sort of 
> "visible 
> function" that would make visible that which I want to filter??? 

Right ... well... you'll want to make that which you want to filter
*invisible*, but... ;)

When you create the GtkTreeModelFilter, you provide a function that fits the
signature of GtkTreeModelFilterVisibleFunc [1].  That is, make a new function
that has the same return value and arguments, and obeys the semantics
defined, then just use it's name to pass a pointer to the function for the
filtering algorithm to invoke later.  Something like:

static gboolean
_gnc_sxslr_filter_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer 
data)
{
// filters out even rows
// (I made up the function name; this is all handwavy... --jsled)
gboolean is_even_row = gtk_tree_iter_get_row_number(model, iter) % 2 == 
0;
return !is_even_row;
}

// [...]

GtkTreeModel *filtered_model = gtk_tree_model_filter_new(existing_model, 
NULL);
gtk_tree_model_filter_set_visible_func(filtered_model, 
_gnc_sxslr_filter_func, NULL, NULL);


This is very similar to the use of an Interface in object-oriented languages
... the function pointer can be thought of as a functional interface.


> And WTF is 
> an "iter"?

It represents a particular row in a particular model.  The 4th paragraph of
[2] has a bit more color.

Generally, you'll want to read [3] to get a sense of how the TreeModel and
TreeView (and the rest of the related classes/types) interact.  The design is
non-trival, but I don't really consider it overly complex, either. 

[1] 
http://library.gnome.org/devel/gtk/unstable/GtkTreeModelFilter.html#GtkTreeModelFilterVisibleFunc
[2] http://library.gnome.org/devel/gtk/unstable/GtkTreeModel.html#id3511622
[3] http://library.gnome.org/devel/gtk/unstable/TreeWidget.html

(All this is in your local devhelp, too.)


>> Color coding is always tricky ... in cultural significance ... in how it
[...]
> Yeah, I know. But it would look purdy if it had colors. ;)

Heh. :)

-- 
...jsled
http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo [EMAIL PROTECTED]


pgpgxrjZKMMw6.pgp
Description: PGP signature
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Can someone help me make the SLR dialog do what I want?

2007-08-24 Thread Tim Wunder
On Friday 24 August 2007 6:54:27 pm Josh Sled wrote:
> Tim Wunder <[EMAIL PROTECTED]> writes:
> > That was easy and I liked the result. Encouraged, I sought to reading
> > more of the code to see where it builds the list of SXs that get
> > displayed. I want only SXs that will be in a Reminder, To Be Created, or
> > Automatically Created state to display. I have a lot of SXs and having
> > those that are neither ready to be created nor reminders adds unwanted
> > clutter for me.
>
> Most of the code in dialog-sx-since-last-run.c adapts the GncSxInstances
> model into a GtkTreeModel, for direct use in the GtkTreeView which is the
> (new) SLR dialog.
>
> You may be better served by using a GtkTreeModelFilter to {dis,en}able the
> rows you want.  This could be exposed via a new control in the dialog,
> maybe with default settings in preferences ... I'm moderately opposed to
> user prefs for this, though maybe we can hide them in an "Advanced" section
> of SX prefs, or something.
>

OK... So I :
"Filter specific rows, based on data from a "visible column", a column storing 
booleans indicating whether the row should be filtered or not, or based on 
the return value of a "visible function", which gets a model, iter and 
user_data and returns a boolean indicating whether the row should be filtered 
or not."
Where do I do this filtering? I guess I'd need to create some sort of "visible 
function" that would make visible that which I want to filter??? And WTF is 
an "iter"?

> > P.S. Another thought I had was to display the SXs in a color-coded manner
> > so that Automatics could be grey'd (I think the State column is grey'd
> > out already), the Reminders could be yellow, the To Be Created without
> > variables could be dark green while the To Be Created that have variables
> > could be displayd light green. (But that's just a crazy idea my left
> > brain cell had...)
>
> Color coding is always tricky ... in cultural significance ... in how it
> interacts with custom gtk themes (dark-green on black = unreadable) ... the
> HIG.
>
> It might be better if they were instead three distinct super-trees (i.e.,
> up at the root level).  Or if the dialog could be "pivoted" around the two
> display modes (grouped by State vs. integrated by SX).

Yeah, I know. But it would look purdy if it had colors. ;)


signature.asc
Description: This is a digitally signed message part.
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Can someone help me make the SLR dialog do what I want?

2007-08-24 Thread Josh Sled
Tim Wunder <[EMAIL PROTECTED]> writes:
> That was easy and I liked the result. Encouraged, I sought to reading more of 
> the code to see where it builds the list of SXs that get displayed. I want 
> only SXs that will be in a Reminder, To Be Created, or Automatically Created 
> state to display. I have a lot of SXs and having those that are neither ready 
> to be created nor reminders adds unwanted clutter for me. 

Most of the code in dialog-sx-since-last-run.c adapts the GncSxInstances
model into a GtkTreeModel, for direct use in the GtkTreeView which is the
(new) SLR dialog.

You may be better served by using a GtkTreeModelFilter to {dis,en}able the
rows you want.  This could be exposed via a new control in the dialog, maybe
with default settings in preferences ... I'm moderately opposed to user prefs
for this, though maybe we can hide them in an "Advanced" section of SX prefs,
or something.


> P.S. Another thought I had was to display the SXs in a color-coded manner so 
> that Automatics could be grey'd (I think the State column is grey'd out 
> already), the Reminders could be yellow, the To Be Created without variables 
> could be dark green while the To Be Created that have variables could be 
> displayd light green. (But that's just a crazy idea my left brain cell 
> had...)

Color coding is always tricky ... in cultural significance ... in how it
interacts with custom gtk themes (dark-green on black = unreadable) ... the
HIG.

It might be better if they were instead three distinct super-trees (i.e., up
at the root level).  Or if the dialog could be "pivoted" around the two
display modes (grouped by State vs. integrated by SX).

-- 
...jsled
http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo [EMAIL PROTECTED]


pgpHKr6QitqIV.pgp
Description: PGP signature
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel