Skip to content

Commit 90d7374

Browse files
committed
todo: load file and pack
1 parent 65640cd commit 90d7374

9 files changed

Lines changed: 381 additions & 100 deletions

File tree

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
"C_Cpp.default.compileCommands": "/home/archlinux/Projects/gusl/builddir/compile_commands.json",
44
"C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild",
55
"files.associations": {
6-
"gi18n.h": "c"
6+
"gi18n.h": "c",
7+
"gusl-window.h": "c",
8+
"glib.h": "c",
9+
"editor-window.h": "c",
10+
"config.h": "c",
11+
"shader_source.h": "c",
12+
"version.h": "c",
13+
"gusl-log.h": "c",
14+
"ranges": "c",
15+
"cstdlib": "c"
716
}
817
}

meson.build

Lines changed: 104 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
project(
2-
'gusl', 'c',
2+
'gusl',
3+
'c',
34
version: '0.0.1',
45
meson_version: '>= 0.59.0',
56
license: 'GPL3+',
6-
default_options: [
7-
'c_std=gnu11',
8-
'warning_level=2',
9-
'buildtype=debugoptimized'
10-
])
11-
12-
pkg_name = meson.project_name()
13-
pkg_id = 'io.github.singlerr.gusl'
14-
pkg_version = meson.project_version()
15-
pkg_is_debug = get_option('buildtype').startswith('debug')
16-
17-
pkg_prefix = get_option('prefix')
18-
pkg_srcdir = meson.project_source_root()
19-
pkg_builddir = meson.project_build_root()
20-
pkg_bindir = join_paths(pkg_prefix, get_option('bindir'))
21-
pkg_libdir = join_paths(pkg_prefix, get_option('libdir'))
7+
default_options: ['c_std=gnu11', 'warning_level=2', 'buildtype=debugoptimized'],
8+
)
9+
10+
pkg_name = meson.project_name()
11+
pkg_id = 'io.github.singlerr.gusl'
12+
pkg_version = meson.project_version()
13+
pkg_is_debug = get_option('buildtype').startswith('debug')
14+
15+
pkg_prefix = get_option('prefix')
16+
pkg_srcdir = meson.project_source_root()
17+
pkg_builddir = meson.project_build_root()
18+
pkg_bindir = join_paths(pkg_prefix, get_option('bindir'))
19+
pkg_libdir = join_paths(pkg_prefix, get_option('libdir'))
2220
pkg_localedir = join_paths(pkg_prefix, get_option('localedir'))
23-
pkg_datadir = join_paths(pkg_prefix, get_option('datadir'))
21+
pkg_datadir = join_paths(pkg_prefix, get_option('datadir'))
2422
pkg_schemadir = join_paths(pkg_datadir, 'glib-2.0', 'schemas')
25-
pkg_po_dir = join_paths(pkg_srcdir, 'po')
26-
top_inc = include_directories('.')
27-
src_inc = include_directories('src')
23+
pkg_po_dir = join_paths(pkg_srcdir, 'po')
24+
top_inc = include_directories('.')
25+
src_inc = include_directories('src')
2826

2927
gnome = import('gnome')
30-
i18n = import('i18n')
31-
cc = meson.get_compiler('c')
32-
28+
i18n = import('i18n')
29+
cc = meson.get_compiler('c')
3330

3431
conf = configuration_data()
3532
conf.set('NDEBUG', (not pkg_is_debug))
@@ -67,50 +64,55 @@ common_flags = [
6764

6865
add_global_arguments(common_flags, language: 'c')
6966
c_args = cc.get_supported_arguments(
70-
['-fasynchronous-unwind-tables',
71-
'-fno-strict-aliasing',
72-
'-Wcast-align',
73-
'-Wdate-time',
74-
'-Werror=format-security',
75-
'-Werror=implicit-function-declaration',
76-
'-Werror=pointer-to-int-cast',
77-
'-Werror=redundant-decls',
78-
'-Werror=return-type',
79-
'-Werror=vla',
80-
'-Werror=write-strings',
81-
'-Wfloat-equal',
82-
'-Wformat=2',
83-
'-Wimplicit-fallthrough',
84-
'-Wlogical-op',
85-
'-Wmissing-format-attribute',
86-
'-Wmissing-include-dirs',
87-
'-Wmissing-prototypes',
88-
'-Wnested-externs',
89-
'-Wno-cast-function-type',
90-
'-Wno-missing-field-initializers',
91-
'-Wno-unused-parameter',
92-
'-Wold-style-declaration',
93-
'-Wold-style-definition',
94-
'-Wpointer-arith',
95-
'-Wshadow',
96-
'-Wswitch-default',
97-
'-Wswitch-enum',
98-
'-Wtrigraphs',
99-
'-Wunused',
100-
'-pipe',
101-
])
67+
[
68+
'-fasynchronous-unwind-tables',
69+
'-fno-strict-aliasing',
70+
'-Wcast-align',
71+
'-Wdate-time',
72+
'-Werror=format-security',
73+
'-Werror=implicit-function-declaration',
74+
'-Werror=pointer-to-int-cast',
75+
'-Werror=redundant-decls',
76+
'-Werror=return-type',
77+
'-Werror=vla',
78+
'-Werror=write-strings',
79+
'-Wfloat-equal',
80+
'-Wformat=2',
81+
'-Wimplicit-fallthrough',
82+
'-Wlogical-op',
83+
'-Wmissing-format-attribute',
84+
'-Wmissing-include-dirs',
85+
'-Wmissing-prototypes',
86+
'-Wnested-externs',
87+
'-Wno-cast-function-type',
88+
'-Wno-missing-field-initializers',
89+
'-Wno-unused-parameter',
90+
'-Wold-style-declaration',
91+
'-Wold-style-definition',
92+
'-Wpointer-arith',
93+
'-Wshadow',
94+
'-Wswitch-default',
95+
'-Wswitch-enum',
96+
'-Wtrigraphs',
97+
'-Wunused',
98+
'-pipe',
99+
],
100+
)
102101

103102
add_project_arguments(c_args, language: 'c')
104103

105104
if cc.get_id() == 'msvc'
106-
warning('Your compiler doesn\'t support C99/C11 features.' +
107-
' Please use MinGW or native GNU/Linux')
105+
warning(
106+
'Your compiler doesn\'t support C99/C11 features.'
107+
+ ' Please use MinGW or native GNU/Linux',
108+
)
108109
endif
109110

110111
pkg_dep = [
111112
dependency('glib-2.0', version: '>= 2.62.0'),
112113
dependency('gtk4', version: '>= 4.6.0'),
113114
dependency('libadwaita-1', version: '>= 1.4'),
115+
dependency('libzip', version: '>= 1.11.4'),
114116
]
115117

116118
subdir('src')
@@ -135,42 +137,53 @@ gnome.post_install(
135137
update_desktop_database: true,
136138
)
137139

138-
run_target('make-po',
139-
command: [
140-
find_program('build-aux/make_po.sh'),
141-
pkg_name,
142-
meson.current_build_dir(),
143-
join_paths(pkg_srcdir, 'po'),
144-
])
145-
146-
run_target('make-help-po',
147-
command: [
148-
find_program('build-aux/make_po.sh'),
149-
pkg_id,
150-
meson.current_build_dir(),
151-
join_paths(pkg_srcdir, 'docs/help'),
152-
'help-',
153-
'true',
154-
])
140+
run_target(
141+
'make-po',
142+
command: [
143+
find_program('build-aux/make_po.sh'),
144+
pkg_name,
145+
meson.current_build_dir(),
146+
join_paths(pkg_srcdir, 'po'),
147+
],
148+
)
149+
150+
run_target(
151+
'make-help-po',
152+
command: [
153+
find_program('build-aux/make_po.sh'),
154+
pkg_id,
155+
meson.current_build_dir(),
156+
join_paths(pkg_srcdir, 'docs/help'),
157+
'help-',
158+
'true',
159+
],
160+
)
155161

156162
system = target_machine.system()
157163
if system == 'linux'
158164
system = 'GNU/Linux'
159165
endif
160166

161-
summary({'Target': system,
162-
'Target arch': target_machine.cpu(),
163-
'Compiler': cc.get_id(),
164-
'Version': cc.version(),
165-
'Linker': cc.get_linker_id(),
166-
}, section: 'Toolchain')
167-
168-
summary({
169-
'Build type': get_option('buildtype'),
170-
'Tests': get_option('tests'),
171-
'Manpage': build_man,
172-
'Documentation': get_option('gtk_doc'),
173-
'Translations': get_option('po'),
174-
'Help': get_option('help'),
175-
'Bash Completion': get_option('bash_completion'),
176-
}, section: 'Configuration')
167+
summary(
168+
{
169+
'Target': system,
170+
'Target arch': target_machine.cpu(),
171+
'Compiler': cc.get_id(),
172+
'Version': cc.version(),
173+
'Linker': cc.get_linker_id(),
174+
},
175+
section: 'Toolchain',
176+
)
177+
178+
summary(
179+
{
180+
'Build type': get_option('buildtype'),
181+
'Tests': get_option('tests'),
182+
'Manpage': build_man,
183+
'Documentation': get_option('gtk_doc'),
184+
'Translations': get_option('po'),
185+
'Help': get_option('help'),
186+
'Bash Completion': get_option('bash_completion'),
187+
},
188+
section: 'Configuration',
189+
)

src/editor-window.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ struct _EditorWindow
4141

4242
G_DEFINE_TYPE (EditorWindow, editor_window, ADW_TYPE_APPLICATION_WINDOW)
4343

44-
bool editor_check_content_type (GFileInfo *meta);
44+
4545
void editor_setup (gchar *path);
4646

47+
void
48+
editor_setup (gchar *path)
49+
{
50+
GFile *file = g_file_new_for_path (path);
51+
}
52+
4753
static void
4854
editor_window_constructed (GObject *object)
4955
{

src/gusl-utils.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#endif
2929

3030
#include "gusl-utils.h"
31+
#include <glib/gi18n.h>
3132

3233
/**
3334
* SECTION: gusl-utils
@@ -61,3 +62,51 @@ gusl_utils_get_main_thread (void)
6162

6263
return main_thread;
6364
}
65+
66+
AdwAlertDialog *
67+
adw_alert_dialog_new_yes_or_no (const char *title, const char *body, GCallback yes_callback, GCallback no_callback)
68+
{
69+
AdwDialog *dialog = adw_alert_dialog_new (title, body);
70+
adw_alert_dialog_add_responses (ADW_ALERT_DIALOG (dialog), "yes", _ ("Yes"), "no", _ ("No"), NULL);
71+
adw_alert_dialog_set_response_appearance (ADW_ALERT_DIALOG (dialog), "yes", ADW_RESPONSE_SUGGESTED);
72+
adw_alert_dialog_set_response_appearance (ADW_ALERT_DIALOG (dialog), "no", ADW_RESPONSE_DESTRUCTIVE);
73+
adw_alert_dialog_set_default_response (ADW_ALERT_DIALOG (dialog), "no");
74+
adw_alert_dialog_set_close_response (ADW_ALERT_DIALOG (dialog), "no");
75+
76+
if (yes_callback)
77+
{
78+
g_signal_connect (dialog, "yes", yes_callback, NULL);
79+
}
80+
81+
if (no_callback)
82+
{
83+
g_signal_connect (dialog, "no", no_callback, NULL);
84+
}
85+
86+
return ADW_ALERT_DIALOG (dialog);
87+
}
88+
89+
AdwAlertDialog *
90+
adw_alert_dialog_new_ok (const char *title, const char *body, GCallback ok_callback)
91+
{
92+
AdwDialog *dialog = adw_alert_dialog_new (title, body);
93+
adw_alert_dialog_add_responses (ADW_ALERT_DIALOG (dialog), "ok", _ ("OK"), NULL);
94+
adw_alert_dialog_set_response_appearance (ADW_ALERT_DIALOG (dialog), "ok", ADW_RESPONSE_SUGGESTED);
95+
adw_alert_dialog_set_default_response (ADW_ALERT_DIALOG (dialog), "ok");
96+
adw_alert_dialog_set_close_response (ADW_ALERT_DIALOG (dialog), "ok");
97+
98+
if (ok_callback)
99+
{
100+
g_signal_connect (dialog, "ok", ok_callback, NULL);
101+
}
102+
103+
return ADW_ALERT_DIALOG (dialog);
104+
}
105+
106+
void
107+
_adw_destroy_dialog (AdwAlertDialog *dialog,
108+
GAsyncResult *result)
109+
{
110+
adw_alert_dialog_choose_finish (dialog, result);
111+
g_object_unref (dialog);
112+
}

src/gusl-utils.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@
2323

2424
#pragma once
2525

26+
27+
#include <adwaita.h>
2628
#include <glib.h>
2729

2830
G_BEGIN_DECLS
2931

32+
extern void
33+
_adw_destroy_dialog (AdwAlertDialog *dialog,
34+
GAsyncResult *result);
35+
3036
#define GUSL_IS_MAIN_THREAD() (g_thread_self () == gusl_utils_get_main_thread ())
37+
#define ADW_DESTROY_DIALOG (G_CALLBACK (_adw_destroy_dialog))
38+
39+
GThread *gusl_utils_get_main_thread (void);
40+
AdwAlertDialog *adw_alert_dialog_new_yes_or_no (const char *title, const char *body, GCallback yes_callback, GCallback no_callback);
41+
AdwAlertDialog *adw_alert_dialog_new_ok (const char *title, const char *body, GCallback ok_callback);
3142

32-
GThread *gusl_utils_get_main_thread (void);
3343

3444
G_END_DECLS

0 commit comments

Comments
 (0)