File: example.cc

package info (click to toggle)
gtkspellmm 3.0.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,940 kB
  • ctags: 260
  • sloc: sh: 11,367; perl: 236; xml: 157; makefile: 74; cpp: 74
file content (61 lines) | stat: -rw-r--r-- 1,952 bytes parent folder | download | duplicates (6)
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
/* Copyright (c) 2013-2014  Sandro Mani <manisandro@gmail.com>
 *
 * This file is part of gtkspellmm.
 *
 * gtkspellmm is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gtkspellmm is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtkmm.h>
#include <gtkspellmm.h>
#include <iostream>

int main(int argc, char **argv)
{
  GtkSpell::init();
  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv,
                                                 "org.gtkmm.examples.gtkspell");

  Gtk::ApplicationWindow window;

  Gtk::TextView view;
  view.set_wrap_mode(Gtk::WRAP_WORD);

  Gtk::ScrolledWindow scroll;
  scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  scroll.set_shadow_type(Gtk::SHADOW_IN);
  scroll.add(view);

  Gtk::Label label("Type some text into the text box.\n"
                   "Try misspelling some words.  Then right-click on them.");

  Gtk::Box box(Gtk::ORIENTATION_VERTICAL, 5);
  box.pack_start(label, false, false, 0);
  box.pack_start(scroll, true, true, 0);

  GtkSpell::Checker spell;
  try {
    spell.set_language("en_US");
  } catch(const GtkSpell::Error& e) {
    label.set_text(Glib::ustring("GtkSpell initialization failed.\n") + e.what());
  }
  spell.attach(view);

  window.set_default_size(400, 400);
  window.set_title("Simple GtkSpell Demonstration");
  window.set_border_width(10);
  window.add(box);
  box.show_all();

  return app->run(window);
}