--- /dev/null
+# 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
-
// see google codesearch for MOZ_GTK_SUCCESS and ensure_checkbox_widget
#include <gtk/gtk.h>
#include <glib/gprintf.h>
#include <tk.h>
-
-/* Are we part of tile, or Tk... */
-#ifdef BUILD_tile
-#include "tkTheme.h"
-#define TTK_VERSION PACKAGE_VERSION
-#else
-#include "ttkTheme.h"
-#endif
+#include <ttkTheme.h>
#include <string.h>
}
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;
}
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;
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);
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);
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);
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
};
/* ----------------------------------------------------------------------
{ 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);
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);
}