Re: [gnome-db] Need Help for libgdata in GTK programing

Vivien Malerba <[email protected]> Mon, 1 Feb 2016 19:53:52 +0100
Newsgroups gmane.comp.gnome.db
Message-ID <CAEP1ZN=8E+Mvd8CfLE6XuL7VOxUtVMkPO5zij7DEA_2YZUiB+g@mail.gmail.com>
--===============6545853244614962846==
Content-Type: multipart/alternative; boundary=001a11c30ff4f9286d052ab9e7a9

--001a11c30ff4f9286d052ab9e7a9
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi!

The gda_data_model_dump_as_string() creates a string which contains the
whole datamodel's values(it's mainly intended for debugging), basically
gda_data_modeil_dump() is just a wrapper around that function.

You should use:
const GValue *value;
value =3D gda_data_model_get_value_at (model, 0, 0, &error);
if (! value)

gchar *str;
str =3D gda_value_stringify (value)



2016-01-31 18:08 GMT+01:00 Nihsant Chawre <[email protected]>:

> Hello Sir,
> I am fresher in development for linux.
>
> I know this is very basic and silly question, but i stuck here.
>
> I am trying to set the text of lable with the value whatever is returned =
by
> database select query, i.e. label should be set as "vedesa1" but is getti=
ng
> set as "shopid =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=
=94=80vedesa1(1 row)"
>
> i think i need to use "gda_data_model_get_value_at" function to get the
> sting "vedes1"  , but somehow with lack of experience i am not ablw to us=
e
> it, cam someone please help me out
>
>
>
> * Table shop contailns single entry as
>
> shopid
> =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80
> vedesa1
>
>
>
>
> * command line used to compile the code is
> gcc `pkg-config --cflags gtk+-3.0`  -o SAMPLE SAMPLE.c `pkg-config --libs
> gtk+-3.0` `pkg-config --cflags --libs libgda-5.0`
>
>
> *  existing code  snipet is as follows
>
> GdaDataModel *data_model0 , *data_model1;
> GdaSqlParser *parser;
> GdaStatement *stmt0 , *stmt1;
> gchar *sql1 =3D "SELECT shopid  FROM shop";
> GError *error =3D NULL;
> GValue *value1;
>
> parser =3D g_object_get_data (G_OBJECT (cnc), "parser");
>
> stmt1 =3D gda_sql_parser_parse_string (parser, sql1, NULL, NULL);
>
> data_model1 =3D gda_connection_statement_execute_select (cnc, stmt1, NULL=
,
> &error);
> g_object_unref (stmt1);
> if (!data_model1)
>                 g_error ("Could not get the contents of the 'products'
> table: %s\n",error && error->message ? error->message : "No detail");
>
>         g_print("above gda_data_model_dump \n");
>         gda_data_model_dump (data_model1, stdout);
>
>
>         g_print ("\nin g_print %s",
> gda_data_model_dump_as_string(data_model1));
>
>
> (GTK_ENTRY(entry1),gda_data_model_dump_as_string(data_model1));
>         gtk_entry_set_text (GTK_ENTRY(entry1),value1);
>
> _______________________________________________
> gnome-db-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/gnome-db-list
>

--001a11c30ff4f9286d052ab9e7a9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:arial,he=
lvetica,sans-serif">Hi!<br><br></div><div class=3D"gmail_default" style=3D"=
font-family:arial,helvetica,sans-serif">The gda_data_model_dump_as_string()=
 creates a string which contains the whole datamodel&#39;s values(it&#39;s =
mainly intended for debugging), basically gda_data_modeil_dump() is just a =
wrapper around that function.<br><br></div><div class=3D"gmail_default" sty=
le=3D"font-family:arial,helvetica,sans-serif">You should use:<br></div><div=
 class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif">c=
onst GValue *value;<br></div><div class=3D"gmail_default" style=3D"font-fam=
ily:arial,helvetica,sans-serif">value =3D gda_data_model_get_value_at (mode=
l, 0, 0, &amp;error);<br></div><div class=3D"gmail_default" style=3D"font-f=
amily:arial,helvetica,sans-serif">if (! value)<br><br></div><div class=3D"g=
mail_default" style=3D"font-family:arial,helvetica,sans-serif">gchar *str;<=
br></div><div class=3D"gmail_default" style=3D"font-family:arial,helvetica,=
sans-serif">str =3D gda_value_stringify (value)<br></div><div class=3D"gmai=
l_default" style=3D"font-family:arial,helvetica,sans-serif"><br><br></div><=
/div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">2016-01-31 1=
8:08 GMT+01:00 Nihsant Chawre <span dir=3D"ltr">&lt;<a href=3D"mailto:nisha=
[email protected]" target=3D"_blank">[email protected]</a>&gt;</sp=
an>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border=
-left:1px #ccc solid;padding-left:1ex">Hello Sir,<br>
I am fresher in development for linux.<br>
<br>
I know this is very basic and silly question, but i stuck here.<br>
<br>
I am trying to set the text of lable with the value whatever is returned by=
<br>
database select query, i.e. label should be set as &quot;vedesa1&quot; but =
is getting<br>
set as &quot;shopid =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80vedesa1(1 row)&quot;<br>
<br>
i think i need to use &quot;gda_data_model_get_value_at&quot; function to g=
et the<br>
sting &quot;vedes1&quot;=C2=A0 , but somehow with lack of experience i am n=
ot ablw to use<br>
it, cam someone please help me out<br>
<br>
<br>
<br>
* Table shop contailns single entry as<br>
<br>
shopid<br>
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80<br>
vedesa1<br>
<br>
<br>
<br>
<br>
* command line used to compile the code is<br>
gcc `pkg-config --cflags gtk+-3.0`=C2=A0 -o SAMPLE SAMPLE.c `pkg-config --l=
ibs<br>
gtk+-3.0` `pkg-config --cflags --libs libgda-5.0`<br>
<br>
<br>
*=C2=A0 existing code=C2=A0 snipet is as follows<br>
<br>
GdaDataModel *data_model0 , *data_model1;<br>
GdaSqlParser *parser;<br>
GdaStatement *stmt0 , *stmt1;<br>
gchar *sql1 =3D &quot;SELECT shopid=C2=A0 FROM shop&quot;;<br>
GError *error =3D NULL;<br>
GValue *value1;<br>
<br>
parser =3D g_object_get_data (G_OBJECT (cnc), &quot;parser&quot;);<br>
<br>
stmt1 =3D gda_sql_parser_parse_string (parser, sql1, NULL, NULL);<br>
<br>
data_model1 =3D gda_connection_statement_execute_select (cnc, stmt1, NULL,<=
br>
&amp;error);<br>
g_object_unref (stmt1);<br>
if (!data_model1)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 g_error (&quot;Coul=
d not get the contents of the &#39;products&#39;<br>
table: %s\n&quot;,error &amp;&amp; error-&gt;message ? error-&gt;message : =
&quot;No detail&quot;);<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 g_print(&quot;above gda_data_model_dump \n&quot=
;);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 gda_data_model_dump (data_model1, stdout);<br>
<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 g_print (&quot;\nin g_print %s&quot;, gda_data_=
model_dump_as_string(data_model1));<br>
<br>
<br>
(GTK_ENTRY(entry1),gda_data_model_dump_as_string(data_model1));<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 gtk_entry_set_text (GTK_ENTRY(entry1),value1);<=
br>
<br>
_______________________________________________<br>
gnome-db-list mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]</a><br>
<a href=3D"https://mail.gnome.org/mailman/listinfo/gnome-db-list" rel=3D"no=
referrer" target=3D"_blank">https://mail.gnome.org/mailman/listinfo/gnome-d=
b-list</a><br>
</blockquote></div><br></div>

--001a11c30ff4f9286d052ab9e7a9--

--===============6545853244614962846==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
gnome-db-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnome-db-list

--===============6545853244614962846==--