This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch main
in repository eradio.
View the commit online.
commit 017c63f632ea04b4eb465ca1bf703edec6db6683
Author: politebot <[email protected]>
AuthorDate: Sat Oct 11 05:01:40 2025 -0500
Sorting
---
src/appdata.h | 2 ++
src/http.c | 52 +++++++++++++++++++++++++++++++++++++++++-----------
src/http.h | 2 +-
src/ui.c | 43 ++++++++++++++++++++++++++++++++++++++++---
4 files changed, 84 insertions(+), 15 deletions(-)
diff --git a/src/appdata.h b/src/appdata.h
index 374c78e..466cfe7 100644
--- a/src/appdata.h
+++ b/src/appdata.h
@@ -31,6 +31,8 @@ typedef struct _AppData
Evas_Object *search_btn;
Evas_Object *load_more_btn;
Evas_Object *search_bar;
+ Evas_Object *sort_hoversel;
+ Evas_Object *reverse_check;
Eina_List *stations;
Eina_List *api_servers; // list of strings (hostnames)
const char *api_selected; // currently selected server hostname
diff --git a/src/http.c b/src/http.c
index c3a68fb..773741e 100644
--- a/src/http.c
+++ b/src/http.c
@@ -33,6 +33,8 @@ typedef struct _Station_Download_Context
Eina_List *current; // current server node
char search_type[64];
char search_term[512];
+ char order[64];
+ Eina_Bool reverse;
int offset;
int limit;
Eina_Bool new_search;
@@ -59,7 +61,7 @@ static Eina_Bool _url_complete_cb(void *data, int type, void *event_info);
static void _refresh_api_servers(AppData *ad);
static void _randomize_servers(AppData *ad);
static const char *_primary_server(AppData *ad);
-static void _populate_station_request(Station_Download_Context *d_ctx, AppData *ad, const char *search_type, const char *search_term);
+static void _populate_station_request(Station_Download_Context *d_ctx, AppData *ad, const char *search_type, const char *search_term, const char *order, Eina_Bool reverse);
static void _issue_station_request(Ecore_Con_Url **url_out, Station_Download_Context *d_ctx);
static void _retry_next_server_station(Ecore_Con_Url *old_url, Station_Download_Context *d_ctx);
static void _populate_counter_request(Counter_Download_Context *c_ctx, AppData *ad, const char *uuid);
@@ -85,7 +87,7 @@ http_shutdown(void)
}
void
-http_search_stations(AppData *ad, const char *search_term, const char *search_type, int offset, int limit, Eina_Bool new_search)
+http_search_stations(AppData *ad, const char *search_term, const char *search_type, const char *order, Eina_Bool reverse, int offset, int limit, Eina_Bool new_search)
{
Ecore_Con_Url *url;
Station_Download_Context *d_ctx;
@@ -98,7 +100,7 @@ http_search_stations(AppData *ad, const char *search_term, const char *search_ty
d_ctx->offset = offset;
d_ctx->limit = limit;
d_ctx->new_search = new_search;
- _populate_station_request(d_ctx, ad, search_type, search_term);
+ _populate_station_request(d_ctx, ad, search_type, search_term, order, reverse);
_issue_station_request(&url, d_ctx);
ecore_con_url_additional_header_add(url, "User-Agent", "eradio/1.0");
ecore_con_url_data_set(url, d_ctx);
@@ -140,8 +142,10 @@ _search_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_inf
AppData *ad = data;
const char *search_term = elm_object_text_get(ad->search_entry);
const char *search_type = elm_object_text_get(ad->search_hoversel);
+ const char *order = elm_object_text_get(ad->sort_hoversel);
+ Eina_Bool reverse = elm_check_state_get(ad->reverse_check);
ad->search_offset = 0; // Reset offset for a new search
- http_search_stations(ad, search_term, search_type, ad->search_offset, 100, EINA_TRUE);
+ http_search_stations(ad, search_term, search_type, order, reverse, ad->search_offset, 100, EINA_TRUE);
}
void
@@ -308,10 +312,18 @@ _handle_station_list_complete(Ecore_Con_Event_Url_Complete *ev)
station_list_populate(ad, ad->stations, d_ctx->new_search);
// Determine if "Load More" button should be visible
- if (xpathObj->nodesetval->nodeNr == d_ctx->limit)
- ui_set_load_more_button_visibility(ad, EINA_TRUE);
+ if (d_ctx->new_search)
+ {
+ if (xpathObj->nodesetval->nodeNr > 0)
+ ui_set_load_more_button_visibility(ad, EINA_TRUE);
+ else
+ ui_set_load_more_button_visibility(ad, EINA_FALSE);
+ }
else
- ui_set_load_more_button_visibility(ad, EINA_FALSE);
+ {
+ if (xpathObj->nodesetval->nodeNr == 0)
+ ui_set_load_more_button_visibility(ad, EINA_FALSE);
+ }
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx);
@@ -470,10 +482,12 @@ static void _prepend_selected_as_primary(Eina_List **list, const char *selected)
}
}
-static void _populate_station_request(Station_Download_Context *d_ctx, AppData *ad, const char *search_type, const char *search_term)
+static void _populate_station_request(Station_Download_Context *d_ctx, AppData *ad, const char *search_type, const char *search_term, const char *order, Eina_Bool reverse)
{
strncpy(d_ctx->search_type, search_type ? search_type : "name", sizeof(d_ctx->search_type) - 1);
strncpy(d_ctx->search_term, search_term ? search_term : "", sizeof(d_ctx->search_term) - 1);
+ strncpy(d_ctx->order, order ? order : "name", sizeof(d_ctx->order) - 1);
+ d_ctx->reverse = reverse;
d_ctx->servers = eina_list_clone(ad->api_servers);
_prepend_selected_as_primary(&d_ctx->servers, ad->api_selected);
d_ctx->current = d_ctx->servers; // start at primary
@@ -482,11 +496,25 @@ static void _populate_station_request(Station_Download_Context *d_ctx, AppData *
static void _issue_station_request(Ecore_Con_Url **url_out, Station_Download_Context *d_ctx)
{
const char *server = d_ctx->current ? (const char *)d_ctx->current->data : NULL;
- char url_str[1024];
+ char url_str[2048];
+ char query_params[1024] = {0};
+
+ // Start with the base search params
+ snprintf(query_params, sizeof(query_params), "%s=%s", d_ctx->search_type, d_ctx->search_term);
+
+ // Add sorting and pagination params
+ char other_params[512];
+ snprintf(other_params, sizeof(other_params), "&offset=%d&limit=%d&order=%s&reverse=%s",
+ d_ctx->offset, d_ctx->limit, d_ctx->order, d_ctx->reverse ? "true" : "false");
+
+ strncat(query_params, other_params, sizeof(query_params) - strlen(query_params) - 1);
+
if (server)
- snprintf(url_str, sizeof(url_str), "http://%s/xml/stations/search?%s=%s&offset=%d&limit=%d", server, d_ctx->search_type, d_ctx->search_term, d_ctx->offset, d_ctx->limit);
+ snprintf(url_str, sizeof(url_str), "http://%s/xml/stations/search?%s", server, query_params);
else
- snprintf(url_str, sizeof(url_str), "http://de2.api.radio-browser.info/xml/stations/search?%s=%s&offset=%d&limit=%d", d_ctx->search_type, d_ctx->search_term, d_ctx->offset, d_ctx->limit);
+ snprintf(url_str, sizeof(url_str), "http://de2.api.radio-browser.info/xml/stations/search?%s", query_params);
+
+ printf("Request URL: %s\n", url_str);
*url_out = ecore_con_url_new(url_str);
}
@@ -532,6 +560,8 @@ static void _issue_counter_request(Ecore_Con_Url **url_out, Counter_Download_Con
snprintf(url_str, sizeof(url_str), "http://%s/xml/url/%s", server, c_ctx->stationuuid);
else
snprintf(url_str, sizeof(url_str), "http://de2.api.radio-browser.info/xml/url/%s", c_ctx->stationuuid);
+
+ printf("Counter Request URL: %s\n", url_str);
*url_out = ecore_con_url_new(url_str);
}
diff --git a/src/http.h b/src/http.h
index 78bdfd3..37f2072 100644
--- a/src/http.h
+++ b/src/http.h
@@ -4,7 +4,7 @@
void http_init(AppData *ad);
void http_shutdown(void);
-void http_search_stations(AppData *ad, const char *search_term, const char *search_type, int offset, int limit, Eina_Bool new_search);
+void http_search_stations(AppData *ad, const char *search_term, const char *search_type, const char *order, Eina_Bool reverse, int offset, int limit, Eina_Bool new_search);
void http_download_icon(AppData *ad, Elm_Object_Item *list_item, const char *url);
void _search_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info);
void _search_entry_activated_cb(void *data, Evas_Object *obj, void *event_info);
diff --git a/src/ui.c b/src/ui.c
index 97e20a6..b858141 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -108,6 +108,35 @@ ui_create(AppData *ad)
elm_box_pack_end(ad->search_bar, ad->search_hoversel);
evas_object_show(ad->search_hoversel);
+ ad->sort_hoversel = elm_hoversel_add(ad->win);
+ elm_hoversel_hover_parent_set(ad->sort_hoversel, ad->win);
+ elm_object_text_set(ad->sort_hoversel, "name");
+ elm_hoversel_item_add(ad->sort_hoversel, "name", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "url", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "homepage", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "favicon", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "tags", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "country", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "state", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "language", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "votes", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "codec", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "bitrate", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "lastcheckok", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "lastchecktime", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "clicktimestamp", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "clickcount", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "clicktrend", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "changetimestamp", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_hoversel_item_add(ad->sort_hoversel, "random", NULL, ELM_ICON_NONE, _hoversel_item_selected_cb, NULL);
+ elm_box_pack_end(ad->search_bar, ad->sort_hoversel);
+ evas_object_show(ad->sort_hoversel);
+
+ ad->reverse_check = elm_check_add(ad->win);
+ elm_object_text_set(ad->reverse_check, "Reverse");
+ elm_box_pack_end(ad->search_bar, ad->reverse_check);
+ evas_object_show(ad->reverse_check);
+
// Server selection hoversel, populated after HTTP init discovers servers
ad->server_hoversel = elm_hoversel_add(ad->win);
elm_hoversel_hover_parent_set(ad->server_hoversel, ad->win);
@@ -157,7 +186,14 @@ ui_create(AppData *ad)
ad->load_more_btn = elm_button_add(ad->win);
elm_object_text_set(ad->load_more_btn, "Load More");
- elm_box_pack_end(controls_hbox, ad->load_more_btn);
+ Evas_Object *load_more_box = elm_box_add(ad->win);
+ elm_box_padding_set(load_more_box, 10, 0);
+ elm_box_align_set(load_more_box, 0.5, 1.0);
+ evas_object_size_hint_weight_set(load_more_box, EVAS_HINT_EXPAND, 0);
+ evas_object_size_hint_align_set(load_more_box, EVAS_HINT_FILL, 0);
+ elm_box_pack_end(load_more_box, ad->load_more_btn);
+ elm_box_pack_end(box, load_more_box);
+ evas_object_show(load_more_box);
evas_object_show(ad->load_more_btn);
evas_object_smart_callback_add(ad->play_pause_btn, "clicked", _play_pause_btn_clicked_cb, ad);
@@ -171,7 +207,6 @@ ui_create(AppData *ad)
/* Default to Search view on startup */
ad->view_mode = VIEW_SEARCH;
ad->search_offset = 0; // Initialize offset
- ui_set_load_more_button_visibility(ad, EINA_FALSE); // Initially hide load more button
evas_object_show(ad->search_bar);
if (ad->stations)
station_list_populate(ad, ad->stations, EINA_TRUE);
@@ -236,8 +271,10 @@ _load_more_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_
AppData *ad = data;
const char *search_term = elm_object_text_get(ad->search_entry);
const char *search_type = elm_object_text_get(ad->search_hoversel);
+ const char *order = elm_object_text_get(ad->sort_hoversel);
+ Eina_Bool reverse = elm_check_state_get(ad->reverse_check);
ad->search_offset += 100; // Increment offset for next page
- http_search_stations(ad, search_term, search_type, ad->search_offset, 100, EINA_FALSE);
+ http_search_stations(ad, search_term, search_type, order, reverse, ad->search_offset, 100, EINA_FALSE);
}
void ui_set_load_more_button_visibility(AppData *ad, Eina_Bool visible)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.