2002-07-05 Rachel Hestilow <hestilow@ximian.com>

* configure.in: Conditionally compile Gnome.

	* parser/gapi_pp.pl: Handle line breaks in function declarations.
	* parser/gapi2xml.pl: Handle non-literals in property definitions.

	* glue/program.c: Added.
	* glue/Makefile.am: Add program.c (conditionally compiled).
	Update INCLUDES.

	* gnome/Makefile.in: Conditionally compile this.
	* gnome/Program.custom, Modules.cs: Added.

	* samples/Makefile.in: Conditionally compile gnome example.
	* samples/GnomeHelloWorld.cs: Use Gnome.Program.

svn path=/trunk/gtk-sharp/; revision=5609
This commit is contained in:
Rachel Hestilow 2002-07-05 20:22:21 +00:00
parent 00e98b4c30
commit 9693ee998e
13 changed files with 451 additions and 47 deletions

View file

@ -1,3 +1,20 @@
2002-07-05 Rachel Hestilow <hestilow@ximian.com>
* configure.in: Conditionally compile Gnome.
* parser/gapi_pp.pl: Handle line breaks in function declarations.
* parser/gapi2xml.pl: Handle non-literals in property definitions.
* glue/program.c: Added.
* glue/Makefile.am: Add program.c (conditionally compiled).
Update INCLUDES.
* gnome/Makefile.in: Conditionally compile this.
* gnome/Program.custom, Modules.cs: Added.
* samples/Makefile.in: Conditionally compile gnome example.
* samples/GnomeHelloWorld.cs: Use Gnome.Program.
2002-07-01 Rachel Hestilow <hestilow@ximian.com> 2002-07-01 Rachel Hestilow <hestilow@ximian.com>
* generator/gtkapi.xml: * generator/gtkapi.xml:

View file

@ -57,20 +57,25 @@ AC_ARG_WITH(crosspkgdir, [ --with-crosspkgdir=/path/to/pkg-config/dir],
fi fi
) )
## Versions of dependencies ## Versions of dependencies
GNOME_REQUIRED_VERSION=2.0.0
GTK_REQUIRED_VERSION=2.0.0 GTK_REQUIRED_VERSION=2.0.0
PKG_CHECK_MODULES(BASE_DEPENDENCIES, libgnome-2.0 >= $GNOME_REQUIRED_VERSION gtk+-2.0 >= $GTK_REQUIRED_VERSION gmodule-2.0 >= $GTK_REQUIRED_VERSION, enable_gnome=yes, enable_gnome=no)
PKG_CHECK_MODULES(BASE_DEPENDENCIES, gtk+-2.0 >= $GTK_REQUIRED_VERSION) if test "x$enable_gnome" = "xno"; then
PKG_CHECK_MODULES(BASE_DEPENDENCIES, gtk+-2.0 >= $GTK_REQUIRED_VERSION gmodule-2.0 >= $GTK_REQUIRED_VERSION)
fi
GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0` #GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-2.0`
GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0` #GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0`
GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0` #GMODULE_CFLAGS=`$PKG_CONFIG --cflags gmodule-2.0`
GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0` #GMODULE_LIBS=`$PKG_CONFIG --libs gmodule-2.0`
AC_SUBST(GTK_CFLAGS) AC_SUBST(BASE_DEPENDENCIES_CFLAGS)
AC_SUBST(GTK_LIBS) AC_SUBST(BASE_DEPENDENCIES_LIBS)
AC_SUBST(GMODULE_CFLAGS)
AC_SUBST(GMODULE_LIBS) AM_CONDITIONAL(ENABLE_GNOME, test "x$enable_gnome" = "xyes")
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)

View file

@ -537,9 +537,24 @@
<method name="GetBuffer" cname="gnome_canvas_rich_text_get_buffer"> <method name="GetBuffer" cname="gnome_canvas_rich_text_get_buffer">
<return-type type="GtkTextBuffer*"/> <return-type type="GtkTextBuffer*"/>
</method> </method>
<method name="GetIterLocation" cname="gnome_canvas_rich_text_get_iter_location">
<return-type type="void"/>
<parameters>
<parameter type="const-GtkTextIter*" name="iter"/>
<parameter type="GdkRectangle*" name="location"/>
</parameters>
</method>
<method name="PasteClipboard" cname="gnome_canvas_rich_text_paste_clipboard"> <method name="PasteClipboard" cname="gnome_canvas_rich_text_paste_clipboard">
<return-type type="void"/> <return-type type="void"/>
</method> </method>
<method name="GetIterAtLocation" cname="gnome_canvas_rich_text_get_iter_at_location">
<return-type type="void"/>
<parameters>
<parameter type="GtkTextIter*" name="iter"/>
<parameter type="gint" name="x"/>
<parameter type="gint" name="y"/>
</parameters>
</method>
</object> </object>
<object name="CanvasShape" cname="GnomeCanvasShape" parent="GnomeCanvasItem"> <object name="CanvasShape" cname="GnomeCanvasShape" parent="GnomeCanvasItem">
<field cname="priv" type="GnomeCanvasShapePriv*"/> <field cname="priv" type="GnomeCanvasShapePriv*"/>
@ -923,25 +938,76 @@
</callback> </callback>
<object name="Program" cname="GnomeProgram" parent="GObject"> <object name="Program" cname="GnomeProgram" parent="GObject">
<field cname="_priv" type="GnomeProgramPrivate*"/> <field cname="_priv" type="GnomeProgramPrivate*"/>
<property name="GNOME_PARAM_POPT_TABLE" cname="GNOME_PARAM_POPT_TABLE" type="gpointer" doc-string=" _(The table of options for popt)" writeable="true" construct-only="true"/> <property name="PoptTable" cname="popt-table" type="gpointer" doc-string=" _(The table of options for popt)" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_POPT_FLAGS" cname="GNOME_PARAM_POPT_FLAGS" type="gint" doc-string=" _(The flags to use for popt)" writeable="true" construct-only="true"/> <property name="PoptFlags" cname="popt-flags" type="gint" doc-string=" _(The flags to use for popt)" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_POPT_CONTEXT" cname="GNOME_PARAM_POPT_CONTEXT" type="gpointer" doc-string=" _(The popt context pointer that GnomeProgram is using)" readable="true"/> <property name="PoptContext" cname="popt-context" type="gpointer" doc-string=" _(The popt context pointer that GnomeProgram is using)" readable="true"/>
<property name="GNOME_PARAM_HUMAN_READABLE_NAME" cname="GNOME_PARAM_HUMAN_READABLE_NAME" type="gchar*" doc-string=" _(Human readable name of this application)" readable="true" writeable="true" construct-only="true"/> <property name="HumanReadableName" cname="human-readable-name" type="gchar*" doc-string=" _(Human readable name of this application)" readable="true" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_GNOME_PATH" cname="GNOME_PARAM_GNOME_PATH" type="gchar*" doc-string=" _(Path in which to look for installed files)" readable="true" writeable="true" construct-only="true"/> <property name="GnomePath" cname="gnome-path" type="gchar*" doc-string=" _(Path in which to look for installed files)" readable="true" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_APP_ID" cname="GNOME_PARAM_APP_ID" type="gchar*" doc-string=" _(ID string to use for this application)" readable="true"/> <property name="AppId" cname="app-id" type="gchar*" doc-string=" _(ID string to use for this application)" readable="true"/>
<property name="GNOME_PARAM_APP_VERSION" cname="GNOME_PARAM_APP_VERSION" type="gchar*" doc-string=" _(Version of this application)" readable="true"/> <property name="AppVersion" cname="app-version" type="gchar*" doc-string=" _(Version of this application)" readable="true"/>
<property name="GNOME_PARAM_GNOME_PREFIX" cname="GNOME_PARAM_GNOME_PREFIX" type="gchar*" doc-string=" _(Prefix where GNOME was installed)" readable="true" writeable="true" construct-only="true"/> <property name="GnomePrefix" cname="gnome-prefix" type="gchar*" doc-string=" _(Prefix where GNOME was installed)" readable="true" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_GNOME_LIBDIR" cname="GNOME_PARAM_GNOME_LIBDIR" type="gchar*" doc-string=" _(Library prefix where GNOME was installed)" readable="true" writeable="true" construct-only="true"/> <property name="GnomeLibdir" cname="gnome-libdir" type="gchar*" doc-string=" _(Library prefix where GNOME was installed)" readable="true" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_GNOME_DATADIR" cname="GNOME_PARAM_GNOME_DATADIR" type="gchar*" doc-string=" _(Data prefix where GNOME was installed)" readable="true" writeable="true" construct-only="true"/> <property name="GnomeDatadir" cname="gnome-datadir" type="gchar*" doc-string=" _(Data prefix where GNOME was installed)" readable="true" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_GNOME_SYSCONFDIR" cname="GNOME_PARAM_GNOME_SYSCONFDIR" type="gchar*" doc-string=" _(Configuration prefix where GNOME was installed)" readable="true" writeable="true" construct-only="true"/> <property name="GnomeSysconfdir" cname="gnome-sysconfdir" type="gchar*" doc-string=" _(Configuration prefix where GNOME was installed)" readable="true" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_APP_PREFIX" cname="GNOME_PARAM_APP_PREFIX" type="gchar*" doc-string=" _(Prefix where this application was installed)" readable="true" writeable="true"/> <property name="AppPrefix" cname="app-prefix" type="gchar*" doc-string=" _(Prefix where this application was installed)" readable="true" writeable="true"/>
<property name="GNOME_PARAM_APP_LIBDIR" cname="GNOME_PARAM_APP_LIBDIR" type="gchar*" doc-string=" _(Library prefix where this application was installed)" readable="true" writeable="true"/> <property name="AppLibdir" cname="app-libdir" type="gchar*" doc-string=" _(Library prefix where this application was installed)" readable="true" writeable="true"/>
<property name="GNOME_PARAM_APP_DATADIR" cname="GNOME_PARAM_APP_DATADIR" type="gchar*" doc-string=" _(Data prefix where this application was installed)" readable="true" writeable="true"/> <property name="AppDatadir" cname="app-datadir" type="gchar*" doc-string=" _(Data prefix where this application was installed)" readable="true" writeable="true"/>
<property name="GNOME_PARAM_APP_SYSCONFDIR" cname="GNOME_PARAM_APP_SYSCONFDIR" type="gchar*" doc-string=" _(Configuration prefix where this application was installed)" readable="true" writeable="true"/> <property name="AppSysconfdir" cname="app-sysconfdir" type="gchar*" doc-string=" _(Configuration prefix where this application was installed)" readable="true" writeable="true"/>
<property name="GNOME_PARAM_CREATE_DIRECTORIES" cname="GNOME_PARAM_CREATE_DIRECTORIES" type="gboolean" doc-string=" _(Create standard GNOME directories on startup)" readable="true" writeable="true" construct-only="true"/> <property name="CreateDirectories" cname="create-directories" type="gboolean" doc-string=" _(Create standard GNOME directories on startup)" readable="true" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_ENABLE_SOUND" cname="GNOME_PARAM_ENABLE_SOUND" type="gboolean" doc-string=" _(Enable sound on startup)" readable="true" writeable="true" construct-only="true"/> <property name="EnableSound" cname="enable-sound" type="gboolean" doc-string=" _(Enable sound on startup)" readable="true" writeable="true" construct-only="true"/>
<property name="GNOME_PARAM_ESPEAKER" cname="GNOME_PARAM_ESPEAKER" type="gchar*" doc-string=" _(How to connect to esd)" readable="true" writeable="true" construct-only="true"/> <property name="Espeaker" cname="espeaker" type="gchar*" doc-string=" _(How to connect to esd)" readable="true" writeable="true" construct-only="true"/>
<method name="GetHumanReadableName" cname="gnome_program_get_human_readable_name">
<return-type type="const-char*"/>
</method>
<method name="GetAppVersion" cname="gnome_program_get_app_version">
<return-type type="const-char*"/>
</method>
<method name="Postinit" cname="gnome_program_postinit">
<return-type type="void"/>
</method>
<method name="Preinit" cname="gnome_program_preinit">
<return-type type="poptContext"/>
<parameters>
<parameter type="const-char*" name="app_id"/>
<parameter type="const-char*" name="app_version"/>
<parameter type="int" name="argc"/>
<parameter type="char**" name="argv"/>
</parameters>
</method>
<method name="LocateFile" cname="gnome_program_locate_file">
<return-type type="gchar*"/>
<parameters>
<parameter type="GnomeFileDomain" name="domain"/>
<parameter type="const-gchar*" name="file_name"/>
<parameter type="gboolean" name="only_if_exists"/>
<parameter type="GSList**" name="ret_locations"/>
</parameters>
</method>
<method name="ParseArgs" cname="gnome_program_parse_args">
<return-type type="void"/>
</method>
<method name="GetAppId" cname="gnome_program_get_app_id">
<return-type type="const-char*"/>
</method>
</object> </object>
<boxed name="ModuleInfo" cname="GnomeModuleInfo">
<field cname="name" type="const-char*"/>
<field cname="version" type="const-char*"/>
<field cname="description" type="const-char*"/>
<field cname="requirements" type="GnomeModuleRequirement*"/>
<field cname="instance_init" type="GnomeModuleHook"/>
<field cname="pre_args_parse" type="GnomeModuleHook"/>
<field cname="post_args_parse" type="GnomeModuleHook"/>
<field cname="poptOption* options" type="struct"/>
<field cname="init_pass" type="GnomeModuleInitHook"/>
<field cname="class_init" type="GnomeModuleClassInitHook"/>
<field cname="opt_prefix" type="const-char*"/>
<field cname="expansion1" type="gpointer"/>
</boxed>
<struct name="ModuleRequirement" cname="GnomeModuleRequirement">
<field cname="required_version" type="const-char*"/>
<field cname="module_info" type="const-GnomeModuleInfo*"/>
</struct>
<struct name="ProgramPrivate" cname="GnomeProgramPrivate"> <struct name="ProgramPrivate" cname="GnomeProgramPrivate">
<field cname="{APP_UNINIT=0" type="enum"/> <field cname="{APP_UNINIT=0" type="enum"/>
<field cname="APP_CREATE_DONE=1" type="enum"/> <field cname="APP_CREATE_DONE=1" type="enum"/>
@ -3714,6 +3780,9 @@
<parameter type="const-gchar*" name="fontname"/> <parameter type="const-gchar*" name="fontname"/>
</parameters> </parameters>
</method> </method>
<method name="GetMode" cname="gnome_font_picker_get_mode">
<return-type type="GnomeFontPickerMode"/>
</method>
<method name="SetPreviewText" cname="gnome_font_picker_set_preview_text"> <method name="SetPreviewText" cname="gnome_font_picker_set_preview_text">
<return-type type="void"/> <return-type type="void"/>
<parameters> <parameters>
@ -4166,6 +4235,12 @@
<return-type type="GtkWidget*"/> <return-type type="GtkWidget*"/>
</method> </method>
<constructor cname="gnome_icon_selection_new"/> <constructor cname="gnome_icon_selection_new"/>
<method name="GetIcon" cname="gnome_icon_selection_get_icon">
<return-type type="gchar*"/>
<parameters>
<parameter type="gboolean" name="full_path"/>
</parameters>
</method>
<method name="AddDirectory" cname="gnome_icon_selection_add_directory"> <method name="AddDirectory" cname="gnome_icon_selection_add_directory">
<return-type type="void"/> <return-type type="void"/>
<parameters> <parameters>
@ -6430,8 +6505,8 @@
<callback cname="child_func"> <callback cname="child_func">
<return-type type="gboolean"/> <return-type type="gboolean"/>
<parameters> <parameters>
<parameter type="gboolean " name="child_func"/> <parameter type=" gboolean " name="child_func"/>
<parameter type="gboolean " name="child_func"/> <parameter type=" gboolean " name="child_func"/>
</parameters> </parameters>
</callback> </callback>
<parameter type="gpointer" name="user_data"/> <parameter type="gpointer" name="user_data"/>
@ -13178,7 +13253,7 @@
<constructor cname="gtk_list_store_new"> <constructor cname="gtk_list_store_new">
<parameters> <parameters>
<parameter type="gint" name="n_columns"/> <parameter type="gint" name="n_columns"/>
<parameter type="g" name=""/> <parameter type=" " name=""/>
</parameters> </parameters>
</constructor> </constructor>
<method name="Prepend" cname="gtk_list_store_prepend"> <method name="Prepend" cname="gtk_list_store_prepend">
@ -16265,7 +16340,7 @@
<return-type type="void"/> <return-type type="void"/>
<parameters> <parameters>
<parameter type="GtkWidget*" name="child"/> <parameter type="GtkWidget*" name="child"/>
<parameter type="gint" name="xpos"/> <parameter type="/*" name="window"/>
<parameter type="gint" name="ypos"/> <parameter type="gint" name="ypos"/>
</parameters> </parameters>
</method> </method>
@ -16473,7 +16548,7 @@
<parameters> <parameters>
<parameter type="GtkWidget*" name="child"/> <parameter type="GtkWidget*" name="child"/>
<parameter type="GtkTextWindowType" name="which_window"/> <parameter type="GtkTextWindowType" name="which_window"/>
<parameter type="gint" name="xpos"/> <parameter type="/*" name="window"/>
<parameter type="gint" name="ypos"/> <parameter type="gint" name="ypos"/>
</parameters> </parameters>
</method> </method>
@ -17250,7 +17325,7 @@
<constructor cname="gtk_tree_store_new"> <constructor cname="gtk_tree_store_new">
<parameters> <parameters>
<parameter type="gint" name="n_columns"/> <parameter type="gint" name="n_columns"/>
<parameter type="g" name=""/> <parameter type=" " name=""/>
</parameters> </parameters>
</constructor> </constructor>
<method name="InsertBefore" cname="gtk_tree_store_insert_before"> <method name="InsertBefore" cname="gtk_tree_store_insert_before">
@ -21446,6 +21521,9 @@
<parameter type="gint**" name="selected"/> <parameter type="gint**" name="selected"/>
</parameters> </parameters>
</method> </method>
<method name="GetCaption" cname="atk_table_get_caption">
<return-type type="AtkObject*"/>
</method>
<method name="GetRowAtIndex" cname="atk_table_get_row_at_index"> <method name="GetRowAtIndex" cname="atk_table_get_row_at_index">
<return-type type="gint"/> <return-type type="gint"/>
<parameters> <parameters>
@ -21464,6 +21542,12 @@
<parameter type="gint" name="row"/> <parameter type="gint" name="row"/>
</parameters> </parameters>
</method> </method>
<method name="RemoveColumnSelection" cname="atk_table_remove_column_selection">
<return-type type="gboolean"/>
<parameters>
<parameter type="gint" name="column"/>
</parameters>
</method>
<method name="SetRowDescription" cname="atk_table_set_row_description"> <method name="SetRowDescription" cname="atk_table_set_row_description">
<return-type type="void"/> <return-type type="void"/>
<parameters> <parameters>
@ -21491,6 +21575,13 @@
<parameter type="AtkObject*" name="header"/> <parameter type="AtkObject*" name="header"/>
</parameters> </parameters>
</method> </method>
<method name="SetColumnDescription" cname="atk_table_set_column_description">
<return-type type="void"/>
<parameters>
<parameter type="gint" name="column"/>
<parameter type="const-gchar*" name="description"/>
</parameters>
</method>
<method name="RemoveRowSelection" cname="atk_table_remove_row_selection"> <method name="RemoveRowSelection" cname="atk_table_remove_row_selection">
<return-type type="gboolean"/> <return-type type="gboolean"/>
<parameters> <parameters>
@ -21571,12 +21662,24 @@
<parameter type="gint**" name="selected"/> <parameter type="gint**" name="selected"/>
</parameters> </parameters>
</method> </method>
<method name="GetRowDescription" cname="atk_table_get_row_description">
<return-type type="const-gchar*"/>
<parameters>
<parameter type="gint" name="row"/>
</parameters>
</method>
<method name="AddColumnSelection" cname="atk_table_add_column_selection"> <method name="AddColumnSelection" cname="atk_table_add_column_selection">
<return-type type="gboolean"/> <return-type type="gboolean"/>
<parameters> <parameters>
<parameter type="gint" name="column"/> <parameter type="gint" name="column"/>
</parameters> </parameters>
</method> </method>
<method name="GetColumnDescription" cname="atk_table_get_column_description">
<return-type type="const-gchar*"/>
<parameters>
<parameter type="gint" name="column"/>
</parameters>
</method>
<method name="GetColumnAtIndex" cname="atk_table_get_column_at_index"> <method name="GetColumnAtIndex" cname="atk_table_get_column_at_index">
<return-type type="gint"/> <return-type type="gint"/>
<parameters> <parameters>

View file

@ -1,6 +1,7 @@
lib_LTLIBRARIES = libgtksharpglue.la lib_LTLIBRARIES = libgtksharpglue.la
INCLUDES = $(GTK_CFLAGS) -I$(top_srcdir) INCLUDES = @BASE_DEPENDENCIES_CFLAGS@ -I$(top_srcdir)
libgtksharpglue_la_SOURCES = \ libgtksharpglue_la_SOURCES = \
value.c \ value.c \
@ -9,6 +10,7 @@ libgtksharpglue_la_SOURCES = \
error.c \ error.c \
event.c \ event.c \
slist.c \ slist.c \
@ENABLE_GNOME_TRUE@ program.c \
# #
libgtksharpglue.dll: $(libgtksharpglue_la_OBJECTS) libgtksharpglue.rc libgtksharpglue.def libgtksharpglue.dll: $(libgtksharpglue_la_OBJECTS) libgtksharpglue.rc libgtksharpglue.def

138
glue/program.c Normal file
View file

@ -0,0 +1,138 @@
#include <libgnome/gnome-program.h>
#include <libgnome/gnome-init.h>
#include <string.h>
#include <config.h>
typedef struct {
char *name;
GValue *value;
} PropertyArg;
static gchar*
get_default (GObjectClass *klass, const gchar *property)
{
GParamSpec *spec = g_object_class_find_property (klass, property);
GParamSpecString *strspec;
gchar *ret;
g_return_val_if_fail (spec != NULL, NULL);
g_return_val_if_fail (strspec != NULL, NULL);
strspec = G_PARAM_SPEC_STRING (spec);
ret = g_strdup (strspec->default_value);
//g_param_spec_unref (spec);
return ret;
}
/* FIXME: HACK */
GnomeProgram*
gtksharp_gnome_program_init (const char *app_id, const char *app_version,
const GnomeModuleInfo *module_info,
int argc, char **argv,
int nargs, PropertyArg* args)
{
GnomeProgram *ret;
int i;
gboolean *unhandled = g_new0 (gboolean, nargs);
/* ok, these are the known construct-time arguments which means we
* _have_ to pass them into init. */
GObjectClass *klass = g_type_class_ref (GNOME_TYPE_PROGRAM);
gchar *human_readable_name = NULL;
gchar *gnome_path = NULL;
gchar *gnome_prefix = NULL;
gchar *gnome_libdir = NULL;
gchar *gnome_datadir = NULL;
gchar *gnome_sysconfdir = NULL;
gboolean create_directories = TRUE;
gchar *gnome_espeaker = NULL;
for (i = 0; i < nargs; i++)
{
if (!strcmp (args[i].name, GNOME_PARAM_HUMAN_READABLE_NAME))
human_readable_name = g_strdup (g_value_get_string (args[i].value));
else if (!strcmp (args[i].name, GNOME_PARAM_GNOME_PATH))
gnome_path = g_strdup (g_value_get_string (args[i].value));
else if (!strcmp (args[i].name, GNOME_PARAM_GNOME_PREFIX))
gnome_prefix = g_strdup (g_value_get_string (args[i].value));
else if (!strcmp (args[i].name, GNOME_PARAM_GNOME_LIBDIR))
gnome_libdir = g_strdup (g_value_get_string (args[i].value));
else if (!strcmp (args[i].name, GNOME_PARAM_GNOME_DATADIR))
gnome_datadir = g_strdup (g_value_get_string (args[i].value));
else if (!strcmp (args[i].name, GNOME_PARAM_GNOME_SYSCONFDIR))
gnome_sysconfdir = g_strdup (g_value_get_string (args[i].value));
else if (!strcmp (args[i].name, GNOME_PARAM_CREATE_DIRECTORIES))
create_directories = g_value_get_boolean (args[i].value);
else
unhandled[i] = TRUE;
}
if (!human_readable_name)
human_readable_name = g_strdup (app_id);
if (!gnome_path)
gnome_path = get_default (klass, GNOME_PARAM_GNOME_PATH);
if (!gnome_prefix)
gnome_prefix = get_default (klass, GNOME_PARAM_GNOME_PREFIX);
if (!gnome_libdir)
gnome_libdir = get_default (klass, GNOME_PARAM_GNOME_LIBDIR);
if (!gnome_datadir)
gnome_datadir = get_default (klass, GNOME_PARAM_GNOME_DATADIR);
if (!gnome_sysconfdir)
gnome_sysconfdir = get_default (klass, GNOME_PARAM_GNOME_SYSCONFDIR);
/* FIXME: string[] marshalling broken */
argc = 1;
argv = g_new0 (char*, 1);
argv[0] = app_id;
ret = gnome_program_init (app_id, app_version, module_info,
argc, argv,
GNOME_PARAM_HUMAN_READABLE_NAME,
human_readable_name,
GNOME_PARAM_GNOME_PREFIX,
gnome_prefix,
GNOME_PARAM_GNOME_LIBDIR,
gnome_libdir,
GNOME_PARAM_GNOME_DATADIR,
gnome_datadir,
GNOME_PARAM_GNOME_SYSCONFDIR,
gnome_sysconfdir,
GNOME_PARAM_CREATE_DIRECTORIES,
create_directories,
(gnome_path) ? (GNOME_PARAM_GNOME_PATH) : ((gnome_espeaker) ? GNOME_PARAM_ESPEAKER : NULL),
(gnome_path) ? (gnome_path) : ((gnome_espeaker) ? gnome_espeaker : NULL),
(gnome_espeaker && gnome_path) ? GNOME_PARAM_ESPEAKER : NULL,
(gnome_espeaker && gnome_path) ? gnome_espeaker : NULL,
NULL);
for (i = 0; i < nargs; i++)
{
if (unhandled[i])
g_object_set_property (G_OBJECT (ret),
args[i].name, args[i].value);
}
if (human_readable_name)
g_free (human_readable_name);
if (gnome_path)
g_free (gnome_path);
if (gnome_prefix)
g_free (gnome_prefix);
if (gnome_libdir)
g_free (gnome_libdir);
if (gnome_datadir)
g_free (gnome_datadir);
if (gnome_sysconfdir)
g_free (gnome_sysconfdir);
if (gnome_espeaker)
g_free (gnome_espeaker);
g_free (unhandled);
/* Remove this too when marshalling fixed */
g_free (argv);
return ret;
}

View file

@ -1,6 +1,7 @@
MCS=mcs MCS=mcs
all: linux @ENABLE_GNOME_TRUE@ all: linux
@ENABLE_GNOME_FALSE@ all:
windows: windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /r:../gtk/gtk-sharp.dll /out:gnome-sharp.dll /recurse:*.cs $(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../pango/pango-sharp.dll /r:../atk/atk-sharp.dll /r:../gdk/gdk-sharp.dll /r:../gtk/gtk-sharp.dll /out:gnome-sharp.dll /recurse:*.cs
@ -15,5 +16,5 @@ clean:
rm -f generated/* rm -f generated/*
install: all install: all
cp gnome-sharp.dll @prefix@/lib @ENABLE_GNOME_TRUE@ cp gnome-sharp.dll @prefix@/lib

22
gnome/Modules.cs Normal file
View file

@ -0,0 +1,22 @@
namespace Gnome
{
using System;
using System.Runtime.InteropServices;
class Modules
{
[DllImport("libgnome-2.so.0")]
static extern System.IntPtr libgnome_module_info_get ();
[DllImport("libgnomeui-2.so.0")]
static extern System.IntPtr libgnomeui_module_info_get ();
public static ModuleInfo LibGnome {
get { return new ModuleInfo (libgnome_module_info_get ()); }
}
public static ModuleInfo UI {
get { return new ModuleInfo (libgnomeui_module_info_get ()); }
}
}
}

83
gnome/Program.custom Normal file
View file

@ -0,0 +1,83 @@
//
// Gnome.Program.custom - Gnome Program class customizations
//
// Author: Rachel Hestilow <hestilow@ximian.com>
//
// Copyright (C) 2002 Rachel Hestilow
//
// This code is inserted after the automatically generated code.
//
[DllImport("gobject-2.0")]
static extern void g_type_init ();
[DllImport("libgnome-2.so.0")]
static extern System.IntPtr gnome_program_get_type ();
[StructLayout(LayoutKind.Sequential)]
struct PropertyArg {
public string name;
public IntPtr value;
}
[DllImport("gtksharpglue")]
static extern System.IntPtr
gtksharp_gnome_program_init (string app_id, string app_version, System.IntPtr module, int argc, string[] argv, int nargs, PropertyArg[] args);
public Program (string app_id, string app_version, ModuleInfo module,
string[] argv, params object[] props)
{
int nargs = props.Length / 2;
PropertyArg[] args = new PropertyArg[nargs];
GLib.Value[] vals = new GLib.Value[nargs];
string[] new_argv = new string[argv.Length + 1];
g_type_init ();
for (int i = 0; i < nargs; i++)
{
args[i].name = (string) props[i * 2];
GLib.Value value;
// FIXME: handle more types
object prop = props[i * 2 + 1];
Type type = prop.GetType ();
if (type == "hello".GetType ())
value = new GLib.Value ((string) prop);
else if (type == true.GetType ())
value = new GLib.Value ((bool) prop);
else
value = null;
vals[i] = value;
args[i].value = value.Handle;
}
/* FIXME: Is there a way to access this in .NET? */
new_argv[0] = app_id;
Array.Copy (argv, 0, new_argv, 1, argv.Length);
Raw = gtksharp_gnome_program_init (app_id, app_version, module.Handle, new_argv.Length, new_argv, nargs, args);
}
public void Run ()
{
Gtk.Application.Run ();
}
public void Quit ()
{
Gtk.Application.Quit ();
}
[DllImport("libgnome-2.so.0")]
static extern System.IntPtr gnome_program_get ();
public static Program Get ()
{
IntPtr raw = gnome_program_get ();
if (raw == IntPtr.Zero)
return null;
Program program = (Program) GLib.Object.GetObject (raw);
if (program == null)
program = new Program (raw);
return program;
}

View file

@ -1,3 +1,5 @@
EXTRA_DIRS =
DIRS=generator glib pango atk gdk gtk gnome sample DIRS=generator glib pango atk gdk gtk gnome sample
ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT))) ROOT=/cygdrive/$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe CSC=$(ROOT)/microsoft.net/framework/v1.0.3705/csc.exe

View file

@ -137,6 +137,11 @@ while ($line = <STDIN>) {
$boxdefs{$1} = $line; $boxdefs{$1} = $line;
} elsif ($line =~ /^BUILTIN\s*\{\s*\"(\w+)\".*GTK_TYPE_(ENUM|FLAGS)/) { } elsif ($line =~ /^BUILTIN\s*\{\s*\"(\w+)\".*GTK_TYPE_(ENUM|FLAGS)/) {
# ignoring these for now. # ignoring these for now.
} elsif ($line =~ /^\#define/) {
my $test_ns = uc ($ns);
if ($line =~ /\#define\s+(\w+)\s+\"(.*)\"/) {
$defines{$1} = $2;
}
} else { } else {
print $line; print $line;
} }
@ -231,7 +236,6 @@ foreach $type (sort(keys(%ifaces))) {
$classdef = $sdefs{$1} if ($ifacetype =~ /struct\s+(\w+)/); $classdef = $sdefs{$1} if ($ifacetype =~ /struct\s+(\w+)/);
if ($initfunc) { if ($initfunc) {
print "parsing $inst\n";
parseInitFunc($iface_el, $initfunc); parseInitFunc($iface_el, $initfunc);
} else { } else {
warn "Don't have an init func for $inst.\n" if $debug; warn "Don't have an init func for $inst.\n" if $debug;
@ -514,9 +518,12 @@ sub addPropElem
my $type = $1; my $type = $1;
my @params = split(/,/, $2); my @params = split(/,/, $2);
# FIXME: Handle non-literals. Needs work in the pp too.
$name = $params[0]; $name = $params[0];
$name =~ s/\"//g; if ($defines{$name}) {
$name = $defines{$name};
} else {
$name =~ s/\"//g;
}
while ($params[2] !~ /(\"|NULL)\s*\)?$/) { while ($params[2] !~ /(\"|NULL)\s*\)?$/) {
die "Unable to reconstruct doc string.\n" if (!$params[3]); die "Unable to reconstruct doc string.\n" if (!$params[3]);

View file

@ -23,12 +23,23 @@ foreach $fname (@hdrs) {
open(INFILE, $fname) || die "Could open $fname\n"; open(INFILE, $fname) || die "Could open $fname\n";
$braces = 0;
$prepend = "";
while ($line = <INFILE>) { while ($line = <INFILE>) {
$braces++ if ($line =~ /{/ and $line !~ /}/);
$braces-- if ($line =~ /}/ and $line !~ /{/);
next if ($line =~ /$ignoreit_regex/); next if ($line =~ /$ignoreit_regex/);
next if ($line !~ /\S/); next if ($line !~ /\S/);
if ($line =~ /#\s*define\s+\w+\s*\D+/) { $line = $prepend . $line;
$prepend = "";
if ($line =~ /#\s*define\s+\w+\s+\"/) {
$def = $line;
while ($def !~ /\".*\"/) {$def .= ($line = <INFILE>);}
print $def;
} elsif ($line =~ /#\s*define\s+\w+\s*\D+/) {
$def = $line; $def = $line;
while ($line =~ /\\\n/) {$def .= ($line = <INFILE>);} while ($line =~ /\\\n/) {$def .= ($line = <INFILE>);}
if ($def =~ /_CHECK_\w*CAST|INSTANCE_GET_INTERFACE/) { if ($def =~ /_CHECK_\w*CAST|INSTANCE_GET_INTERFACE/) {
@ -48,7 +59,12 @@ foreach $fname (@hdrs) {
} elsif ($line =~ /^enum\s+\{/) { } elsif ($line =~ /^enum\s+\{/) {
while ($line !~ /^};/) {$line = <INFILE>;} while ($line !~ /^};/) {$line = <INFILE>;}
} else { } else {
print $line; if ($braces or $line =~ /;/) {
print $line;
} else {
$prepend = $line;
$prepend =~ s/\n/ /g;
}
} }
} }
} }

View file

@ -105,12 +105,15 @@ namespace GtkSamples {
public static int Main (string[] args) public static int Main (string[] args)
{ {
Application.Init (); /* FIXME: Broken params support in mcs, should be fixed soonish */
object[] props = new object[0];
Program kit = new Program ("gnome-hello-world", "0.0.1", Modules.UI,
args, props);
GnomeHelloWorld hello = new GnomeHelloWorld (); GnomeHelloWorld hello = new GnomeHelloWorld ();
Window win = hello.CreateWindow (); Window win = hello.CreateWindow ();
win.ShowAll (); win.ShowAll ();
Application.Run (); kit.Run ();
return 0; return 0;
} }
@ -123,6 +126,7 @@ namespace GtkSamples {
static void exit_cb (object o, EventArgs args) static void exit_cb (object o, EventArgs args)
{ {
Console.WriteLine ("hi {0}", Gnome.Program.Get ().AppId);
Application.Quit (); Application.Quit ();
} }

View file

@ -1,7 +1,11 @@
MCS=mcs MCS=mcs
local_paths=-L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk -L ../gnome @ENABLE_GNOME_TRUE@ GNOME_PATH=-L ../gnome
all_assemblies=-r glib-sharp -r pango-sharp -r atk-sharp -r gdk-sharp -r gtk-sharp -r gnome-sharp -r System.Drawing @ENABLE_GNOME_TRUE@ GNOME_ASSEMBLY=-r gnome-sharp
@ENABLE_GNOME_TRUE@ GNOME_TARGETS=gnome-hello-world.exe
local_paths=-L ../glib -L ../pango -L ../atk -L ../gdk -L ../gtk $(GNOME_PATH)
all_assemblies=-r glib-sharp -r pango-sharp -r atk-sharp -r gdk-sharp -r gtk-sharp $(GNOME_ASSEMBLY) -r System.Drawing
all: linux all: linux
@ -10,7 +14,7 @@ windows:
$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs $(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs
$(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs $(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs
linux: gtk-hello-world.exe button.exe menu.exe gnome-hello-world.exe linux: gtk-hello-world.exe button.exe menu.exe $(GNOME_TARGETS)
gtk-hello-world.exe: HelloWorld.cs gtk-hello-world.exe: HelloWorld.cs
$(MCS) --unsafe -o gtk-hello-world.exe $(local_paths) $(all_assemblies) HelloWorld.cs $(MCS) --unsafe -o gtk-hello-world.exe $(local_paths) $(all_assemblies) HelloWorld.cs