[gtkmm] Gtk::Notebook and StyleContext: Minor deprecation fixes.



commit 942d36a5be9d34ab27a97f12b163660fbafdba1f
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Sat Jul 6 10:25:54 2013 +0200

    Gtk::Notebook and StyleContext: Minor deprecation fixes.
    
    * gtk/src/notebook.hg: Disable deprecation warnings when notebook.cc is
    compiled.
    * gtk/src/stylecontext.[hg|ccg]: get_font(): Use gtk_style_context_get()
    instead of the deprecated gtk_style_context_get_font().

 gtk/src/notebook.hg      |    5 +++++
 gtk/src/stylecontext.ccg |    9 +++++++++
 gtk/src/stylecontext.hg  |   13 +++++++++----
 3 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/gtk/src/notebook.hg b/gtk/src/notebook.hg
index 094f239..0b26d9a 100644
--- a/gtk/src/notebook.hg
+++ b/gtk/src/notebook.hg
@@ -25,6 +25,11 @@ _DEFS(gtkmm,gtk)
 _PINCLUDE(gtkmm/private/container_p.h)
 #m4 _CONVERSION(guint,PositionType,`$2($3)')
 
+#m4 _PUSH(SECTION_CC_PRE_INCLUDES)
+#undef GTK_DISABLE_DEPRECATED
+#define GDK_DISABLE_DEPRECATION_WARNINGS 1
+#m4 _POP()
+
 namespace Gtk
 {
 
diff --git a/gtk/src/stylecontext.ccg b/gtk/src/stylecontext.ccg
index 3222d4e..6bac053 100644
--- a/gtk/src/stylecontext.ccg
+++ b/gtk/src/stylecontext.ccg
@@ -44,6 +44,15 @@ Gdk::RGBA StyleContext::get_border_color(StateFlags state) const
   return Gdk::RGBA(&crgba, true);
 }
 
+Pango::FontDescription StyleContext::get_font(StateFlags state) const
+{
+  // gtk_style_context_get_font() is deprecated.
+  PangoFontDescription* description = 0;
+  gtk_style_context_get(const_cast<GtkStyleContext*>(gobj()), (GtkStateFlags)state, "font", &description, 
NULL);
+  // gtk_style_context_get() returns a newly allocated font description, owned by the caller.
+  return Glib::wrap(description, false);
+}
+
 Border StyleContext::get_border(StateFlags state) const
 {
   GtkBorder cborder;
diff --git a/gtk/src/stylecontext.hg b/gtk/src/stylecontext.hg
index 7bfd894..927af41 100644
--- a/gtk/src/stylecontext.hg
+++ b/gtk/src/stylecontext.hg
@@ -210,10 +210,15 @@ public:
   Gdk::RGBA  get_border_color(StateFlags state = (StateFlags)0) const;
   _IGNORE(gtk_style_context_get_border_color)
 
-  //TODO: gtk_style_context_get_font() is deprecated. It's replaced by gtk_style_context_get(), which we
-  // probably don't want to wrap. It takes '...' parameters. Make a handcoded get_font()?
-#m4 _CONVERSION(`const 
PangoFontDescription*',`Pango::FontDescription',`Glib::wrap(const_cast<PangoFontDescription*>($3), true)')
-  _WRAP_METHOD(Pango::FontDescription get_font(StateFlags state = (StateFlags)0) const, 
gtk_style_context_get_font)
+  /** Returns the font description for a given state.
+   * 
+   * @newin{3,0}
+   * 
+   * @param state State to retrieve the font for.
+   * @return The Pango::FontDescription for the given state.
+   */
+  Pango::FontDescription get_font(StateFlags state =  (StateFlags)0) const;
+  _IGNORE(gtk_style_context_get_font)
 
   Border get_border(StateFlags state = (StateFlags)0) const;
   _IGNORE(gtk_style_context_get_border)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]