/usr/share/doc/gtkmm-documentation/tutorial/html/sec-infobar.html is in gtkmm-documentation 3.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>InfoBar</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Programming with gtkmm 3">
<link rel="up" href="chapter-misc-widgets.html" title="Chapter 7. Miscellaneous Widgets">
<link rel="prev" href="sec-progressbar.html" title="ProgressBar">
<link rel="next" href="sec-tooltips.html" title="Tooltips">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">InfoBar</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="sec-progressbar.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<th width="60%" align="center">Chapter 7. Miscellaneous Widgets</th>
<td width="20%" align="right"> <a accesskey="n" href="sec-tooltips.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="InfoBar">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sec-infobar"></a>InfoBar</h2></div></div></div>
<p>
An <code class="classname">InfoBar</code> may show small items of information or to ask brief questions. Unlike a <code class="classname">Dialog</code>, it appears at the top of the current window instead of opening a new window. Its API is very similar to the <a class="link" href="chapter-dialogs.html" title="Chapter 16. Dialogs">Gtk::Dialog</a> API.</p>
<p><a class="ulink" href="http://developer.gnome.org/gtkmm/unstable/classGtk_1_1InfoBar.html" target="_top">Reference</a></p>
<div class="sect2" title="Example">
<div class="titlepage"><div><div><h3 class="title">
<a name="infobar-example"></a>Example</h3></div></div></div>
<div class="figure">
<a name="figure-infobar"></a><p class="title"><b>Figure 7.8. InfoBar</b></p>
<div class="figure-contents"><div class="screenshot"><div><img src="figures/infobar.png" alt="InfoBar"></div></div></div>
</div>
<br class="figure-break"><p><a class="ulink" href="http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/infobar?h=master" target="_top">Source Code</a></p>
<p>File: <code class="filename">examplewindow.h</code> (For use with gtkmm 3, not gtkmm 2)
</p>
<pre class="programlisting">
#ifndef GTKMM_EXAMPLEWINDOW_H
#define GTKMM_EXAMPLEWINDOW_H
#include <gtkmm.h>
class ExampleWindow : public Gtk::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
//Signal handlers:
void on_infobar_response(int response);
void on_button_quit();
void on_button_clear();
void on_textbuffer_changed();
//Child widgets:
Gtk::Box m_VBox;
Gtk::ScrolledWindow m_ScrolledWindow;
Gtk::TextView m_TextView;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBuffer;
Gtk::InfoBar m_InfoBar;
Gtk::Label m_Message_Label;
Gtk::ButtonBox m_ButtonBox;
Gtk::Button m_Button_Quit, m_Button_Clear;
};
#endif //GTKMM_EXAMPLEWINDOW_H
</pre>
<p>File: <code class="filename">examplewindow.cc</code> (For use with gtkmm 3, not gtkmm 2)
</p>
<pre class="programlisting">
#include "examplewindow.h"
ExampleWindow::ExampleWindow()
: m_VBox(Gtk::ORIENTATION_VERTICAL, 6),
m_Button_Quit(Gtk::Stock::QUIT),
m_Button_Clear("Clear")
{
set_title("Gtk::InfoBar example");
set_border_width(6);
set_default_size(400, 200);
add(m_VBox);
// Add the message label to the InfoBar:
Gtk::Container* infoBarContainer =
dynamic_cast<Gtk::Container*>(m_InfoBar.get_content_area());
if (infoBarContainer)
infoBarContainer->add(m_Message_Label);
// Add an ok button to the InfoBar:
m_InfoBar.add_button(Gtk::Stock::OK, 0);
// Add the InfoBar to the vbox:
m_VBox.pack_start(m_InfoBar, Gtk::PACK_SHRINK);
// Create the buffer and set it for the TextView:
m_refTextBuffer = Gtk::TextBuffer::create();
m_TextView.set_buffer(m_refTextBuffer);
// Add the TreeView, inside a ScrolledWindow:
m_ScrolledWindow.add(m_TextView);
// Show the scrollbars only when they are necessary:
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
m_VBox.pack_start(m_ScrolledWindow);
// Add button box:
m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_Button_Clear, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
m_ButtonBox.set_spacing(6);
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
// Connect signals:
m_InfoBar.signal_response().connect(sigc::mem_fun(*this,
&ExampleWindow::on_infobar_response) );
m_Button_Quit.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow::on_button_quit) );
m_Button_Clear.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow::on_button_clear) );
m_refTextBuffer->signal_changed().connect(sigc::mem_fun(*this,
&ExampleWindow::on_textbuffer_changed) );
show_all_children();
// Keep the InfoBar hidden until a message needs to be shown:
m_InfoBar.hide();
// Make the clear button insensitive until text is typed in the buffer. When
// the button is sensitive and it is pressed, the InfoBar is displayed with a
// message.
m_Button_Clear.set_sensitive(false);
}
ExampleWindow::~ExampleWindow()
{
}
void ExampleWindow::on_infobar_response(int)
{
// Clear the message and hide the info bar:
m_Message_Label.set_text("");
m_InfoBar.hide();
}
void ExampleWindow::on_button_quit()
{
hide();
}
void ExampleWindow::on_button_clear()
{
m_refTextBuffer->set_text("");
m_Message_Label.set_text("Cleared the text.");
m_InfoBar.set_message_type(Gtk::MESSAGE_INFO);
m_InfoBar.show();
}
void ExampleWindow::on_textbuffer_changed()
{
m_Button_Clear.set_sensitive(m_refTextBuffer->size() > 0);
}
</pre>
<p>File: <code class="filename">main.cc</code> (For use with gtkmm 3, not gtkmm 2)
</p>
<pre class="programlisting">
#include "examplewindow.h"
#include <gtkmm/main.h>
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
//Shows the window and returns when it is closed.
Gtk::Main::run(window);
return 0;
}
</pre>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="sec-progressbar.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<td width="20%" align="center"><a accesskey="u" href="chapter-misc-widgets.html"><img src="icons/up.png" alt="Up"></a></td>
<td width="40%" align="right"> <a accesskey="n" href="sec-tooltips.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">ProgressBar </td>
<td width="20%" align="center"><a accesskey="h" href="index.html"><img src="icons/home.png" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Tooltips</td>
</tr>
</table>
</div>
</body>
</html>
|