diff --git a/configure.ac b/configure.ac index d8504a7a..97cbc716 100644 --- a/configure.ac +++ b/configure.ac @@ -191,6 +191,9 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.62.0], [], [AC_MSG_ERROR([glib 2.62.0 or higher is required for profanity])]) PKG_CHECK_MODULES([gio], [gio-2.0], [], [AC_MSG_ERROR([libgio-2.0 from glib-2.0 is required for profanity])]) +#TODO: only under cond +PKG_CHECK_MODULES([pixbuf], [gdk-pixbuf-2.0], [], + [AC_MSG_ERROR([gdk-pixbuf-2.0 from glib-2.0 is required for profanity])]) ### Check for other profanity dependencies AC_SEARCH_LIBS([fmod], [m], [], @@ -203,6 +206,10 @@ PKG_CHECK_MODULES([curl], [libcurl], [], PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.22.0], [], [AC_MSG_ERROR([sqlite3 3.22.0 or higher is required for profanity])]) +#TODO: only under cond +PKG_CHECK_MODULES([chafa], [chafa >= 1.4.1], [], + [AC_MSG_ERROR([chafa needed])]) + AS_IF([test "x$enable_icons_and_clipboard" != xno], [PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.24.0], [AC_DEFINE([HAVE_GTK], [1], [libgtk module])], @@ -359,9 +366,9 @@ AS_IF([test "x$PACKAGE_STATUS" = xdevelopment], AS_IF([test "x$PLATFORM" = xosx], [AM_CFLAGS="$AM_CFLAGS -Qunused-arguments"]) AM_LDFLAGS="$AM_LDFLAGS -export-dynamic" -AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $gio_CFLAGS $curl_CFLAGS $libnotify_CFLAGS $PYTHON_CPPFLAGS ${GTK_CFLAGS} ${SQLITE_CFLAGS}" +AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $gio_CFLAGS $curl_CFLAGS $libnotify_CFLAGS $PYTHON_CPPFLAGS ${GTK_CFLAGS} ${SQLITE_CFLAGS} ${chafa_CFLAGS}" AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\" -DICONS_PATH=\"\\\"$ICONS_PATH\\\"\"" -LIBS="$glib_LIBS $gio_LIBS $curl_LIBS $libnotify_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_LDFLAGS ${GTK_LIBS} ${SQLITE_LIBS} $LIBS" +LIBS="$glib_LIBS $gio_LIBS $curl_LIBS $libnotify_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_LDFLAGS ${GTK_LIBS} ${SQLITE_LIBS} ${chafa_LIBS} $LIBS" AC_SUBST(AM_LDFLAGS) AC_SUBST(AM_CFLAGS) diff --git a/src/ui/console.c b/src/ui/console.c index 1bfd1cc1..4000981c 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -407,6 +407,7 @@ cons_about(void) getmaxyx(stdscr, rows, cols); if (prefs_get_boolean(PREF_SPLASH)) { + win_pictest(console); _cons_splash_logo(); } else { diff --git a/src/ui/window.c b/src/ui/window.c index cca6d902..39374632 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -44,6 +44,10 @@ #include +//TODO: ifdef +#include +#include + #ifdef HAVE_NCURSESW_NCURSES_H #include #elif HAVE_NCURSES_H @@ -1953,3 +1957,48 @@ win_insert_last_read_position_marker(ProfWin* window, char* id) g_date_time_unref(time); } + +void +win_pictest(ProfWin* window) +{ + GdkPixbuf *file = gdk_pixbuf_new_from_file ("/home/michael/Pictures/test.png", NULL); + //GdkPixbuf *file = gdk_pixbuf_new_from_file ("/home/michael/ask2.png", NULL); + if (file == NULL) { + win_println(window, THEME_ERROR, "!", "pictest"); + return; + } + ChafaCanvasConfig *config; + ChafaCanvas *canvas; + ChafaSymbolMap *symbol_map; + + symbol_map = chafa_symbol_map_new (); + //chafa_symbol_map_add_by_tags (symbol_map, CHAFA_SYMBOL_TAG_ALL); + chafa_symbol_map_add_by_tags (symbol_map, CHAFA_SYMBOL_TAG_ASCII); + //chafa_symbol_map_add_by_tags (symbol_map, CHAFA_SYMBOL_TAG_BRAILLE); + //chafa_symbol_map_add_by_tags (symbol_map, CHAFA_SYMBOL_TAG_BLOCK | CHAFA_SYMBOL_TAG_BORDER); + //chafa_symbol_map_add_by_tags (symbol_map, CHAFA_SYMBOL_TAG_BLOCK | CHAFA_SYMBOL_TAG_BORDER | CHAFA_SYMBOL_TAG_SPACE); + + // TODO: use chafa_calc_canvas_geometry() to get recommended canvas size + // TODO: could be a that a user shrinks its terminal. then we would need to redraw I guess? + + config = chafa_canvas_config_new (); + //chafa_canvas_config_set_geometry (config, 23, 12); + chafa_canvas_config_set_geometry (config, 100, 65); + chafa_canvas_config_set_symbol_map (config, symbol_map); + // mono for now (no escape code) + chafa_canvas_config_set_canvas_mode (config, CHAFA_CANVAS_MODE_FGBG); + + canvas = chafa_canvas_new (config); + + //CHAFA_PIXEL_RGBA8_UNASSOCIATED, + guchar *pixels = gdk_pixbuf_get_pixels (file); + chafa_canvas_draw_all_pixels (canvas, + CHAFA_PIXEL_ARGB8_UNASSOCIATED, + pixels, + gdk_pixbuf_get_width(file), + gdk_pixbuf_get_height(file), + gdk_pixbuf_get_rowstride(file)); + + GString *gs = chafa_canvas_build_ansi (canvas); + win_print(window, THEME_DEFAULT, "!", gs->str); +} diff --git a/src/ui/window.h b/src/ui/window.h index 22a1db51..c822a983 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -93,4 +93,7 @@ void win_sub_page_up(ProfWin* window); void win_insert_last_read_position_marker(ProfWin* window, char* id); void win_remove_entry_message(ProfWin* window, const char* const id); +// TODO: ifdef +void win_pictest(ProfWin* window); + #endif