aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile11
-rw-r--r--src/textadept.c8
2 files changed, 13 insertions, 6 deletions
diff --git a/src/Makefile b/src/Makefile
index a5fce727..cd15187a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -83,6 +83,13 @@ LUADIR = luajit
LUAJIT_FLAG = -DLUAJIT
endif
+# Single instance unless NO_SINGLE_INSTANCE=1
+ifndef NO_SINGLE_INSTANCE
+SI_FLAG = -DSINGLE_INSTANCE
+else
+SI_FLAG =
+endif
+
INCLUDEDIRS = -Iscintilla/include -I$(LUADIR)/src -Igcocoadialog
ifdef GTK3
@@ -93,8 +100,8 @@ endif
# Textadept
-CFLAGS = -std=c99 $(DEBUG_FLAG) $(LUAJIT_FLAG) -O $(PLAT_FLAGS) $(INCLUDEDIRS) \
- -W -Wall -Wno-sign-compare -Wno-unused
+CFLAGS = -std=c99 $(DEBUG_FLAG) $(LUAJIT_FLAG) $(SI_FLAG) -O $(PLAT_FLAGS) \
+ $(INCLUDEDIRS) -W -Wall -Wno-sign-compare -Wno-unused
GTKFLAGS = $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) \
--cflags $(GTKVERSION))
GTKLIBS = $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) \
diff --git a/src/textadept.c b/src/textadept.c
index ff09e465..b5c477b9 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -55,7 +55,7 @@ static gboolean s_buttonpress(GtkWidget *, GdkEventButton *, gpointer);
static gboolean w_focus(GtkWidget *, GdkEventFocus *, gpointer);
static gboolean w_keypress(GtkWidget *, GdkEventKey *, gpointer);
static gboolean w_exit(GtkWidget *, GdkEventAny *, gpointer);
-#if GLIB_CHECK_VERSION(2,28,0)
+#if GLIB_CHECK_VERSION(2,28,0) && SINGLE_INSTANCE
static int a_command_line(GApplication *, GApplicationCommandLine *, gpointer);
#endif
#if __OSX__
@@ -162,7 +162,7 @@ int main(int argc, char **argv) {
if (last_slash) *last_slash = '\0';
#endif
-#if GLIB_CHECK_VERSION(2,28,0)
+#if GLIB_CHECK_VERSION(2,28,0) && SINGLE_INSTANCE
int force = 0;
for (int i = 0; i < argc; i++)
if (strcmp("-f", argv[i]) == 0 || strcmp("--force", argv[i]) == 0) {
@@ -183,7 +183,7 @@ int main(int argc, char **argv) {
gtk_osxapplication_ready(osxapp);
#endif
-#if GLIB_CHECK_VERSION(2,28,0)
+#if GLIB_CHECK_VERSION(2,28,0) && SINGLE_INSTANCE
gtk_main();
} else g_application_run(app, argc, argv);
g_object_unref(app);
@@ -533,7 +533,7 @@ static gboolean w_exit(GtkWidget*_, GdkEventAny*__, gpointer ___) {
return FALSE;
}
-#if GLIB_CHECK_VERSION(2,28,0)
+#if GLIB_CHECK_VERSION(2,28,0) && SINGLE_INSTANCE
/**
* Processes a remote Textadept's command line arguments.
*/