[libvtemm] Use C++ API for getting style properties.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libvtemm] Use C++ API for getting style properties.
- Date: Fri, 18 Dec 2009 00:02:21 +0000 (UTC)
commit 9cd22b5a552fc75fc5585f946e05c962a18291ef
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Thu Dec 17 22:13:07 2009 +0100
Use C++ API for getting style properties.
* configure.ac: Require latest gtkmm - should be rather version
of unstable release, but there are none post-2.18 yet.
* examples/gettexter/gettexter.cc:
* examples/simple/simple/cc:
* libvte/src/terminal.ccg: Use C++ API for getting style
properties.
configure.ac | 3 ++-
examples/gettexter/gettexter.cc | 30 ++++--------------------------
examples/simple/simple.cc | 30 ++++--------------------------
libvte/src/terminal.ccg | 26 +++++++-------------------
4 files changed, 17 insertions(+), 72 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a67a998..3dc9e79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,8 @@ 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.18.0 pangomm-1.4 >= 2.24.0 gtkmm-2.4 >= 2.14.0 vte >= 0.23.1'])
+# gtkmm-2.4 version should be >= 2.19.0, but there is still no unstable release.
+AC_SUBST([LIBVTEMM_MODULES], ['glibmm-2.4 >= 2.18.0 pangomm-1.4 >= 2.24.0 gtkmm-2.4 >= 2.18.2 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 b1515fd..30c8683 100644
--- a/examples/gettexter/gettexter.cc
+++ b/examples/gettexter/gettexter.cc
@@ -48,33 +48,11 @@ 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;
-// 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;
- }
+ 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;
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 79e9912..27ff62f 100644
--- a/examples/simple/simple.cc
+++ b/examples/simple/simple.cc
@@ -42,33 +42,11 @@ Simple::Simple()
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;
-// 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;
- }
+ 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;
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/src/terminal.ccg b/libvte/src/terminal.ccg
index 2984fd4..3f28388 100644
--- a/libvte/src/terminal.ccg
+++ b/libvte/src/terminal.ccg
@@ -20,6 +20,8 @@
#include <vte/vte.h>
+#include <gtkmm/border.h>
+
#include "internalroutines.h"
namespace Gnome
@@ -150,7 +152,7 @@ Terminal::get_text(const Gnome::Vte::Terminal::SlotSelectedCallback& slot) const
TextAndCharAttrs
Terminal::get_text_include_trailing_spaces(const Gnome::Vte::Terminal::SlotSelectedCallback& slot) const
{
- GArray* array = g_array_new(FALSE, FALSE, sizeof(struct _VteCharAttributes));
+ GArray* array = g_array_new(FALSE, FALSE, sizeof(VteCharAttributes));
char* c_text = vte_terminal_get_text_include_trailing_spaces(const_cast<VteTerminal*>(gobj()), &Private::SignalProxy_selected_gtk_callback, const_cast<Gnome::Vte::Terminal::SlotSelectedCallback*>(&slot), array);
Glib::ustring text(c_text);
g_free(c_text);
@@ -162,7 +164,7 @@ Terminal::get_text_include_trailing_spaces(const Gnome::Vte::Terminal::SlotSelec
TextAndCharAttrs
Terminal::get_text_range(long start_row, long start_col, long end_row, long end_col, const Gnome::Vte::Terminal::SlotSelectedCallback& slot) const
{
- GArray* array = g_array_new(FALSE, FALSE, sizeof(struct _VteCharAttributes));
+ GArray* array = g_array_new(FALSE, FALSE, sizeof(VteCharAttributes));
char* c_text = vte_terminal_get_text_range(const_cast<VteTerminal*>(gobj()), start_row, start_col, end_row, end_col, &Private::SignalProxy_selected_gtk_callback, const_cast<Gnome::Vte::Terminal::SlotSelectedCallback*>(&slot), array);
Glib::ustring text(c_text);
g_free(c_text);
@@ -198,23 +200,9 @@ Terminal::set_default_emulation()
Padding
Terminal::get_padding() const
{
- int xpad(0), ypad(0);
-// 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);
+ Gtk::Border border;
+ get_style_property("inner-border", border);
+ return Padding(border.left + border.right, border.top + border.bottom);
}
} // namespace Vte
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]