Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 916d33628a558f568f42a3b32e800b17 > files > 75

libvtemm-docs-0.23.1-2.fc15.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>libvtemm: simple/main.cc</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>simple/main.cc</h1><p>The simple terminal launching shell. </p>
<div class="fragment"><pre class="fragment"><span class="comment">/* simple.h</span>
<span class="comment"> *</span>
<span class="comment"> * Copyright (C) 2008, 2009 libvtemm Development Team</span>
<span class="comment"> *</span>
<span class="comment"> * This file is part of Terminal Example.</span>
<span class="comment"> *</span>
<span class="comment"> * Terminal Example is free software: you can redistribute it and/or modify</span>
<span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<span class="comment"> * the Free Software Foundation, either version 3 of the License, or</span>
<span class="comment"> * (at your option) any later version.</span>
<span class="comment"> *</span>
<span class="comment"> * Terminal Example is distributed in the hope that it will be useful,</span>
<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<span class="comment"> * GNU General Public License for more details.</span>
<span class="comment"> *</span>
<span class="comment"> * You should have received a copy of the GNU General Public License</span>
<span class="comment"> * along with Terminal Example. If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span class="comment"> */</span>

<span class="preprocessor">#ifndef _LIBVTEMM_EXAMPLE_SIMPLE_H_</span>
<span class="preprocessor"></span><span class="preprocessor">#define _LIBVTEMM_EXAMPLE_SIMPLE_H_</span>
<span class="preprocessor"></span>
<span class="preprocessor">#include &lt;gtkmm.h&gt;</span>
<span class="preprocessor">#include &lt;libvtemm/terminal.h&gt;</span>

<span class="keyword">class </span>Simple : <span class="keyword">public</span> Gtk::Window
{
<span class="keyword">public</span>:
  Simple();
  <span class="keyword">virtual</span> ~Simple();
<span class="keyword">protected</span>:
  <span class="comment">//Signal handlers:</span>
  <span class="keyword">virtual</span> <span class="keywordtype">void</span> on_child_exited();
<span class="keyword">private</span>:
  <span class="comment">//Member widgets:</span>
  <a name="_a0"></a><a class="codeRef" href="../../../gtkmm-2.4/reference/html/classGtk_1_1HBox.html">Gtk::HBox</a> m_box;
  <a name="_a1"></a><a class="code" href="classGnome_1_1Vte_1_1Terminal.html" title="Terminal - a terminal emulator implemented as a gtkmm widget.">Gnome::Vte::Terminal</a> m_terminal;
  <a name="_a2"></a><a class="codeRef" href="../../../gtkmm-2.4/reference/html/classGtk_1_1VScrollbar.html">Gtk::VScrollbar</a> m_scrollbar;
};

<span class="preprocessor">#endif // _LIBVTEMM_EXAMPLE_SIMPLE_H_</span>
</pre></div> <div class="fragment"><pre class="fragment"><span class="comment">/* simple.cc</span>
<span class="comment"> *</span>
<span class="comment"> * Copyright (C) 2008, 2009 libvtemm Development Team</span>
<span class="comment"> *</span>
<span class="comment"> * This file is part of Terminal Example.</span>
<span class="comment"> *</span>
<span class="comment"> * Terminal Example is free software: you can redistribute it and/or modify</span>
<span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<span class="comment"> * the Free Software Foundation, either version 3 of the License, or</span>
<span class="comment"> * (at your option) any later version.</span>
<span class="comment"> *</span>
<span class="comment"> * Terminal Example is distributed in the hope that it will be useful,</span>
<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<span class="comment"> * GNU General Public License for more details.</span>
<span class="comment"> *</span>
<span class="comment"> * You should have received a copy of the GNU General Public License</span>
<span class="comment"> * along with Terminal Example. If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &lt;<a class="codeRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01090.html">vector</a>&gt;</span>

<span class="preprocessor">#include &quot;simple.h&quot;</span>

Simple::Simple()
:
  m_box(),
  m_terminal(),
  m_scrollbar(m_terminal.get_adjustment())
{
  <span class="comment">// first put everything into their proper places, then set them up.</span>
  <span class="comment">// add terminal to box.</span>
  m_box.pack_start(m_terminal);
  <span class="comment">// add scrollbar to box.</span>
  m_box.pack_start(m_scrollbar);
  <span class="comment">// put box into window.</span>
  <a class="codeRef" href="../../../gtkmm-2.4/reference/html/namespaceGtk_1_1Stock.html#af5a3d62d679e3dd162bd77ac76205105">add</a>(m_box);
  <span class="comment">// set up a terminal.</span>
  m_terminal.fork_command();
  m_terminal.set_size(80, 24);
  m_terminal.signal_child_exited().connect(<a name="a3"></a><a class="codeRef" href="../../../libsigc++-2.0/reference/html/group__mem__fun.html#ga7d9ea809173f48bf5c76cf1989591602">sigc::mem_fun</a>(*<span class="keyword">this</span>, &amp;Simple::on_child_exited));
  m_terminal.set_flags(<a name="a4"></a><a class="codeRef" href="../../../gtkmm-2.4/reference/html/group__gtkmmEnums.html#gga3d42e9e6671e48764b3b42bcc8da0b47adb2ae38c34591e0b352336f576033ffe">Gtk::CAN_FOCUS</a>);
  m_terminal.grab_focus();
  <span class="comment">// Set geometry hints, so resizing will work nicely.</span>
  <a class="codeRef" href="../../../gtkmm-2.4/reference/html/namespaceGdk.html#af6948e754cab4e79c6430fb94e438d83">Gdk::Geometry</a> hints;
  <a class="codeRef" href="../../../gtkmm-2.4/reference/html/namespaceGtk.html#a0aed0ea6fbd347e76872f23f9313545e">Gtk::Border</a> inner_border;
  m_terminal.get_style_property(<span class="stringliteral">&quot;inner-border&quot;</span>, 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();
  <span class="keyword">const</span> <span class="keywordtype">int</span> min_width_chars = 4;
  <span class="keyword">const</span> <span class="keywordtype">int</span> 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, <a name="a5"></a><a class="codeRef" href="../../../gtkmm-2.4/reference/html/group__gdkmmEnums.html#gga7dd31e80216f3452a1e080bd22fcfd9cae225c378cd4334c2615a8435d7d0ad6a">Gdk::HINT_RESIZE_INC</a> | <a name="a6"></a><a class="codeRef" href="../../../gtkmm-2.4/reference/html/group__gdkmmEnums.html#gga7dd31e80216f3452a1e080bd22fcfd9ca2acd5d248d5280290d4ef8a1669578af">Gdk::HINT_MIN_SIZE</a> | <a name="a7"></a><a class="codeRef" href="../../../gtkmm-2.4/reference/html/group__gdkmmEnums.html#gga7dd31e80216f3452a1e080bd22fcfd9ca2ec7605e5e173f09ac7cc9c31e8f0c38">Gdk::HINT_BASE_SIZE</a>);
  <span class="comment">// scrollbar is already set up during initialization, so nothing to do here.</span>
  <span class="comment">// set up a window.</span>
  set_title(<span class="stringliteral">&quot;Simple Gnome::Vte::Terminal example&quot;</span>);
  <span class="comment">// show us the co... terminal, we mean.</span>
  show_all_children();
}

Simple::~Simple()
{}

<span class="keywordtype">void</span>
Simple::on_child_exited()
{
  <a name="a8"></a><a class="codeRef" href="../../../libsigc++-2.0/reference/html/group__hide.html#gaf28d43958b26c67e314f726540463c44">hide</a>();
}
</pre></div><div class="fragment"><pre class="fragment"><span class="comment">/* main.cc</span>
<span class="comment"> *</span>
<span class="comment"> * Copyright (C) 2008, 2009 libvtemm Development Team</span>
<span class="comment"> *</span>
<span class="comment"> * This file is part of Terminal Example.</span>
<span class="comment"> *</span>
<span class="comment"> * Terminal Example is free software: you can redistribute it and/or modify</span>
<span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<span class="comment"> * the Free Software Foundation, either version 3 of the License, or</span>
<span class="comment"> * (at your option) any later version.</span>
<span class="comment"> *</span>
<span class="comment"> * Terminal Example is distributed in the hope that it will be useful,</span>
<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<span class="comment"> * GNU General Public License for more details.</span>
<span class="comment"> *</span>
<span class="comment"> * You should have received a copy of the GNU General Public License</span>
<span class="comment"> * along with Terminal Example. If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &lt;gtkmm.h&gt;</span>
<span class="preprocessor">#include &lt;libvtemm/init.h&gt;</span>
<span class="preprocessor">#include &quot;simple.h&quot;</span>

<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
{
  <a name="_a9"></a><a class="codeRef" href="../../../gtkmm-2.4/reference/html/classGtk_1_1Main.html">Gtk::Main</a> kit(argc, argv);
  Gnome::Vte::init();
  Simple window;
  <a name="a10"></a><a class="codeRef" href="../../../gtkmm-2.4/reference/html/classGtk_1_1Main.html#a6a8904c35952006d13cb07c1d0c16c10">Gtk::Main::run</a>(window);
  <span class="keywordflow">return</span> 0;
}
</pre></div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 14 Jan 2010 for libvtemm by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>