From 32bcadb4763c2b57a6587e0daf95c421d5391526 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Sat, 11 Aug 2012 10:54:35 +0200 Subject: [PATCH] Use GtkFontChooser on Gtk+ 3.2 and up. * src/gtkutil.c (gtk_font_chooser_dialog_new, GTK_FONT_CHOOSER) (gtk_font_chooser_set_font, gtk_font_chooser_get_font): Define for Gtk+ versions less than 3.2. (xg_get_font_name): Use those functions/macros here. Reported by Frans Oilinki . --- src/ChangeLog | 8 ++++++++ src/gtkutil.c | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0fc90a14825..b60ab6ec56f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2012-08-11 Jan Djärv + + * gtkutil.c (gtk_font_chooser_dialog_new, GTK_FONT_CHOOSER) + (gtk_font_chooser_set_font, gtk_font_chooser_get_font): Define + for Gtk+ versions less than 3.2. + (xg_get_font_name): Use those functions/macros here. + Reported by Frans Oilinki . + 2012-08-11 YAMAMOTO Mitsuharu * unexmacosx.c (copy_data_segment): Copy initialized data in diff --git a/src/gtkutil.c b/src/gtkutil.c index 4879479201a..dec4ee079e2 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -75,6 +75,18 @@ along with GNU Emacs. If not, see . */ #define remove_submenu(w) gtk_menu_item_remove_submenu ((w)) #endif +#if GTK_MAJOR_VERSION < 3 || \ + (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 2) +#define gtk_font_chooser_dialog_new(x, y) \ + gtk_font_selection_dialog_new (x) +#undef GTK_FONT_CHOOSER +#define GTK_FONT_CHOOSER(x) GTK_FONT_SELECTION_DIALOG (x) +#define gtk_font_chooser_set_font(x, y) \ + gtk_font_selection_dialog_set_font_name (x, y) +#define gtk_font_chooser_get_font(x) \ + gtk_font_selection_dialog_get_font_name (x) +#endif + #ifndef HAVE_GTK3 #ifdef USE_GTK_TOOLTIP #define gdk_window_get_screen(w) gdk_drawable_get_screen (w) @@ -2000,12 +2012,13 @@ 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", GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); + 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"); done = xg_dialog_run (f, w); @@ -2015,8 +2028,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; -- 2.39.2