From 450d16b153ca65b088474c69e5d8972659735731 Mon Sep 17 00:00:00 2001 From: Luca Padovani Date: Thu, 4 Sep 2003 18:46:14 +0000 Subject: [PATCH] * added test View interface. It is basically empty but eventually it will host any gtkmathview-specific method --- helm/gtkmathview-bonobo/Makefile.am | 2 +- helm/gtkmathview-bonobo/configure.ac | 7 +++ helm/gtkmathview-bonobo/idl/.cvsignore | 2 + .../idl/GNOME_GtkMathView_View.idl | 18 ++++++ helm/gtkmathview-bonobo/idl/Makefile.am | 5 ++ helm/gtkmathview-bonobo/src/.cvsignore | 9 +++ .../src/GNOME_GtkMathView.server.in.in | 1 + helm/gtkmathview-bonobo/src/Makefile.am | 32 +++++++++- helm/gtkmathview-bonobo/src/control-factory.c | 8 ++- helm/gtkmathview-bonobo/src/view.c | 58 +++++++++++++++++++ helm/gtkmathview-bonobo/src/view.h | 29 ++++++++++ helm/gtkmathview-bonobo/test/Makefile.am | 5 +- helm/gtkmathview-bonobo/test/main.c | 54 +++++++++++++---- 13 files changed, 213 insertions(+), 17 deletions(-) create mode 100644 helm/gtkmathview-bonobo/idl/.cvsignore create mode 100644 helm/gtkmathview-bonobo/idl/GNOME_GtkMathView_View.idl create mode 100644 helm/gtkmathview-bonobo/idl/Makefile.am create mode 100644 helm/gtkmathview-bonobo/src/view.c create mode 100644 helm/gtkmathview-bonobo/src/view.h diff --git a/helm/gtkmathview-bonobo/Makefile.am b/helm/gtkmathview-bonobo/Makefile.am index 8524127c1..afa1ecdc2 100644 --- a/helm/gtkmathview-bonobo/Makefile.am +++ b/helm/gtkmathview-bonobo/Makefile.am @@ -1,5 +1,5 @@ EXTRA_DIST = config.h.in -SUBDIRS = src test +SUBDIRS = idl src test CLEANFILES = core *.log *.eps pkgconfigdir = $(libdir)/pkgconfig diff --git a/helm/gtkmathview-bonobo/configure.ac b/helm/gtkmathview-bonobo/configure.ac index 06f35c6d0..d07109de5 100644 --- a/helm/gtkmathview-bonobo/configure.ac +++ b/helm/gtkmathview-bonobo/configure.ac @@ -97,9 +97,16 @@ PKG_CHECK_MODULES(GNOMEUI, libgnomeui-2.0) AC_SUBST(GNOMEUI_CFLAGS) AC_SUBST(GNOMEUI_LIBS) +ORBIT_IDL="`$PKG_CONFIG --variable=orbit_idl ORBit-2.0`" +AC_SUBST(ORBIT_IDL) + +BONOBO_IDL_INCLUDES="-I`$PKG_CONFIG --variable=idldir libbonobo-2.0` -I`$PKG_CONFIG --variable=idldir bonobo-activation-2.0`" +AC_SUBST(BONOBO_IDL_INCLUDES) + AC_CONFIG_FILES([ Makefile gtkmathview-bonobo.pc + idl/Makefile src/Makefile src/GNOME_GtkMathView.server.in test/Makefile diff --git a/helm/gtkmathview-bonobo/idl/.cvsignore b/helm/gtkmathview-bonobo/idl/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/helm/gtkmathview-bonobo/idl/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/helm/gtkmathview-bonobo/idl/GNOME_GtkMathView_View.idl b/helm/gtkmathview-bonobo/idl/GNOME_GtkMathView_View.idl new file mode 100644 index 000000000..4cbe0d6bc --- /dev/null +++ b/helm/gtkmathview-bonobo/idl/GNOME_GtkMathView_View.idl @@ -0,0 +1,18 @@ + +#include + +module GNOME { + + module GtkMathView { + + interface View : Bonobo::Unknown { + + void freeze (); + void thaw (); + + }; + + }; + +}; + diff --git a/helm/gtkmathview-bonobo/idl/Makefile.am b/helm/gtkmathview-bonobo/idl/Makefile.am new file mode 100644 index 000000000..1f5839309 --- /dev/null +++ b/helm/gtkmathview-bonobo/idl/Makefile.am @@ -0,0 +1,5 @@ + +idldir = $(datadir)/idl/bonobo-2.0 +idl_DATA = GNOME_GtkMathView_View.idl + +EXTRA_DIST = $(idl_DATA) diff --git a/helm/gtkmathview-bonobo/src/.cvsignore b/helm/gtkmathview-bonobo/src/.cvsignore index f7ad5df6d..d65d76132 100644 --- a/helm/gtkmathview-bonobo/src/.cvsignore +++ b/helm/gtkmathview-bonobo/src/.cvsignore @@ -6,4 +6,13 @@ Makefile Makefile.in libgtkmathview-bonobo.la control-factory.lo +view.lo persist-file.lo +persist-stream.lo +GNOME_GtkMathView_View-common.c +GNOME_GtkMathView_View-common.lo +GNOME_GtkMathView_View-skels.c +GNOME_GtkMathView_View-skels.lo +GNOME_GtkMathView_View-stubs.c +GNOME_GtkMathView_View-stubs.lo +GNOME_GtkMathView_View.h diff --git a/helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in b/helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in index 5d4919470..957c40004 100644 --- a/helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in +++ b/helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in @@ -13,6 +13,7 @@ + diff --git a/helm/gtkmathview-bonobo/src/Makefile.am b/helm/gtkmathview-bonobo/src/Makefile.am index 3abccce7c..9ae3d2cff 100644 --- a/helm/gtkmathview-bonobo/src/Makefile.am +++ b/helm/gtkmathview-bonobo/src/Makefile.am @@ -5,25 +5,51 @@ server_in_files = GNOME_GtkMathView.server.in.in CLEANFILES = $(server_in_files:.server.in.in=.server) +IDL = $(top_srcdir)/idl/GNOME_GtkMathView_View.idl + +IDL_GENERATED_C = \ + GNOME_GtkMathView_View-common.c \ + GNOME_GtkMathView_View-skels.c \ + GNOME_GtkMathView_View-stubs.c + +IDL_GENERATED_H = \ + GNOME_GtkMathView_View.h + +IDL_GENERATED = $(IDL_GENERATED_C) $(IDL_GENERATED_H) + lib_LTLIBRARIES = libgtkmathview-bonobo.la -libgtkmathview_bonobo_la_LIBADD = $(GTKMATHVIEW_LIBS) $(BONOBOUI_LIBS) $(BONOBO_LIBS) +libgtkmathview_bonobo_la_LIBADD = \ + $(GTKMATHVIEW_LIBS) \ + $(BONOBOUI_LIBS) \ + $(BONOBO_LIBS) + libgtkmathview_bonobo_la_LDFLAGS = -version-info @GTKMATHVIEW_CONTROL_VERSION_INFO@ libgtkmathview_bonobo_la_SOURCES = \ + $(IDL_GENERATED_C) \ control-factory.c \ persist-file.c \ - persist-stream.c + persist-stream.c \ + view.c pkginclude_HEADERS = \ control-factory.h \ persist-file.h \ - persist-stream.h + persist-stream.h \ + view.h server_DATA = $(server_in_files:.server.in.in=.server) $(server_in_files:.server.in.in=.server): $(server_in_files:.server.in.in=.server.in) Makefile sed -e "s|\@GTKMATHVIEW_FACTORY_LOCATION\@|$(location)|g" $< >$@ +view.c : $(VIEW_CORBA_GENERATED) + +$(IDL_GENERATED): $(IDL) + $(ORBIT_IDL) $(BONOBO_IDL_INCLUDES) $< + +EXTRA_DIST = $(server_DATA) + INCLUDES = \ $(BONOBOUI_CFLAGS) \ $(BONOBO_CFLAGS) \ diff --git a/helm/gtkmathview-bonobo/src/control-factory.c b/helm/gtkmathview-bonobo/src/control-factory.c index bfed0d5b8..8d4e9a12a 100644 --- a/helm/gtkmathview-bonobo/src/control-factory.c +++ b/helm/gtkmathview-bonobo/src/control-factory.c @@ -1,7 +1,9 @@ + #include #include #include #include "control-factory.h" +#include "view.h" typedef struct _GtkMathViewControlData { @@ -235,7 +237,8 @@ gtk_math_view_control_init(BonoboControl *control,GtkWidget *scrolled_window) BonoboPropertyBag *prop_bag; BonoboObject *persist_file; BonoboObject *persist_stream; - + View* view; + math_view = gtk_math_view_new(NULL,NULL); gtk_widget_show(math_view); @@ -244,6 +247,9 @@ gtk_math_view_control_init(BonoboControl *control,GtkWidget *scrolled_window) gtk_container_add(GTK_CONTAINER (scrolled_window), GTK_WIDGET (control_data->math_view)); + view = view_new(); + bonobo_object_add_interface(BONOBO_OBJECT(control), BONOBO_OBJECT(view)); + persist_file = gtk_math_view_persist_file_new(GTK_MATH_VIEW(math_view)); bonobo_object_add_interface(BONOBO_OBJECT(control), persist_file); diff --git a/helm/gtkmathview-bonobo/src/view.c b/helm/gtkmathview-bonobo/src/view.c new file mode 100644 index 000000000..dc8226e39 --- /dev/null +++ b/helm/gtkmathview-bonobo/src/view.c @@ -0,0 +1,58 @@ + +#include + +#include "view.h" + +static GObjectClass* view_parent_class; + +static void +view_object_finalize(GObject* object) +{ + View* view = VIEW(object); + /* free resources */ + view_parent_class->finalize(object); +} + +static void +impl_view_freeze(PortableServer_Servant servant, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + printf("called freeze\n"); +} + +static void +impl_view_thaw(PortableServer_Servant servant, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + printf("called thaw\n"); +} + +static void +view_class_init(ViewClass* klass) +{ + GObjectClass* object_class = (GObjectClass *) klass; + POA_GNOME_GtkMathView_View__epv* epv = &klass->epv; + + view_parent_class = g_type_class_peek_parent (klass); + object_class->finalize = view_object_finalize; + + epv->freeze = impl_view_freeze; + epv->thaw = impl_view_thaw; +} + +static void +view_init(View* view) +{ + /* do some initialization */ +} + +BONOBO_TYPE_FUNC_FULL (View, GNOME_GtkMathView_View, BONOBO_TYPE_OBJECT, view) + +View* +view_new() +{ + View* view = g_object_new(VIEW_TYPE, NULL); + return view; +} diff --git a/helm/gtkmathview-bonobo/src/view.h b/helm/gtkmathview-bonobo/src/view.h new file mode 100644 index 000000000..1d88c0cfc --- /dev/null +++ b/helm/gtkmathview-bonobo/src/view.h @@ -0,0 +1,29 @@ + +#ifndef __view_h__ +#define __view_h__ + +#include + +#include "GNOME_GtkMathView_View.h" + +#define VIEW_TYPE (view_get_type()) +#define VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), VIEW_TYPE, View)) +#define VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), VIEW_TYPE, ViewClass)) +#define VIEW_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), VIEW_TYPE)) +#define VIEW_IS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), VIEW_TYPE)) +#define VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), VIEW_TYPE, ViewClass)) + +typedef struct { + BonoboObject parent; +} View; + +typedef struct { + BonoboObjectClass parent_class; + POA_GNOME_GtkMathView_View__epv epv; +} ViewClass; + +GType view_get_type(void); +View* view_new(void); + +#endif /* __view_h__ */ + diff --git a/helm/gtkmathview-bonobo/test/Makefile.am b/helm/gtkmathview-bonobo/test/Makefile.am index 7dd730e7e..3336948ff 100644 --- a/helm/gtkmathview-bonobo/test/Makefile.am +++ b/helm/gtkmathview-bonobo/test/Makefile.am @@ -1,7 +1,10 @@ noinst_PROGRAMS = viewer -viewer_SOURCES = main.c +viewer_SOURCES = \ + main.c \ + $(top_srcdir)/src/GNOME_GtkMathView_View-common.c \ + $(top_srcdir)/src/GNOME_GtkMathView_View-stubs.c viewer_LDADD = \ $(BONOBOUI_LIBS) \ diff --git a/helm/gtkmathview-bonobo/test/main.c b/helm/gtkmathview-bonobo/test/main.c index dccb6e63a..84aa7cae1 100644 --- a/helm/gtkmathview-bonobo/test/main.c +++ b/helm/gtkmathview-bonobo/test/main.c @@ -4,6 +4,7 @@ #include #include "control-factory.h" +#include "GNOME_GtkMathView_View.h" static GtkWidget *control; @@ -91,15 +92,14 @@ file_selection_ok_cb (GtkWidget *widget, else { const gchar *fname; - fname = gtk_file_selection_get_filename - (GTK_FILE_SELECTION (file_selection_info.widget)); + fname = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selection_info.widget)); switch (file_selection_info.Operations) { - case LOAD_STREAM: - load_through_persist_stream (fname, interface); - break; - case LOAD_FILE: - load_through_persist_file (fname, interface); - break; + case LOAD_STREAM: + load_through_persist_stream (fname, interface); + break; + case LOAD_FILE: + load_through_persist_file (fname, interface); + break; } } @@ -147,14 +147,44 @@ static void open_through_persist_file_cb (GtkWidget *widget, gpointer data) { - open_dialog (BONOBO_WINDOW (data),LOAD_FILE); + open_dialog (BONOBO_WINDOW (data), LOAD_FILE); } static void open_through_persist_stream_cb(GtkWidget *widget, gpointer data) { - open_dialog(BONOBO_WINDOW(data),LOAD_STREAM); + open_dialog(BONOBO_WINDOW(data), LOAD_STREAM); +} + +static void +test_view(GtkWidget* widget, gpointer data) +{ + CORBA_Object interface; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (bonobo_window_get_contents (BONOBO_WINDOW(data)))), + "IDL:GNOME/GtkMathView/View:1.0", &ev); + CORBA_exception_free (&ev); + + if (interface == CORBA_OBJECT_NIL) + { + g_warning ("The Control does not seem to support `View'."); + } + + CORBA_exception_init (&ev); + GNOME_GtkMathView_View_freeze(interface, &ev); + CORBA_exception_free (&ev); + + CORBA_exception_init (&ev); + GNOME_GtkMathView_View_thaw(interface, &ev); + CORBA_exception_free (&ev); + + CORBA_exception_init (&ev); + Bonobo_Unknown_unref (interface, &ev); + CORBA_Object_release (interface, &ev); + CORBA_exception_free (&ev); } static void @@ -318,6 +348,7 @@ get_font_manager(GtkWidget *widget, static BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("OpenFile", open_through_persist_file_cb), BONOBO_UI_UNSAFE_VERB ("OpenStream", open_through_persist_stream_cb), + BONOBO_UI_UNSAFE_VERB ("TestView", test_view), BONOBO_UI_UNSAFE_VERB ("Size", get_size), BONOBO_UI_UNSAFE_VERB ("Top", get_top), BONOBO_UI_UNSAFE_VERB ("Font Size", get_font_size), @@ -354,11 +385,12 @@ static char ui [] = " " " " " " +" " " " " " " " " " -" " +" " " " -- 2.39.2