Re: REMINDER: List moved to Discourse; archival in 1 week

2019-04-29 Thread Osmo Antero via gtk-app-devel-list
I go down with the boat.

Emmanuele Bassi via gtk-app-devel-list 
escreveu no dia quarta, 24/04/2019 à(s) 12:36:

> Hi all;
>
> next week, on May 1st, this list will be archived[0]. This means no new
> subscriptions, and no new email.
>
> If you have questions about GTK, GLib, and the rest of the core GNOME
> development platform, you can use the Discourse[1] instance hosted on GNOME
> infrastructure; we have a Platform/Core category, and we can use
> appropriate tags that you can watch[2] and filter on.
>
> You can use existing single-sign on systems, like Google and Github, to
> authenticate yourself; if you have a GNOME LDAP account already, you're
> strongly encouraged to use that method of authentication.
>
> You can still use email to interact with Discourse, and a guide is
> available[3] to configure your account.
>
> If you have any questions or feedback on Discourse, please use the
> appropriate category[4].
>
> Ciao,
>  Emmanuele.
>
> [0]:
> https://mail.gnome.org/archives/gtk-devel-list/2019-March/msg00024.html
> [1]: https://discourse.gnome.org
> [2]: https://discourse.gnome.org/t/tags-and-watching/94
> [3]: https://discourse.gnome.org/t/interacting-with-discourse-via-email/46
> [4]: https://discourse.gnome.org/c/site-feedback
>
> --
> https://www.bassi.io
> [@] ebassi [@gmail.com]
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>


-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

GtkTreeView. How to hide or show an individual cell in a row

2019-04-06 Thread Osmo Antero via gtk-app-devel-list
Hello,
I am making a GTK3 application with GtkTreeView listing.
The simple listing will show country flags + names and number of
radio-channels (to later choose from).

I want to show a button or icon in a column (in the cell) when the row has
been selected.
Otherwise the cell should be empty (button/icon is hidden).

So I want to show the cell content when row is selected, otherwise hide it
(hide the button).
How to do this?
Please be generous with examples and explanation, especially if you refer
to CSS and internal layouts of cell renderers.

Here is an example GTK3 application with GtkTreeView (sortable and
filterable view) with some data.
The sample shows a “small-arrow.png” icon in the last column. This is the
cell I want to hide/show depending on the row is/is not selected.

Sample code: test1.c and small-arrow.png
Get them from:
https://drive.google.com/drive/folders/1JfCzZPPKvtT13bIwu-dgqvKD_zwDySnt?usp=sharing

// Compile and link it
gcc -Wall -o test1 test1.c $(pkg-config --cflags --libs gtk±3.0)

// Run it
./test1

Same question on Discourse.GNOME:
https://discourse.gnome.org/t/gtktreeview-how-to-hide-or-show-an-individual-cell-in-a-row/739

Cumprimentos
Osmo Moma Antero
Wine tasting lad in
Portugal

-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Finding .desktop file and application info

2019-03-04 Thread Osmo Antero via gtk-app-devel-list
Hello,
Yes,  g_desktop_app_info_search() is exactly what I need.
I will test it later.

Thanks a lot for your help.
// Moma

tito-wolit  escreveu no dia segunda, 4/03/2019 à(s)
06:59:

>
>
> On 3/3/19 9:53 PM, Osmo Antero wrote:
> > Hello Tito,
> > Muito obrigado.
> > Thank you, the call with "kde4-" worked fine.
> >
> > However,  the "DesktopEntry" value from Amarok/DBus does not contain the
> "kde4" part.
> > Please see the MRIS2-spec:
> https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry
> > My application cannot guess that it must include the "kde4" to get a
> valid .desktop file.
> > I think g_desktop_app_info_new() should also browse all sub-directories,
> but is does not.
>
> Hi,
>
> GDesktopAppInfo *app_info =
> g_desktop_app_info_new("org.kde.amarok.desktop");
> if (app_info == NULL )
> app_info = g_desktop_app_info_new("kde-org.kde.amarok.desktop");
> if (app_info == NULL )
> app_info = g_desktop_app_info_new("kde2-org.kde.amarok.desktop");
> if (app_info == NULL )
> app_info = g_desktop_app_info_new("kde3-org.kde.amarok.desktop");
> if (app_info == NULL )
> app_info = g_desktop_app_info_new("kde4-org.kde.amarok.desktop");
> if (app_info == NULL )
> app_info = g_desktop_app_info_new("kde5-org.kde.amarok.desktop");
> else
> puts("can't find org.kde.amarok.desktop")
>
> BTW: debian does set only:
>
> XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
>
> maybe g_desktop_app_info_search ("amarok");
> and then app_info = g_desktop_app_info_new(**strv);
>
> g_desktop_app_info_search ()
>
> gchar ***
> g_desktop_app_info_search (const gchar *search_string);
>
> Searches desktop files for ones that match search_string .
>
> The return value is an array of strvs. Each strv contains a list of
> applications that matched search_string with an equal score.
> The outer list is sorted by score so that the first strv contains the
> best-matching applications, and so on.
> The algorithm for determining matches is undefined and may change at any
> time.
>
> Ciao,
> Tito
>
> > One possible solutions is this:
> > The application should find the real location and path of
> "org.kde.amarok.desktop".
> > The "locate" command does the same thing.
> > My app cannot call "locate" directly because it depends on "sudo
> updatedb".
> > I will write my own routine that dives to usr/share/applications/ and
> its sub folders.
> > This is my best shot !
> >
> > Then the app can call:
> > GDesktopAppInfo *g_desktop_app_info_new_from_filename(const char
> *filename);
> >
> > My very old app is this: (the latest is v3.0.2)
> > https://launchpad.net/~audio-recorder
> >
> > Thanks,
> > Obrigado e boa noite.
> > // Moma
> > Portugal
> >
> >
> >
> >
> > tito-wolit via gtk-app-devel-list  gtk-app-devel-list@gnome.org>> escreveu no dia domingo, 3/03/2019 à(s)
> 19:42:
> >
> >
> >
> > On 3/3/19 6:36 PM, Osmo Antero via gtk-app-devel-list wrote:
> >  > Hello,
> >  > I have an application that uses g_desktop_app_info_new() function
> to
> >  > find GDesktopAppInfo.
> >  >
> >  > I just wonder why the g_desktop_app_info_new() FAILS to find the
> >  > GDesktopAppInfo if the .desktop file is in a sub directory
> >  > under usr/share/applications/.
> >  >
> >  > So this fails:
> >  > GDesktopAppInfo *app_info =
> g_desktop_app_info_new("org.kde.amarok.desktop")
> >
> > hi,
> > try:
> >
> > GDesktopAppInfo *app_info =
> g_desktop_app_info_new("kde4-org.kde.amarok.desktop")
> >
> > ciao,
> > Tito
> >
> >  > If the "org.kde.amarok.desktop" file is located in:
> >  > /usr/share/applications/kde4/org.kde.amarok.desktop
> >  > This is the default location of Amarok player.
> >  > ---
> >  > Then I move the file "org.kde.amarok.desktop"  to
> /usr/share/applications/.
> >  >
> >  > $ sudo mv /usr/share/applications/kde4/org.kde.amarok.desktop
> >  > /usr/share/applications/org.kde.amarok.desktop
> >  >
> >  > $ sudo updatedb
> >  > $ locate org.kde.amarok.desktop
> >  > /usr/share/applications/org

Re: Finding .desktop file and application info

2019-03-03 Thread Osmo Antero via gtk-app-devel-list
Btw:
Totem (GNOME `s Video Player) has very similar problem.
It «lies» about its .desktop file name. It says "totem" instead of
"org.gnome.Totem".
My app asks for it via DBus/MPRIS2 and gets wrong data.

$ locate -i totem | grep ".desktop"
/usr/share/applications/org.gnome.Totem.desktop

It is hard to co-operate on the Desktop when apps do stick to the damn
rules.

Boa noite,
  Moma

Osmo Antero  escreveu no dia domingo, 3/03/2019 à(s)
21:05:

>
> Osmo Antero
> 20:53 (há 11 minutos)
> para tito-wolit
>
> Hello Tito,
> Muito obrigado.
> Thank you, the call with "kde4-" worked fine.
>
> However,  the "DesktopEntry" value from Amarok/DBus does not contain the
> "kde4" part.
> Please see the MRIS2-spec:
> https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry
>
> My application cannot guess that it must include the "kde4" to get a valid
> .desktop file.
> I think g_desktop_app_info_new() should also browse all sub-directories,
> but is does not.
>
> One possible solutions is this:
> The application should find the real location and path of
> "org.kde.amarok.desktop".
> The "locate" command does the same thing.
> My app cannot call "locate" directly because it depends on "sudo
> updatedb".
> I will write my own routine that dives to usr/share/applications/ and its
> sub folders.
> This is my best shot !
>
> Then the app can call:
> GDesktopAppInfo *g_desktop_app_info_new_from_filename(const char
> *filename);
>
> My very old app is this: (the latest is v3.0.2)
> https://launchpad.net/~audio-recorder
>
> Thanks,
> Obrigado e boa noite.
> // Moma
> Portugal
>
> tito-wolit via gtk-app-devel-list  escreveu
> no dia domingo, 3/03/2019 à(s) 19:42:
>
>>
>>
>> On 3/3/19 6:36 PM, Osmo Antero via gtk-app-devel-list wrote:
>> > Hello,
>> > I have an application that uses g_desktop_app_info_new() function to
>> > find GDesktopAppInfo.
>> >
>> > I just wonder why the g_desktop_app_info_new() FAILS to find the
>> > GDesktopAppInfo if the .desktop file is in a sub directory
>> > under usr/share/applications/.
>> >
>> > So this fails:
>> > GDesktopAppInfo *app_info =
>> g_desktop_app_info_new("org.kde.amarok.desktop")
>>
>> hi,
>> try:
>>
>> GDesktopAppInfo *app_info =
>> g_desktop_app_info_new("kde4-org.kde.amarok.desktop")
>>
>> ciao,
>> Tito
>>
>> > If the "org.kde.amarok.desktop" file is located in:
>> > /usr/share/applications/kde4/org.kde.amarok.desktop
>> > This is the default location of Amarok player.
>> > ---
>> > Then I move the file "org.kde.amarok.desktop"  to
>> /usr/share/applications/.
>> >
>> > $ sudo mv /usr/share/applications/kde4/org.kde.amarok.desktop
>> > /usr/share/applications/org.kde.amarok.desktop
>> >
>> > $ sudo updatedb
>> > $ locate org.kde.amarok.desktop
>> > /usr/share/applications/org.kde.amarok.desktop
>> >
>> > Now the call succeeds. It returns GDesktopAppInfo structure.
>> > GDesktopAppInfo *app_info =
>> g_desktop_app_info_new("org.kde.amarok.desktop")
>> >
>> > Something is wrong, because the manual says that the desktop file can
>> stay
>> > in a sub directory:
>> >
>> > """"
>> > g_desktop_app_info_new ()
>> > GDesktopAppInfo * g_desktop_app_info_new (const char *desktop_id);
>> >
>> > Creates a new GDesktopAppInfo based on a desktop file id.
>> >
>> > A desktop file id is the basename of the desktop file, including the
>> > .desktop extension. GIO is looking for a desktop file with this name in
>> the
>> > applications subdirectories of the XDG data directories (i.e. the
>> > directories specified in the XDG_DATA_HOME and XDG_DATA_DIRS environment
>> > variables). GIO also supports the prefix-to-subdirectory mapping that is
>> > described in the Menu Spec (i.e. a desktop id of kde-foo.desktop will
>> > match/usr/share/applications/kde/foo.desktop).
>> > """"
>> >
>> > Just for info:
>> > My application gets the "org.kde.amarok.desktop" name from Amarok via
>> the
>> > MPRIS2 DBus-interface.  Please see "DesktopEntry" of
>> >
>> https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry
>> >
>> > Please educate me.
>> >
>> > Kindly
>> >Osmo Moma Antero
>> >Portugal
>> >
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>
>
>
> --
> Sent from my PC, laptop or phone with Ubuntu-Linux.
>


-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Finding .desktop file and application info

2019-03-03 Thread Osmo Antero via gtk-app-devel-list
Osmo Antero
20:53 (há 11 minutos)
para tito-wolit

Hello Tito,
Muito obrigado.
Thank you, the call with "kde4-" worked fine.

However,  the "DesktopEntry" value from Amarok/DBus does not contain the
"kde4" part.
Please see the MRIS2-spec:
https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry

My application cannot guess that it must include the "kde4" to get a valid
.desktop file.
I think g_desktop_app_info_new() should also browse all sub-directories,
but is does not.

One possible solutions is this:
The application should find the real location and path of
"org.kde.amarok.desktop".
The "locate" command does the same thing.
My app cannot call "locate" directly because it depends on "sudo updatedb".
I will write my own routine that dives to usr/share/applications/ and its
sub folders.
This is my best shot !

Then the app can call:
GDesktopAppInfo *g_desktop_app_info_new_from_filename(const char *filename);

My very old app is this: (the latest is v3.0.2)
https://launchpad.net/~audio-recorder

Thanks,
Obrigado e boa noite.
// Moma
Portugal

tito-wolit via gtk-app-devel-list  escreveu
no dia domingo, 3/03/2019 à(s) 19:42:

>
>
> On 3/3/19 6:36 PM, Osmo Antero via gtk-app-devel-list wrote:
> > Hello,
> > I have an application that uses g_desktop_app_info_new() function to
> > find GDesktopAppInfo.
> >
> > I just wonder why the g_desktop_app_info_new() FAILS to find the
> > GDesktopAppInfo if the .desktop file is in a sub directory
> > under usr/share/applications/.
> >
> > So this fails:
> > GDesktopAppInfo *app_info =
> g_desktop_app_info_new("org.kde.amarok.desktop")
>
> hi,
> try:
>
> GDesktopAppInfo *app_info =
> g_desktop_app_info_new("kde4-org.kde.amarok.desktop")
>
> ciao,
> Tito
>
> > If the "org.kde.amarok.desktop" file is located in:
> > /usr/share/applications/kde4/org.kde.amarok.desktop
> > This is the default location of Amarok player.
> > ---
> > Then I move the file "org.kde.amarok.desktop"  to
> /usr/share/applications/.
> >
> > $ sudo mv /usr/share/applications/kde4/org.kde.amarok.desktop
> > /usr/share/applications/org.kde.amarok.desktop
> >
> > $ sudo updatedb
> > $ locate org.kde.amarok.desktop
> > /usr/share/applications/org.kde.amarok.desktop
> >
> > Now the call succeeds. It returns GDesktopAppInfo structure.
> > GDesktopAppInfo *app_info =
> g_desktop_app_info_new("org.kde.amarok.desktop")
> >
> > Something is wrong, because the manual says that the desktop file can
> stay
> > in a sub directory:
> >
> > """"
> > g_desktop_app_info_new ()
> > GDesktopAppInfo * g_desktop_app_info_new (const char *desktop_id);
> >
> > Creates a new GDesktopAppInfo based on a desktop file id.
> >
> > A desktop file id is the basename of the desktop file, including the
> > .desktop extension. GIO is looking for a desktop file with this name in
> the
> > applications subdirectories of the XDG data directories (i.e. the
> > directories specified in the XDG_DATA_HOME and XDG_DATA_DIRS environment
> > variables). GIO also supports the prefix-to-subdirectory mapping that is
> > described in the Menu Spec (i.e. a desktop id of kde-foo.desktop will
> > match/usr/share/applications/kde/foo.desktop).
> > """"
> >
> > Just for info:
> > My application gets the "org.kde.amarok.desktop" name from Amarok via the
> > MPRIS2 DBus-interface.  Please see "DesktopEntry" of
> >
> https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry
> >
> > Please educate me.
> >
> > Kindly
> >Osmo Moma Antero
> >Portugal
> >
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>


-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Finding .desktop file and application info

2019-03-03 Thread Osmo Antero via gtk-app-devel-list
Hello,
I have an application that uses g_desktop_app_info_new() function to
find GDesktopAppInfo.

I just wonder why the g_desktop_app_info_new() FAILS to find the
GDesktopAppInfo if the .desktop file is in a sub directory
under usr/share/applications/.

So this fails:
GDesktopAppInfo *app_info = g_desktop_app_info_new("org.kde.amarok.desktop")
If the "org.kde.amarok.desktop" file is located in:
/usr/share/applications/kde4/org.kde.amarok.desktop
This is the default location of Amarok player.
---
Then I move the file "org.kde.amarok.desktop"  to /usr/share/applications/.

$ sudo mv /usr/share/applications/kde4/org.kde.amarok.desktop
/usr/share/applications/org.kde.amarok.desktop

$ sudo updatedb
$ locate org.kde.amarok.desktop
/usr/share/applications/org.kde.amarok.desktop

Now the call succeeds. It returns GDesktopAppInfo structure.
GDesktopAppInfo *app_info = g_desktop_app_info_new("org.kde.amarok.desktop")

Something is wrong, because the manual says that the desktop file can stay
in a sub directory:


g_desktop_app_info_new ()
GDesktopAppInfo * g_desktop_app_info_new (const char *desktop_id);

Creates a new GDesktopAppInfo based on a desktop file id.

A desktop file id is the basename of the desktop file, including the
.desktop extension. GIO is looking for a desktop file with this name in the
applications subdirectories of the XDG data directories (i.e. the
directories specified in the XDG_DATA_HOME and XDG_DATA_DIRS environment
variables). GIO also supports the prefix-to-subdirectory mapping that is
described in the Menu Spec (i.e. a desktop id of kde-foo.desktop will
match/usr/share/applications/kde/foo.desktop).


Just for info:
My application gets the "org.kde.amarok.desktop" name from Amarok via the
MPRIS2 DBus-interface.  Please see "DesktopEntry" of
https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry

Please educate me.

Kindly
  Osmo Moma Antero
  Portugal

-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Searching for text in PDF files is wrong

2018-12-19 Thread Osmo Antero via gtk-app-devel-list
Re-hi,

I think the mark_text(...) function can be simplified.
Check also open_page(...).

Ref: https://pastebin.com/52dU2kv8

Feliz Natal
Moma

Osmo Antero  escreveu no dia quarta, 19/12/2018 à(s)
20:08:

> Hello,
>
> This code might work even you resize the window.
> Please see: https://pastebin.com/GJMPwLU3
>
> It draws the selected text in the "draw" event.
>
> ps. I hard coded the PDF_DOC and FIND_TEXT values.
>
> Feliz Natal,
>   moma, Portugal
>
> Marius Gedminas  escreveu no dia segunda, 3/12/2018
> à(s) 17:12:
>
>> On Fri, Nov 30, 2018 at 09:56:12PM +0100, Радомир Хаџић via
>> gtk-app-devel-list wrote:
>> > I use poppler_page_find_text() to find text in PDF files. This returns
>> > GList of pointers to PopplerRectangles. Then I use
>> > poppler_page_render_selection() to mark the found text.
>> >
>> > What is wrong is that PopplerRectangles returned by
>> > poppler_page_find_text() are incompatible with those that
>> > poppler_page_render_selection() requests, which is why the wrong text
>> > is selected.
>> >
>> > I have found that to make those two compatible, I have to do the
>> > following to PopplerRectangles returned by poppler_page_find_text():
>> > 1) SWAP(rectangle.x1, rectangle.x2);
>> > 2) SWAP(rectangle.y1, rectangle.y2);
>> > 3) rectangle.y1 = page_height - rectangle.y1;
>> > 4) rectangle.y2 = page_height - rectangle.y2;
>> > But this does not solve the problem because the marked text cycles
>> > between right and wrong again while resizing the window.
>>
>> > is: https://pastebin.com/h3F56Yv7
>>
>> You're doing in-place coordinate conversions in your drawing code.
>> Every expose event will change the coordinates event, which is why
>> you're seeing the flip-flopping.
>>
>> Do the conversion only once, or use a local temporary PopplerRectangle
>> variable and avoid in-place conversions.
>>
>> (I'm not familiar with poppler's APIs and cannot say if your conversion
>> code is correct.)
>>
>> HTH,
>> Marius Gedminas
>> --
>> Lutetium is the heaviest and hardest of the rare earth metals, and is
>> used in
>> the production of umlauts and other fraktur font features.
>> -- Charles Stross
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
>
>
> --
> Sent from my PC, laptop or phone with Ubuntu-Linux.
>


-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Searching for text in PDF files is wrong

2018-12-19 Thread Osmo Antero via gtk-app-devel-list
Hello,

This code might work even you resize the window.
Please see: https://pastebin.com/GJMPwLU3

It draws the selected text in the "draw" event.

ps. I hard coded the PDF_DOC and FIND_TEXT values.

Feliz Natal,
  moma, Portugal

Marius Gedminas  escreveu no dia segunda, 3/12/2018 à(s)
17:12:

> On Fri, Nov 30, 2018 at 09:56:12PM +0100, Радомир Хаџић via
> gtk-app-devel-list wrote:
> > I use poppler_page_find_text() to find text in PDF files. This returns
> > GList of pointers to PopplerRectangles. Then I use
> > poppler_page_render_selection() to mark the found text.
> >
> > What is wrong is that PopplerRectangles returned by
> > poppler_page_find_text() are incompatible with those that
> > poppler_page_render_selection() requests, which is why the wrong text
> > is selected.
> >
> > I have found that to make those two compatible, I have to do the
> > following to PopplerRectangles returned by poppler_page_find_text():
> > 1) SWAP(rectangle.x1, rectangle.x2);
> > 2) SWAP(rectangle.y1, rectangle.y2);
> > 3) rectangle.y1 = page_height - rectangle.y1;
> > 4) rectangle.y2 = page_height - rectangle.y2;
> > But this does not solve the problem because the marked text cycles
> > between right and wrong again while resizing the window.
>
> > is: https://pastebin.com/h3F56Yv7
>
> You're doing in-place coordinate conversions in your drawing code.
> Every expose event will change the coordinates event, which is why
> you're seeing the flip-flopping.
>
> Do the conversion only once, or use a local temporary PopplerRectangle
> variable and avoid in-place conversions.
>
> (I'm not familiar with poppler's APIs and cannot say if your conversion
> code is correct.)
>
> HTH,
> Marius Gedminas
> --
> Lutetium is the heaviest and hardest of the rare earth metals, and is used
> in
> the production of umlauts and other fraktur font features.
> -- Charles Stross
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

How to replace gtk_image_menu_item_new_from_stock() in GTK3

2014-03-08 Thread Osmo Antero
Hello,

My application has used gtk_image_menu_item_new_from_stock(GTK_STOCK_XXX, )
to create menu items, but this function is now deprecated in the newest
GTK3.

The new method gtk_menu_item_new_with_mnemonic() requires me to translate
the menu label to many languages.

Why should I translate common menu labels like E_xit, _Quit and
_About?

// This is deprecated in GTK 3.
// menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT,
NULL);

// New method
menu_item = gtk_menu_item_new_with_mnemonic (_(_About));

[[
warning: 'gtk_image_menu_item_new_from_stock' is deprecated (declared at
/usr/include/gtk-3.0/gtk/deprecated/gtkimagemenuitem.h:78): Use
'gtk_menu_item_new' instead [-Wdeprecated-declarations]
menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL);

warning: 'GtkStock' is deprecated [-Wdeprecated-declarations]
]]

My app:
https://launchpad.net/audio-recorder

Please enlighten me,
  Osmo Antero
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Delay time to spawn new threads?

2013-11-28 Thread Osmo Antero
My audio-recorder that was based on GTK2 had some threads that also
modified the GUI-elements. I had to call
GDK_THREADS_ENTERhttps://developer.gnome.org/gdk3/3.10/gdk3-Threads.html#GDK-THREADS-ENTER:CAPS
 / 
GDK_THREADS_LEAVEhttps://developer.gnome.org/gdk3/3.10/gdk3-Threads.html#GDK-THREADS-ENTER:CAPS
 before modifying the GTK-elements, otherwise the GUI froze.

Now in GTK3, I've replaced the threads with
g_timeout_add_fullhttps://developer.gnome.org/glib/2.30/glib-The-Main-Event-Loop.html#g-timeout-add-full
() and 
GAsyncQueuehttps://developer.gnome.org/glib/2.26/glib-Asynchronous-Queues.html#GAsyncQueue
.
g_timeout_full_id() runs within the MainLoop so GUI-locking is handled
automatically.

The code is here:
http://bazaar.launchpad.net/~osmoma/audio-recorder/trunk/view/head:/src/rec-manager.c
The recorder receives commands (like: start/stop/pause/etc.) from various
modules and sources. All commands go through the GAsyncQueue.

 Bom dia
   Osmo (Moma) Antero


On Thu, Nov 28, 2013 at 3:32 AM, David Buchan pdbuc...@yahoo.com wrote:



 David Buchan pdbuc...@yahoo.com wrote:
  Hi Michael,
 
  My 32-bit, GTK+2 version does
 
// Secure glib
if (!g_thread_supported ()) {
  g_thread_init (NULL);
}
 
  at the beginning, and then the thread is spawned via:
 
 
  on_button1_clicked (GtkButton *button1, MyData *data)
  {
GThread *thread;
GError *error = NULL;
 
thread = g_thread_create ((GThreadFunc) my_function, data, FALSE,
  error); if (! thread) {
g_print (Error: Unable to create new thread for my_function()
  in on_button1_clicked().%s\n, error-message); exit (EXIT_FAILURE);
  }
 
  My 64-bit, GTK+3 versions does not do the g_thread_init() call.
 
  It spawns a new thread via:
 
  int
  on_button1_clicked (GtkButton *button1, MyData *data)
  {
GThread *thread;
 
thread = g_thread_new (my_function, (GThreadFunc) my_function,
  data); if (! thread) {
fprintf (stderr, Error: Unable to create new thread for
  my_function() in on_button1_clicked().\n); exit (EXIT_FAILURE);
  }

 Show us your my_function(): you are almost certainly doing something
 wrong. Best of all, provide a complete compilable example which
 demonstrates the problem. And why are you casting the function pointer
 to GThreadFunc?  You do not need to call g_thread_init() with glib =
 2.32, and you do with earlier versions. Prior to version 2.24
 g_thread_init() had to be the first glib call. Between 2.24 and 2.30 it
 had to be the first
  call relevant to threads.

 Also, please don't top post.

 Chris
 ==
 Hi Chris,


 I removed the call to g_thread_init() and it still works fine! Great catch
 there.

 I had put the cast to GThreadFunc there because otherwise I get the
 following error:

 callbacks.c: In function ‘on_button1_clicked’:
 callbacks.c:3829: warning: passing argument 1 of ‘g_thread_create_full’
 from incompatible pointer type
 /usr/include/glib-2.0/glib/gthread.h:225: note: expected ‘GThreadFunc’ but
 argument is of type ‘int (*)(struct MyData *)’

 I saw other people on the web do the cast as well to remove that error. Is
 there a mistake in how I use g_thread_create()? I'd like to drop the cast
 if I can. It seemed strange at the time I put it in.

 Top-posting is due to the way Yahoo mail handles replies.
 Maybe this
  is better, but it didn't put the 's in, thus the ... line. I
 dunno. Sorry about that.

 I'm still investigating the delay. The my_function() code is hundreds of
 lines, so I'd need to create a small example to post.
 Let me continue to investigate.

 Dave

 ==
 ... and now I see what's going on.

 My newly spawned thread calls a function which starts a messaging
 idle-function.

 [my main program] --- [my new thread]  [post_message function] ===
 [update GUI idle function]

 In my new thread, I call:

 post_message (text, data);

 and that looks like:

 // Start an instance of activity_message() idle function.
 int
 post_message (char *message, MyData *data)
 {
   // Allocate memory for string; Idle function will free it.
   data-activity_message = allocate_strmem (TEXTLEN);
   // Copy message.
   strncpy (data-activity_message, message, TEXTLEN - 1);  // Minus 1 for
 string termination.

   g_idle_add ((GSourceFunc) activity_message, data);
   sleep (1);
   return (EXIT_SUCCESS);
 }

 // Idle function to add a message to the activity textview
 // This idle function returns 0 in order to stop.
 int
 activity_message (MyData *data)
 {
   ...
   Update a textview with our message ...

   return (0)
 }

 I set it up this way so the GUI can be updated.

 The call to sleep() protects me against the situation in which my thread
 makes a second call to post_message() when activity_message() hasn't
 finished updating the GUI from the first call.

 Is there a way to have my thread call post_message() whenever it needs to,
 and have the messages queue-up?

 Dave
 

Re: gdbus - register handler/object on interface NULL

2013-08-21 Thread Osmo Antero
Hello,
I have made a small server for Audio-Recorder. Take a look at
dbus-server.[ch] modules.
http://bazaar.launchpad.net/~osmoma/audio-recorder/trunk/view/head:/src/

$ audio-recorder --help
can show the commands that can be sent to the server (to set or ask the
recording state).

// Osmo (Moma) Antero


On Wed, Aug 21, 2013 at 6:10 PM, Bernhard Schuster 
schuster.bernh...@googlemail.com wrote:

 I have to deal with a closed source server being based on qt + dbus.
 I try to connect to it via gdbus,glib.
 The connection works as follows:

 A mehod/object called message_handler has to be registered to the bus
 /exported.
 I call a remote method named send_data, afterwards the service/server
 calls the local message_handler. Unfortunately it expects the
 method/object to be at interface NULL, at least that is what I read from
 the dbus-monitor/bustle logs

 g_dbus_connection_register_object does not allow a interface NULL pointer.


 Any help or pointers are appreciated.


 I opened a pretty detailed question on stackoverflow


 http://stackoverflow.com/questions/18357703/dbus-register-object-to-remote-on-interface-null

 Thanks in advance!

 Best

 Bernhard
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




-- 
// moma
   http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GSettings child schemas

2013-03-01 Thread Osmo Antero
Hello,
I will not answer to your question directly, but I have implemented
GSettings schemas for my audio-recorder app.
It may give you some tips. Please take a look at:
http://bazaar.launchpad.net/~osmoma/audio-recorder/trunk/view/head:/src/dconf.c
However, do take grated everything is correct and optimally coded ;-)

The GNOME-desktop uses normally DConf as Gsettings backend. But that's
behind the curtains.

Bom fim de semana.
Osmo Antero


On Fri, Mar 1, 2013 at 10:45 AM, Geert Janssens i...@kobaltwit.be wrote:

 Hi,

 I'm working on replacing GConf with GSettings in the GnuCash application.
 I have read through the GSettings reference documentation and migration
 guide. With that I think I can mostly manage the conversion in the code.

 I'm unsure about the schema conversion though. I used
 gsettings-schema-convert to automatically generate GSettings compatible
 schemas from the existing GConf schemas. I notice that for some schemas the
 conversion tool decided to generate schemas with child schemas.

 For example, after conversion I have these two schemas defined:
 schema id=org.gnucash.general path=/aps/gnucash/general/
 schema id=org.gnucash.general.**register path=/apps/gnucash/general/**
 register/

 (Note: I'm aware I should not use the apps for path, but this is only
 temporary during the conversion.)

 The second schema is marked as a child schema of the first one.

 Yet due to the way our GConf schemas were organized I also have these two
 schemas:
 schema id=org.gnucash.dialogs path=/aps/gnucash/dialogs/
 schema id=org.gnucash.dialogs.sxs path=/apps/gnucash/dialogs/**
 scheduled_trans/

 And while they also share the same path and id prefix, the second is *not*
 marked as a child schema.

 I found the GSettings documentation very thin on the rationale behind
 child schemas and hence I have no idea about what would be best practise
 here.

 Should I attempt to make the schema hierarchy complete, mark schemas as
 children of others wherever I can ?
 Is it illegal to have two schemas of which one is  in a subpath of the
 other without it being a child schema ?
 What benefit do I get from defining child schemas ?

 Any advice here would be greatly appreciated.

 Thanks,

 Geert
 __**_
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/**mailman/listinfo/gtk-app-**devel-listhttps://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




-- 
// moma
   http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK+ 3.6 threading?

2012-10-24 Thread Osmo Antero
Hello,
What if the GSourceFunc blocks for a longer time, eg. for 3 seconds time.
Does it freeze the GUI because it runs within the main-loop?

One possible approach:
My audio-recorder uses a message queue (g_async_queue_new()) to receive
data from various modules and threads.
Ref:
http://bazaar.launchpad.net/~osmoma/audio-recorder/trunk/view/head:/src/rec-manager.c
(notice: this solution is too slow to update a progressbar or levelbar may
times a second).

This message queue is checked continuously by a thread which then updates
the GUI, starts/stops/pauses recording etc.
See the rec_manager_init() function.

Various parts of the program can send messages to the GUI/app by calling:

void rec_manager_send_command(RecorderCommand *cmd) {
// Push command to the queue
g_async_queue_push(g_cmd_queue, (gpointer)cmd);
}

void rec_manager_init() {
LOG_DEBUG(Init rec-manager.c.\n);

// Create a message queue
// Ref: http://www.gtk.org/api/2.6/glib/glib-Asynchronous-Queues.html
g_cmd_queue = g_async_queue_new();

// Message thread within GTK's main loop
// Ref: http://developer.gnome.org/glib/2.31/glib-The-Main-Event-Loop.html
g_thread_id =  g_timeout_add_full(G_PRIORITY_DEFAULT, 200,
rec_manager_command_thread, NULL, NULL);

// Init recorder.c
rec_module_init();
}

Audio-recorder
https://launchpad.net/audio-recorder

Kindly
  Moma Antero


On Wed, Oct 24, 2012 at 4:34 AM, Ardhan Madras ard...@rocksis.net wrote:

 Hi,

  Now that from GTK+ 3.6, thread functions are deprecated.  Is there
any
  new rules to do threading with the gtk+ 3.6 version?

 Are you talking about Glib? yes, there are many changes since 2.32
 (for now stable version is 2.34), from high level view, the changes
 such as new thread creation functions, thread reference counting
 functions, thread synchronization tools, etc. and many other functions
 and macros has been removed.

 In 2.32 and above to create a thread you will use the new
 g_thread_new() or the g_thread_try_new() (previously with
 g_thread_create()), to create synchronization tools for example a
 rwlock then you call g_rwlock_init (previously g_rwlock_new() or
 G_STATIC_RWLOCK_INIT), call g_thread_unref() after you finish with the
 thread.

  I tried */g_main_context_invoke/*, but seems it did not work. I
can't
  update GUI from that GSourceFunc. Maybe is my mistaken use...

 I don't understand why you call g_main_context_invoke() here but If
 you want to call GTK+ functions from your thread, the safe method is
 to wrap the functions to a GSourceFunc and call it with g_idle_add()
 or g_idle_add_full() (from your thread function).

 Regards.


 On Tue, Oct 23, 2012 at 9:43 AM, Weitian Leung just_fa...@live.com
wrote:
  Hi,
  Now that from GTK+ 3.6, thread functions are deprecated.  Is there
any
  new rules to do threading with the gtk+ 3.6 version?
  Just for an example, I want to download many files in background,
and
  show the progress in GUI, how should I do it?
  I tried */g_main_context_invoke/*, but seems it did not work. I
can't
  update GUI from that GSourceFunc. Maybe is my mistaken use...
  Anyone know how? Or just give me some examples.
 
  Sorry for my bad English.
  Thanks.
 
  --
  Weitian
 
  ___
  gtk-app-devel-list mailing list
  gtk-app-devel-list@gnome.org
  https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



 --
 Please do not send me any propriety format such as Microsoft Offices:
 Word, Excel, Power Point, etc. Please use standard non-propriety
 format such as plain text, HTML, PDF or OpenOffices format.

 ROCKSIS | Indonesia
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to draw GtkCellRendererCombo in (inside) a custom cell renderer?

2012-06-06 Thread Osmo Antero
Hello,
I wanted to study the GtkCellRendererCombo so I added it directly to the
treeview (as column).
The combobox is initially hidden, only the text value is shown.
The combo becomes visible after user clicks or double-clicks the column in
the row.

Unfortunately the click event does not work (or pass through) when the
GtkCellRendererCombo is baked inside a custom-renderer class. Therefore it
simply shows the text value, the combo-list itself is not accessible or
visible.

This might explain why GTK3 has NO renderer for very common type of
widgets, like GtkButton.
There is no GtkCellRendererButton class because it cannot handle the events.

I may need to use the low-level painting functions directly, like
gtk_paint_arrow(...)
gtk_paint_shadow(...)
gtk_paint_box(...)
And somehow calculate the co-ordinates for click-events.

Ref: http://developer.gnome.org/gtk3/3.4/GtkStyle.html

All comments are welcome.
// Osmo Antero

/*
Adding GtkCellRendererCombo directly (as column) to the treeview, just to
study its behaviour.

GtkTreeStore *store = gtk_tree_store_new(NUM_COLS,
   G_TYPE_INT,
   G_TYPE_POINTER,
   G_TYPE_STRING); // -- combo text field
...

// Combo cell renderer (directly as column)
renderer = gtk_cell_renderer_combo_new();

GtkTreeIter iter;
GtkListStore *combo_store = gtk_list_store_new (1, G_TYPE_STRING);
gtk_list_store_append(combo_store, iter);
gtk_list_store_set(combo_store, iter, 0, First Item, -1);
gtk_list_store_append(combo_store, iter);
gtk_list_store_set(combo_store, iter, 0, Second Item, -1);

g_object_set (renderer, editable, FALSE,
has-entry, TRUE,
model, combo_store,
text-column, 0,
NULL);

col = gtk_tree_view_column_new();
gtk_tree_view_column_pack_start (col, renderer, TRUE);
gtk_tree_view_column_add_attribute(col, renderer, text, COL_2);
gtk_tree_view_column_set_title (col, Combo);
gtk_tree_view_append_column(GTK_TREE_VIEW(tv),col);
*/


On Tue, Jun 5, 2012 at 8:38 PM, Osmo Antero osm...@gmail.com wrote:

 Hello,
 I want to create my own cell-renderer for a treeview widget.
 This custom cell will contain a text string and a combobox with some
 values.
 So my custom cell (row) contains both GtkCellRendererText and
 GtkCellRendererCombo widgets.

 The cell renderer works well that it displays the text string, but the
 combobox is *invisible*.

 In cell-renderer.c, I carefully get the size of the combobox:
 gtk_cell_renderer_get_preferred_size(p-combo_renderer, widget, NULL,
 size);
 combo_area.width = size.width;
 combo_area.height = size.height;

 And then render it to cell with:
 combo_area.x = title_area.x + title_area.width + GUI_PAD;
 combo_area.y = fill_area.y + (fill_area.height - combo_area.height )/2;
 gtk_cell_renderer_render(p-combo_renderer, window, widget,
 background_area, combo_area, flags);

 See the render_row(...) function in cell-renderer.c file.
 But the p-combo_renderer (of type GtkCellRendererCombo) will not show up.

 The treeview row should display:
  Node 1-0 text  [Combobox with values]
  Node 1-1 text [Combobox with values]
  Node 1-2 text [Combobox with values]
 ...
 What could be wrong with my code?

 Here is a complete example of this:
 http://www.futuredesktop.org/tmp/Test6.tar.gz

 Use the m.sh script to compile it:
 $ ./m.sh

 Then run:
 $ ./main

 You should see this:
 http://bildr.no/view/1197967



 Ref: http://developer.gnome.org/gtk3/stable/GtkCellRendererCombo.html
 GtkCellRendererCombo

 Thanks for all comments.

 Kindly
 Osmo Antero


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Identifying a structure by reading it's first field.

2012-06-02 Thread Osmo Antero
Very good.
This makes code much cleaner because I do not have to send around both the
type field and node separately. Now I simply

void func(gpointer node) {

   switch (NODE_TYPE(node)) {
  case TYPE_1:
  ...
  case TYPE_2:
  ...

}
}

// Osmo Antero

On Sat, Jun 2, 2012 at 6:04 AM, Ernie Wright ern...@comcast.net wrote:

 On 6/1/2012 2:17 PM, Osmo Antero wrote:

  I have couple of C structures that I want to distinguish between by
  reading the structures' first (type) field.  [...]
 
  Q:  Can I assume that the type field is always first in the
  structures, so I can read it with: NodeType type = *(NodeType*)node;

 Yes.  Structure members are stored in the order in which they're
 defined, and a pointer to a structure also points to its first member
 (suitably cast).  This is guaranteed by the C standards.

  but can I trust it on all *nix plattforms and GCC compilers.

 Anything that's standards-compliant.

 - Ernie  http://home.comcast.net/~erniew

 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Identifying a structure by reading it's first field.

2012-06-01 Thread Osmo Antero
Hello,
I have couple of C structures that I want to distinguish between by reading
the structures' first (type) field.

typedef enum {NODE_1, NODE_2} NodeType;

typedef struct {
NodeType type;
gchar *title;
} Group;

typedef struct {
NodeType type;
gchar *url;
gint id;
} Station;

#define NODE_TYPE(node) (*(NodeType*)node)
---

Q:  Can I assume that the type field is always first in the structures,
so I can read it with:
NodeType type = *(NodeType*)node;

The node can be either be Group* or Station*, Source*.
I do not want to use the *union* {} method.
The NODE_TYPE() macro works fine here and now, but can I trust it on all
*nix plattforms and GCC compilers.

Here is a código exemplo:
http://www.futuredesktop.org/tmp/test5.c

Compile and run it:
gcc test5.c -o test5 $(pkg-config --cflags --libs gdk-2.0)
./test5

TIA again.
Osmo Antero
http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Help with a multi-threaded application. Spot a crash.

2012-05-31 Thread Osmo Antero
Hello,
Thank you very much.
I actually commented out pretty much everything but the G_IS_OBJECT().
I took it granted that GRegex was a gobject.
Now learned that it's a POD, Perl Object.

The actual code has also a LockedCounter (mutex controlled) object
that feeds each thread with a unique sequence number. Only the thread
with highest sequence number can tick and change the GUI, others will
simply die away.

Now the project can progress.

Obrigado
 Osmo Antero

On Wed, May 30, 2012 at 9:02 PM, David Nečas y...@physics.muni.cz wrote:
 On Wed, May 30, 2012 at 08:30:40PM +0100, Osmo Antero wrote:
 I have a multi-threaded application that filters data practically
 while user types text in an entry-field. But this applications
 regularly crashes.

 GRegex is not a GObject, it's just POD.  So

    if (G_IS_OBJECT(search-regex))

 will surely attempt to read some bogus memory location and crash.
 I cannot see why such code is there at all but anyway set search-regex
 to NULL if it does not exist and then just use

    if (search-regex)

 if necessary.

 Yeti




-- 
// moma
   http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Help with a multi-threaded application. Spot a crash.

2012-05-30 Thread Osmo Antero
Hello,
I have a multi-threaded application that filters data practically
while user types text in an entry-field. But this applications
regularly crashes. This surprises me because I have done similar code
in another occacion and language. This particular Gtk code is from an
open source app. So

Would you help me to spot this annoying segmentation fault so I
could move on. This seq-fault happens every time.

 $ ./test2
Came here 0
Came here 0
Came here 0
Came here 0
Came here 0
Came here 0
Came here 0
Came here 0
Came here 0
Came here 0
Came here 1
Came here 1
Segmentation fault

Here is a complete test-code which I modelled after the actual
application. It will show the crash.
http://www.futuredesktop.org/tmp/test2.c

Compile it for Gtk2:
gcc -Wall test2.c -o test2 $(pkg-config --cflags --libs gtk+-2.0
gdk-2.0 gthread-2.0)

Or for Gtk3:
gcc -Wall test2.c -o test2 $(pkg-config --cflags --libs gtk+-3.0
gdk-3.0 gthread-2.0)

And run:
./test2

TIA! All comments are welcomed.

Kindly
osmo antero
http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Help with a multi-threaded application. Spot a crash.

2012-05-30 Thread Osmo Antero
Oh, I forgot to mension.
Compile and start the test2 app and then press the Test... button at the top.
It will fire 10 threads. Each of them creates own a GRegex  object.
Then the crash.

// Osmo Antero
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: xml parse

2012-05-28 Thread Osmo Antero
Hello,
I have also used libxml2 with success.
Take a look at this examle.
http://www.futuredesktop.org/tmp/xml-loader.tar.gz

The xml-parser is baked into a gobject (in xml-loader.[ch]), so it's
very easy to use,

Install libxml2-dev-dev package. It contains header files and
libraries for development,
sudo apt-get install libxml2-dev

// Osmo Antero

On Sun, May 27, 2012 at 12:19 PM, Rudra Banerjee bnrj.ru...@yahoo.com wrote:
 Thanks Emmanuel and xiaohu
 I am new to GTK and C programming. Hence don't know things.
 Both of your reply helped me to find things out.
 Google said libxml2 is the standard way, where markup is not so
 standard to parse xml. I think I will stick to libxml2.

 On Sun, 2012-05-27 at 11:39 +0530, Rudra Banerjee wrote:
 Friends,
 I have an xml file.
 I want to search its Author and Year from GTK entry.
 The xml file looks like this:


 xml
 records
 record
 database name=My Collection.enl path=My Collection.enlMy
 Collection.enl/database
 ref-type name=Journal Article0/ref-type
 contributors
 authors
 authorBanerjee, Mitali/author
 authorBanerjee, Rudra/author
 authorMajumdar, a.K./author
 authorMookerjee, Abhijit/author
 authorSanyal, Biplab/author
 authorNigam, a.K./author
 /authors
 /contributors
 titles
 title
 Magnetism in NiFeMo disordered alloys: Experiment and theory
 /title
 secondary-titlePhysica B: Condensed Matter/secondary-title
 /titles
 periodical
 full-titlePhysica B: Condensed Matter/full-title
 /periodical
 pages4287-4293/pages
 volume405/volume
 issue20/issue
 keywords
 keywordMagnetic phases/keyword
 keywordSpin glasses/keyword
 /keywords
 dates
 year2010/year
 /dates
 publisherElsevier/publisher
 electronic-resource-num10.1016/j.physb.2010.07.028/electronic-resource-num
 urls
 pdf-urls
 url
 internal-pdf://Banerjee et al. - 2010 - Magnetism in NiFeMo disordered
 alloys Experiment and theory.pdf
 /url
 /pdf-urls
 web-urls
 url
 http://linkinghub.elsevier.com/retrieve/pii/S0921452610007271
 /url
 /web-urls
 /urls
 /record
 
 
 /records
 /xml

 Is there any xml parser that I can use with GTK2+? google says xml
 parsing can be done with php. What about C?

 Please help.

 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



-- 
// moma
   http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Slow combo box when adding 500 rows

2012-05-25 Thread Osmo Antero
Hello,
I just tested the code on my older 2-cpu-core laptop and it loads
lightning fast (within 0.5 or 2 seconds for both gtk2 and gtk3.). So
it must be some peculiarities with my i7 8-core laptop, or with the
Ubuntu 12.04 itself.

Here are also GtkPerf tests on both these machine.

1) GtkPerf test on this super 8-cpu-core laptop.
CPU: Intel® Core™ i7-2670QM CPU @ 2.20GHz × 8.
RAM: 8GB.
GPU: GeForce GT 525M.
The combo loads very slowly on this.

$ gtkperf
GtkPerf 0.40 - Starting testing: Fri May 25 15:12:54 2012
GtkEntry - time:  0.03
GtkComboBox - time:  1.47
GtkComboBoxEntry - time:  0.97
GtkSpinButton - time:  0.09
GtkProgressBar - time:  0.07
GtkToggleButton - time:  0.65
GtkCheckButton - time:  0.09
GtkRadioButton - time:  0.13
GtkTextView - Add text - time:  0.50
GtkTextView - Scroll - time:  0.05
GtkDrawingArea - Lines - time:  0.52
GtkDrawingArea - Circles - time:  0.62
GtkDrawingArea - Text - time:  0.21
GtkDrawingArea - Pixbufs - time:  0.04
 ---
Total time:  5.45
---

2) GtkPerf test on my old 2-core-cpu laptop.
CPU: Genuine Intel(R) CPU  T2080  @ 1.73GHz.
RAM: 2GB.
GPU: Advanced Micro Devices [AMD] nee ATI RC410 [Radeon Xpress 200M]
The combo appears almost instantly on this laptop. Especially fast on
gtk2, but gtk3 is quick too.

$ gtkperf
GtkPerf 0.40 - Starting testing: Fri May 25 15:38:56 2012

GtkEntry - time:  0.09
GtkComboBox - time:  3.31
GtkComboBoxEntry - time:  2.77
GtkSpinButton - time:  0.30
GtkProgressBar - time:  0.23
GtkToggleButton - time:  1.29
GtkCheckButton - time:  0.23
GtkRadioButton - time:  0.38
GtkTextView - Add text - time:  1.30
GtkTextView - Scroll - time:  0.46
GtkDrawingArea - Lines - time:  0.96
GtkDrawingArea - Circles - time:  1.70
GtkDrawingArea - Text - time:  0.92
GtkDrawingArea - Pixbufs - time:  0.19
 ---
Total time: 14.15

These GtkPerf tests do not support the bad video adapter theory. The
results are as expected.

I will later test Fedora and maybe LinuxMint 13 on this super machine.
Maybe I kill Ubuntu!

And BTW: The actual application will be a desktop-radio. It loads
station names and urls from a large xml-file
(Ref: http://home.online.no/~osmoma//radio/all_radio_channels.xml ).
The radio stations are Grouped by countries, genres of music etc,
and I will let user search among these channel groups. The xml-file
itself loads without delay.

Ok, thanks so far. All well.
Kindly
  Osmo Moma Antero

On Thu, May 24, 2012 at 10:14 PM, Michael Cronenworth m...@cchtml.com wrote:
 Osmo Antero wrote:
 Adding rows to a combo box with a GtkListStore is immensely slow.
 Is it right that adding 500 rows can take upto 10 seconds and the GUI 
 freezes?

 I have similar hardware but with the NVIDIA driver so it only freezes
 for about 2 seconds on my system.

 [snip]
 What is your opinion?
 Should I use a thread to add data after the GUI has been displayed?

 It looks like a GTK3 performance issue. Running your app against GTK2
 results in the combo widget displaying instantly. Another reason why I
 have not jumped from GTK2 to GTK3 yet.

 You should file a bug with this test case.
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



-- 
// moma
   http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Slow combo box when adding 500 rows

2012-05-25 Thread Osmo Antero
Re-hello,
Just to round up,
I installed LinuxMint 13 (with Cinnamon Desktop), and the combo box
loads very, very fast on this installation, with both gtk2 and gtk3.
This is a huge difference compared to my Ubuntu 12.04 partition.

I tried to fix Ubuntu by upgrading its linux 3.2.generic-pae kernel
to linux 3.4 generic, but it did not help. So there's something
inside Ubuntu that is the  hindrance.

$ dpkg -l | egrep -i dbg|debug
nada

Anyway, this is a happy ending.
LinuxMint13 runs like a dream on this 8-core Toshiba Satellite L755 laptop.

Osmo Antero
ps. audio-recorder;
https://launchpad.net/audio-recorder
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Slow combo box when adding 500 rows

2012-05-24 Thread Osmo Antero
Hello,
Adding rows to a combo box with a GtkListStore is immensely slow.
Is it right that adding 500 rows can take upto 10 seconds and the GUI freezes?

I have also tested gtk_combo_box_text_new_with_entry() and it is equally slow.

Here is a complete test code based on gtk 3.0:
http://www.futuredesktop.org/tmp/test1.c

Version of Gtk is:
$ pkg-config --modversion gtk+-3.0
3.4.1

This laptop has:
$ cat /proc/cpuinfo
processor cores: 7
vendor_id   : GenuineIntel
model name  : Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz

Memory:
$ cat /proc/meminfo
MemTotal:  8 GB

Operating system is:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:Ubuntu 12.04 LTS
Release:12.04
Codename:   precise

What is your opinion?
Should I use a thread to add data after the GUI has been displayed?

Kindly
Osmo Antero
http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to make a progress-bar thinner?

2012-04-01 Thread Osmo Antero
Hello,
It wasn't so easy to make the GtkProgressBar smaller. It's also controlled
by desktop's active theme and style.
So I created a simple GtkLevelBar widget that is thinner and lighter.
Picture: http://bildr.no/view/1146365

Here is the source code
https://launchpad.net/audio-recorder
Look for src/gtklevelbar.[ch]
It's nothing prime-art but works very well for this recorder.

Audio-recorder runs on all major Linux-distros.
I run Ubuntu 11.10/12.04.

Happy eastern
 Osmo Antero


On Thu, Mar 29, 2012 at 12:03 PM, Osmo Antero osm...@gmail.com wrote:

 Hello,
 How can I make a GtkProgressBar thinner in this application.
 See:
 http://www.futuredesktop.com/tmp/test1.c
 And
 http://www.futuredesktop.com/tmp/screenshot1.png

 Compile/link the code with
 gcc test1.c -o test1 `pkg-config --cflags --libs gtk+-3.0`
 and run
 ./test1

 I have tried to use GtkAlignment to set paddings with
 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment0), 10, 10, 0, 0);
 but this then makes the other widgets in hbox0 thicker/fatter.
 Eg. the [Button 1] is fatter than the [Button 2].

 This GtkAlignment trick used to work in GTK 2.

 The screenshot shows also the actual target application.
 I want to make the level indicator (GtkProgressBar) in the audio-recorder
 much smaller.

 Notice: I have no plans to use gtk-builder or glade!

 Do you have any suggestions?

 Greetings
  Osmo (Moma) Antero




-- 
// moma
   http://www.futuredesktop.org
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to make a progress-bar thinner?

2012-03-31 Thread Osmo Antero
Ok, I see.

It's rather easy to create a cairo-based (amplitude) level bar.
Here is a sample
http://www.futuredesktop.com/tmp/test3.c

Compile/link with
$ gcc test3.c -o test3 `pkg-config --cflags --libs gtk+-3.0`
and run
$ ./test3

I think I will go for this solution. Would be nice to create a proper
widget class for this.

Cheers,
 Osmo (Moma) Antero

On Fri, Mar 30, 2012 at 9:54 AM, Milan Bouchet-Valat nalimi...@club.frwrote:

 Le vendredi 30 mars 2012 à 09:35 +0200, Osmo Antero a écrit :
  Hello,
  How can I make a GtkProgressBar thinner in this application.
  See:
  http://www.futuredesktop.com/tmp/test1.c
  And
  http://www.futuredesktop.com/tmp/screenshot1.png
 I'm not sure at all you can make it smaller. Actually, the button on the
 left hand-side is higher than the progress bar, so you cannot gain space
 here - and this size depends on the font size, so no luck with padding.

 The general problem IMHO is that you're basically trying to theme your
 application, and GTK is really not designed that way. You don't really
 control the appearance of the widgets, at least not at such a detailed
 level.

 If you're not happy with the progress bar, you may use a slider instead
 (just like other sound applications).

 PS : this list is about discussion of GTK internal development. YOu
 should have used gtk-app-devel-list for this problem.

 Regards



Thanks for your reply.

use a slider instead (just like other sound applications).
Do you mean the GtkScale widget? It might work well in my case.
But can I HIDE the slider (the draggable handle) on a GtkScale widget?

Ref: http://developer.gnome.org/gtk3/stable/GtkScale.html

 Osmo Antero
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


How to make a progress-bar thinner?

2012-03-30 Thread Osmo Antero
Hello,
How can I make a GtkProgressBar thinner in this application.
See:
http://www.futuredesktop.com/tmp/test1.c
And
http://www.futuredesktop.com/tmp/screenshot1.png

Compile/link the code with
$ gcc test1.c -o test1 `pkg-config --cflags --libs gtk+-3.0`
and run
$ ./test1

I have tried to use GtkAlignment to set the paddings with
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment0), 10, 10, 0, 0);
but this then makes the other widgets in hbox0 thicker/fatter.
Eg. the [Button 1] is fatter than the [Button 2].

This GtkAlignment trick used to work in GTK 2.

The screenshot shows also the actual target application.
I want to make the level indicator (GtkProgressBar) in the audio-recorder
much smaller.

Notice: I have no plans to use gtk-builder or glade.

Do you have any suggestions?

Greetings
 Osmo (Moma) Antero
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


How to make a progress-bar thinner?

2012-03-29 Thread Osmo Antero
Hello,
How can I make a GtkProgressBar thinner in this application.
See:
http://www.futuredesktop.com/tmp/test1.c
And
http://www.futuredesktop.com/tmp/screenshot1.png

Compile/link the code with
gcc test1.c -o test1 `pkg-config --cflags --libs gtk+-3.0`
and run
./test1

I have tried to use GtkAlignment to set paddings with
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment0), 10, 10, 0, 0);
but this then makes the other widgets in hbox0 thicker/fatter.
Eg. the [Button 1] is fatter than the [Button 2].

This GtkAlignment trick used to work in GTK 2.

The screenshot shows also the actual target application.
I want to make the level indicator (GtkProgressBar) in the audio-recorder
much smaller.

Notice: I have no plans to use gtk-builder or glade!

Do you have any suggestions?

Greetings
 Osmo (Moma) Antero
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list