[gnucash-de] Re: Aktien: AusführlicherInfozeile

Christian Stimming stimming at tuhh.de
Mon Sep 8 10:49:41 CDT 2003


Joerg Sommer schrieb:
> Nur mal so eine prinzipelle Frage: Ihr habt so ein halbes C++ in C
> nachgebaut? Macht das Sinn?

Gute Frage. Nein, wir haben nicht C++ nachgebaut, sondern wir haben in C 
objektorientiert (OO) programmiert. OO gibts schon viel länger als es 
C++ gibt, und OO-Programmierung ist im Prinzip in (fast) jeder 
Programmiersprache möglich. Nur in manchen ist es halt leichter als in 
anderen, so wie es eben in C++ definitiv leichter ist als in C. Aber wie 
dir die GTK+ Community treuherzig versichern wird, kann man auch in C 
"ganz toll" OO programmieren. Warum überhaupt C siehe 
http://gnomesupport.org/wiki/index.php/GnuCashFrequentlyAskedQuestions . 
Persönliche ANmerkung: Ich finde C für GUI-Programmierung zum kotzen. 
Solange man sich an die OO-Konventionen hält, ist es wenigsten gerade so 
noch erträglich. Eine andere Sprache würde ich liebend gerne nehmen, 
aber geht halt nicht.

> Hier ist mein pre-patch. Ist das schonmal richtig oder ist es die falsche
> Stelle? Wie bekomme ich die gesamten Buchungen in einem Konto heraus? Ich
> wollte jetzt die ganzen Buchungen abklappern und die dortigen Werte
> zusammen addieren und von amount in Zeile 839 (in der leeren if(){})
> einfach dann abziehen. Wird das was?

Sieht soweit erstmal ok aus. Ich hab allerdings z.Zt. Null Zeit, das 
patch selber auszuprobieren. Schicks doch lieber gleich auf Englisch an 
gnucash-devel. Dort melden sich dann sicher auch noch mehr 
Programmierer. Oder #gnucash in irc.gnome.org. Ach ja, und alle 
Buchungen bzw. den Saldo gibt es über eine Query. Beispiele für jene 
u.a. in src/register/ledger-core/gnc-ledger-display.c Funktion 
gnc_ledger_display_make_query(). Leider kam ich nie dazu, die Doku für 
Query mal aufzuarbeiten. Übrigens, die Funktionsdokumentation im HEAD 
branch vom CVS ist gigantisch viel besser als in 1.8. Wenn du also Doku 
suchst, dann bitte immer im CVS-HEAD.

Gruß

Christian

> 
> #v+
> diff -urb gnucash-1.8.5/src/gnome/gnc-split-reg.c /home/Sources/gnucash-1.8.5/src/gnome/gnc-split-reg.c
> --- gnucash-1.8.5/src/gnome/gnc-split-reg.c	2003-06-25 06:27:48.000000000 +0200
> +++ /home/Sources/gnucash-1.8.5/src/gnome/gnc-split-reg.c	2003-09-04 17:12:43.000000000 +0200
> @@ -735,7 +735,7 @@
>        }
>  
>      /* Print the summary share value */
> -    if (gsr->value_label != NULL)
> +    if (gsr->value_label != NULL || gsr->profit_label != NULL)
>        {
>          GNCPrice *price;
>  
> @@ -754,11 +754,27 @@
>  
>                   xaccSPrintAmount (string, amount, print_info);
>  
> +		 if (gsr->value_label != NULL)
> +		   {
>                   gnc_set_label_color (gsr->value_label, amount);
>                   gtk_label_set_text (GTK_LABEL (gsr->value_label), string);
>                }
> +		 if (gsr->profit_label != NULL)
> +		   {
> +		      gnc_set_label_color (gsr->profit_label, amount);
> +		      gtk_label_set_text (GTK_LABEL (gsr->profit_label), string);
> +		   }
> +		 
> +              }
>              else
>                {
> +		 if (gsr->profit_label != NULL)
> +		   {
> +		      gnc_set_label_color (gsr->profit_label, gnc_numeric_zero ());
> +		      gtk_label_set_text (GTK_LABEL (gsr->profit_label),
> +					  _("<No information>"));
> +		   }
> +		 if (gsr->value_label != NULL) {
>                  /* else try to do a double-price-conversion :-( */
>                  price = account_latest_price_any_currency (leader);
>                  if(!price)
> @@ -800,6 +816,7 @@
>                    }
>                }
>            }
> +          }
>          else
>            {
>              gnc_commodity *currency = gnc_price_get_currency (price);
> @@ -810,10 +827,17 @@
>                                        gnc_commodity_get_fraction (currency),
>                                        GNC_RND_ROUND);
>  
> +	    if (gsr->value_label != NULL)
> +	       {
>              xaccSPrintAmount (string, amount, print_info);
>  
>              gnc_set_label_color (gsr->value_label, amount);
>              gtk_label_set_text (GTK_LABEL (gsr->value_label), string);
> +	       }
> +	    if (gsr->profit_label != NULL)
> +	       {
> +		  
> +	       }
>  
>              gnc_price_unref (price);
>            }
> @@ -1871,6 +1895,7 @@
>    gsr->projectedminimum_label  = NULL;
>    gsr->shares_label     = NULL;
>    gsr->value_label      = NULL;
> +  gsr->profit_labal       = NULL;
>  
>    if ( gnc_ledger_display_type(gsr->ledger) >= LD_SUBACCOUNT ) {
>      gsr->summarybar = NULL;
> @@ -1911,6 +1936,7 @@
>    {
>      gsr->shares_label     = add_summary_label (summarybar, _("Shares:"));
>      gsr->value_label      = add_summary_label (summarybar, _("Current Value:"));
> +    gsr->profit_label       = add_summary_label (summarybar, _("Profit:"));
>    }
>  
>    gsr->summarybar = summarybar;
> diff -urb gnucash-1.8.5/src/gnome/gnc-split-reg.h /home/Sources/gnucash-1.8.5/src/gnome/gnc-split-reg.h
> --- gnucash-1.8.5/src/gnome/gnc-split-reg.h	2003-06-25 06:27:49.000000000 +0200
> +++ /home/Sources/gnucash-1.8.5/src/gnome/gnc-split-reg.h	2003-09-04 16:34:24.000000000 +0200
> @@ -115,6 +115,7 @@
>    GtkWidget *projectedminimum_label;
>    GtkWidget *shares_label;
>    GtkWidget *value_label;
> +  GtkWidget *profit_label;
>  
>    /** The current ledger display. **/
>    GNCLedgerDisplay *ledger;
> #v-
> 
> Bye, Jörg.
> 
> 
>>Christian
>>-----BEGIN PGP SIGNATURE-----
>>Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
>>
>>iQCVAwUBPyxO/2XAi+BfhivFAQEf6AP+KmXRAnmq88LNlGhPZsy9ty6LAZsoxzo8
>>N/a3n5IjDo1Ss2WXhVaS14o8CU9cgUpSkuaBRlPA1US2nr/fF4tS46rpcemxdPN0
>>U8EGaemJbce+ugVwgV855+FKpZcICsMSghjfk4nAQvXDD0GD43ZOwpCdERxqR1zb
>>fzdF+hU7xSI=
>>=nQu7
>>-----END PGP SIGNATURE-----
>>
>>_______________________________________________
>>gnucash-de mailing list
>>gnucash-de at lists.gnucash.org
>>https://lists.gnucash.org/mailman/listinfo/gnucash-de
>>
> 
> 
> end.