unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Frans Oilinki <moilinki@gmail.com>
To: emacs-devel@gnu.org
Subject: GTK3 deprecation fix (GtkFontSelection replaced with GtkFontChooser)
Date: Fri, 10 Aug 2012 17:35:28 +0800	[thread overview]
Message-ID: <CAL2O=cB3Yq6-UiRB6b_-nTWSd3gnsFv+TeA2rxA8-qu7cosJ6Q@mail.gmail.com> (raw)

Hello,

I just tried building the newest emacs master branch (git cloned
repository), running Ubuntu 12.04 GNU/Linux system.

I made a mistake of adding option  "--enable-gcc-warnings" to
"./configure" (not anticipating it would add option -Werror :-). The
complete list of options to ./configure: "--prefix=/usr/local
--program-suffix=-git.master --enable-check-lisp-object-type
--enable-link-time-optimization  --enable-gcc-warnings
--with-x-toolkit=gtk3 --with-x".

The file "src/gtkutil.c" gave the following warning:

    gcc -std=gnu99 -c  -Demacs  -I.
-I/home/fo/work/OpenSource/Emacs/emacs/src -I../lib
-I/home/fo/work/OpenSource/Emacs/emacs/src/../lib   -pthread -isystem
/usr/include/gtk-3.0 -isystem /usr/include/pango-1.0 -isystem
/usr/include/gio-unix-2.0/ -isystem /usr/include/atk-1.0 -isystem
/usr/include/cairo -isystem /usr/include/gdk-pixbuf-2.0 -isystem
/usr/include/freetype2 -isystem /usr/include/glib-2.0 -isystem
/usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem
/usr/include/pixman-1 -isystem /usr/include/libpng12   -isystem
/usr/include/freetype2    -isystem /usr/include/alsa   -pthread
-isystem /usr/include/librsvg-2.0 -isystem /usr/include/glib-2.0
-isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem
/usr/include/gdk-pixbuf-2.0 -isystem /usr/include/cairo -isystem
/usr/include/libpng12 -isystem /usr/include/pixman-1 -isystem
/usr/include/freetype2   -fopenmp -isystem /usr/include/ImageMagick
-isystem /usr/include/libxml2   -isystem /usr/include/dbus-1.0
-isystem /usr/lib/x86_64-linux-gnu/dbus-1.0/include   -pthread
-isystem /usr/include/glib-2.0 -isystem
/usr/lib/x86_64-linux-gnu/glib-2.0/include   -pthread -isystem
/usr/include/gconf/2 -isystem /usr/include/dbus-1.0 -isystem
/usr/lib/x86_64-linux-gnu/dbus-1.0/include -isystem
/usr/include/glib-2.0 -isystem
/usr/lib/x86_64-linux-gnu/glib-2.0/include   -isystem
/usr/include/freetype2    -isystem /usr/include/freetype2    -MMD -MF
deps/gtkutil.d -MP  -isystem /usr/include/p11-kit-1   -Wall -W
-Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs
-Wunused -Wunknown-pragmas -Wstrict-aliasing
-Wdeclaration-after-statement -Wpointer-arith -Wbad-function-cast
-Wcast-align -Wwrite-strings -Wstrict-prototypes
-Wold-style-definition -Wmissing-prototypes -Wmissing-declarations
-Wmissing-noreturn -Wmissing-format-attribute -Wpacked -Winvalid-pch
-Wvolatile-register-var -Wdisabled-optimization
-Wbuiltin-macro-redefined -Wmudflap -Wpacked-bitfield-compat
-Wattributes -Wcoverage-mismatch -Wunused-macros -Wabi -Wcpp
-Wdeprecated -Wdeprecated-declarations -Wdiv-by-zero
-Wdouble-promotion -Wendif-labels -Wextra -Wformat-contains-nul
-Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar
-Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas
-Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wtrampolines
-Wno-missing-field-initializers -Wno-missing-field-initializers
-Wno-sign-compare -Wno-type-limits -Wno-switch -Wno-unused-parameter
-Wno-format-nonliteral -Wno-logical-op -fdiagnostics-show-option
-funit-at-a-time -Werror -g -O2 -flto=1 gtkutil.c
    gtkutil.c: In function ‘xg_get_font_name’:
    gtkutil.c:2003:3: error: ‘gtk_font_selection_dialog_new’ is
deprecated (declared at
/usr/include/gtk-3.0/gtk/deprecated/gtkfontsel.h:142): Use
'GtkFontChooser' instead [-Werror=deprecated-declarations]
    gtkutil.c:2006:3: error: ‘gtk_font_selection_dialog_set_font_name’
is deprecated (declared at
/usr/include/gtk-3.0/gtk/deprecated/gtkfontsel.h:153): Use
'GtkFontChooser' instead [-Werror=deprecated-declarations]
    gtkutil.c:2019:7: error: ‘gtk_font_selection_dialog_get_font_name’
is deprecated (declared at
/usr/include/gtk-3.0/gtk/deprecated/gtkfontsel.h:151): Use
'GtkFontChooser' instead [-Werror=deprecated-declarations]
    cc1: all warnings being treated as errors
    make[1]: *** [gtkutil.o] Error 1
    make[1]: *** Waiting for unfinished jobs....
    make[1]: Leaving directory `/home/fo/work/OpenSource/Emacs/emacs/src'
    make: *** [src] Error 2

I found GTK3 API documentation and within couple of minutes of reading
quickly applied the following fix:

    $ git diff
     diff --git a/src/gtkutil.c b/src/gtkutil.c
     index 4879479..ce9b851 100644
     --- a/src/gtkutil.c
     +++ b/src/gtkutil.c
     @@ -2000,11 +2000,10 @@ xg_get_font_name (FRAME_PTR f, const char
*default_name)
        sigblock (sigmask (__SIGRTMIN));
      #endif /* HAVE_PTHREAD */

     -  w = gtk_font_selection_dialog_new ("Pick a font");
     +  w = gtk_font_chooser_dialog_new ("Pick a font", NULL);
        if (!default_name)
          default_name = "Monospace 10";
     -  gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (w),
     -                                           default_name);
     +  gtk_font_chooser_set_font (GTK_FONT_CHOOSER (w), default_name);

        gtk_widget_set_name (w, "emacs-fontdialog");

     @@ -2015,8 +2014,7 @@ xg_get_font_name (FRAME_PTR f, const char
*default_name)
      #endif

        if (done == GTK_RESPONSE_OK)
     -    fontname = gtk_font_selection_dialog_get_font_name
     -      (GTK_FONT_SELECTION_DIALOG (w));
     +    fontname = gtk_font_chooser_get_font(GTK_FONT_CHOOSER (w));

        gtk_widget_destroy (w);
        return fontname;

This fixed the compilation for my Ubuntu 12.04 machine (gtk3 seems to
be version 3.4.2). I tried selecting font (by [SHIFT] +
[LEFT-MOUSE-BUTTON]), and the new font selection widget worked for me.

Note that I have never before done programming with GTK API, so you
might review this with some care, and check the compatibility with the
supported versions of GTK3 if you choose to apply this kind of fix to
future versions of Emacs.

Best regards and thanks for everybody's work for fabulous text editing
environment (or whatever emacs should be called),

Frans



             reply	other threads:[~2012-08-10  9:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10  9:35 Frans Oilinki [this message]
2012-08-11  9:00 ` GTK3 deprecation fix (GtkFontSelection replaced with GtkFontChooser) Jan Djärv
2012-08-20  9:45   ` Frans Oilinki
2012-08-21 20:54     ` Jan Djärv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL2O=cB3Yq6-UiRB6b_-nTWSd3gnsFv+TeA2rxA8-qu7cosJ6Q@mail.gmail.com' \
    --to=moilinki@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).