Basics
This commit is contained in:
+75
-2
@@ -1,14 +1,87 @@
|
||||
#include <iup.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#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 ();
|
||||
|
||||
Reference in New Issue
Block a user