[libvtemm] Deprecate padding stuff.



commit 479b9bf24d39f738f9aa6ec8deff79fad3f1fa63
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Wed Dec 16 21:09:54 2009 +0100

    Deprecate padding stuff.
    
    * configure.ac: Depend on vte >= 0.23.1.
    * libvte/libvtemm.h: Add a TODO - remove inclusion on API break.
    * libvte/libvtemm/padding.h: Wrap in deprecation macros.
    * libvte/src/terminal.hg:
    * libvte/src/terminal.ccg: Deprecate get_padding() method. Inside
    this method, use gtk_widget_style_get_property() to avoid using
    deprecated C function.
    * examples/gettexter/gettexter.cc:
    * examples/simple/simple.cc: Updated examples to not use deprecated
    stuff.

 .gitignore                      |    3 +++
 configure.ac                    |    2 +-
 examples/gettexter/gettexter.cc |   29 ++++++++++++++++++++++++++---
 examples/simple/simple.cc       |   29 ++++++++++++++++++++++++++---
 libvte/libvtemm.h               |    2 +-
 libvte/libvtemm/padding.h       |    8 ++++++++
 libvte/src/terminal.ccg         |   16 +++++++++++++++-
 libvte/src/terminal.hg          |    7 +++++++
 8 files changed, 87 insertions(+), 9 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 79ed43a..8bef0a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,8 @@
 /INSTALL
 /libvte/libvtemmconfig.h
 
+/examples/*/example
+
 Makefile
 Makefile.in
 stamp-*
@@ -17,3 +19,4 @@ stamp-*
 *.deps/
 *.libs/
 *.pc
+.dirstamp
diff --git a/configure.ac b/configure.ac
index f92d516..a67a998 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ AC_SUBST([LIBVTEMM_SO_VERSION], [9:0:0])
 LT_INIT([win32-dll disable-static])
 AC_PROG_CXX
 
-AC_SUBST([LIBVTEMM_MODULES], ['glibmm-2.4 >= 2.14.0 pangomm-1.4 >= 2.24.0 gtkmm-2.4 >= 2.14.0 vte >= 0.22.0'])
+AC_SUBST([LIBVTEMM_MODULES], ['glibmm-2.4 >= 2.18.0 pangomm-1.4 >= 2.24.0 gtkmm-2.4 >= 2.14.0 vte >= 0.23.1'])
 PKG_CHECK_MODULES([LIBVTEMM], [$LIBVTEMM_MODULES])
 
 MM_PKG_CONFIG_SUBST([GTHREAD_CFLAGS], [--cflags-only-other gthread-2.0])
diff --git a/examples/gettexter/gettexter.cc b/examples/gettexter/gettexter.cc
index 4e4cd2b..b1515fd 100644
--- a/examples/gettexter/gettexter.cc
+++ b/examples/gettexter/gettexter.cc
@@ -48,10 +48,33 @@ GetTexter::GetTexter()
   m_button_box.pack_start(m_get_every_second_button);
   m_button_box.pack_start(m_get_only_a_button);
   // Set geometry hints, so resizing will work nicely.
+  // setting geometry hints is based on gnome-terminal code.
   Gdk::Geometry hints;
-  Gnome::Vte::Padding pads(m_terminal.get_padding());
-  hints.base_width = pads.get_x_pad();
-  hints.base_height = pads.get_y_pad();
+//  deprecated:
+//  Gnome::Vte::Padding pads(m_terminal.get_padding());
+//  hints.base_width = pads.get_x_pad();
+//  hints.base_height = pads.get_y_pad();
+
+//  C++ API does not work - wait for #603926 to be fixed.
+//  Gtk::Border inner_border;
+//  m_terminal.get_style_property("inner-border", inner_border);
+//  hints.base_width = inner_border.left + inner_border.right;
+//  hints.base_height = inner_border.top + inner_border.bottom;
+
+//  C API does work
+  GtkBorder* inner_border = NULL;
+  gtk_widget_style_get(GTK_WIDGET(m_terminal.gobj()), "inner-border", &inner_border, NULL);
+  if (inner_border)
+  {
+    hints.base_width = inner_border->left + inner_border->right;
+    hints.base_height = inner_border->top + inner_border->bottom;
+    gtk_border_free(inner_border);
+  }
+  else
+  {
+    hints.base_width = 2;
+    hints.base_height = 2;
+  }
   hints.width_inc = m_terminal.get_char_width();
   hints.height_inc = m_terminal.get_char_height();
   const int min_width_chars = 4;
diff --git a/examples/simple/simple.cc b/examples/simple/simple.cc
index 584f553..79e9912 100644
--- a/examples/simple/simple.cc
+++ b/examples/simple/simple.cc
@@ -41,11 +41,34 @@ Simple::Simple()
   m_terminal.signal_child_exited().connect(sigc::mem_fun(*this, &Simple::on_child_exited));
   m_terminal.set_flags(Gtk::CAN_FOCUS);
   m_terminal.grab_focus();
+  // Set geometry hints, so resizing will work nicely.
   // setting geometry hints is based on gnome-terminal code.
   Gdk::Geometry hints;
-  Gnome::Vte::Padding pads(m_terminal.get_padding());
-  hints.base_width = pads.get_x_pad();
-  hints.base_height = pads.get_y_pad();
+//  deprecated:
+//  Gnome::Vte::Padding pads(m_terminal.get_padding());
+//  hints.base_width = pads.get_x_pad();
+//  hints.base_height = pads.get_y_pad();
+
+//  C++ API does not work - wait for #603926 to be fixed.
+//  Gtk::Border inner_border;
+//  m_terminal.get_style_property("inner-border", inner_border);
+//  hints.base_width = inner_border.left + inner_border.right;
+//  hints.base_height = inner_border.top + inner_border.bottom;
+
+//  C API does work
+  GtkBorder* inner_border = NULL;
+  gtk_widget_style_get(GTK_WIDGET(m_terminal.gobj()), "inner-border", &inner_border, NULL);
+  if (inner_border)
+  {
+    hints.base_width = inner_border->left + inner_border->right;
+    hints.base_height = inner_border->top + inner_border->bottom;
+    gtk_border_free(inner_border);
+  }
+  else
+  {
+    hints.base_width = 2;
+    hints.base_height = 2;
+  }
   hints.width_inc = m_terminal.get_char_width();
   hints.height_inc = m_terminal.get_char_height();
   const int min_width_chars = 4;
diff --git a/libvte/libvtemm.h b/libvte/libvtemm.h
index 2f3481a..d117fb5 100644
--- a/libvte/libvtemm.h
+++ b/libvte/libvtemm.h
@@ -27,7 +27,7 @@
 #include <libvtemm/cursorposition.h>
 #include <libvtemm/init.h>
 #include <libvtemm/match.h>
-#include <libvtemm/padding.h>
+#include <libvtemm/padding.h> // TODO: deprecated.
 #include <libvtemm/ptymaster.h>
 #include <libvtemm/ptysize.h>
 #include <libvtemm/shared.h>
diff --git a/libvte/libvtemm/padding.h b/libvte/libvtemm/padding.h
index 6bfc788..813a65f 100644
--- a/libvte/libvtemm/padding.h
+++ b/libvte/libvtemm/padding.h
@@ -21,12 +21,18 @@
 #ifndef _LIBVTEMM_PADDING_H_
 #define _LIBVTEMM_PADDING_H_
 
+#include <libvtemmconfig.h>
+
+#ifndef LIBVTEMM_DISABLE_DEPRECATED
+
 namespace Gnome
 {
 
 namespace Vte
 {
 /** Padding - simple class holding padding.
+ *
+ * @deprecated Use "inner-border" style property instead.
  */
 class Padding
 {
@@ -56,4 +62,6 @@ private:
 
 } // namespace Gnome
 
+#endif // LIBVTEMM_DISABLE_DEPRECATED
+
 #endif // _LIBVTEMM_PADDING_H_
diff --git a/libvte/src/terminal.ccg b/libvte/src/terminal.ccg
index dd2f577..2984fd4 100644
--- a/libvte/src/terminal.ccg
+++ b/libvte/src/terminal.ccg
@@ -199,7 +199,21 @@ Padding
 Terminal::get_padding() const
 {
   int xpad(0), ypad(0);
-  vte_terminal_get_padding(const_cast<VteTerminal*>(gobj()), &xpad, &ypad);
+//  TODO: use C++ API, when #603926 is fixed.
+  GtkWidget* c_widget = GTK_WIDGET(gobj());
+  GtkBorder* c_border = NULL;
+  gtk_widget_style_get(c_widget, "inner-border", &c_border, NULL);
+  if (c_border)
+  {
+    x_pad = c_border->left + c_border->right;
+    y_pad = c_border->top + c_border->bottom;
+    gtk_border_free(c_border);
+  }
+  else
+  {
+    x_pad = 2;
+    y_pad = 2;
+  }
   return Padding(xpad, ypad);
 }
 
diff --git a/libvte/src/terminal.hg b/libvte/src/terminal.hg
index 36d931e..30110c1 100644
--- a/libvte/src/terminal.hg
+++ b/libvte/src/terminal.hg
@@ -33,7 +33,9 @@ _PINCLUDE(gtkmm/private/widget_p.h)
 #include <gtkmm/adjustment.h>
 #include <libvtemm/cursorposition.h>
 #include <libvtemm/match.h>
+#ifndef LIBVTEMM_DISABLE_DEPRECATED
 #include <libvtemm/padding.h>
+#endif // LIBVTEMM_DISABLE_DEPRECATED
 #include <libvtemm/shared.h>
 #include <libvtemm/textandcharattrs.h>
 
@@ -477,6 +479,8 @@ public:
    */
   _WRAP_METHOD(Glib::ustring get_status_line() const, vte_terminal_get_status_line)
 
+
+#ifndef LIBVTEMM_DISABLE_DEPRECATED
   /** Determines the amount of additional space the widget is using to pad the
    * edges of its visible area. This is necessary for cases where characters in
    * the selected font don't themselves include a padding area and the text
@@ -487,8 +491,11 @@ public:
    * size. The values returned in Gnome::Vte::Padding are the total padding
    * used in each direction, and do not need to be doubled.
    * @return Gnome::Vte::Padding instance holding both paddings.
+   *
+   * @deprecated Use "inner-border" style property instead.
    */
   Padding get_padding() const;
+#endif // LIBVTEMM_DISABLE_DEPRECATED
 
   /** Attach an existing PTY master side to the terminal widget. Use
    * instead of fork_command() or forkpty().



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