wip rewrite listbox
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
10fda7bfc4
commit
a666010564
7 changed files with 67 additions and 228 deletions
|
|
@ -210,20 +210,16 @@ static void layout(MwWidget handle) {
|
|||
ww = 160;
|
||||
wh = h - 10 - 24 - 5 - 24 - 5 - 24 - 5;
|
||||
if(fc->nav == NULL) {
|
||||
MwListBoxPacket* p = MwListBoxCreatePacket();
|
||||
int index;
|
||||
|
||||
index = MwListBoxPacketInsert(p, -1);
|
||||
MwListBoxPacketSet(p, index, 0, "Home");
|
||||
MwListBoxPacketSetIcon(p, index, fc->computer);
|
||||
int index;
|
||||
|
||||
fc->nav = MwVaCreateWidget(MwListBoxClass, "nav", handle, wx, wy, ww, wh,
|
||||
MwNleftPadding, 16,
|
||||
NULL);
|
||||
MwListBoxInsert(fc->nav, -1, p);
|
||||
MwAddUserHandler(fc->nav, MwNlistBoxActivateHandler, nav_activate, NULL);
|
||||
|
||||
MwListBoxDestroyPacket(p);
|
||||
index = MwListBoxInsert(fc->nav, -1, 0, "Home");
|
||||
MwListBoxSetIcon(fc->nav, index, fc->computer);
|
||||
|
||||
MwAddUserHandler(fc->nav, MwNlistBoxActivateHandler, nav_activate, NULL);
|
||||
} else {
|
||||
MwVaApply(fc->nav,
|
||||
MwNx, wx,
|
||||
|
|
@ -409,11 +405,10 @@ static int qsort_files(const void* a, const void* b) {
|
|||
}
|
||||
|
||||
static void scan(MwWidget handle, const char* path, int record) {
|
||||
filechooser_t* fc = handle->opaque;
|
||||
void* dir = MwDirectoryOpen(path);
|
||||
int i;
|
||||
MwListBoxPacket* p = MwListBoxCreatePacket();
|
||||
int index;
|
||||
filechooser_t* fc = handle->opaque;
|
||||
void* dir = MwDirectoryOpen(path);
|
||||
int i;
|
||||
int index;
|
||||
|
||||
if(dir != NULL) {
|
||||
MwDirectoryEntry* entry;
|
||||
|
|
@ -467,10 +462,9 @@ static void scan(MwWidget handle, const char* path, int record) {
|
|||
MwListBoxSetWidth(fc->files, 1, 128);
|
||||
MwListBoxSetWidth(fc->files, 2, 0);
|
||||
|
||||
index = MwListBoxPacketInsert(p, -1);
|
||||
MwListBoxPacketSet(p, index, -1, "Name");
|
||||
MwListBoxPacketSet(p, index, -1, "Date modified");
|
||||
MwListBoxPacketSet(p, index, -1, "Size");
|
||||
index = MwListBoxInsert(fc->files, -1, 0, "Name");
|
||||
MwListBoxInsert(fc->files, index, -1, "Date modified");
|
||||
MwListBoxInsert(fc->files, index, -1, "Size");
|
||||
|
||||
for(i = 0; i < arrlen(fc->entries); i++) {
|
||||
if(strcmp(fc->entries[i]->name, ".") == 0 || strcmp(fc->entries[i]->name, "..") == 0) continue;
|
||||
|
|
@ -479,11 +473,10 @@ static void scan(MwWidget handle, const char* path, int record) {
|
|||
|
||||
MwStringTime(date, fc->entries[i]->mtime);
|
||||
|
||||
index = MwListBoxPacketInsert(p, -1);
|
||||
MwListBoxPacketSetIcon(p, index, fc->dir);
|
||||
MwListBoxPacketSet(p, index, -1, fc->entries[i]->name);
|
||||
MwListBoxPacketSet(p, index, -1, date);
|
||||
MwListBoxPacketSet(p, index, -1, NULL);
|
||||
index = MwListBoxInsert(fc->files, -1, 0, fc->entries[i]->name);
|
||||
MwListBoxInsert(fc->files, index, -1, date);
|
||||
MwListBoxInsert(fc->files, index, -1, NULL);
|
||||
MwListBoxSetIcon(fc->files, index, fc->dir);
|
||||
|
||||
arrput(fc->sorted_entries, fc->entries[i]);
|
||||
}
|
||||
|
|
@ -496,17 +489,14 @@ static void scan(MwWidget handle, const char* path, int record) {
|
|||
MwStringTime(date, fc->entries[i]->mtime);
|
||||
MwStringSize(size, fc->entries[i]->size);
|
||||
|
||||
index = MwListBoxPacketInsert(p, -1);
|
||||
MwListBoxPacketSetIcon(p, index, fc->file);
|
||||
MwListBoxPacketSet(p, index, -1, fc->entries[i]->name);
|
||||
MwListBoxPacketSet(p, index, -1, date);
|
||||
MwListBoxPacketSet(p, index, -1, size);
|
||||
index = MwListBoxInsert(fc->files, -1, 0, fc->entries[i]->name);
|
||||
MwListBoxInsert(fc->files, index, -1, date);
|
||||
MwListBoxInsert(fc->files, index, -1, size);
|
||||
MwListBoxSetIcon(fc->files, index, fc->file);
|
||||
|
||||
arrput(fc->sorted_entries, fc->entries[i]);
|
||||
}
|
||||
}
|
||||
MwListBoxInsert(fc->files, -1, p);
|
||||
MwListBoxDestroyPacket(p);
|
||||
}
|
||||
|
||||
MwWidget MwFileChooserEx(MwWidget handle, const char* title, int dir) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue