static const char *program_name;
static GSettings *settings;
+static int model_state;
static struct option long_options[] = {
{"version", no_argument, 0, 'v'},
model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
+ printf("update(): clear feed tree\n");
+ model_state = 1;
gtk_list_store_clear(GTK_LIST_STORE(model));
+ printf("update(): clear feed tree done\n");
feeds = ttrss_get_feeds();
while(feeds && *feeds) {
if ((*feeds)->unread)
free(title);
feeds++;
}
+ model_state = 0;
+
printf("refresh done\n");
}
headline_model = gtk_tree_view_get_model(w_headlineview);
headline_store = GTK_LIST_STORE(headline_model);
+ model_state = 1;
gtk_list_store_clear(headline_store);
headlines = ttrss_get_headlines(feed);
headlines++;
}
+ model_state = 0;
gtk_tree_path_free(path);
}
const char *str;
printf("headline_cursor_changed_cbk\n");
+
+ if (model_state)
+ return TRUE;
gtk_tree_view_get_cursor(treeview, &path, &cols);
gtk_tree_model_get_iter(model, &iter, path);
gtk_tree_model_get(model, &iter, 1, &headline, -1);
- str = ttrss_get_headline_content((struct headline *)headline);
+ str = ttrss_get_headline_content(headline);
+
+ if (headline->unread)
+ ttrss_set_article_unread(headline->id, 0);
if (str)
web_load(str);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);
- curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(body));
+ if (body) {
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(body));
+ }
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cbk_curl);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
#include <string.h>
#include <json/json.h>
+#include <gtk/gtk.h>
#include "phttp.h"
#include "ttrss.h"
return f->headlines;
}
+
+void ttrss_set_article_unread(int id, int unread)
+{
+ struct json_object *rp, *rq;
+
+ printf("ttrss_set_article_unread %d %d\n", id, unread);
+
+ rq = create_op("updateArticle");
+ json_object_object_add(rq, "article_ids", json_object_new_int(id));
+ json_object_object_add(rq, "field", json_object_new_int(2));
+ json_object_object_add(rq, "mode", json_object_new_int(unread));
+
+ rp = post_json_object(session_url, rq);
+
+ json_object_put(rq);
+ json_object_put(rp);
+}
struct headline **ttrss_get_headlines(struct feed *);
const char *ttrss_get_headline_content(struct headline *);
+void ttrss_set_article_unread(int id, int unread);
#endif