| 10 |
#include <stdio.h> |
#include <stdio.h> |
| 11 |
#include <string.h> |
#include <string.h> |
| 12 |
#include <sys/stat.h> |
#include <sys/stat.h> |
| 13 |
|
#include <sys/types.h> |
| 14 |
#include <oslib/colourtrans.h> |
#include <oslib/colourtrans.h> |
| 15 |
#include <oslib/osfile.h> |
#include <oslib/osfile.h> |
| 16 |
#include <oslib/uri.h> |
#include <oslib/uri.h> |
| 27 |
#define FEEDS_WRITE "<Choices$Write>.Sargasso.Feeds" |
#define FEEDS_WRITE "<Choices$Write>.Sargasso.Feeds" |
| 28 |
#define CHOICES_READ "Choices:Sargasso.Choices" |
#define CHOICES_READ "Choices:Sargasso.Choices" |
| 29 |
#define CHOICES_WRITE "<Choices$Write>.Sargasso.Choices" |
#define CHOICES_WRITE "<Choices$Write>.Sargasso.Choices" |
| 30 |
|
#define WRITE_DIR "<Choices$Write>.Sargasso" |
| 31 |
|
|
| 32 |
typedef void (*click_callback)(unsigned int i); |
typedef void (*click_callback)(unsigned int i); |
| 33 |
|
|
| 55 |
struct paragraph *main_window_paragraphs = 0; |
struct paragraph *main_window_paragraphs = 0; |
| 56 |
struct paragraph *feed_window_paragraphs = 0; |
struct paragraph *feed_window_paragraphs = 0; |
| 57 |
unsigned int current_feed = 0; |
unsigned int current_feed = 0; |
| 58 |
|
char font_headings[100] = "Homerton"; |
| 59 |
|
char font_summaries[100] = "NewHall"; |
| 60 |
|
char font_links[100] = "Homerton"; |
| 61 |
|
|
| 62 |
#define ICON_FLAGS (wimp_ICON_TEXT | \ |
#define ICON_FLAGS (wimp_ICON_TEXT | \ |
| 63 |
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT)) |
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT)) |
| 75 |
{ wimp_MENU_LAST, 0, ICON_FLAGS, { "Remove feed" } } } }; |
{ wimp_MENU_LAST, 0, ICON_FLAGS, { "Remove feed" } } } }; |
| 76 |
wimp_menu *current_menu; |
wimp_menu *current_menu; |
| 77 |
unsigned int current_removing = 0; |
unsigned int current_removing = 0; |
| 78 |
|
wimp_i current_font_menu; |
| 79 |
|
|
| 80 |
const char *default_feeds[] = { |
const char *default_feeds[] = { |
| 81 |
"http://news.google.co.uk/?output=rss", |
"http://news.google.co.uk/?output=rss", |
| 130 |
char error[200]; |
char error[200]; |
| 131 |
struct stat s; |
struct stat s; |
| 132 |
|
|
| 133 |
memdebug_memdebug("memdump"); |
/* memdebug_memdebug("memdump"); */ |
| 134 |
|
|
| 135 |
if (!feed_init()) |
if (!feed_init()) |
| 136 |
die(feed_error); |
die(feed_error); |
| 142 |
if (stat(FEEDS_READ, &s)) { |
if (stat(FEEDS_READ, &s)) { |
| 143 |
warn("Welcome to Sargasso! A selection of feeds have been " |
warn("Welcome to Sargasso! A selection of feeds have been " |
| 144 |
"added. To add more feeds, use the main menu."); |
"added. To add more feeds, use the main menu."); |
| 145 |
|
mkdir(WRITE_DIR, S_IRWXU); |
| 146 |
for (unsigned int i = 0; i != sizeof default_feeds / |
for (unsigned int i = 0; i != sizeof default_feeds / |
| 147 |
sizeof default_feeds[0]; i++) |
sizeof default_feeds[0]; i++) |
| 148 |
feed_add(default_feeds[i]); |
feed_add(default_feeds[i]); |
| 533 |
set_icon_string(choices_window, 1, minutes); |
set_icon_string(choices_window, 1, minutes); |
| 534 |
xwimp_set_caret_position(choices_window, 1, |
xwimp_set_caret_position(choices_window, 1, |
| 535 |
0, 0, -1, strlen(minutes)); |
0, 0, -1, strlen(minutes)); |
| 536 |
|
} else if (i == 7 || i == 8 || |
| 537 |
|
i == 10 || i == 11 || |
| 538 |
|
i == 13 || i == 14) { |
| 539 |
|
if (i == 8 || i == 11 || i == 14) |
| 540 |
|
i--; |
| 541 |
|
wimp_window_state state; |
| 542 |
|
wimp_icon_state icon_state; |
| 543 |
|
state.w = w; |
| 544 |
|
xwimp_get_window_state(&state); |
| 545 |
|
icon_state.w = w; |
| 546 |
|
icon_state.i = i; |
| 547 |
|
xwimp_get_icon_state(&icon_state); |
| 548 |
|
open_menu((wimp_menu *) rufl_family_menu, |
| 549 |
|
state.visible.x0 + icon_state.icon.extent.x1, |
| 550 |
|
state.visible.y1 + icon_state.icon.extent.y1); |
| 551 |
|
current_font_menu = i; |
| 552 |
} |
} |
| 553 |
} |
} |
| 554 |
} |
} |
| 626 |
void menu_selection(wimp_selection *selection) |
void menu_selection(wimp_selection *selection) |
| 627 |
{ |
{ |
| 628 |
char minutes[10]; |
char minutes[10]; |
| 629 |
|
wimp_pointer pointer; |
| 630 |
|
|
| 631 |
|
xwimp_get_pointer_info(&pointer); |
| 632 |
|
|
| 633 |
if (current_menu == (wimp_menu *) &iconbar_menu) { |
if (current_menu == (wimp_menu *) &iconbar_menu) { |
| 634 |
switch (selection->items[0]) { |
switch (selection->items[0]) { |
| 635 |
case 1: |
case 1: |
| 636 |
snprintf(minutes, sizeof minutes, "%i", interval / 60); |
snprintf(minutes, sizeof minutes, "%i", interval / 60); |
| 637 |
set_icon_string(choices_window, 1, minutes); |
set_icon_string(choices_window, 1, minutes); |
| 638 |
|
set_icon_string(choices_window, 8, font_headings); |
| 639 |
|
set_icon_string(choices_window, 11, font_summaries); |
| 640 |
|
set_icon_string(choices_window, 14, font_links); |
| 641 |
open_window(choices_window); |
open_window(choices_window); |
| 642 |
xwimp_set_caret_position(choices_window, 1, |
xwimp_set_caret_position(choices_window, 1, |
| 643 |
0, 0, -1, strlen(minutes)); |
0, 0, -1, strlen(minutes)); |
| 667 |
warn(feed_error); |
warn(feed_error); |
| 668 |
break; |
break; |
| 669 |
} |
} |
| 670 |
|
} else if (current_menu == (wimp_menu *) rufl_family_menu) { |
| 671 |
|
char *font = ((wimp_menu *) rufl_family_menu)-> |
| 672 |
|
entries[selection->items[0]].data.indirected_text.text; |
| 673 |
|
if (current_font_menu == 7) |
| 674 |
|
strncpy(font_headings, font, sizeof font_headings); |
| 675 |
|
else if (current_font_menu == 10) |
| 676 |
|
strncpy(font_summaries, font, sizeof font_summaries); |
| 677 |
|
else if (current_font_menu == 13) |
| 678 |
|
strncpy(font_links, font, sizeof font_links); |
| 679 |
|
set_icon_string(choices_window, 8, font_headings); |
| 680 |
|
set_icon_string(choices_window, 11, font_summaries); |
| 681 |
|
set_icon_string(choices_window, 14, font_links); |
| 682 |
|
update_main_window(); |
| 683 |
|
if (feed_count) |
| 684 |
|
update_feed_window(current_feed); |
| 685 |
} |
} |
| 686 |
|
|
| 687 |
|
if (pointer.buttons == wimp_CLICK_ADJUST) |
| 688 |
|
xwimp_create_menu(current_menu, pointer.pos.x, pointer.pos.y); |
| 689 |
} |
} |
| 690 |
|
|
| 691 |
|
|
| 794 |
|
|
| 795 |
p = add_paragraph(&main_window_paragraphs, 0, y, 700, |
p = add_paragraph(&main_window_paragraphs, 0, y, 700, |
| 796 |
0xffaa99, 0x000000, |
0xffaa99, 0x000000, |
| 797 |
"Homerton", style, 200, |
font_headings, style, 200, |
| 798 |
feeds[i].title ? (char *) feeds[i].title : |
feeds[i].title ? (char *) feeds[i].title : |
| 799 |
feeds[i].url, |
feeds[i].url, |
| 800 |
click_main_window, i); |
click_main_window, i); |
| 823 |
} |
} |
| 824 |
p = add_paragraph(&main_window_paragraphs, 700, y, 1000, |
p = add_paragraph(&main_window_paragraphs, 700, y, 1000, |
| 825 |
0xffaa99, 0x000000, |
0xffaa99, 0x000000, |
| 826 |
"Homerton", style, 200, |
font_headings, style, 200, |
| 827 |
status + i * 40, |
status + i * 40, |
| 828 |
click_main_window, i); |
click_main_window, i); |
| 829 |
y = p->y1 = y1; |
y = p->y1 = y1; |
| 831 |
if (feeds[i].error) { |
if (feeds[i].error) { |
| 832 |
p = add_paragraph(&main_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&main_window_paragraphs, 0, y, 1000, |
| 833 |
0, 0x0000a0, |
0, 0x0000a0, |
| 834 |
"NewHall", style, 200, |
font_summaries, style, 200, |
| 835 |
feeds[i].error, |
feeds[i].error, |
| 836 |
click_main_window, i); |
click_main_window, i); |
| 837 |
y = p->y1; |
y = p->y1; |
| 840 |
if (feeds[i].description) { |
if (feeds[i].description) { |
| 841 |
p = add_paragraph(&main_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&main_window_paragraphs, 0, y, 1000, |
| 842 |
0, 0x000000, |
0, 0x000000, |
| 843 |
"NewHall", rufl_WEIGHT_400, 200, |
font_summaries, rufl_WEIGHT_400, 200, |
| 844 |
feeds[i].description, |
feeds[i].description, |
| 845 |
click_main_window, i); |
click_main_window, i); |
| 846 |
y = p->y1; |
y = p->y1; |
| 922 |
|
|
| 923 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
| 924 |
0xffaa99, 0x000000, |
0xffaa99, 0x000000, |
| 925 |
"Homerton", rufl_WEIGHT_400, 200, |
font_headings, rufl_WEIGHT_400, 200, |
| 926 |
feeds[i].title ? (char *) feeds[i].title : feeds[i].url, |
feeds[i].title ? (char *) feeds[i].title : feeds[i].url, |
| 927 |
0, 0); |
0, 0); |
| 928 |
y = p->y1; |
y = p->y1; |
| 930 |
if (feeds[i].link) { |
if (feeds[i].link) { |
| 931 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
| 932 |
0, 0xff0000, |
0, 0xff0000, |
| 933 |
"Homerton", rufl_WEIGHT_400, 160, |
font_links, rufl_WEIGHT_400, 160, |
| 934 |
feeds[i].link, |
feeds[i].link, |
| 935 |
click_feed_link, i); |
click_feed_link, i); |
| 936 |
y = p->y1; |
y = p->y1; |
| 938 |
if (feeds[i].pub_date) { |
if (feeds[i].pub_date) { |
| 939 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
| 940 |
0, 0x0060ee, |
0, 0x0060ee, |
| 941 |
"NewHall", rufl_WEIGHT_400 | rufl_SLANTED, 160, |
font_summaries, rufl_WEIGHT_400 | rufl_SLANTED, |
| 942 |
|
160, |
| 943 |
feeds[i].pub_date, |
feeds[i].pub_date, |
| 944 |
0, 0); |
0, 0); |
| 945 |
y = p->y1; |
y = p->y1; |
| 947 |
if (feeds[i].description) { |
if (feeds[i].description) { |
| 948 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
| 949 |
0, 0x000000, |
0, 0x000000, |
| 950 |
"NewHall", rufl_WEIGHT_400, 200, |
font_summaries, rufl_WEIGHT_400, 200, |
| 951 |
feeds[i].description, |
feeds[i].description, |
| 952 |
0, 0); |
0, 0); |
| 953 |
y = p->y1; |
y = p->y1; |
| 955 |
if (feeds[i].copyright) { |
if (feeds[i].copyright) { |
| 956 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
| 957 |
0, 0x666666, |
0, 0x666666, |
| 958 |
"NewHall", rufl_WEIGHT_400 | rufl_SLANTED, 160, |
font_summaries, rufl_WEIGHT_400 | rufl_SLANTED, 160, |
| 959 |
feeds[i].copyright, |
feeds[i].copyright, |
| 960 |
0, 0); |
0, 0); |
| 961 |
y = p->y1; |
y = p->y1; |
| 969 |
|
|
| 970 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
| 971 |
0xa0dddd, 0x000000, |
0xa0dddd, 0x000000, |
| 972 |
"Homerton", style, 200, |
font_headings, style, 200, |
| 973 |
feeds[i].item[j].title ? |
feeds[i].item[j].title ? |
| 974 |
(char *) feeds[i].item[j].title : "", |
(char *) feeds[i].item[j].title : "", |
| 975 |
0, j); |
0, j); |
| 978 |
if (feeds[i].item[j].pub_date) { |
if (feeds[i].item[j].pub_date) { |
| 979 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 420, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 420, |
| 980 |
0, 0x0060ee, |
0, 0x0060ee, |
| 981 |
"NewHall", |
font_summaries, |
| 982 |
rufl_WEIGHT_400 | rufl_SLANTED, 160, |
rufl_WEIGHT_400 | rufl_SLANTED, 160, |
| 983 |
feeds[i].item[j].pub_date, |
feeds[i].item[j].pub_date, |
| 984 |
0, j); |
0, j); |
| 988 |
if (feeds[i].item[j].author) { |
if (feeds[i].item[j].author) { |
| 989 |
p = add_paragraph(&feed_window_paragraphs, 420, y, 720, |
p = add_paragraph(&feed_window_paragraphs, 420, y, 720, |
| 990 |
0, 0x666666, |
0, 0x666666, |
| 991 |
"NewHall", |
font_summaries, |
| 992 |
rufl_WEIGHT_400 | rufl_SLANTED, 160, |
rufl_WEIGHT_400 | rufl_SLANTED, 160, |
| 993 |
feeds[i].item[j].author, |
feeds[i].item[j].author, |
| 994 |
0, j); |
0, j); |
| 998 |
if (feeds[i].item[j].category) { |
if (feeds[i].item[j].category) { |
| 999 |
p = add_paragraph(&feed_window_paragraphs, 720, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 720, y, 1000, |
| 1000 |
0, 0xee6000, |
0, 0xee6000, |
| 1001 |
"NewHall", rufl_WEIGHT_400, 160, |
font_summaries, rufl_WEIGHT_400, 160, |
| 1002 |
feeds[i].item[j].category, |
feeds[i].item[j].category, |
| 1003 |
0, j); |
0, j); |
| 1004 |
if (y1 < p->y1) |
if (y1 < p->y1) |
| 1009 |
if (feeds[i].item[j].link) { |
if (feeds[i].item[j].link) { |
| 1010 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
| 1011 |
0, 0xff0000, |
0, 0xff0000, |
| 1012 |
"Homerton", rufl_WEIGHT_400, 160, |
font_links, rufl_WEIGHT_400, 160, |
| 1013 |
feeds[i].item[j].link, |
feeds[i].item[j].link, |
| 1014 |
click_item_link, j); |
click_item_link, j); |
| 1015 |
y = p->y1; |
y = p->y1; |
| 1018 |
if (feeds[i].item[j].description) { |
if (feeds[i].item[j].description) { |
| 1019 |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, |
| 1020 |
0, 0x000000, |
0, 0x000000, |
| 1021 |
"NewHall", rufl_WEIGHT_400, 180, |
font_summaries, rufl_WEIGHT_400, 180, |
| 1022 |
feeds[i].item[j].description, |
feeds[i].item[j].description, |
| 1023 |
0, j); |
0, j); |
| 1024 |
y = p->y1; |
y = p->y1; |
| 1219 |
return; |
return; |
| 1220 |
} |
} |
| 1221 |
fprintf(choices, "interval: %i\n", interval); |
fprintf(choices, "interval: %i\n", interval); |
| 1222 |
|
fprintf(choices, "font_headings: %s\n", font_headings); |
| 1223 |
|
fprintf(choices, "font_summaries: %s\n", font_summaries); |
| 1224 |
|
fprintf(choices, "font_links: %s\n", font_links); |
| 1225 |
fclose(choices); |
fclose(choices); |
| 1226 |
} |
} |
| 1227 |
|
|
| 1245 |
} |
} |
| 1246 |
while (fgets(s, sizeof s, choices)) { |
while (fgets(s, sizeof s, choices)) { |
| 1247 |
sscanf(s, "interval: %i", &interval); |
sscanf(s, "interval: %i", &interval); |
| 1248 |
|
sscanf(s, "font_headings: %s", font_headings); |
| 1249 |
|
sscanf(s, "font_summaries: %s", font_summaries); |
| 1250 |
|
sscanf(s, "font_links: %s", font_links); |
| 1251 |
} |
} |
| 1252 |
fclose(choices); |
fclose(choices); |
| 1253 |
} |
} |
| 1339 |
|
|
| 1340 |
xwimp_set_icon_state(w, i, 0, 0); |
xwimp_set_icon_state(w, i, 0, 0); |
| 1341 |
} |
} |
|
|
|