sdgtk -> sdgui, improve build, mention in README
It's finally not horrible.
This commit is contained in:
parent
9d7bc2a839
commit
573554b9de
|
@ -78,6 +78,9 @@ if (WITH_X11)
|
||||||
list (APPEND dependencies_LIBRARIES ${xcb_LIBRARIES})
|
list (APPEND dependencies_LIBRARIES ${xcb_LIBRARIES})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
pkg_check_modules (gtk gtk+-3.0)
|
||||||
|
option (WITH_GUI "Build a work-in-progress GTK+ UI" ${gtk_FOUND})
|
||||||
|
|
||||||
link_directories (${dependencies_LIBRARY_DIRS})
|
link_directories (${dependencies_LIBRARY_DIRS})
|
||||||
include_directories (${ZLIB_INCLUDE_DIRS} ${icu_INCLUDE_DIRS}
|
include_directories (${ZLIB_INCLUDE_DIRS} ${icu_INCLUDE_DIRS}
|
||||||
${dependencies_INCLUDE_DIRS} ${Ncursesw_INCLUDE_DIRS}
|
${dependencies_INCLUDE_DIRS} ${Ncursesw_INCLUDE_DIRS}
|
||||||
|
@ -117,7 +120,7 @@ add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
|
||||||
|
|
||||||
# Project libraries
|
# Project libraries
|
||||||
set (project_common_libraries ${ZLIB_LIBRARIES} ${icu_LIBRARIES}
|
set (project_common_libraries ${ZLIB_LIBRARIES} ${icu_LIBRARIES}
|
||||||
${dependencies_LIBRARIES} ${Ncursesw_LIBRARIES} termo-static)
|
${dependencies_LIBRARIES})
|
||||||
|
|
||||||
set (project_common_headers
|
set (project_common_headers
|
||||||
${PROJECT_BINARY_DIR}/config.h
|
${PROJECT_BINARY_DIR}/config.h
|
||||||
|
@ -151,17 +154,17 @@ set (project_headers
|
||||||
add_definitions (-DGLIB_DISABLE_DEPRECATION_WARNINGS)
|
add_definitions (-DGLIB_DISABLE_DEPRECATION_WARNINGS)
|
||||||
add_executable (${PROJECT_NAME}
|
add_executable (${PROJECT_NAME}
|
||||||
${project_sources} ${project_headers} ${project_common_sources})
|
${project_sources} ${project_headers} ${project_common_sources})
|
||||||
target_link_libraries (${PROJECT_NAME} ${project_common_libraries})
|
target_link_libraries (${PROJECT_NAME} ${project_common_libraries}
|
||||||
|
${Ncursesw_LIBRARIES} termo-static)
|
||||||
|
|
||||||
# Experimental GTK+ frontend, we link it with ncurses but we don't care
|
# The same for the alternative GTK+ UI
|
||||||
pkg_check_modules (gtk gtk+-3.0)
|
if (WITH_GUI)
|
||||||
if (gtk_FOUND)
|
add_executable (sdgui
|
||||||
add_executable (sdgtk EXCLUDE_FROM_ALL
|
src/sdgui.c
|
||||||
src/sdgtk.c
|
|
||||||
src/stardict-view.c
|
src/stardict-view.c
|
||||||
${project_common_sources})
|
${project_common_sources})
|
||||||
target_include_directories (sdgtk PUBLIC ${gtk_INCLUDE_DIRS})
|
target_include_directories (sdgui PUBLIC ${gtk_INCLUDE_DIRS})
|
||||||
target_link_libraries (sdgtk ${gtk_LIBRARIES} ${project_common_libraries})
|
target_link_libraries (sdgui ${gtk_LIBRARIES} ${project_common_libraries})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
|
@ -193,6 +196,9 @@ add_custom_target (dicts DEPENDS ${dicts_targets})
|
||||||
include (GNUInstallDirs)
|
include (GNUInstallDirs)
|
||||||
install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||||
|
if (WITH_GUI)
|
||||||
|
install (TARGETS sdgui DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif ()
|
||||||
|
|
||||||
foreach (page ${project_MAN_PAGES})
|
foreach (page ${project_MAN_PAGES})
|
||||||
string (REGEX MATCH "\\.([0-9])$" manpage_suffix "${page}")
|
string (REGEX MATCH "\\.([0-9])$" manpage_suffix "${page}")
|
||||||
|
|
|
@ -79,6 +79,11 @@ Linux and/or BSD distributions:
|
||||||
Given the entangledness of this codebase, issues with the file format,
|
Given the entangledness of this codebase, issues with the file format,
|
||||||
and general undesirability of terminal UIs, it might be better to start anew.
|
and general undesirability of terminal UIs, it might be better to start anew.
|
||||||
|
|
||||||
|
Graphical UI
|
||||||
|
------------
|
||||||
|
With GTK+ 3 development packages installed, an alternative, work-in-progress
|
||||||
|
frontend will be built and installed.
|
||||||
|
|
||||||
Contributing and Support
|
Contributing and Support
|
||||||
------------------------
|
------------------------
|
||||||
Use https://git.janouch.name/p/sdtui to report any bugs, request features,
|
Use https://git.janouch.name/p/sdtui to report any bugs, request features,
|
||||||
|
|
29
src/sdtui.c
29
src/sdtui.c
|
@ -36,8 +36,12 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
#include <termo.h> // input
|
#include <termo.h> // input
|
||||||
#include <ncurses.h> // output
|
#include <ncurses.h> // output
|
||||||
|
#include <termios.h>
|
||||||
|
#ifndef TIOCGWINSZ
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#endif // ! TIOCGWINSZ
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "stardict.h"
|
#include "stardict.h"
|
||||||
|
@ -62,6 +66,27 @@ unichar_width (gunichar ch)
|
||||||
return 1 + g_unichar_iswide (ch);
|
return 1 + g_unichar_iswide (ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
update_curses_terminal_size (void)
|
||||||
|
{
|
||||||
|
#if defined (HAVE_RESIZETERM) && defined (TIOCGWINSZ)
|
||||||
|
struct winsize size;
|
||||||
|
if (!ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &size))
|
||||||
|
{
|
||||||
|
char *row = getenv ("LINES");
|
||||||
|
char *col = getenv ("COLUMNS");
|
||||||
|
unsigned long tmp;
|
||||||
|
resizeterm (
|
||||||
|
(row && xstrtoul (&tmp, row, 10)) ? tmp : size.ws_row,
|
||||||
|
(col && xstrtoul (&tmp, col, 10)) ? tmp : size.ws_col);
|
||||||
|
}
|
||||||
|
#else // HAVE_RESIZETERM && TIOCGWINSZ
|
||||||
|
// The standard endwin/refresh sequence makes the terminal flicker.
|
||||||
|
endwin ();
|
||||||
|
refresh ();
|
||||||
|
#endif // HAVE_RESIZETERM && TIOCGWINSZ
|
||||||
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
add_read_watch (int fd, GIOFunc func, gpointer user_data)
|
add_read_watch (int fd, GIOFunc func, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
|
28
src/utils.c
28
src/utils.c
|
@ -23,12 +23,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <curses.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#ifndef TIOCGWINSZ
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#endif // ! TIOCGWINSZ
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
@ -101,28 +95,6 @@ xstrtoul (unsigned long *out, const char *s, int base)
|
||||||
return errno == 0 && !*end && end != s;
|
return errno == 0 && !*end && end != s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Didn't want to have this ugly piece of code in the main source file;
|
|
||||||
// the standard endwin/refresh sequence makes the terminal flicker.
|
|
||||||
void
|
|
||||||
update_curses_terminal_size (void)
|
|
||||||
{
|
|
||||||
#if defined (HAVE_RESIZETERM) && defined (TIOCGWINSZ)
|
|
||||||
struct winsize size;
|
|
||||||
if (!ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &size))
|
|
||||||
{
|
|
||||||
char *row = getenv ("LINES");
|
|
||||||
char *col = getenv ("COLUMNS");
|
|
||||||
unsigned long tmp;
|
|
||||||
resizeterm (
|
|
||||||
(row && xstrtoul (&tmp, row, 10)) ? tmp : size.ws_row,
|
|
||||||
(col && xstrtoul (&tmp, col, 10)) ? tmp : size.ws_col);
|
|
||||||
}
|
|
||||||
#else // HAVE_RESIZETERM && TIOCGWINSZ
|
|
||||||
endwin ();
|
|
||||||
refresh ();
|
|
||||||
#endif // HAVE_RESIZETERM && TIOCGWINSZ
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Print a fatal error message and terminate the process immediately.
|
/// Print a fatal error message and terminate the process immediately.
|
||||||
void
|
void
|
||||||
fatal (const gchar *format, ...)
|
fatal (const gchar *format, ...)
|
||||||
|
|
|
@ -41,7 +41,6 @@ gchar *xdxf_to_pango_markup_with_reduced_effort (const gchar *xml);
|
||||||
gboolean stream_read_all (GByteArray *ba, GInputStream *is, GError **error);
|
gboolean stream_read_all (GByteArray *ba, GInputStream *is, GError **error);
|
||||||
gchar *stream_read_string (GDataInputStream *dis, GError **error);
|
gchar *stream_read_string (GDataInputStream *dis, GError **error);
|
||||||
gboolean xstrtoul (unsigned long *out, const char *s, int base);
|
gboolean xstrtoul (unsigned long *out, const char *s, int base);
|
||||||
void update_curses_terminal_size (void);
|
|
||||||
void fatal (const gchar *format, ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN;
|
void fatal (const gchar *format, ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN;
|
||||||
|
|
||||||
#endif // ! UTILS_H
|
#endif // ! UTILS_H
|
||||||
|
|
Loading…
Reference in New Issue