gdk_pixbuf_new_from_inline to Gresource conversion

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

gdk_pixbuf_new_from_inline to Gresource conversion

Charles Curley
I have an application developed on Linux using Gnome, specifically GTK+
2 version 2.24.25-3+deb8u2. It has been compiling and running for seven
years. This on debian 8.

I would like to port it to debian 9, stretch. Which has GTK+ 2 version
2.24.31.

On debian 9, I get the following error:

--------------------------------------------------
make[1]: Entering directory '/home/charles/gnome-gps/src'
gcc -O2 -o gnome-gps.do -ggdb -Wall -c gnome-gps.c `pkg-config --cflags --libs gtk+-2.0 libgps`
gnome-gps.c:26:2: warning: #warning Setting up for version 6.1 [-Wcpp]
 #warning Setting up for version 6.1
  ^~~~~~~
gnome-gps.c: In function ‘main’:
gnome-gps.c:1375:30: warning: ‘gdk_pixbuf_new_from_inline’ is deprecated [-Wdeprecated-declarations]
                              gdk_pixbuf_new_from_inline ( -1, my_pixbuf,
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/gdk-pixbuf-2.0/gdk-pixbuf/gdk-pixbuf.h:34:0,
                 from /usr/include/gtk-2.0/gdk/gdkpixbuf.h:37,
                 from /usr/include/gtk-2.0/gdk/gdkcairo.h:28,
                 from /usr/include/gtk-2.0/gdk/gdk.h:33,
                 from /usr/include/gtk-2.0/gtk/gtk.h:32,
                 from gnome-gps.c:40:
/usr/include/gdk-pixbuf-2.0/gdk-pixbuf/gdk-pixbuf-core.h:355:12: note: declared here
 GdkPixbuf* gdk_pixbuf_new_from_inline (gint          data_length,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O2 -o icon.image.do -ggdb -Wall -c icon.image.c `pkg-config --cflags --libs gtk+-2.0 libgps`
gcc -Wall gnome-gps.do icon.image.do -o gnome-gps `pkg-config --cflags --libs gtk+-2.0 libgps`
make[1]: Leaving directory '/home/charles/gnome-gps/src'
--------------------------------------------------

The offending line is:

--------------------------------------------------

        /* Set our icon. */
        gtk_window_set_icon ((GtkWindow *)window,
                             gdk_pixbuf_new_from_inline ( -1, my_pixbuf,
                                                          false, NULL));

--------------------------------------------------

The first warning is deliberate, and not at issue here.

The second one is new on debian 9. I have several options. The
documentation for gdk_pixbuf_new_from_inline () indicates that it is
deprecated and one should use a Gresource.

Question: how do I use a Gresource here?


--

The right of the people to be secure in their persons, houses, papers,
and effects, against unreasonable searches and seizures, shall not be
violated, and no Warrants shall issue, but upon probable cause,
supported by Oath or affirmation, and particularly describing the
place to be searched, and the persons or things to be seized.
-- U.S. Const. Amendment IV

Key fingerprint = CE5C 6645 A45A 64E4 94C0  809C FFF6 4C48 4ECD DFDB
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: gdk_pixbuf_new_from_inline to Gresource conversion

Chris Vine-3
On Tue, 5 Sep 2017 16:39:12 -0600
Charles Curley <[hidden email]> wrote:
[snip]
> The second one is new on debian 9. I have several options. The
> documentation for gdk_pixbuf_new_from_inline () indicates that it is
> deprecated and one should use a Gresource.
>
> Question: how do I use a Gresource here?

I am not going to answer your question I am afraid, but I am going to
make the observation that since GTK+2 will not be updated except for bug
fixes, unless you are thinking of porting your code to GTK+3 or GTK+4
you might as well leave it as it is.  If the warning bothers you, you
can add -Wno-deprecated-declarations to your CFLAGS to suppress it.

Chris
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: gdk_pixbuf_new_from_inline to Gresource conversion

Charles Curley
On Wed, 6 Sep 2017 11:22:25 +0100
Chris Vine <[hidden email]> wrote:

> I am not going to answer your question I am afraid, but I am going to
> make the observation that since GTK+2 will not be updated except for
> bug fixes, unless you are thinking of porting your code to GTK+3 or
> GTK+4 you might as well leave it as it is.  If the warning bothers
> you, you can add -Wno-deprecated-declarations to your CFLAGS to
> suppress it.

Thanks, Chris.

I was afraid that might be the case.

As a general rule, I dislike code that litters the countryside with
warnings. Yeah, it compiles, and yeah, it runs, but those warnings are
usually there for a reason, and sometimes mask other more serious
problems. So I think it is best practice to not allow warnings to creep
into one's code.

As for porting to GTK+3 or 4, would I not have the same problem?

Enough venting. Thanks for the thought.

--

The right of the people to be secure in their persons, houses, papers,
and effects, against unreasonable searches and seizures, shall not be
violated, and no Warrants shall issue, but upon probable cause,
supported by Oath or affirmation, and particularly describing the
place to be searched, and the persons or things to be seized.
-- U.S. Const. Amendment IV

Key fingerprint = CE5C 6645 A45A 64E4 94C0  809C FFF6 4C48 4ECD DFDB
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: gdk_pixbuf_new_from_inline to Gresource conversion

Emmanuele Bassi
On 6 September 2017 at 13:55, Charles Curley
<[hidden email]> wrote:
> On Wed, 6 Sep 2017 11:22:25 +0100
> Chris Vine <[hidden email]> wrote:
>
>> I am not going to answer your question I am afraid, but I am going to
>> make the observation that since GTK+2 will not be updated except for
>> bug fixes, unless you are thinking of porting your code to GTK+3 or
>> GTK+4 you might as well leave it as it is.  If the warning bothers
>> you, you can add -Wno-deprecated-declarations to your CFLAGS to
>> suppress it.

GdkPixbuf is separate from GTK+, so its deprecation warnings are
actually useful even if you're never going to port to newer GTK+
versions.

In this case, the idea is to remove the "inline image" support in
GdkPixbuf and replace it with GResources, which allow to portably and
safely embed any kind of resources inside the binary (either
application or shared library) or inside a blob that can be loaded at
run time.

More information about GResource is available here:
  https://developer.gnome.org/gio/stable/GResource.html

In short:

 - write an XML catalogue with the list of files to be included in the resource
 - generate the GResource from the catalogue using
`glib-compile-resources` as part of your build
  - you can either generate C source and header files, and compile
them into your own project
  - or you can generate a gresource binary blob and install it
somewhere alongside the rest of your project

Ciao,
 Emmanuele.

--
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list