[libvtemm] Lots and lots of small various changes.



commit ad7c49a45be47cd697ade03527c669423e15b115
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Tue May 12 14:19:17 2009 +0200

    Lots and lots of small various changes.
    
    * TODO: Left only 'squashing bugs' task.
    * examples/simple/main.cc:
    * examples/simple/simple.cc:
    * examples/simple/simple.h: Cleaned up includes. Changed indentation
    from tabs to two spaces. Written a function getting user's shell
    from passwd (so now it won't work on MS Windows).
    * src/libvtemm/Makefile.am: Cleaned it up a bit. Changed API version to 1.1.
    Added cursorposition.(h|cc) files.
    * src/libvtemm/g/libvte_docs_override.xml: Overriden get_cursor_position
    documentation.
    * src/libvtemm/g/terminal.ccg: Added get_cursor_position() method.
    * src/libvtemm/g/terminal.hg: Moved CursorPosition to separate file.
    * src/libvtemm/textandcharattrs.cc: Removed 'inline' keywords.
    * src/libvtemm/textandcharattrs.h: Destructor is now virtual.
    * src/libvtemm/*.(cc|h):
    * src/libvtemm/g/*.(cc|h)g:
    * examples/simple/*.(cc|h):
    Updated copyright years (added 2009).
    * src/libvtemm/cursorposition.(h|cc): New.
---
 TODO                                    |    5 +--
 examples/simple/main.cc                 |   15 ++++----
 examples/simple/simple.cc               |   58 +++++++++++++++++++-----------
 examples/simple/simple.h                |   22 ++++++------
 src/libvtemm/Makefile.am                |   60 +++---------------------------
 src/libvtemm/g/charattributes.ccg       |    2 +-
 src/libvtemm/g/charattributes.hg        |    2 +-
 src/libvtemm/g/libvte_docs_override.xml |   16 ++++++++
 src/libvtemm/g/reaper.ccg               |    2 +-
 src/libvtemm/g/reaper.hg                |    2 +-
 src/libvtemm/g/terminal.ccg             |   25 ++++++++++---
 src/libvtemm/g/terminal.hg              |   12 +-----
 src/libvtemm/g/terminalaccessible.ccg   |    2 +-
 src/libvtemm/g/terminalaccessible.hg    |    2 +-
 src/libvtemm/init.cc                    |    2 +-
 src/libvtemm/init.h                     |    2 +-
 src/libvtemm/pty.cc                     |    2 +-
 src/libvtemm/pty.h                      |    2 +-
 src/libvtemm/textandcharattrs.cc        |    6 ++--
 src/libvtemm/textandcharattrs.h         |   10 +++---
 src/libvtemm/wrap_init.h                |    2 +-
 21 files changed, 118 insertions(+), 133 deletions(-)

diff --git a/TODO b/TODO
index 2a90267..2a143e9 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,3 @@
-src/libvtemm/g/terminal.(h|cc)g:
-	1. wrap commit signal by hand, when it will be possible.
-	("char, int" -> ("std::string"|"Glib::ustring"))
 src/libvtemm/g/*.(h|cc)g:
-src/libvtemm/*.(cc|h):
+src/libvtemm/*.(h|cc):
 	1. squashing bugs. as always.
diff --git a/examples/simple/main.cc b/examples/simple/main.cc
index b374a67..e98dddf 100644
--- a/examples/simple/main.cc
+++ b/examples/simple/main.cc
@@ -1,6 +1,6 @@
 /* main.cc
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of Terminal Example.
  *
@@ -18,15 +18,14 @@
  * along with Terminal Example.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <gtkmm/main.h>
+#include <gtkmm.h>
 #include "simple.h"
-#include <libvtemm/init.h>
 
 int main(int argc, char *argv[])
 {
-	Gtk::Main kit(argc, argv);
-	Gnome::Vte::init();
-	Simple window;
-	Gtk::Main::run(window);
-	return 0;
+  Gtk::Main kit(argc, argv);
+  Gnome::Vte::init();
+  Simple window;
+  Gtk::Main::run(window);
+  return 0;
 }
diff --git a/examples/simple/simple.cc b/examples/simple/simple.cc
index 54d699f..82680d4 100644
--- a/examples/simple/simple.cc
+++ b/examples/simple/simple.cc
@@ -1,6 +1,6 @@
 /* simple.cc
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of Terminal Example.
  *
@@ -18,36 +18,52 @@
  * along with Terminal Example.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "simple.h"
 #include <vector>
 #include <string>
 
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+#include "simple.h"
+
+static
+std::string get_shell();
+
 Simple::Simple()
-: m_terminal()
+:
+  m_terminal()
 {
-	/*
-	we are making a NULL terminated string vector. as we are passing neither
-	argv nor envv, the string vector contains one empty string only.
-	*/
-	std::vector<std::string> nil;
-	nil.push_back(std::string());
-	std::string command("sh");
-	set_title("Simple Gnome::Vte::Terminal example");
-	m_terminal.fork_command(command, nil, nil, std::string(), false, false, false);
-	m_terminal.set_size(80, 24);
-	m_terminal.signal_child_exited().connect(sigc::mem_fun(*this, &Simple::on_child_exited));
-	add(m_terminal);
-	m_terminal.set_flags(Gtk::CAN_DEFAULT);
-	m_terminal.grab_default();
-	show_all_children();
+  /*
+  we are making a NULL terminated string vector. as we are passing neither
+  argv nor envv, the string vector contains one empty string only.
+  */
+  std::vector<std::string> nil(1, std::string());
+  std::string command(get_shell());
+  set_title("Simple Gnome::Vte::Terminal example");
+  m_terminal.fork_command(command, nil, nil, std::string(), false, false, false);
+  m_terminal.set_size(80, 24);
+  m_terminal.signal_child_exited().connect(sigc::mem_fun(*this, &Simple::on_child_exited));
+  add(m_terminal);
+  m_terminal.set_flags(Gtk::CAN_DEFAULT);
+  m_terminal.grab_default();
+  show_all_children();
 }
 
 Simple::~Simple()
+{}
+
+void Simple::on_child_exited()
 {
-	
+  hide();
 }
 
-void Simple::on_child_exited()
+// static
+
+static
+std::string get_shell()
 {
-	hide();
+  uid_t uid(getuid());
+  passwd* pwd(getpwuid(uid));
+  return pwd->pw_shell;
 }
diff --git a/examples/simple/simple.h b/examples/simple/simple.h
index 56c8aee..5127a6e 100644
--- a/examples/simple/simple.h
+++ b/examples/simple/simple.h
@@ -1,6 +1,6 @@
 /* simple.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of Terminal Example.
  *
@@ -21,21 +21,21 @@
 #ifndef LIBVTEMM_EXAMPLE_SIMPLE_H
 #define LIBVTEMM_EXAMPLE_SIMPLE_H
 
-#include <gtkmm/window.h>
-#include <libvtemm/terminal.h>
+#include <gtkmmh>
+#include <libvtemm.h>
 
 class Simple : public Gtk::Window
 {
-	public:
-		Simple();
-		virtual ~Simple();
+public:
+  Simple();
+  virtual ~Simple();
 
-	protected:
-		//Signal handlers:
-		virtual void on_child_exited();
+protected:
+  //Signal handlers:
+  virtual void on_child_exited();
 
-		//Member widgets:
-		Gnome::Vte::Terminal m_terminal;
+  //Member widgets:
+  Gnome::Vte::Terminal m_terminal;
 };
 
 #endif // LIBVTEMM_EXAMPLE_SIMPLE_H
diff --git a/src/libvtemm/Makefile.am b/src/libvtemm/Makefile.am
index a62919a..9a0489e 100644
--- a/src/libvtemm/Makefile.am
+++ b/src/libvtemm/Makefile.am
@@ -3,64 +3,16 @@
 
 SUBDIRS = g private
 
-files_extra_h = wrap_init.h init.h textandcharattrs.h pty.h
-files_extra_cc = init.cc textandcharattrs.cc pty.cc
+files_extra_h = cursorposition.h init.h pty.h textandcharattrs.h wrap_init.h
+files_extra_cc = cursorposition.cc init.cc pty.cc textandcharattrs.cc
 
 include $(top_srcdir)/build_shared/Makefile_shared.am_fragment
 #defined:
-# generated_sources_h
 # generated_sources_cc
-# files_defs_from_g
-# tools_m4
-# run_gmmproc
-# generated_private_headers
 
-# # # #
-# should not ever exist, but hack needs to be used
-#
-#h_p_name = hacky_patch
-#run_sed_hack = $(SED) "s;~~~SRC_DIR~~~;$(srcdir);" $(srcdir)/g/$(h_p_name).tmpl >$(srcdir)/$(h_p_name)
-#run_patch_hack = $(PATCH) -f -p0 <$(srcdir)/$(h_p_name)
-#
-# end of "should not ever exist"
-# # # #
-
-# # # #
-# should be shared, but hack needs to be used
-#
-#BUILT_SOURCES = $(h_p_name) $(generated_sources_h) $(generated_sources_cc) $(generated_sources_private)
-#
-#$(srcdir)/private/%_p.h: %.h
-#
-#%.cc: %.h
-#
-#%.h: $(srcdir)/g/%.hg $(srcdir)/g/%.ccg $(tools_m4) $(files_defs_from_g) $(srcdir)/$(h_p_name)
-#	$(run_gmmproc) $(notdir $*) $(srcdir)/g $(srcdir)
-#	if test "x$*" = "xterminal"; then $(run_patch_hack); fi
-#
-# end of "should be shared"
-# # # #
-
-# # # #
-# should not ever exist, but hack needs to be used
-#
-#$(h_p_name): $(srcdir)/g/$(h_p_name).tmpl
-#	$(run_sed_hack)
-#
-# end of "should not ever exist"
-# # # #
-
-lib_LTLIBRARIES = libvtemm-1.0.la
-libvtemm_1_0_la_SOURCES = $(files_extra_cc) $(generated_sources_cc)
-libvtemm_1_0_la_LDFLAGS = $(common_ldflags)
-libvtemm_1_0_la_LIBADD = @LIBVTEMM_LIBS@
-
-# # # #
-# should be shared, but hack needs to be used
-#
-#MOSTLYCLEANFILES = $(generated_sources_cc) $(generated_sources_h) $(h_p_name) $(generated_private_headers)
-#
-# end of "should be shared"
-# # # #
+lib_LTLIBRARIES = libvtemm-1.1.la
+libvtemm_1_1_la_SOURCES = $(files_extra_cc) $(generated_sources_cc)
+libvtemm_1_1_la_LDFLAGS = $(common_ldflags)
+libvtemm_1_1_la_LIBADD = @LIBVTEMM_LIBS@
 
 -include $(top_srcdir)/git.mk
diff --git a/src/libvtemm/g/charattributes.ccg b/src/libvtemm/g/charattributes.ccg
index e59bd48..68503b2 100644
--- a/src/libvtemm/g/charattributes.ccg
+++ b/src/libvtemm/g/charattributes.ccg
@@ -1,6 +1,6 @@
 /* charattributes.cc
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/g/charattributes.hg b/src/libvtemm/g/charattributes.hg
index b87f9ab..d755514 100644
--- a/src/libvtemm/g/charattributes.hg
+++ b/src/libvtemm/g/charattributes.hg
@@ -1,6 +1,6 @@
 /* charattributes.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/g/libvte_docs_override.xml b/src/libvtemm/g/libvte_docs_override.xml
index 1cc66b9..93f9cf7 100644
--- a/src/libvtemm/g/libvte_docs_override.xml
+++ b/src/libvtemm/g/libvte_docs_override.xml
@@ -323,4 +323,20 @@ expressions.
 </return>
 </function>
 
+<function name="vte_terminal_get_cursor_position">
+<description>
+Reads the location of the insertion cursor and returns it.  The row
+coordinate is absolute.
+
+
+</description>
+<parameters>
+<parameter name="terminal">
+<parameter_description> a #VteTerminal
+</parameter_description>
+</parameter>
+</parameters>
+<return> #Gnome::Vte::CursorPosition instance holding both coordinates</return>
+</function>
+
 </root>
diff --git a/src/libvtemm/g/reaper.ccg b/src/libvtemm/g/reaper.ccg
index cde9cd1..8e296a7 100644
--- a/src/libvtemm/g/reaper.ccg
+++ b/src/libvtemm/g/reaper.ccg
@@ -1,6 +1,6 @@
 /* reaper.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/g/reaper.hg b/src/libvtemm/g/reaper.hg
index 4c9482b..a93a518 100644
--- a/src/libvtemm/g/reaper.hg
+++ b/src/libvtemm/g/reaper.hg
@@ -1,6 +1,6 @@
 /* reaper.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/g/terminal.ccg b/src/libvtemm/g/terminal.ccg
index 79cc68b..bcf3ee7 100644
--- a/src/libvtemm/g/terminal.ccg
+++ b/src/libvtemm/g/terminal.ccg
@@ -1,6 +1,6 @@
 /* terminal.cc
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
@@ -89,7 +89,16 @@ Terminal::get_text_range(long start_row, long start_col, long end_row, long end_
   return TextAndCharAttrs(text, attributes);
 }
 
-Glib::ustring Terminal::match_check(long column, long row, int& tag)
+CursorPosition
+Terminal::get_cursor_position() const
+{
+  long column(0), row(0);
+  vte_terminal_get_cursor_position(gobj(), &column, &row);
+  return CursorPosition(column, row);
+}
+
+Glib::ustring
+Terminal::match_check(long column, long row, int& tag)
 {
   char* c_text = vte_terminal_match_check(gobj(), column, row, &tag);
   Glib::ustring text(c_text);
@@ -97,22 +106,26 @@ Glib::ustring Terminal::match_check(long column, long row, int& tag)
   return text;
 }
 
-void Terminal::set_colors(const Gdk::Color& foreground, const Gdk::Color& background, const Gdk::ArrayHandle_Color& palette)
+void
+Terminal::set_colors(const Gdk::Color& foreground, const Gdk::Color& background, const Gdk::ArrayHandle_Color& palette)
 {
   vte_terminal_set_colors(gobj(), foreground.gobj(), background.gobj(), palette.data(), palette.size());
 }
 
-void Terminal::feed(const Glib::ustring& data)
+void
+Terminal::feed(const Glib::ustring& data)
 {
   vte_terminal_feed(gobj(), data.data(), data.size());
 }
 
-void Terminal::feed_child(const Glib::ustring& text)
+void
+Terminal::feed_child(const Glib::ustring& text)
 {
   vte_terminal_feed_child(gobj(), text.data(), text.size());
 }
 
-void Terminal::feed_child_binary(const std::string& data)
+void
+Terminal::feed_child_binary(const std::string& data)
 {
   vte_terminal_feed_child_binary(gobj(), data.data(), data.size());
 }
diff --git a/src/libvtemm/g/terminal.hg b/src/libvtemm/g/terminal.hg
index 38d577c..8a82b20 100644
--- a/src/libvtemm/g/terminal.hg
+++ b/src/libvtemm/g/terminal.hg
@@ -1,6 +1,6 @@
 /* terminal.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
@@ -141,17 +141,9 @@ public:
   TextAndCharAttrs get_text_include_trailing_spaces(const SlotSelectedCallback& slot) const;
   _WRAP_METHOD_DOCS_ONLY(vte_terminal_get_text_range)
   TextAndCharAttrs get_text_range(long start_row, long start_col, long end_row, long end_col, const SlotSelectedCallback& slot) const;
-  _IGNORE(vte_terminal_get_text, vte_terminal_get_text_include_trailing_spaces, vte_terminal_get_text_range)
   _WRAP_METHOD_DOCS_ONLY(vte_terminal_get_cursor_position)
-/** @struct CursorPosition - simple struct holding cursor position.
- * It contains two members describing cursor position - column and row.
- */
-  struct CursorPosition
-  {
-  	long column;
-  	long row;
-  };
   CursorPosition get_cursor_position() const;
+  _IGNORE(vte_terminal_get_text, vte_terminal_get_text_include_trailing_spaces, vte_terminal_get_text_range, vte_terminal_get_cursor_position)
 
   _WRAP_METHOD(void match_clear_all(), vte_terminal_match_clear_all)
 
diff --git a/src/libvtemm/g/terminalaccessible.ccg b/src/libvtemm/g/terminalaccessible.ccg
index 82001d0..9855d99 100644
--- a/src/libvtemm/g/terminalaccessible.ccg
+++ b/src/libvtemm/g/terminalaccessible.ccg
@@ -1,6 +1,6 @@
 /* terminalaccessible.cc
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/g/terminalaccessible.hg b/src/libvtemm/g/terminalaccessible.hg
index fde00b5..ea8d7ca 100644
--- a/src/libvtemm/g/terminalaccessible.hg
+++ b/src/libvtemm/g/terminalaccessible.hg
@@ -1,6 +1,6 @@
 /* terminalaccessible.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/init.cc b/src/libvtemm/init.cc
index 9abae05..100f4eb 100644
--- a/src/libvtemm/init.cc
+++ b/src/libvtemm/init.cc
@@ -1,6 +1,6 @@
 /* init.cc
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/init.h b/src/libvtemm/init.h
index 42c69d8..ea0e7aa 100644
--- a/src/libvtemm/init.h
+++ b/src/libvtemm/init.h
@@ -1,6 +1,6 @@
 /* init.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/pty.cc b/src/libvtemm/pty.cc
index cbb37b4..0d82b83 100644
--- a/src/libvtemm/pty.cc
+++ b/src/libvtemm/pty.cc
@@ -1,6 +1,6 @@
 /* pty.cc
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/pty.h b/src/libvtemm/pty.h
index 06bc392..44e9269 100644
--- a/src/libvtemm/pty.h
+++ b/src/libvtemm/pty.h
@@ -1,6 +1,6 @@
 /* pty.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
diff --git a/src/libvtemm/textandcharattrs.cc b/src/libvtemm/textandcharattrs.cc
index 2862964..68fc12f 100644
--- a/src/libvtemm/textandcharattrs.cc
+++ b/src/libvtemm/textandcharattrs.cc
@@ -1,6 +1,6 @@
 /* textandcharattrs.cc
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
@@ -36,12 +36,12 @@ TextAndCharAttrs::~TextAndCharAttrs()
 {
 }
 
-inline Glib::ustring TextAndCharAttrs::get_text() const
+Glib::ustring TextAndCharAttrs::get_text() const
 {
   return text;
 }
 
-inline ArrayHandle_CharAttributes TextAndCharAttrs::get_attributes() const
+ArrayHandle_CharAttributes TextAndCharAttrs::get_attributes() const
 {
   return attributes;
 }
diff --git a/src/libvtemm/textandcharattrs.h b/src/libvtemm/textandcharattrs.h
index 874d492..f35972d 100644
--- a/src/libvtemm/textandcharattrs.h
+++ b/src/libvtemm/textandcharattrs.h
@@ -1,6 +1,6 @@
 /* textandcharattrs.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *
@@ -33,16 +33,13 @@ namespace Vte
  */
 class TextAndCharAttrs
 {
-private:
-  ArrayHandle_CharAttributes attributes;
-  Glib::ustring text;
 public:
 /** The only way to fill #Gnome::Vte::TextAndCharAttrs class.
  * @param src_text String to store.
  * @param src_attributes Array of string's attributes.
  */
   TextAndCharAttrs(const Glib::ustring& src_text, const ArrayHandle_CharAttributes& src_attributes);
-  ~TextAndCharAttrs();
+  virtual ~TextAndCharAttrs();
 
 /** Gets stored string.
  * @return Stored string.
@@ -54,6 +51,9 @@ public:
  */
   ArrayHandle_CharAttributes get_attributes() const;
   // well, setters are not needed.
+private:
+  ArrayHandle_CharAttributes attributes;
+  Glib::ustring text;
 };
 
 } // namespace Vte
diff --git a/src/libvtemm/wrap_init.h b/src/libvtemm/wrap_init.h
index 6dcfff1..7fd12de 100644
--- a/src/libvtemm/wrap_init.h
+++ b/src/libvtemm/wrap_init.h
@@ -1,6 +1,6 @@
 /* wrap_init.h
  *
- * Copyright (C) 2008 libvtemm Development Team
+ * Copyright (C) 2008, 2009 libvtemm Development Team
  *
  * This file is part of libvtemm.
  *



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