Browse Source

Basically initial commit

dirkson 6 months ago
parent
commit
27023b5e49

+ 2
- 0
.gitignore View File

@@ -42,3 +42,5 @@ bin/*
42 42
 
43 43
 # Build framework
44 44
 meson/*
45
+subprojects
46
+

+ 1
- 1
.lvimrc View File

@@ -1,6 +1,6 @@
1 1
 "Stuff you're more likely to edit goes near the top
2 2
 
3
-let s:projstd = '-std=c89 -Wall -Wno-comment'
3
+let s:projstd = '-std=gnu89 -Wall -Wno-comment'
4 4
 let s:projinc = '-Iinclude -Isrc -Imeson/debug -Isrc/methods -Isrc/example -Isrc/dynload '
5 5
 let s:projopt = ''
6 6
 

+ 0
- 2
include/boksi.h View File

@@ -2,8 +2,6 @@
2 2
 #ifndef BOKSI_H
3 3
 #define BOKSI_H
4 4
 
5
-#define BOKSI_BUILD_GTK3
6
-
7 5
 typedef enum boksi_method
8 6
 {
9 7
 	BOKSI_GIVEUP      =0,

BIN
lib/lin/libdynload.a View File


+ 30
- 2
meson.build View File

@@ -1,10 +1,38 @@
1 1
 project('boksi', 'c', default_options : ['default_library=static', 'c_std=gnu89'])
2 2
 incdir = include_directories(['include', 'src', 'src/methods', 'src/dynload'])
3 3
 
4
-boksisrc = ['src/boksi.c', 'src/methods/boksi_gtk3.c', 'src/methods/boksi_gtk2.c', 'src/methods/boksi_xaw.c', 'src/methods/boksi_xlib.c', 'src/methods/boksi_xt.c']
4
+boksisrc = ['src/boksi.c', 'src/methods/boksi_gtk3.c', 'src/methods/boksi_gtk2.c', 'src/methods/boksi_xaw.c', 'src/methods/boksi_xlib.c', 'src/methods/boksi_xt.c', 'src/methods/boksi_std.c']
5
+
6
+#TODO These shouldn't be global arguments
7
+
8
+depgtk3 = dependency('gtk+-3.0', required:false)
9
+if depgtk3.found()
10
+	add_global_arguments('-DBOKSI_BUILD_GTK3', language : 'c')
11
+endif
12
+
13
+depgtk2 = dependency('gtk+-2.0', required:false)
14
+if depgtk2.found()
15
+	#Currently erroring. Disabled for now.
16
+	#add_global_arguments('-DBOKSI_BUILD_GTK2', language : 'c')
17
+endif
18
+
19
+depxt = dependency('xt', required:false)
20
+if depxt.found()
21
+	add_global_arguments('-DBOKSI_BUILD_XT', language : 'c')
22
+endif
23
+
24
+depxaw = dependency('Xaw', required:false)
25
+if depxaw.found()
26
+	add_global_arguments('-DBOKSI_BUILD_XAW', language : 'c')
27
+endif
28
+
29
+
30
+subproject('dynload', default_options : ['default_library=static', 'c_std=gnu89'])
31
+depdynload = dependency('dynload', fallback : ['dynload', 'dynload_dep'])
32
+
5 33
 
6 34
 #library
7
-libboksi = library('boksi', boksisrc, include_directories : incdir)
35
+libboksi = library('boksi', boksisrc, include_directories : incdir, dependencies: [depdynload, depgtk3, depgtk2, depxt, depxaw] )
8 36
 depboksi = declare_dependency(link_with : libboksi, include_directories : incdir)
9 37
 
10 38
 executable('boksibasic', 'src/example/basic.c', include_directories : incdir, dependencies: depboksi)

+ 17
- 0
scripts/dependencies View File

@@ -0,0 +1,17 @@
1
+#!/bin/bash
2
+# This file gets included wholesale into the mesonbuild script.
3
+# Anything you could do in that file, you can do in this.
4
+# The "#!/bin/sh" isn't required, but helps with syntax highlighting.
5
+# This file is executed in projectdir/dependencydir
6
+
7
+if [ ! -x "$(command /sbin/ldconfig -p)" ]; then
8
+	if [ -z "$(/sbin/ldconfig -p | grep -i dynload)" ]; then
9
+		mesonbuild_get dynload "git clone https://git.orangehattech.com/dirkson/dynload.git"
10
+	fi
11
+else
12
+	mesonbuild_get dynload "git clone https://git.orangehattech.com/dirkson/dynload.git"
13
+fi
14
+
15
+#Don't exit unless you want to quit the parent script too.
16
+#exit 0
17
+

+ 0
- 13
scripts/getdependencies View File

@@ -1,13 +0,0 @@
1
-#!/bin/bash
2
-#echo "protobuf-c, libsodium, glfw, lob, dynload, nuklear"
3
-read -p "This will download the latest git releases of the above required dependencies. You may wish to download stable releases instead. Press enter to continue, or control+c to abort."
4
-mkdir dependencies
5
-cd dependencies
6
-wget http://fltk.org/pub/fltk/1.3.4/fltk-1.3.4-1-source.tar.gz
7
-tar -xzf fltk-*.tar.gz
8
-git clone https://github.com/dirkson/dynload.git
9
-#git clone https://github.com/protobuf-c/protobuf-c.git
10
-#git clone https://github.com/jedisct1/libsodium.git
11
-#git clone https://github.com/glfw/glfw.git
12
-#git clone https://github.com/vurtun/nuklear.git
13
-#git clone https://github.com/dirkson/lob.git

+ 0
- 7
scripts/minimizesize View File

@@ -1,7 +0,0 @@
1
-#!/bin/bash
2
-ls -l bin/*
3
-strip -s -R .comment -R .gnu.version bin/*
4
-strip --strip-unneeded bin/*
5
-ls -l bin/*
6
-upx -9 bin/*
7
-ls -l bin/*

+ 29
- 14
src/boksi.c View File

@@ -23,28 +23,43 @@ void boksi_set_info(boksi_info* info, const boksi_method method[])
23 23
 
24 24
 int boksi_explicit(const boksi_info info, boksi_level level, const char* name, const char* button, const char *msg)
25 25
 {
26
-	if (boksi_gtk3(level, name, button, msg) == 1)
27
-		return EXIT_SUCCESS;
28
-
29
-	if (boksi_gtk2(level, name, button, msg) == 1)
30
-		return EXIT_SUCCESS;
31
-
32
-	if (boksi_xaw(level, name, button, msg) == 1)
33
-		return EXIT_SUCCESS;
34
-
35
-	//if (boksi_xlib6(level, name, button, msg) == 1)
36
-	//return EXIT_SUCCESS;
26
+	unsigned short int i;
27
+	for (i = 0; i < info.method_num; i++)
28
+	{
29
+		switch (info.method[i])
30
+		{
31
+		case BOKSI_GTK3:
32
+			if (BOKSI_SUCCESS == boksi_gtk3(level, name, button, msg))
33
+				return BOKSI_SUCCESS;
34
+		break;
35
+		case BOKSI_GTK2:
36
+		break;
37
+		case BOKSI_XAW:
38
+		break;
39
+		case BOKSI_XT:
40
+		break;
41
+		case BOKSI_STDOUT:
42
+			if (BOKSI_SUCCESS == boksi_std(BOKSI_INFO, msg))
43
+				return BOKSI_SUCCESS;
44
+		break;
45
+		case BOKSI_GIVEUP:
46
+			//shouldn't have gotten there.
47
+			i = info.method_num;
48
+		break;
49
+		default:
50
+		break;
51
+		}
52
+	}
37 53
 
38 54
 	//The worst possible thing.
39
-	return EXIT_FAILURE;
55
+	return BOKSI_FAILURE;
40 56
 
41
-	//boksi_xt6(level, name, button, msg);
42 57
 }
43 58
 
44 59
 int boksi(const boksi_level level, const char *msg)
45 60
 {
46 61
 	boksi_info info;
47
-	boksi_method method[] = { BOKSI_WIN32, BOKSI_GTK3, BOKSI_GTK2, BOKSI_QT, BOKSI_GIVEUP };
62
+	boksi_method method[] = { BOKSI_WIN32, BOKSI_GTK3, BOKSI_GTK2, BOKSI_QT, BOKSI_STDOUT, BOKSI_GIVEUP };
48 63
 	boksi_set_info(&info, method);
49 64
 	switch(level)
50 65
 	{

+ 0
- 6
src/dynload/dynload_gtk2.c View File

@@ -1,9 +1,3 @@
1 1
 //File generated by libdynload. Changes will probably be overwritten.
2 2
 
3 3
 #include "dynload_gtk2.h"
4
-#define DYNLOAD_GTK2_SYMBOL_NUM 4
5
-#define DYNLOAD_GTK2_DYNOBJ_NUM 2
6
-char* dynload_gtk2_symbol_names[DYNLOAD_GTK2_SYMBOL_NUM] = { "gtk_init", "gtk_window_new", "gtk_widget_show", "gtk_main", };
7
-void* dynload_gtk2_symbol_pointers[DYNLOAD_GTK2_SYMBOL_NUM];
8
-char* dynload_gtk2_dynobj[DYNLOAD_GTK2_SYMBOL_NUM] = { "libgtk-x11-2.0.so.0", "libgtk-x11-2.0.so", };
9
-dynload_library dynload_gtk2 = { NULL, &dynload_gtk2_symbol_names[0], &dynload_gtk2_symbol_pointers[0], DYNLOAD_GTK2_SYMBOL_NUM, &dynload_gtk2_dynobj[0], DYNLOAD_GTK2_DYNOBJ_NUM };

+ 6
- 0
src/dynload/dynload_gtk2.h View File

@@ -5,6 +5,12 @@
5 5
 #define dynload_gtk2_included
6 6
 #include <dynload.h>
7 7
 #include <gtk-2.0/gtk/gtk.h>
8
+#define DYNLOAD_GTK2_SYMBOL_NUM 4
9
+#define DYNLOAD_GTK2_DYNOBJ_NUM 2
10
+char* dynload_gtk2_symbol_names[DYNLOAD_GTK2_SYMBOL_NUM] = { "gtk_init", "gtk_window_new", "gtk_widget_show", "gtk_main", };
11
+void* dynload_gtk2_symbol_pointers[DYNLOAD_GTK2_SYMBOL_NUM];
12
+char* dynload_gtk2_dynobj[DYNLOAD_GTK2_SYMBOL_NUM] = { "libgtk-x11-2.0.so.0", "libgtk-x11-2.0.so", };
13
+dynload_library dynload_gtk2 = { NULL, &dynload_gtk2_symbol_names[0], &dynload_gtk2_symbol_pointers[0], DYNLOAD_GTK2_SYMBOL_NUM, &dynload_gtk2_dynobj[0], DYNLOAD_GTK2_DYNOBJ_NUM };
8 14
 typedef  void (*dynload_gtk2_gtk_init) (int *argc,                                    char ***argv);
9 15
 #define gtk_init ((dynload_gtk2_gtk_init)dynload_gtk2.symbol_pointer[0])
10 16
 typedef  GtkWidget* (*dynload_gtk2_gtk_window_new) (GtkWindowType type);

+ 0
- 6
src/dynload/dynload_gtk3.c View File

@@ -1,9 +1,3 @@
1 1
 //File generated by libdynload. Changes will probably be overwritten.
2 2
 
3 3
 #include "dynload_gtk3.h"
4
-#define DYNLOAD_GTK3_SYMBOL_NUM 21
5
-#define DYNLOAD_GTK3_DYNOBJ_NUM 1
6
-char* dynload_gtk3_symbol_names[DYNLOAD_GTK3_SYMBOL_NUM] = { "g_signal_connect_data", "gtk_application_new", "g_application_run", "g_object_unref", "gtk_window_set_title", "gtk_window_set_default_size", "gtk_widget_show_all", "gtk_init", "gtk_widget_show", "gtk_window_new", "gtk_main", "g_application_get_type", "gtk_application_window_new", "g_type_check_instance_cast", "gtk_button_box_new", "gtk_container_get_type", "gtk_container_add", "gtk_button_new_with_label", "gtk_widget_destroy", "gtk_window_get_type", "gtk_label_new", };
7
-void* dynload_gtk3_symbol_pointers[DYNLOAD_GTK3_SYMBOL_NUM];
8
-char* dynload_gtk3_dynobj[DYNLOAD_GTK3_SYMBOL_NUM] = { "libgtk-3.so", };
9
-dynload_library dynload_gtk3 = { NULL, &dynload_gtk3_symbol_names[0], &dynload_gtk3_symbol_pointers[0], DYNLOAD_GTK3_SYMBOL_NUM, &dynload_gtk3_dynobj[0], DYNLOAD_GTK3_DYNOBJ_NUM };

+ 7
- 0
src/dynload/dynload_gtk3.h View File

@@ -5,6 +5,12 @@
5 5
 #define dynload_gtk3_included
6 6
 #include <dynload.h>
7 7
 #include <gtk-3.0/gtk/gtk.h>
8
+#define DYNLOAD_GTK3_SYMBOL_NUM 21
9
+#define DYNLOAD_GTK3_DYNOBJ_NUM 1
10
+char* dynload_gtk3_symbol_names[DYNLOAD_GTK3_SYMBOL_NUM] = { "g_signal_connect_data", "gtk_application_new", "g_application_run", "g_object_unref", "gtk_window_set_title", "gtk_window_set_default_size", "gtk_widget_show_all", "gtk_init", "gtk_widget_show", "gtk_window_new", "gtk_main", "g_application_get_type", "gtk_application_window_new", "g_type_check_instance_cast", "gtk_button_box_new", "gtk_container_get_type", "gtk_container_add", "gtk_button_new_with_label", "gtk_widget_destroy", "gtk_window_get_type", "gtk_label_new", };
11
+void* dynload_gtk3_symbol_pointers[DYNLOAD_GTK3_SYMBOL_NUM];
12
+char* dynload_gtk3_dynobj[DYNLOAD_GTK3_SYMBOL_NUM] = { "libgtk-3.so", };
13
+dynload_library dynload_gtk3 = { NULL, &dynload_gtk3_symbol_names[0], &dynload_gtk3_symbol_pointers[0], DYNLOAD_GTK3_SYMBOL_NUM, &dynload_gtk3_dynobj[0], DYNLOAD_GTK3_DYNOBJ_NUM };
8 14
 typedef         gulong (*dynload_gtk3_g_signal_connect_data) (gpointer instance,             const gchar *detailed_signal,             GCallback c_handler,             gpointer data,             GClosureNotify destroy_data,             GConnectFlags connect_flags);
9 15
 #define g_signal_connect_data ((dynload_gtk3_g_signal_connect_data)dynload_gtk3.symbol_pointer[0])
10 16
 typedef         GtkApplication * (*dynload_gtk3_gtk_application_new) (const gchar *application_id,                                                 GApplicationFlags flags);
@@ -49,3 +55,4 @@ typedef         GtkWidget* (*dynload_gtk3_gtk_label_new) (const gchar *str);
49 55
 #define gtk_label_new ((dynload_gtk3_gtk_label_new)dynload_gtk3.symbol_pointer[20])
50 56
 extern dynload_library dynload_gtk3;
51 57
 #endif
58
+

+ 13
- 4
src/methods/boksi_gtk2.c View File

@@ -1,8 +1,12 @@
1 1
 
2
-#include <dynload_gtk2.h>
2
+#include "boksi.h"
3 3
 
4
-//extern int boksi_gtk2(char *, char*);
5
-extern int boksi_gtk2(char* name_window, char* name_button, char* msg)
4
+#ifdef BOKSI_BUILD_GTK2
5
+
6
+#include "boksi_gtk2.h"
7
+#include "dynload_gtk2.h"
8
+
9
+extern boksi_return boksi_gtk2(const boksi_level level, const char* name_window, const char* name_button, const char* msg)
6 10
 {
7 11
 	if (dynload(&dynload_gtk2) != DYNLOAD_SUCCESS)
8 12
 		return 0;
@@ -19,4 +23,9 @@ extern int boksi_gtk2(char* name_window, char* name_button, char* msg)
19 23
 	return 1;
20 24
 }
21 25
 
22
-
26
+#else
27
+extern boksi_return boksi_gtk2(const boksi_level level, const char* name_window, const char* name_button, const char* msg)
28
+{
29
+	return BOKSI_FAILURE;
30
+}
31
+#endif

+ 3
- 1
src/methods/boksi_gtk2.h View File

@@ -1,3 +1,5 @@
1 1
 
2
-extern int boksi_gtk2(int level, char*, char*, char*);
2
+#include "boksi.h"
3
+
4
+extern boksi_return boksi_gtk2(const boksi_level, const char*, const char*, const char*);
3 5
 

+ 20
- 7
src/methods/boksi_gtk3.c View File

@@ -1,6 +1,10 @@
1 1
 
2
-#include <boksi.h>
3
-#include <dynload_gtk3.h>
2
+#include "boksi.h"
3
+
4
+#ifdef BOKSI_BUILD_GTK3
5
+
6
+#include "boksi_gtk3.h"
7
+#include "dynload_gtk3.h"
4 8
 
5 9
 typedef struct {
6 10
 	boksi_level level;
@@ -36,19 +40,28 @@ static void activate (GtkApplication *app, gpointer        user_data)
36 40
 	gtk_widget_show_all (window);
37 41
 }
38 42
 
39
-extern int boksi_gtk3(boksi_level level, char* name, char* button, char* msg)
43
+extern boksi_return boksi_gtk3(const boksi_level level, const char* name, const char* button, const char* msg)
40 44
 {
41 45
 	if (dynload(&dynload_gtk3) != DYNLOAD_SUCCESS)
42
-		return 0;
46
+		return BOKSI_FAILURE;
43 47
 
44
-	boksi_thinks_gtk_is_annoying data = { level, name, button, msg };
48
+	boksi_thinks_gtk_is_annoying data = { (boksi_level)level, (char*)name, (char*)button, (char*)msg };
45 49
 
46 50
 	GtkApplication* app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
47 51
 	g_signal_connect (app, "activate", G_CALLBACK (activate), &data);
48
-	int status = g_application_run (G_APPLICATION (app), 0, NULL);
52
+
53
+	//int status =
54
+	g_application_run (G_APPLICATION (app), 0, NULL);
55
+
49 56
 	g_object_unref (app);
50 57
 
51
-	return 1;
58
+	return BOKSI_SUCCESS;
52 59
 }
53 60
 
61
+#else
62
+extern boksi_return boksi_gtk3(const boksi_level level, const char* name, const char* button, const char* msg)
63
+{
64
+	return BOKSI_FAILURE;
65
+}
66
+#endif
54 67
 

+ 2
- 2
src/methods/boksi_gtk3.h View File

@@ -1,4 +1,4 @@
1 1
 
2
-extern int boksi_gtk3(int, char*, char*, char*);
3
-
2
+#include "boksi.h"
4 3
 
4
+extern boksi_return boksi_gtk3(const boksi_level, const char*, const char*, const char*);

+ 23
- 0
src/methods/boksi_std.c View File

@@ -0,0 +1,23 @@
1
+
2
+#include "boksi.h"
3
+
4
+//#ifdef BOKSI_BUILD_STD
5
+
6
+#include <stdio.h>
7
+
8
+extern boksi_return boksi_std(const boksi_level level, const char* msg)
9
+{
10
+
11
+	printf("Boksi: %s\n", msg);
12
+
13
+	return BOKSI_SUCCESS;
14
+}
15
+
16
+/*
17
+#else
18
+extern boksi_return boksi_gtk3(const boksi_level level, const char* name, const char* button, const char* msg)
19
+{
20
+	return BOKSI_FAILURE;
21
+}
22
+#endif
23
+*/

+ 4
- 0
src/methods/boksi_std.h View File

@@ -0,0 +1,4 @@
1
+
2
+#include "boksi.h"
3
+
4
+extern boksi_return boksi_std(const boksi_level, const char*);

+ 9
- 1
src/methods/boksi_xaw.c View File

@@ -1,4 +1,7 @@
1 1
 
2
+#include <boksi.h>
3
+
4
+#ifdef BOKSI_BUILD_XAW
2 5
 
3 6
 #include <X11/Intrinsic.h>
4 7
 #include <X11/StringDefs.h>
@@ -12,7 +15,6 @@
12 15
 #include <dynload_xt.h>
13 16
 #include <dynload_xaw.h>
14 17
 
15
-#include <boksi.h>
16 18
 
17 19
 void boksi_xaw_button_press(Widget w, XtPointer client_data, XtPointer Unknown)
18 20
 {
@@ -61,4 +63,10 @@ extern int boksi_xaw(boksi_level level, char* name, char* button, char* msg)
61 63
 	return 1;
62 64
 }
63 65
 
66
+#else
67
+extern int boksi_xaw(boksi_level level, char* name, char* button, char* msg)
68
+{
69
+	return 0;
70
+}
71
+#endif
64 72
 

+ 2
- 1
src/methods/boksi_xlib.h View File

@@ -1,3 +1,4 @@
1 1
 
2
-extern int boksi_xlib(int level, char*, char*, char*);
2
+
3
+extern int boksi_xlib(int level, const char*, const char*, const char*);
3 4
 

Loading…
Cancel
Save