diff --git a/ChangeLog b/ChangeLog index 610a0536..70df208c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,8 @@ Use PACKAGE_LIB_DIR. Load plugins in ~/.geany/plugins/ prior to the default location. * src/symbols.c: Hide empty symbol types in the symbol list. + * makefile.win32, win32-config.h, plugins/makefile.win32, + src/plugins.c: Make plugins working and compiling on Windows. 2007-07-27 Nick Treleaven diff --git a/makefile.win32 b/makefile.win32 index b07e9e95..ba8902ff 100644 --- a/makefile.win32 +++ b/makefile.win32 @@ -23,6 +23,7 @@ RM = del all: check-tools config.h cd tagmanager && make -f makefile.win32 && cd .. cd scintilla && make -f makefile.win32 && cd .. + cd plugins && make -f makefile.win32 && cd .. cd src && make -f makefile.win32 && cd .. # first check the required tools are installed @@ -35,7 +36,7 @@ config.h: win32-config.h $(CP) $< $@ deps: - -$(RM) tagmanager\deps.mak scintilla\deps.mak src\deps.mak + -$(RM) tagmanager\deps.mak scintilla\deps.mak plugins\deps.mak src\deps.mak # used by src/makefile.win32 to avoid del ../file which is an error clean-local: @@ -44,4 +45,5 @@ clean-local: clean: deps cd tagmanager && make -f makefile.win32 clean && cd .. cd scintilla && make -f makefile.win32 clean && cd .. + cd plugins && make -f makefile.win32 clean && cd .. cd src && make -f makefile.win32 clean && cd .. diff --git a/plugins/makefile.win32 b/plugins/makefile.win32 new file mode 100644 index 00000000..722892c7 --- /dev/null +++ b/plugins/makefile.win32 @@ -0,0 +1,58 @@ +# Adapted from Pidgin's plugins/Makefile.am, thanks + +CC = gcc +CXX = g++ +PREFIX = C:\libs +RM = del +-include ../localwin32.mk +.SUFFIXES: +.SUFFIXES: .c .dll + +GTK_INCLUDES= \ + -I$(PREFIX)/include/gtk-2.0 \ + -I$(PREFIX)/lib/gtk-2.0/include \ + -I$(PREFIX)/include/atk-1.0 \ + -I$(PREFIX)/include/pango-1.0 \ + -I$(PREFIX)/include/cairo \ + -I$(PREFIX)/include/glib-2.0 \ + -I$(PREFIX)/lib/glib-2.0/include \ + -I$(PREFIX)/include/gettext \ + -I$(PREFIX)/include + +INCLUDEDIRS= -I.. \ + -I../src \ + -I../scintilla/include \ + -I../tagmanager/include \ + $(GTK_INCLUDES) + +ALL_GTK_LIBS= \ + -L"$(PREFIX)/lib" \ + -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 \ + -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl -liconv + +CCFLAGS=-Wall -O2 -mms-bitfields + +.PHONY: all clean plugins + +all: plugins + +.c.dll: + $(CC) $(CCFLAGS) $(DEFINES) $(INCLUDEDIRS) -o $@.o -c $< + $(CC) -shared $@.o $(ALL_GTK_LIBS) $(DLL_LD_FLAGS) -o $@ + +plugins: \ + htmlchars.dll \ + demoplugin.dll \ + classbuilder.dll + +clean: + -$(RM) deps.mak *.o *.dll + +deps.mak: + $(CC) -MM $(CCFLAGS) $(DEFINES) $(INCLUDEDIRS) *.c >deps.mak + +# Generate header dependencies with "make deps.mak" +include deps.mak + +..\localwin32.mk: + echo # Set local variables here >$@ diff --git a/src/dialogs.c b/src/dialogs.c index 1913afde..9ee60b3f 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -652,6 +652,7 @@ gboolean dialogs_show_unsaved_file(gint idx) } +#ifndef G_OS_WIN32 static void on_font_apply_button_clicked (GtkButton *button, gpointer user_data) @@ -681,6 +682,7 @@ on_font_cancel_button_clicked (GtkButton *button, { gtk_widget_hide(app->open_fontsel); } +#endif /* This shows the font selection dialog to choose a font. */ diff --git a/src/plugins.c b/src/plugins.c index c8e77b61..840dcdfc 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -28,6 +28,8 @@ #ifdef HAVE_PLUGINS +#include + #include "plugins.h" #include "plugindata.h" #include "support.h" @@ -37,6 +39,12 @@ #include "sciwrappers.h" #include "ui_utils.h" +#ifdef G_OS_WIN32 +# define PLUGIN_EXT "dll" +#else +# define PLUGIN_EXT "so" +#endif + typedef struct Plugin { @@ -267,14 +275,18 @@ static void load_plugins(const gchar *path) { GSList *list, *item; + gchar *fname, *tmp; + Plugin *plugin; list = utils_get_file_list(path, NULL, NULL); for (item = list; item != NULL; item = g_slist_next(item)) { - gchar *fname = g_strconcat(path, G_DIR_SEPARATOR_S, item->data, NULL); - Plugin *plugin; + tmp = strrchr(item->data, '.'); + if (tmp == NULL || strcasecmp(tmp, "." PLUGIN_EXT) != 0) + continue; + fname = g_strconcat(path, G_DIR_SEPARATOR_S, item->data, NULL); plugin = plugin_new(fname); if (plugin != NULL) { @@ -288,25 +300,43 @@ load_plugins(const gchar *path) } +#ifdef G_OS_WIN32 +static gchar *get_plugin_path() +{ + gchar *install_dir = g_win32_get_package_installation_directory("geany", NULL); + gchar *path; + + path = g_strconcat(install_dir, "\\plugins", NULL); + + return path; +} +#endif + + void plugins_init() { GtkWidget *widget; - gchar *path_user; + gchar *path; geany_data_init(); widget = gtk_separator_menu_item_new(); gtk_container_add(GTK_CONTAINER(geany_data.tools_menu), widget); - path_user = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", NULL); + path = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", NULL); // first load plugins in ~/.geany/plugins/, then in $prefix/lib/geany - load_plugins(path_user); + load_plugins(path); +#ifdef G_OS_WIN32 + g_free(path); + path = get_plugin_path(); + load_plugins(path); +#else load_plugins(PACKAGE_LIB_DIR G_DIR_SEPARATOR_S "geany"); - +#endif if (g_list_length(plugin_list) > 0) gtk_widget_show(widget); - g_free(path_user); + g_free(path); } diff --git a/win32-config.h b/win32-config.h index b61adcaf..52663ce9 100644 --- a/win32-config.h +++ b/win32-config.h @@ -138,7 +138,7 @@ /* #undef HAVE_NDIR_H */ /* Define if plugins are enabled. */ -//#define HAVE_PLUGINS 1 +#define HAVE_PLUGINS 1 /* Define to 1 if you have the `putenv' function. */ #define HAVE_PUTENV 1