From d0d66233469c34dd727efb0af779b3c83588d0b4 Mon Sep 17 00:00:00 2001 From: Emil Kosz Date: Sun, 26 Jul 2026 20:34:15 +0200 Subject: [PATCH] Basics --- DESIGN.md | 20 +++++++++++ DESIGN.org | 0 README.org => README.md | 2 +- src/main.c | 77 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 DESIGN.md create mode 100644 DESIGN.org rename README.org => README.md (78%) diff --git a/DESIGN.md b/DESIGN.md new file mode 100644 index 0000000..e65d0b8 --- /dev/null +++ b/DESIGN.md @@ -0,0 +1,20 @@ +# Design of DocMan + +There are two kinds of tabs: library tab and viewer tab. + +The book library is a split view: on the left, the list of books in +the library; on the right, the metadata of the currently selected +book, which has editable fields. + +How does the library work? It's just a folder, no database, no +nothing. The way the folder is organized is completely up to the +user. It could just be a mashup of PDFs and EPUBs, completely without +any subfolders. The software organizes those files into a neat view. + +Second, the document viewer. It's something vastly more optimized than +the GNOME bloatware, something that uses perhaps Poppler, like +qpdfview which is absurdly fast. The document viewer can annotate, +make bookmarks, etc. None or several tabs of the viewer can be opened +at once. + +DocMan should be like the DeaDBeeF or Foobar2000 but for books. diff --git a/DESIGN.org b/DESIGN.org new file mode 100644 index 0000000..e69de29 diff --git a/README.org b/README.md similarity index 78% rename from README.org rename to README.md index 4935513..7bbe9e0 100644 --- a/README.org +++ b/README.md @@ -1,3 +1,3 @@ -#+TITLE: DocMan +# DocMan A document and book management system, similar to Calibre. diff --git a/src/main.c b/src/main.c index 7e0d7fc..81b8f9d 100644 --- a/src/main.c +++ b/src/main.c @@ -1,14 +1,87 @@ #include #include +#define DOCMAN_DOC_FILTER "PDF files|*.pdf|DjVu files|*.djvu|EPUB files|*.epub|MOBI files|*.mobi|AZW files|*.azw;*.azw3;*.kfx|" + +Ihandle *tabs; + +int +callback_open_lib (Ihandle *item) +{ + Ihandle *file_dlg = IupFileDlg (); + IupSetAttribute (file_dlg, "DIALOGTYPE", "DIR"); + IupSetAttributeHandle (file_dlg, "PARENTDIALOG", IupGetDialog (item)); + + IupPopup (file_dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); + + + Ihandle *lst = IupList (NULL); + IupSetAttribute (lst, "EXPAND", "YES"); + IupAppend (tabs, lst); + IupMap (lst); + IupRefresh (tabs); + + IupDestroy (file_dlg); + + return IUP_DEFAULT; +} + +int +callback_open_file (Ihandle *item) +{ + Ihandle *file_dlg = IupFileDlg (); + IupSetAttribute (file_dlg, "DIALOGTYPE", "OPEN"); + IupSetAttribute (file_dlg, "EXTFILTER", DOCMAN_DOC_FILTER); + IupSetAttribute (file_dlg, "MULTIPLEFILES", "YES"); + IupSetAttributeHandle (file_dlg, "PARENTDIALOG", IupGetDialog (item)); + /* TODO: SHOWPREVIEW */ + + IupPopup (file_dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); + + Ihandle *ml = IupMultiLine (NULL); + IupSetAttribute (ml, "EXPAND", "YES"); + IupAppend (tabs, ml); + IupMap (ml); + IupRefresh (tabs); + + IupDestroy (file_dlg); + + return IUP_DEFAULT; +} + +int +callback_exit (Ihandle *unused) +{ + (void) unused; + return IUP_CLOSE; +} + int main (int argc, char **argv) { IupOpen (&argc, &argv); - Ihandle *dlg = IupDialog (NULL); - IupSetAttribute (dlg, "TITLE", "DocMan"); + tabs = IupTabs (NULL); + IupSetAttribute (tabs, "SHOWCLOSE", "YES"); + Ihandle *dlg = IupDialog (tabs); + IupSetAttribute (dlg, "TITLE", "DocMan"); + IupSetAttribute (dlg, "SIZE", "HALFxHALF"); + + Ihandle *item_open_lib = IupItem ("Open library", NULL); + IupSetCallback (item_open_lib, "ACTION", (Icallback) callback_open_lib); + + Ihandle *item_open_file = IupItem ("Open file", NULL); + IupSetCallback (item_open_file, "ACTION", (Icallback) callback_open_file); + + Ihandle *item_exit = IupItem ("Exit", NULL); + IupSetCallback (item_exit, "ACTION", (Icallback) callback_exit); + + Ihandle *file_menu = IupMenu (item_open_lib, item_open_file, IupSeparator (), item_exit, NULL); + Ihandle *submenu = IupSubmenu ("File", file_menu); + + IupSetAttributeHandle (dlg, "MENU", IupMenu (submenu, NULL)); + IupShowXY (dlg, IUP_CENTER, IUP_CENTER); IupMainLoop (); IupClose ();