From: Pat Thoyts Date: Sat, 1 Oct 2016 11:13:23 +0000 (+0100) Subject: Amended Makefile to build with 8.7 X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=ttkGtkTheme Amended Makefile to build with 8.7 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d22eb4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +*.so diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2fc6bbb --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +# NOTE: when installing Tcl and Tk make sure to install the private +# headers. ie: make; make install install-private-headers +#include /opt/tcl/lib/tclConfig.sh +#include /opt/tcl/lib/tkConfig.sh + +CC := gcc +CFLAGS := -g -Wall -fPIC +LD := gcc +LDFLAGS := -g -Wall +RM := rm -f + +V := @ +Q := $(V:1=) +QUIET_CC = $(Q:@=@echo CC $@ &)$(CC) +QUIET_LD = $(Q:@=@echo LD $@ &)$(LD) + +TCL_INSTALL_DIR=/opt/tcl + +GTK_INC := $(shell pkg-config --cflags gtk+-2.0) +GTK_LIBS:= $(shell pkg-config --libs gtk+-2.0) +TCL_INC := $(shell PKG_CONFIG_PATH=$(TCL_INSTALL_DIR)/lib/pkgconfig pkg-config --cflags tcl tk) +TCL_LIBS:= $(shell PKG_CONFIG_PATH=$(TCL_INSTALL_DIR)/lib/pkgconfig pkg-config --libs tcl tk) +DEFS := -DUSE_TCL_STUBS -DUSE_TK_STUBS -DUSE_TTK_STUBS + +#_TCL_SRC_DIR=$(TCL_SRC_DIR:\'=) +#_TK_SRC_DIR=$(TK_SRC_DIR:\'=) + +#INC = $(GTK_INC) $(TCL_INCLUDE_SPEC) $(TK_INCLUDE_SPEC) -I$(_TK_SRC_DIR)/generic/ttk +#LIBS = $(GTK_LIBS) $(TCL_STUB_LIB_SPEC:\'=) $(TK_STUB_LIB_SPEC:\'=) +INC = $(GTK_INC) $(TCL_INC) +LIBS = $(GTK_LIBS) $(TCL_LIBS) + +libttkgtktheme.so: ttkGtkTheme.o + $(QUIET_LD) $(LDFLAGS) -shared -o $@ $< $(LIBS) + +ttkGtkTheme.o: ttkGtkTheme.c + $(QUIET_CC) $(CFLAGS) $(DEFS) $(INC) -c $< -o $@ + +shell: libttkgtktheme.so + env LD_LIBRARY_PATH=`pwd` $(TCL_INSTALL_DIR)/bin/wish8.7 `which tkcon` + +test: libttkgtktheme.so + @echo "load $^\nexit 0" | env LD_LIBRARY_PATH=`pwd` $(TCL_INSTALL_DIR)/bin/wish8.7 + +clean: + -@rm -f ttkGtkTheme.o libttkgtktheme.so + +.PHONY: clean diff --git a/ttkGtkTheme.c b/ttkGtkTheme.c index 3410d7d..8296377 100644 --- a/ttkGtkTheme.c +++ b/ttkGtkTheme.c @@ -1,4 +1,3 @@ - // see google codesearch for MOZ_GTK_SUCCESS and ensure_checkbox_widget #include @@ -6,14 +5,7 @@ #include #include - -/* Are we part of tile, or Tk... */ -#ifdef BUILD_tile -#include "tkTheme.h" -#define TTK_VERSION PACKAGE_VERSION -#else -#include "ttkTheme.h" -#endif +#include #include @@ -124,7 +116,7 @@ DestroyElementData(void *clientData) } static void -GenericElementGeometry(void *clientData, void *elementRecord, Tk_Window tkwin, +GtkElementGeometry(void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ElementData *elementData = clientData; @@ -143,8 +135,8 @@ GenericElementGeometry(void *clientData, void *elementRecord, Tk_Window tkwin, } static void -GenericElementDraw(void *clientData, void *elementRecord, Tk_Window tkwin, - Drawable d, Ttk_Box b, unsigned int state) +GtkElementDraw(void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) { ElementData *elementData = clientData; GdkDisplay *gdkdisplay = 0; @@ -156,14 +148,14 @@ GenericElementDraw(void *clientData, void *elementRecord, Tk_Window tkwin, gdkdisplay = gdk_display_get_default(); } if (gdkdisplay == NULL) { - g_printf("GenericDrawElement: failed to get display\n"); + g_printf("GtkDrawElement: failed to get display\n"); } gdkdrawable = gdk_window_foreign_new_for_display(gdkdisplay, Tk_WindowId(tkwin)); style = gtk_style_attach(elementData->style, gdkdrawable); TSOffsetStyleGCs(style, b.x, b.y); switch (elementData->info->id) { case WIDGET_GTK_CHECKBUTTON: { - GtkShadowType gshadow = (GtkShadowType)Ttk_StateTableLookup(button_shadowmap, state); + GtkShadowType gshadow = (GtkShadowType)Ttk_StateTableLookup(button_shadowmap, state); //GtkShadowType gshadow = (state & TTK_STATE_SELECTED)?GTK_SHADOW_IN:GTK_SHADOW_OUT; GtkStateType gstate = (GtkStateType)Ttk_StateTableLookup(button_statemap, state); GTK_TOGGLE_BUTTON(elementData->widget)->active = (state & TTK_STATE_SELECTED); @@ -178,9 +170,9 @@ GenericElementDraw(void *clientData, void *elementRecord, Tk_Window tkwin, break; } case WIDGET_GTK_RADIOBUTTON: { - GtkShadowType gshadow = (GtkShadowType)Ttk_StateTableLookup(button_shadowmap, state); + GtkShadowType gshadow = (GtkShadowType)Ttk_StateTableLookup(button_shadowmap, state); //GtkShadowType gshadow = (state & TTK_STATE_SELECTED)?GTK_SHADOW_IN:GTK_SHADOW_OUT; - GtkStateType gstate = (GtkStateType)Ttk_StateTableLookup(button_statemap, state); + GtkStateType gstate = (GtkStateType)Ttk_StateTableLookup(button_statemap, state); GTK_TOGGLE_BUTTON(elementData->widget)->active = (state & TTK_STATE_SELECTED); if (state & TTK_STATE_FOCUS) { GTK_WIDGET_SET_FLAGS(elementData->widget, GTK_HAS_FOCUS); @@ -196,7 +188,7 @@ GenericElementDraw(void *clientData, void *elementRecord, Tk_Window tkwin, Ttk_Padding p = {-2, -2, -2, -2}; //GtkShadowType gshadow = (state & TTK_STATE_PRESSED) // ? GTK_SHADOW_IN : GTK_SHADOW_OUT; - GtkShadowType gshadow = (GtkShadowType)Ttk_StateTableLookup(button_shadowmap, state); + GtkShadowType gshadow = (GtkShadowType)Ttk_StateTableLookup(button_shadowmap, state); GtkStateType gstate = (GtkStateType)Ttk_StateTableLookup(button_statemap, state); if (state & TTK_STATE_FOCUS) { GTK_WIDGET_SET_FLAGS(elementData->widget, GTK_HAS_FOCUS); @@ -219,13 +211,19 @@ GenericElementDraw(void *clientData, void *elementRecord, Tk_Window tkwin, gtk_style_detach(style); } -static Ttk_ElementSpec GtkElementSpec = +typedef NullElement GtkElement; + +static Ttk_ElementOptionSpec GtkElementOptions[] = { + { NULL, 0, 0, NULL }, +}; + +static Ttk_ElementSpec GtkElementSpec = { TK_STYLE_VERSION_2, - sizeof(NullElement), - TtkNullElementOptions, - GenericElementGeometry, - GenericElementDraw + sizeof(GtkElement), + GtkElementOptions, + GtkElementGeometry, + GtkElementDraw }; /* ---------------------------------------------------------------------- @@ -285,13 +283,25 @@ static ElementInfo ElementInfoTable[] = { { 0, 0, 0 } }; +#define TCL_VERSION_WRONG "8.0" /* see tktable bug #1091431 */ + MODULE_SCOPE int -TtkGtkTheme_Init(Tcl_Interp *interp) +Ttkgtktheme_Init(Tcl_Interp *interp) { ThemeData *themeData; ElementInfo *infoPtr = NULL; Ttk_Theme theme = NULL, parent = NULL; + if (Tcl_InitStubs(interp, TCL_VERSION_WRONG, 0) == NULL) { + return TCL_ERROR; + } + if (Tk_InitStubs(interp, TCL_VERSION_WRONG, 0) == NULL) { + return TCL_ERROR; + } + if (Ttk_InitStubs(interp) == NULL) { + return TCL_ERROR; + } + parent = Ttk_GetTheme(interp, "clam"); theme = Ttk_CreateTheme(interp, "gtk", parent); @@ -322,7 +332,7 @@ TtkGtkTheme_Init(Tcl_Interp *interp) for (infoPtr = ElementInfoTable; infoPtr->elementName != 0; ++infoPtr) { ClientData clientData = NewElementData(infoPtr, themeData); - Ttk_RegisterElementSpec(theme, infoPtr->elementName, + Ttk_RegisterElement(interp, theme, infoPtr->elementName, infoPtr->elementSpec, clientData); Ttk_RegisterCleanup(interp, clientData, DestroyElementData); }