summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGlenn Rice <glennricster@gmail.com>2012-12-17 22:53:29 -0600
committerGlenn Rice <glennricster@gmail.com>2012-12-17 22:53:29 -0600
commit8f8154409d5b17e6f7eb3840a52943a5bbe8ec57 (patch)
tree1bfc6f155c1e61b36f1e1117bb4d0780a5ad80eb /examples
parent2fdd7b5a7001168fd3931489d577f9004a9051fc (diff)
Add a remove annots button.
Diffstat (limited to 'examples')
-rw-r--r--examples/demo/annots.cc23
-rw-r--r--examples/demo/annots.h5
2 files changed, 24 insertions, 4 deletions
diff --git a/examples/demo/annots.cc b/examples/demo/annots.cc
index 951b04d..34c7089 100644
--- a/examples/demo/annots.cc
+++ b/examples/demo/annots.cc
@@ -32,9 +32,10 @@
namespace PGD
{
-AnnotView::AnnotView(const Glib::RefPtr<Poppler::Document>& document) :
+AnnotView::AnnotView(const Glib::RefPtr<Poppler::Document>& document, Gtk::Button* remove_button) :
m_Document(document),
- m_Alignment(0.5, 0.5, 1, 1)
+ m_Alignment(0.5, 0.5, 1, 1),
+ m_RemoveButton(remove_button)
{
set_shadow_type(Gtk::SHADOW_NONE);
m_Label.set_markup("<b>Annot Properties</b>");
@@ -266,6 +267,9 @@ void AnnotView::set_annot(const Glib::RefPtr<Poppler::Annot>& annot)
default:
break;
}
+
+ grid->add_row_widget(*m_RemoveButton);
+
grid->show_all();
}
@@ -277,8 +281,9 @@ Annots::Annots(const Glib::RefPtr<Poppler::Document>& document) :
m_PageLabel("Page:"),
m_AddButton("Add Annot"),
m_GetButton("Get Annots"),
+ m_RemoveButton(Gtk::Stock::REMOVE),
m_HPaned(Gtk::ORIENTATION_HORIZONTAL),
- m_AnnotView(document)
+ m_AnnotView(document, &m_RemoveButton)
{
int n_pages = m_Document->get_n_pages();
m_PageSelector.set_range(1, n_pages);
@@ -289,6 +294,8 @@ Annots::Annots(const Glib::RefPtr<Poppler::Document>& document) :
m_AddButton.signal_clicked().connect(sigc::mem_fun(*this, &Annots::add_annot));
m_GetButton.signal_clicked().connect(sigc::mem_fun(*this, &Annots::get_annots));
+ m_RemoveButton.signal_clicked().connect(sigc::mem_fun(*this, &Annots::remove_annot));
+ m_RemoveButton.set_hexpand();
m_HBoxTop.pack_start(m_PageLabel, false, true);
m_HBoxTop.pack_start(m_PageSelector, false, true);
@@ -413,6 +420,16 @@ void Annots::add_annot()
page->add_annot(annot);
}
+void Annots::remove_annot()
+{
+ Gtk::TreeIter iter = m_TreeView.get_selection()->get_selected();
+ if (iter)
+ {
+ m_Document->get_page(m_Page)->remove_annot((*iter)[m_StoreColumns.m_Annot]);
+ m_AnnotStore->erase(iter);
+ }
+}
+
static Glib::ustring get_annot_type_string(Poppler::AnnotType type)
{
switch (type)
diff --git a/examples/demo/annots.h b/examples/demo/annots.h
index 2fc8b8f..988e8f5 100644
--- a/examples/demo/annots.h
+++ b/examples/demo/annots.h
@@ -37,7 +37,7 @@ namespace PGD
class AnnotView : public Gtk::Frame
{
public:
- AnnotView(const Glib::RefPtr<Poppler::Document>& document);
+ AnnotView(const Glib::RefPtr<Poppler::Document>& document, Gtk::Button* remove_button);
void set_annot(const Glib::RefPtr<Poppler::Annot>& annot);
void save_file_attachment();
@@ -47,6 +47,7 @@ class AnnotView : public Gtk::Frame
Gtk::Label m_Label;
Gtk::Alignment m_Alignment;
+ Gtk::Button* m_RemoveButton;
};
class Annots : public Gtk::Box
@@ -57,6 +58,7 @@ class Annots : public Gtk::Box
private:
void page_selector_changed();
void add_annot();
+ void remove_annot();
void get_annots();
void selection_changed();
@@ -86,6 +88,7 @@ class Annots : public Gtk::Box
Gtk::SpinButton m_PageSelector;
Gtk::Button m_AddButton;
Gtk::Button m_GetButton;
+ Gtk::Button m_RemoveButton;
Gtk::ScrolledWindow m_ScrolledWin;
Gtk::Paned m_HPaned;
AnnotView m_AnnotView;