Fully bind MaigreRcStyle as well
Does the same thing to MaigreRcStyle as the previous commit did to MaigreStyle. Also added back a ThemeModule static class with Init and Exit methods.
This commit is contained in:
Родитель
839f7b3cda
Коммит
c6179c2317
|
@ -23,4 +23,6 @@ Makefile.in
|
|||
|
||||
/.run/
|
||||
libmaigre/maigre-style.c
|
||||
Maigre/Maigre_Theme.cs
|
||||
libmaigre/maigre-rc-style.c
|
||||
Maigre/MaigreStyle.cs
|
||||
Maigre/MaigreRcStyle.cs
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// OsxRcStyle.cs
|
||||
//
|
||||
// Author:
|
||||
// Aaron Bockover <abockover@novell.com>
|
||||
//
|
||||
// Copyright 2010 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using Cairo;
|
||||
|
||||
namespace Maigre.Osx
|
||||
{
|
||||
public class OsxRcStyle : RcStyle
|
||||
{
|
||||
public OsxRcStyle (IntPtr raw) : base (raw)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,5 +68,21 @@ namespace Maigre.Osx
|
|||
Cr.Color = ColorExtensions.FromRgba (0x00000005);
|
||||
Cr.Stroke ();
|
||||
}
|
||||
|
||||
protected override void OnDrawFlatBox ()
|
||||
{
|
||||
Console.WriteLine (Detail);
|
||||
Cr.Rectangle (Shape);
|
||||
switch (Detail) {
|
||||
case "base":
|
||||
Cr.Color = new Cairo.Color (0, 0, 0);
|
||||
break;
|
||||
case "cell_even":
|
||||
case "cell_odd":
|
||||
Cr.Color = new Cairo.Color (1, 0, 0, 0.25);
|
||||
break;
|
||||
}
|
||||
Cr.Fill ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
<Compile Include="Cairo\ContextExtensions.cs" />
|
||||
<Compile Include="Cairo\RectangleExtensions.cs" />
|
||||
<Compile Include="Maigre.Osx\OsxStyle.cs" />
|
||||
<Compile Include="Maigre.Osx\OsxRcStyle.cs" />
|
||||
<Compile Include="Maigre\ThemeModule.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
@ -50,6 +52,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Maigre\Style_Template.cs" />
|
||||
<None Include="Maigre\RcStyle_Template.cs" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// maigre-rc-style.c
|
||||
// RcStyle.cs
|
||||
//
|
||||
// Author:
|
||||
// Aaron Bockover <abockover@novell.com>
|
||||
|
@ -24,44 +24,26 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "maigre-rc-style.h"
|
||||
#include "maigre-style.h"
|
||||
using System;
|
||||
|
||||
struct MaigreRcStyle {
|
||||
GtkRcStyle parent_instance;
|
||||
};
|
||||
|
||||
struct MaigreRcStyleClass {
|
||||
GtkRcStyleClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE (MaigreRcStyle, maigre_rc_style, GTK_TYPE_RC_STYLE);
|
||||
|
||||
void
|
||||
maigre_rc_style_register_types (GTypeModule *module)
|
||||
namespace Maigre
|
||||
{
|
||||
maigre_rc_style_register_type (module);
|
||||
}
|
||||
public class RcStyle : Gtk.RcStyle
|
||||
{
|
||||
protected RcStyle (IntPtr raw) : base (raw)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
maigre_rc_style_init (MaigreRcStyle *maigre_rc)
|
||||
{
|
||||
}
|
||||
private static RcStyle New (IntPtr nativeParent)
|
||||
{
|
||||
return new Maigre.Osx.OsxRcStyle (nativeParent);
|
||||
}
|
||||
|
||||
static GtkStyle *
|
||||
maigre_rc_style_create_style (GtkRcStyle *rc_style)
|
||||
{
|
||||
return GTK_STYLE (g_object_new (MAIGRE_TYPE_STYLE, NULL));
|
||||
}
|
||||
public static new GLib.GType GType { get; private set; }
|
||||
|
||||
static void
|
||||
maigre_rc_style_class_init (MaigreRcStyleClass *klass)
|
||||
{
|
||||
GtkRcStyleClass *rc_style_class = GTK_RC_STYLE_CLASS (klass);
|
||||
rc_style_class->create_style = maigre_rc_style_create_style;
|
||||
}
|
||||
|
||||
static void
|
||||
maigre_rc_style_class_finalize (MaigreRcStyleClass *klass)
|
||||
{
|
||||
private static void ConfigureClass (IntPtr gtype)
|
||||
{
|
||||
GType = new GLib.GType (gtype);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -57,10 +57,10 @@ namespace Maigre
|
|||
private static ParentVTable parent_vtable;
|
||||
public static new GLib.GType GType { get; private set; }
|
||||
|
||||
private static void ConfigureClass (IntPtr vtablePtr, IntPtr styleGetType)
|
||||
private static void ConfigureClass (IntPtr vtablePtr, IntPtr gtype)
|
||||
{
|
||||
parent_vtable = (ParentVTable)Marshal.PtrToStructure (vtablePtr, typeof (ParentVTable));
|
||||
GType = new GLib.GType (styleGetType);
|
||||
GType = new GLib.GType (gtype);
|
||||
}
|
||||
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// ThemeModule.cs
|
||||
//
|
||||
// Author:
|
||||
// Aaron Bockover <abockover@novell.com>
|
||||
//
|
||||
// Copyright 2010 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Maigre
|
||||
{
|
||||
public static class ThemeModule
|
||||
{
|
||||
private static void Init ()
|
||||
{
|
||||
}
|
||||
|
||||
private static void Exit ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,19 +3,27 @@ MAIGRE_SOURCES = \
|
|||
Cairo/ContextExtensions.cs \
|
||||
Cairo/Corner.cs \
|
||||
Cairo/RectangleExtensions.cs \
|
||||
Maigre.Osx/OsxStyle.cs
|
||||
Maigre.Osx/OsxRcStyle.cs \
|
||||
Maigre.Osx/OsxStyle.cs \
|
||||
Maigre/ThemeModule.cs
|
||||
|
||||
MAIGRE_TEMPLATE_SOURCES_IN = Maigre/Style_Template.cs
|
||||
MAIGRE_TEMPLATE_SOURCES_IN = \
|
||||
Maigre/RcStyle_Template.cs \
|
||||
Maigre/Style_Template.cs
|
||||
|
||||
MAIGRE_TEMPLATE_SOURCES_OUT = \
|
||||
Maigre_Style.cs
|
||||
MaigreRcStyle.cs \
|
||||
MaigreStyle.cs
|
||||
|
||||
MAIGRE_SOURCES_BUILD = $(foreach src, $(MAIGRE_SOURCES), $(srcdir)/$(src)) $(MAIGRE_TEMPLATE_SOURCES_OUT)
|
||||
|
||||
Maigre.dll: $(MAIGRE_SOURCES_BUILD)
|
||||
@echo " GMCS $@"; $(MCS) -out:$@ -target:library -debug -r:Mono.Cairo -r:System.Core $(GTK_SHARP_LIBS) $(MAIGRE_SOURCES_BUILD)
|
||||
|
||||
Maigre_Style.cs: Maigre/Style_Template.cs $(top_srcdir)/maigre-codegen/maigre-codegen.py
|
||||
MaigreRcStyle.cs: Maigre/RcStyle_Template.cs $(top_srcdir)/maigre-codegen/maigre-codegen.py
|
||||
@echo " GEN $@"; $(top_srcdir)/maigre-codegen/maigre-codegen.py $< $@
|
||||
|
||||
MaigreStyle.cs: Maigre/Style_Template.cs $(top_srcdir)/maigre-codegen/maigre-codegen.py
|
||||
@echo " GEN $@"; $(top_srcdir)/maigre-codegen/maigre-codegen.py $< $@
|
||||
|
||||
all: Maigre.dll
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
EXTRA_DIST = maigre-style.template.c libmaigre.cproj
|
||||
CLEANFILES = maigre-style.c
|
||||
MAINTAINERCLEANFILES = Makefile.in libmaigre.pidb libmaigre.md.pc
|
||||
|
||||
INCLUDES = \
|
||||
-Wall -ggdb3 -D_FORTIFY_SOURCE=2 \
|
||||
$(MONO_CFLAGS) \
|
||||
|
@ -9,22 +5,29 @@ INCLUDES = \
|
|||
|
||||
MAIGRE_SRC = \
|
||||
maigre-mono-bridge.c \
|
||||
maigre-rc-style.c \
|
||||
maigre-theme-module.c
|
||||
|
||||
MAIGRE_OTHER = \
|
||||
maigre-mono-bridge.h \
|
||||
maigre-rc-style.h \
|
||||
maigre-style.h \
|
||||
maigre-rc-style.template.c \
|
||||
maigre-style.template.c
|
||||
|
||||
enginedir = $(libdir)/gtk-2.0/$(GTK_VERSION)/engines
|
||||
engine_LTLIBRARIES = libmaigre.la
|
||||
|
||||
libmaigre_la_SOURCES = $(MAIGRE_SRC)
|
||||
nodist_libmaigre_la_SOURCES = maigre-style.c
|
||||
nodist_libmaigre_la_SOURCES = maigre-style.c maigre-rc-style.c
|
||||
libmaigre_la_LDFLAGS = -module -avoid-version -no-undefined
|
||||
libmaigre_la_LIBADD = $(MONO_LIBS) $(GTK_LIBS)
|
||||
|
||||
maigre-style.c: maigre-style.template.c $(top_srcdir)/maigre-codegen/maigre-codegen.py
|
||||
@echo " GEN $@"; $(top_srcdir)/maigre-codegen/maigre-codegen.py $< $@
|
||||
|
||||
maigre-rc-style.c: maigre-rc-style.template.c $(top_srcdir)/maigre-codegen/maigre-codegen.py
|
||||
@echo " GEN $@"; $(top_srcdir)/maigre-codegen/maigre-codegen.py $< $@
|
||||
|
||||
EXTRA_DIST = $(MAIGRE_OTHER) libmaigre.cproj
|
||||
CLEANFILES = maigre-style.c maigre-rc-style.c
|
||||
MAINTAINERCLEANFILES = Makefile.in libmaigre.pidb libmaigre.md.pc
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
<CompileTarget>SharedLibrary</CompileTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="maigre-rc-style.c" />
|
||||
<Compile Include="maigre-theme-module.c" />
|
||||
<Compile Include="maigre-mono-bridge.c" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -35,8 +35,6 @@ maigre_mono_bridge ()
|
|||
static MaigreMonoBridge *bridge;
|
||||
static gboolean load_attempted;
|
||||
|
||||
MonoMethod *theme_create_method;
|
||||
|
||||
if (load_attempted) {
|
||||
return bridge;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
//
|
||||
// maigre-rc-style.c
|
||||
//
|
||||
// Author:
|
||||
// Aaron Bockover <abockover@novell.com>
|
||||
//
|
||||
// Copyright 2010 Novell, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "maigre-rc-style.h"
|
||||
#include "maigre-style.h"
|
||||
#include "maigre-mono-bridge.h"
|
||||
|
||||
struct MaigreRcStyle {
|
||||
GtkRcStyle parent_instance;
|
||||
MonoObject *mono_object;
|
||||
};
|
||||
|
||||
struct MaigreRcStyleClass {
|
||||
GtkRcStyleClass parent_class;
|
||||
MonoClass *mono_class;
|
||||
};
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE (MaigreRcStyle, maigre_rc_style, GTK_TYPE_RC_STYLE);
|
||||
|
||||
void
|
||||
maigre_rc_style_register_types (GTypeModule *module)
|
||||
{
|
||||
maigre_rc_style_register_type (module);
|
||||
}
|
||||
|
||||
static GtkStyle *
|
||||
maigre_rc_style_create_style (GtkRcStyle *rc_style)
|
||||
{
|
||||
return GTK_STYLE (g_object_new (MAIGRE_TYPE_STYLE, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
maigre_rc_style_init (MaigreRcStyle *maigre_rc)
|
||||
{
|
||||
static MonoMethod *managed_method = NULL;
|
||||
|
||||
gpointer args[1];
|
||||
|
||||
if (managed_method == NULL) {
|
||||
managed_method = mono_class_get_method_from_name (
|
||||
MAIGRE_RC_STYLE_GET_CLASS (maigre_rc)->mono_class,
|
||||
"New", 1);
|
||||
if (managed_method == NULL) {
|
||||
g_warning ("Maigre.RcStyle does not contain a Style:New(IntPtr) method");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
args[0] = &maigre_rc;
|
||||
maigre_rc->mono_object = mono_runtime_invoke (managed_method, NULL, args, NULL);
|
||||
g_object_ref (maigre_rc);
|
||||
}
|
||||
|
||||
static void
|
||||
maigre_rc_style_class_init (MaigreRcStyleClass *klass)
|
||||
{
|
||||
MaigreMonoBridge *bridge;
|
||||
MonoMethod *configure_class_method;
|
||||
gpointer args[1];
|
||||
GType type = maigre_rc_style_get_type ();
|
||||
|
||||
bridge = maigre_mono_bridge ();
|
||||
if (bridge == NULL) {
|
||||
return;
|
||||
} else if ((klass->mono_class = mono_class_from_name (bridge->image,
|
||||
"Maigre", "RcStyle")) == NULL) {
|
||||
g_warning ("Maigre.dll assembly does not contain Maigre.RcStyle");
|
||||
return;
|
||||
} else if ((configure_class_method = mono_class_get_method_from_name (
|
||||
klass->mono_class, "ConfigureClass", 1)) == NULL) {
|
||||
g_warning ("Maigre.RcStyle does not contain a ConfigureClass method.");
|
||||
return;
|
||||
}
|
||||
|
||||
args[0] = &type;
|
||||
mono_runtime_invoke (configure_class_method, NULL, args, NULL);
|
||||
|
||||
GTK_RC_STYLE_CLASS (klass)->create_style = maigre_rc_style_create_style;
|
||||
}
|
||||
|
||||
static void
|
||||
maigre_rc_style_class_finalize (MaigreRcStyleClass *klass)
|
||||
{
|
||||
}
|
|
@ -109,13 +109,14 @@ maigre_style_init (MaigreStyle *maigre)
|
|||
|
||||
args[0] = &maigre;
|
||||
maigre->mono_object = mono_runtime_invoke (managed_method, NULL, args, NULL);
|
||||
g_object_ref (maigre);
|
||||
}
|
||||
|
||||
static void
|
||||
maigre_style_class_init (MaigreStyleClass *klass)
|
||||
{
|
||||
MaigreMonoBridge *bridge;
|
||||
MonoMethod *load_parent_vtable_method;
|
||||
MonoMethod *configure_class_method;
|
||||
MaigreParentVTable parent_vtable, *parent_vtable_ptr;
|
||||
gpointer args[2];
|
||||
GType type = maigre_style_get_type ();
|
||||
|
@ -127,7 +128,7 @@ maigre_style_class_init (MaigreStyleClass *klass)
|
|||
"Maigre", "Style")) == NULL) {
|
||||
g_warning ("Maigre.dll assembly does not contain Maigre.Style");
|
||||
return;
|
||||
} else if ((load_parent_vtable_method = mono_class_get_method_from_name (
|
||||
} else if ((configure_class_method = mono_class_get_method_from_name (
|
||||
klass->mono_class, "ConfigureClass", 2)) == NULL) {
|
||||
g_warning ("Maigre.Style does not contain a ConfigureClass method.");
|
||||
return;
|
||||
|
@ -140,7 +141,7 @@ maigre_style_class_init (MaigreStyleClass *klass)
|
|||
parent_vtable_ptr = &parent_vtable;
|
||||
args[0] = &parent_vtable_ptr;
|
||||
args[1] = &type;
|
||||
mono_runtime_invoke (load_parent_vtable_method, NULL, args, NULL);
|
||||
mono_runtime_invoke (configure_class_method, NULL, args, NULL);
|
||||
|
||||
% for method in parser.methods:
|
||||
GTK_STYLE_CLASS (klass)->${method.native_name} = maigre_style_${method.native_name};
|
||||
|
|
|
@ -36,8 +36,9 @@
|
|||
G_MODULE_EXPORT void
|
||||
theme_init (GTypeModule *module)
|
||||
{
|
||||
MonoMethod *init_method;
|
||||
MaigreMonoBridge *bridge = maigre_mono_bridge ();
|
||||
MonoClass *klass;
|
||||
MonoMethod *method;
|
||||
|
||||
if (bridge == NULL) {
|
||||
g_warning ("Maigre failed to initialize. Default internal "
|
||||
|
@ -46,11 +47,26 @@ theme_init (GTypeModule *module)
|
|||
}
|
||||
|
||||
maigre_rc_style_register_types (module);
|
||||
|
||||
if (bridge != NULL &&
|
||||
(klass = mono_class_from_name (bridge->image, "Maigre", "ThemeModule")) != NULL &&
|
||||
(method = mono_class_get_method_from_name (klass, "Init", 0)) != NULL) {
|
||||
mono_runtime_invoke (method, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
theme_exit ()
|
||||
{
|
||||
MaigreMonoBridge *bridge = maigre_mono_bridge ();
|
||||
MonoClass *klass;
|
||||
MonoMethod *method;
|
||||
|
||||
if (bridge != NULL &&
|
||||
(klass = mono_class_from_name (bridge->image, "Maigre", "ThemeModule")) != NULL &&
|
||||
(method = mono_class_get_method_from_name (klass, "Exit", 0)) != NULL) {
|
||||
mono_runtime_invoke (method, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT GtkRcStyle *
|
||||
|
|
Загрузка…
Ссылка в новой задаче