Skip to content

Commit

Permalink
Added osapp_argc, osapp_argv
Browse files Browse the repository at this point in the history
  • Loading branch information
frang75 committed Apr 16, 2024
1 parent 761ce9a commit 10a8dbc
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 20 deletions.
6 changes: 5 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

## v1.4.2 - WIP

### Added

* `osapp_argc()` and `osapp_argv()`.

### Fixed

* WindowsXP TableView/ListBox select colors. [Commit](https://github.com/frang75/nappgui_src/commit/fd0983ff06cbea190a543e9f119e749c436b954d).
* macOS TableView/ListBox select colors. [Issue](https://github.com/frang75/nappgui_src/issues/115). [Commit](https://github.com/frang75/nappgui_src/commit/7485964f68e5647c5a31e267ce3a8d2b059ca031).
* WindowsXP flat buttons drawing. [Commit](https://github.com/frang75/nappgui_src/commit/adbb2db0f614db810a17f6c945a44134294efa60).
* macOS Snow Leopard focus ring. [Commit](https://github.com/frang75/nappgui_src/commit/0bd24f6dcb2135e8de763a8a98dd64dc7c98d6c6).
* Crash in ColorView demo. [Issue](https://github.com/frang75/nappgui_src/issues/131).
* Crash in ColorView demo. [Issue](https://github.com/frang75/nappgui_src/issues/131). [Commit](https://github.com/frang75/nappgui_src/commit/761ce9ab81a33f74f7591609f02508d5da2c1dc7).

### Removed

Expand Down
2 changes: 1 addition & 1 deletion prj/build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5038
5042
20 changes: 10 additions & 10 deletions src/osapp/gtk3/osapp_gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <osbs/bfile.h>
#include <sewer/bmem.h>
#include <sewer/cassert.h>
#include <sewer/unicode.h>
#include <stdlib.h>
#include <locale.h>

Expand Down Expand Up @@ -159,22 +160,21 @@ void osapp_terminate_imp(OSApp **app, const bool_t abnormal_termination, FPtr_de

/*---------------------------------------------------------------------------*/

uint32_t osapp_argc(OSApp *app)
uint32_t osapp_argc_imp(OSApp *app)
{
cassert_no_null(app);
cassert(FALSE);
return 0;
cassert(app == &i_APP);
return app->argc;
}

/*---------------------------------------------------------------------------*/

void osapp_argv(OSApp *app, const uint32_t index, char_t *argv, const uint32_t max_size)
uint32_t osapp_argv_imp(OSApp *app, const uint32_t index, char_t *argv, const uint32_t max_size)
{
unref(app);
unref(index);
unref(argv);
unref(max_size);
cassert(FALSE);
cassert_no_null(app);
cassert(app == &i_APP);
cassert(index < app->argc);
return unicode_convers((const char_t *)app->argv[index], argv, ekUTF8, ekUTF8, max_size);
}

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -263,7 +263,7 @@ void osapp_run(OSApp *app)
cassert(app->with_run_loop == TRUE);
signal_id = g_signal_connect(app->gtk_app, "activate", G_CALLBACK(i_OnActivate), (gpointer)app);
cassert_unref(signal_id > 0, signal_id);
status = g_application_run(G_APPLICATION(app->gtk_app), app->argc, app->argv);
status = g_application_run(G_APPLICATION(app->gtk_app), 0, NULL);
unref(status);
app->func_OnExecutionEnd();
}
Expand Down
16 changes: 16 additions & 0 deletions src/osapp/osapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,22 @@ void osapp_finish(void)

/*---------------------------------------------------------------------------*/

uint32_t osapp_argc(void)
{
i_App *app = osapp_listener(i_App);
return osapp_argc_imp(app->osapp);
}

/*---------------------------------------------------------------------------*/

uint32_t osapp_argv(const uint32_t index, char_t *argv, const uint32_t size)
{
i_App *app = osapp_listener(i_App);
return osapp_argv_imp(app->osapp, index, argv, size);
}

/*---------------------------------------------------------------------------*/

void osapp_task_imp(void *data, const real32_t updtime, FPtr_task_main func_task_main, FPtr_task_update func_task_update, FPtr_task_end func_task_end)
{
i_App *app = osapp_listener(i_App);
Expand Down
4 changes: 4 additions & 0 deletions src/osapp/osapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ __EXTERN_C

_osapp_api void osapp_finish(void);

_osapp_api uint32_t osapp_argc(void);

_osapp_api uint32_t osapp_argv(const uint32_t index, char_t *argv, const uint32_t size);

_osapp_api void osapp_task_imp(void *data, const real32_t updtime, FPtr_task_main func_task_main, FPtr_task_update func_task_update, FPtr_task_end func_task_end);

_osapp_api void osapp_menubar(Menu *menu, Window *window);
Expand Down
4 changes: 2 additions & 2 deletions src/osapp/osapp.inl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ void osapp_terminate_imp(
FPtr_destroy func_destroy,
FPtr_app_void func_OnExecutionEnd);

uint32_t osapp_argc(OSApp *app);
uint32_t osapp_argc_imp(OSApp *app);

void osapp_argv(OSApp *app, const uint32_t index, char_t *argv, const uint32_t max_size);
uint32_t osapp_argv_imp(OSApp *app, const uint32_t index, char_t *argv, const uint32_t max_size);

void osapp_run(OSApp *app);

Expand Down
7 changes: 4 additions & 3 deletions src/osapp/osx/osapp_osx.m
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void osapp_terminate_imp(

/*---------------------------------------------------------------------------*/

uint32_t osapp_argc(OSApp *app)
uint32_t osapp_argc_imp(OSApp *app)
{
OSXAppDelegate *delegate = NULL;
cassert_no_null(app);
Expand All @@ -327,13 +327,14 @@ uint32_t osapp_argc(OSApp *app)

/*---------------------------------------------------------------------------*/

void osapp_argv(OSApp *app, const uint32_t idx, char_t *argv, const uint32_t max_size)
uint32_t osapp_argv_imp(OSApp *app, const uint32_t index, char_t *argv, const uint32_t max_size)
{
OSXAppDelegate *delegate = NULL;
cassert_no_null(app);
cassert((NSApplication *)app == NSApp);
delegate = [(NSApplication *)app delegate];
unicode_convers((const char_t *)delegate->argv[idx], argv, ekUTF8, ekUTF8, max_size);
cassert(index < delegate->argc);
return unicode_convers((const char_t *)delegate->argv[index], argv, ekUTF8, ekUTF8, max_size);
}

/*---------------------------------------------------------------------------*/
Expand Down
8 changes: 5 additions & 3 deletions src/osapp/win/osapp_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,21 @@ void osapp_terminate_imp(OSApp **app, const bool_t abnormal_termination, FPtr_de

/*---------------------------------------------------------------------------*/

uint32_t osapp_argc(OSApp *app)
uint32_t osapp_argc_imp(OSApp *app)
{
cassert_no_null(app);
cassert(app == &i_APP);
return (uint32_t)app->nArgs;
}

/*---------------------------------------------------------------------------*/

void osapp_argv(OSApp *app, const uint32_t index, char_t *argv, const uint32_t max_size)
uint32_t osapp_argv_imp(OSApp *app, const uint32_t index, char_t *argv, const uint32_t max_size)
{
cassert_no_null(app);
cassert(app == &i_APP);
cassert(index < (uint32_t)app->nArgs);
unicode_convers((const char_t *)app->szArgList[index], argv, ekUTF16, ekUTF8, max_size);
return unicode_convers((const char_t *)app->szArgList[index], argv, ekUTF16, ekUTF8, max_size);
}

/*---------------------------------------------------------------------------*/
Expand Down

0 comments on commit 10a8dbc

Please sign in to comment.