[libvtemm] Extended a simple terminal example.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: svn-commits-list gnome org
- Subject: [libvtemm] Extended a simple terminal example.
- Date: Thu, 14 May 2009 10:52:16 -0400 (EDT)
commit 51add74acd9aeda213d8f7463b56110f770bcea0
Author: Krzesimir Nowak <krnowak svn gnome org>
Date: Thu May 14 16:51:09 2009 +0200
Extended a simple terminal example.
* examples/simple.cc:
* examples/simple.h: Added a scrollbar and fix setting geometry
hints code (based on code from gnome-terminal).
---
examples/simple/simple.cc | 32 ++++++++++++++++++++++++++------
examples/simple/simple.h | 2 ++
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/examples/simple/simple.cc b/examples/simple/simple.cc
index eac8daf..6975b63 100644
--- a/examples/simple/simple.cc
+++ b/examples/simple/simple.cc
@@ -18,8 +18,8 @@
* along with Terminal Example. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <vector>
#include <string>
+#include <vector>
#include <unistd.h>
#include <sys/types.h>
@@ -32,25 +32,45 @@ std::string get_shell();
Simple::Simple()
:
- m_terminal()
+ m_box(),
+ m_terminal(),
+ m_scrollbar(*(m_terminal.get_adjustment()))
{
+ // first put everything into their proper places, then set them up.
+ // add terminal to box.
+ m_box.pack_start(m_terminal);
+ // add scrollbar to box.
+ m_box.pack_start(m_scrollbar);
+ // put box into window.
+ add(m_box);
+ // set up a 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(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();
+ // setting geometry hints is based on gnome-terminal code.
Gdk::Geometry hints;
- hints.base_width = hints.min_width = hints.width_inc = m_terminal.get_char_width();
- hints.base_height = hints.min_height = hints.height_inc = m_terminal.get_char_height();
+ Gnome::Vte::Padding pads(m_terminal.get_padding());
+ hints.base_width = pads.get_x_pad();
+ hints.base_height = pads.get_y_pad();
+ hints.width_inc = m_terminal.get_char_width();
+ hints.height_inc = m_terminal.get_char_height();
+ const int min_width_chars = 4;
+ const int min_height_chars = 2;
+ hints.min_width = hints.base_width + hints.width_inc * min_width_chars;
+ hints.min_height = hints.base_height + hints.height_inc * min_height_chars;
set_geometry_hints(m_terminal, hints, Gdk::HINT_RESIZE_INC | Gdk::HINT_MIN_SIZE | Gdk::HINT_BASE_SIZE);
+ // scrollbar is already set up during initialization, so nothing to do here.
+ // set up a window.
+ set_title("Simple Gnome::Vte::Terminal example");
+ // show us the co... terminal, we mean.
show_all_children();
}
diff --git a/examples/simple/simple.h b/examples/simple/simple.h
index fdb8fcc..9248e53 100644
--- a/examples/simple/simple.h
+++ b/examples/simple/simple.h
@@ -35,7 +35,9 @@ protected:
virtual void on_child_exited();
//Member widgets:
+ Gtk::HBox m_box;
Gnome::Vte::Terminal m_terminal;
+ Gtk::VScrollbar m_scrollbar;
};
#endif // _LIBVTEMM_EXAMPLE_SIMPLE_H_
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]