[g-a-devel]C++ bindings



Sorry for the flood of mails !
As my previous posts have been showing, I've a hard time avoiding 
troubles with the at-spi API :-(
Not your fault, but managing ref & unref is error prone with threads 
and exceptions (I' coding in C++).
I could live with the leaks, but SPI_exit is not so forgiving and it  
then segfaults on me :-(
Tired of chasing my bugs, I wanted to use a C++ wrapper to manage the 
pointers. On Gtkmm.org, I only found atk stuff so I  decided to bite 
the bullet and code the C++ wrapper.

For now, it's only at proof-of-concept stage. I'm using 
boost::shared_pointer for ref & unref and a global variable for init 
& exit. Glib::ustring is used for UTF8 strings handling.

Would anybody here be interested in this stuff or would gtkmm be more 
appropriate ?

I don't want to bother you with the library code (and my coding 
standards would upset you :-) ) if there is no interest, but here is 
some use code:

//g++ -o TestSPI++ TestSPI++.cxx  `pkg-config  cspi-1.0 libspi-1.0 
gtkmm-2.0 --cflags --libs` -lstdc++

#include <iostream>
#include "SPI++.hxx"

struct dummy_handler: spi::event_handler {
  void operator()( spi::event e){

    spi::accessible source(e.source());
    unsigned int nbParents;
    for( nbParents =0 ; source.parent()!= 
spi::accessible::no_accessible; ++nbPa
rents){
      source = source.parent();
    }
    std::cerr<<"type "<< e.type()<<" with "<<nbParents<<" parents\n"; 
}
};

struct quit_handler: spi::event_handler{
  void operator()( spi::event e){ spi::quit();}
};

int main(){
  char* eventTypes[]={   "focus:"
                         , "mouse:button"
                         , "window:maximize"
                         , "window:restore"
                         , "window:activate"
                         , "window:deactivate"
                         , "window:close"
                         , "window:lower"
                         , "window:raise"
                         , "window:resize"
                         , "window:shade"
                         , "window:unshade"
  };

  dummy_handler dh;
  spi::event_listener<dummy_handler> listener(dh);
  for(unsigned int e=0; e !=  sizeof(eventTypes)/sizeof(char*); ++e)
    { listener.handle(eventTypes[e]); }
  quit_handler qh;
  spi::event_listener<quit_handler> quit(qh);
  quit.handle("mouse:button:3p");
  spi::main();
  return 0;
}

Anybody interested ?

Bernard




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