--- sargasso2/sargasso.c 2006/09/26 21:31:28 77 +++ sargasso2/sargasso.c 2006/09/30 21:35:19 79 @@ -53,6 +53,9 @@ struct paragraph *main_window_paragraphs = 0; struct paragraph *feed_window_paragraphs = 0; unsigned int current_feed = 0; +char font_headings[100] = "Homerton"; +char font_summaries[100] = "NewHall"; +char font_links[100] = "Homerton"; #define ICON_FLAGS (wimp_ICON_TEXT | \ (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT)) @@ -70,6 +73,7 @@ { wimp_MENU_LAST, 0, ICON_FLAGS, { "Remove feed" } } } }; wimp_menu *current_menu; unsigned int current_removing = 0; +wimp_i current_font_menu; const char *default_feeds[] = { "http://news.google.co.uk/?output=rss", @@ -124,7 +128,7 @@ char error[200]; struct stat s; - memdebug_memdebug("memdump"); +/* memdebug_memdebug("memdump"); */ if (!feed_init()) die(feed_error); @@ -526,6 +530,22 @@ set_icon_string(choices_window, 1, minutes); xwimp_set_caret_position(choices_window, 1, 0, 0, -1, strlen(minutes)); + } else if (i == 7 || i == 8 || + i == 10 || i == 11 || + i == 13 || i == 14) { + if (i == 8 || i == 11 || i == 14) + i--; + wimp_window_state state; + wimp_icon_state icon_state; + state.w = w; + xwimp_get_window_state(&state); + icon_state.w = w; + icon_state.i = i; + xwimp_get_icon_state(&icon_state); + open_menu((wimp_menu *) rufl_family_menu, + state.visible.x0 + icon_state.icon.extent.x1, + state.visible.y1 + icon_state.icon.extent.y1); + current_font_menu = i; } } } @@ -603,12 +623,18 @@ void menu_selection(wimp_selection *selection) { char minutes[10]; + wimp_pointer pointer; + + xwimp_get_pointer_info(&pointer); if (current_menu == (wimp_menu *) &iconbar_menu) { switch (selection->items[0]) { case 1: snprintf(minutes, sizeof minutes, "%i", interval / 60); set_icon_string(choices_window, 1, minutes); + set_icon_string(choices_window, 8, font_headings); + set_icon_string(choices_window, 11, font_summaries); + set_icon_string(choices_window, 14, font_links); open_window(choices_window); xwimp_set_caret_position(choices_window, 1, 0, 0, -1, strlen(minutes)); @@ -638,7 +664,25 @@ warn(feed_error); break; } + } else if (current_menu == (wimp_menu *) rufl_family_menu) { + char *font = ((wimp_menu *) rufl_family_menu)-> + entries[selection->items[0]].data.indirected_text.text; + if (current_font_menu == 7) + strncpy(font_headings, font, sizeof font_headings); + else if (current_font_menu == 10) + strncpy(font_summaries, font, sizeof font_summaries); + else if (current_font_menu == 13) + strncpy(font_links, font, sizeof font_links); + set_icon_string(choices_window, 8, font_headings); + set_icon_string(choices_window, 11, font_summaries); + set_icon_string(choices_window, 14, font_links); + update_main_window(); + if (feed_count) + update_feed_window(current_feed); } + + if (pointer.buttons == wimp_CLICK_ADJUST) + xwimp_create_menu(current_menu, pointer.pos.x, pointer.pos.y); } @@ -747,7 +791,7 @@ p = add_paragraph(&main_window_paragraphs, 0, y, 700, 0xffaa99, 0x000000, - "Homerton", style, 200, + font_headings, style, 200, feeds[i].title ? (char *) feeds[i].title : feeds[i].url, click_main_window, i); @@ -776,7 +820,7 @@ } p = add_paragraph(&main_window_paragraphs, 700, y, 1000, 0xffaa99, 0x000000, - "Homerton", style, 200, + font_headings, style, 200, status + i * 40, click_main_window, i); y = p->y1 = y1; @@ -784,7 +828,7 @@ if (feeds[i].error) { p = add_paragraph(&main_window_paragraphs, 0, y, 1000, 0, 0x0000a0, - "NewHall", style, 200, + font_summaries, style, 200, feeds[i].error, click_main_window, i); y = p->y1; @@ -793,7 +837,7 @@ if (feeds[i].description) { p = add_paragraph(&main_window_paragraphs, 0, y, 1000, 0, 0x000000, - "NewHall", rufl_WEIGHT_400, 200, + font_summaries, rufl_WEIGHT_400, 200, feeds[i].description, click_main_window, i); y = p->y1; @@ -875,7 +919,7 @@ p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, 0xffaa99, 0x000000, - "Homerton", rufl_WEIGHT_400, 200, + font_headings, rufl_WEIGHT_400, 200, feeds[i].title ? (char *) feeds[i].title : feeds[i].url, 0, 0); y = p->y1; @@ -883,7 +927,7 @@ if (feeds[i].link) { p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, 0, 0xff0000, - "Homerton", rufl_WEIGHT_400, 160, + font_links, rufl_WEIGHT_400, 160, feeds[i].link, click_feed_link, i); y = p->y1; @@ -891,7 +935,8 @@ if (feeds[i].pub_date) { p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, 0, 0x0060ee, - "NewHall", rufl_WEIGHT_400 | rufl_SLANTED, 160, + font_summaries, rufl_WEIGHT_400 | rufl_SLANTED, + 160, feeds[i].pub_date, 0, 0); y = p->y1; @@ -899,7 +944,7 @@ if (feeds[i].description) { p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, 0, 0x000000, - "NewHall", rufl_WEIGHT_400, 200, + font_summaries, rufl_WEIGHT_400, 200, feeds[i].description, 0, 0); y = p->y1; @@ -907,7 +952,7 @@ if (feeds[i].copyright) { p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, 0, 0x666666, - "NewHall", rufl_WEIGHT_400 | rufl_SLANTED, 160, + font_summaries, rufl_WEIGHT_400 | rufl_SLANTED, 160, feeds[i].copyright, 0, 0); y = p->y1; @@ -921,7 +966,7 @@ p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, 0xa0dddd, 0x000000, - "Homerton", style, 200, + font_headings, style, 200, feeds[i].item[j].title ? (char *) feeds[i].item[j].title : "", 0, j); @@ -930,7 +975,7 @@ if (feeds[i].item[j].pub_date) { p = add_paragraph(&feed_window_paragraphs, 0, y, 420, 0, 0x0060ee, - "NewHall", + font_summaries, rufl_WEIGHT_400 | rufl_SLANTED, 160, feeds[i].item[j].pub_date, 0, j); @@ -940,7 +985,7 @@ if (feeds[i].item[j].author) { p = add_paragraph(&feed_window_paragraphs, 420, y, 720, 0, 0x666666, - "NewHall", + font_summaries, rufl_WEIGHT_400 | rufl_SLANTED, 160, feeds[i].item[j].author, 0, j); @@ -950,7 +995,7 @@ if (feeds[i].item[j].category) { p = add_paragraph(&feed_window_paragraphs, 720, y, 1000, 0, 0xee6000, - "NewHall", rufl_WEIGHT_400, 160, + font_summaries, rufl_WEIGHT_400, 160, feeds[i].item[j].category, 0, j); if (y1 < p->y1) @@ -961,7 +1006,7 @@ if (feeds[i].item[j].link) { p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, 0, 0xff0000, - "Homerton", rufl_WEIGHT_400, 160, + font_links, rufl_WEIGHT_400, 160, feeds[i].item[j].link, click_item_link, j); y = p->y1; @@ -970,7 +1015,7 @@ if (feeds[i].item[j].description) { p = add_paragraph(&feed_window_paragraphs, 0, y, 1000, 0, 0x000000, - "NewHall", rufl_WEIGHT_400, 180, + font_summaries, rufl_WEIGHT_400, 180, feeds[i].item[j].description, 0, j); y = p->y1; @@ -1171,6 +1216,9 @@ return; } fprintf(choices, "interval: %i\n", interval); + fprintf(choices, "font_headings: %s\n", font_headings); + fprintf(choices, "font_summaries: %s\n", font_summaries); + fprintf(choices, "font_links: %s\n", font_links); fclose(choices); } @@ -1194,6 +1242,9 @@ } while (fgets(s, sizeof s, choices)) { sscanf(s, "interval: %i", &interval); + sscanf(s, "font_headings: %s", font_headings); + sscanf(s, "font_summaries: %s", font_summaries); + sscanf(s, "font_links: %s", font_links); } fclose(choices); } @@ -1285,4 +1336,3 @@ xwimp_set_icon_state(w, i, 0, 0); } -