2025-12-28 03:14:31 +01:00
|
|
|
/*
|
|
|
|
|
* DWN - Desktop Window Manager
|
2025-12-28 04:30:10 +01:00
|
|
|
* retoor <retoor@molodetz.nl>
|
2025-12-28 03:14:31 +01:00
|
|
|
* News ticker for bottom panel
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef DWN_NEWS_H
|
|
|
|
|
#define DWN_NEWS_H
|
|
|
|
|
|
|
|
|
|
#include "dwn.h"
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
#define MAX_NEWS_ARTICLES 50
|
|
|
|
|
#define NEWS_API_URL "https://news.app.molodetz.nl/api"
|
|
|
|
|
|
2025-12-28 04:30:10 +01:00
|
|
|
typedef enum {
|
|
|
|
|
SENTIMENT_NEUTRAL = 0,
|
|
|
|
|
SENTIMENT_POSITIVE,
|
|
|
|
|
SENTIMENT_NEGATIVE
|
|
|
|
|
} NewsSentiment;
|
|
|
|
|
|
2025-12-28 03:14:31 +01:00
|
|
|
typedef struct {
|
|
|
|
|
char title[256];
|
|
|
|
|
char content[1024];
|
|
|
|
|
char link[512];
|
|
|
|
|
char author[128];
|
2025-12-28 04:30:10 +01:00
|
|
|
NewsSentiment sentiment;
|
|
|
|
|
float sentiment_score;
|
2025-12-28 03:14:31 +01:00
|
|
|
} NewsArticle;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
NewsArticle articles[MAX_NEWS_ARTICLES];
|
|
|
|
|
int article_count;
|
2025-12-28 05:01:46 +01:00
|
|
|
int current_article;
|
|
|
|
|
double scroll_offset;
|
|
|
|
|
bool fetching;
|
|
|
|
|
bool has_error;
|
|
|
|
|
long last_fetch;
|
|
|
|
|
long last_scroll_update;
|
|
|
|
|
bool interactive_mode;
|
|
|
|
|
int display_widths[MAX_NEWS_ARTICLES];
|
|
|
|
|
int total_width;
|
|
|
|
|
int render_x;
|
|
|
|
|
int render_width;
|
|
|
|
|
bool widths_dirty;
|
2025-12-28 03:14:31 +01:00
|
|
|
} NewsState;
|
|
|
|
|
|
|
|
|
|
extern NewsState news_state;
|
|
|
|
|
|
|
|
|
|
void news_init(void);
|
|
|
|
|
void news_cleanup(void);
|
|
|
|
|
|
|
|
|
|
void news_fetch_async(void);
|
2025-12-28 05:01:46 +01:00
|
|
|
void news_update(void);
|
2025-12-28 03:14:31 +01:00
|
|
|
|
|
|
|
|
void news_next_article(void);
|
|
|
|
|
void news_prev_article(void);
|
|
|
|
|
void news_open_current(void);
|
|
|
|
|
|
|
|
|
|
void news_render(Panel *panel, int x, int max_width, int *used_width);
|
|
|
|
|
void news_handle_click(int x, int y);
|
|
|
|
|
|
|
|
|
|
void news_lock(void);
|
|
|
|
|
void news_unlock(void);
|
|
|
|
|
|
2025-12-28 05:01:46 +01:00
|
|
|
#endif
|