[gtksourceviewmm] Fix and add completion test to build.



commit b4b50b8b9d1715d401528acccc4310845c0b9821
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Mon Nov 8 17:05:11 2010 +0100

    Fix and add completion test to build.
    
    * tests/Makefile.am: Added completion test to build.
    * tests/completion/main.cc: Fixed custom object creation, reference count
    of 'this' object and added get_activation() vfunc implementation to make it
    work.

 tests/Makefile.am        |    4 +++-
 tests/completion/main.cc |   20 +++++++++++++++-----
 2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a1c1b5e..1e4e206 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -5,13 +5,15 @@ check_PROGRAMS =	\
 	langs/test	\
 	search/test	\
 	get_buffer/test	\
-	mime_types/test
+	mime_types/test	\
+	completion/test
 
 basic_test_SOURCES	= basic/main.cc
 langs_test_SOURCES	= langs/main.cc
 search_test_SOURCES	= search/main.cc
 get_buffer_test_SOURCES	= get_buffer/main.cc
 mime_types_test_SOURCES	= mime_types/main.cc
+completion_test_SOURCES	= completion/main.cc
 
 gtksourceviewmm_includes = -I$(top_builddir)/gtksourceview $(if $(srcdir:.=),-I$(top_srcdir)/gtksourceview)
 gtksourceviewmm_ldadd    = $(top_builddir)/gtksourceview/gtksourceviewmm/libgtksourceviewmm-$(GTKSOURCEVIEWMM_API_VERSION).la
diff --git a/tests/completion/main.cc b/tests/completion/main.cc
index d6993bc..84a2fce 100644
--- a/tests/completion/main.cc
+++ b/tests/completion/main.cc
@@ -38,7 +38,7 @@ private:
   //virtual void update_info_vfunc(const Glib::RefPtr<const Gsv::SourceCompletionProposal>& proposal, const Gsv::SourceCompletionInfo& info);
   //virtual bool get_start_iter_vfunc(const Glib::RefPtr<const Gsv::SourceCompletionContext>& context, const Glib::RefPtr<const Gsv::SourceCompletionProposal>& proposal, Gtk::TextIter& iter);
   //virtual bool activate_proposal_vfunc(const Glib::RefPtr<Gsv::SourceCompletionProposal>& proposal, const Gtk::TextIter& iter);
-  //virtual Gsv::SourceCompletionActivation get_activation_vfunc() const;
+  virtual Gsv::SourceCompletionActivation get_activation_vfunc() const;
   //virtual int get_interactive_delay_vfunc() const;
   virtual int get_priority_vfunc() const;
 
@@ -67,6 +67,9 @@ void TestProvider::set_name(const Glib::ustring& name)
 }
 
 TestProvider::TestProvider()
+: Glib::ObjectBase(typeid(TestProvider)),
+  Glib::Object(),
+  Gsv::SourceCompletionProvider()
 {
   m_proposals.push_back( Gsv::SourceCompletionItem::create( "Proposal 1", "Proposal 1", get_icon_vfunc(), "" ) );
   m_proposals.push_back( Gsv::SourceCompletionItem::create( "Proposal 2", "Proposal 2", get_icon_vfunc(), "" ) );
@@ -90,14 +93,21 @@ Glib::RefPtr<const Gdk::Pixbuf> TestProvider::get_icon_vfunc() const
 
 void TestProvider::populate_vfunc(const Glib::RefPtr<Gsv::SourceCompletionContext>& context)
 {
-  context->add_proposals(Glib::RefPtr<TestProvider>(this), m_proposals, true);
+  Glib::RefPtr<TestProvider> reffed_this(this);
+  reffed_this->reference();
+  context->add_proposals(reffed_this, m_proposals, true);
 }
 
-bool TestProvider::match_vfunc(const Glib::RefPtr<const Gsv::SourceCompletionContext>& context) const
+bool TestProvider::match_vfunc(const Glib::RefPtr<const Gsv::SourceCompletionContext>& /* context */) const
 {
   return true;
 }
 
+Gsv::SourceCompletionActivation TestProvider::get_activation_vfunc() const
+{
+  return Gsv::SOURCE_COMPLETION_ACTIVATION_INTERACTIVE | Gsv::SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED;
+}
+
 int TestProvider::get_priority_vfunc() const
 {
   return m_priority;
@@ -181,13 +191,13 @@ TestWindow::TestWindow()
 
   tp->set_priority(1);
   tp->set_name("Test Provider 1");
-  m_completion->add_provider(Glib::RefPtr<Gsv::SourceCompletionProvider>::cast_dynamic(tp));
+  m_completion->add_provider(tp);
 
   tp = TestProvider::create();
 
   tp->set_priority(5);
   tp->set_name("Test Provider 5");
-  m_completion->add_provider(Glib::RefPtr<Gsv::SourceCompletionProvider>::cast_dynamic(tp));
+  m_completion->add_provider(tp);
 }
 
 TestWindow::~TestWindow()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]