# HG changeset patch # User Thinker K.F. Li # Date 1219335124 -28800 # Node ID ea758bb3bbe2e7412d8556a64be671655e02d644 # Parent 4bb6451ef03687ab2bd86deb5609397f6a6d5620 example diff -r 4bb6451ef036 -r ea758bb3bbe2 examples/svg2code_ex/main.c --- a/examples/svg2code_ex/main.c Thu Aug 21 14:13:50 2008 +0800 +++ b/examples/svg2code_ex/main.c Fri Aug 22 00:12:04 2008 +0800 @@ -3,16 +3,41 @@ #include #include "svg2code_ex.h" +typedef struct _ex_rt ex_rt_t; +struct _ex_rt { + X_MB_runtime_t *rt; + svg2code_ex_t *code; +}; + +static void file_button_handler(event_t *evt, void *arg) { + ex_rt_t *ex_rt = (ex_rt_t *)arg; + + coord_show(ex_rt->code->file_menu); + rdman_coord_changed(ex_rt->rt->rdman, ex_rt->code->file_menu); + rdman_redraw_changed(ex_rt->rt->rdman); +} + int main(int argc, char * const argv[]) { X_MB_runtime_t rt; svg2code_ex_t *svg2code; + ob_factory_t *factory; + subject_t *subject; + ex_rt_t ex_rt; int r; r = X_MB_init(":0.0", 800, 600, &rt); svg2code = svg2code_ex_new(rt.rdman); - X_MB_handle_connection(rt.display, rt.rdman, rt.tman); + factory = rdman_get_ob_factory(rt.rdman); + subject = coord_get_mouse_event(svg2code->file_button); + ex_rt.rt = &rt; + ex_rt.code = svg2code; + subject_add_observer(factory, subject, file_button_handler, &ex_rt); + + X_MB_handle_connection(&rt); + + svg2code_ex_free(svg2code); X_MB_destroy(&rt); return 0; diff -r 4bb6451ef036 -r ea758bb3bbe2 examples/svg2code_ex/svg2code_ex.svg --- a/examples/svg2code_ex/svg2code_ex.svg Thu Aug 21 14:13:50 2008 +0800 +++ b/examples/svg2code_ex/svg2code_ex.svg Fri Aug 22 00:12:04 2008 +0800 @@ -15,8 +15,8 @@ sodipodi:version="0.32" inkscape:version="0.45.1" version="1.0" - sodipodi:docbase="/usr/home/thinker" - sodipodi:docname="drawing.svg" + sodipodi:docbase="/usr/home/thinker/progm/MadButterfly/examples/svg2code_ex" + sodipodi:docname="svg2code_ex.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape"> @@ -229,7 +229,7 @@ rx="4.0216751" ry="5.0559778" />