summaryrefslogtreecommitdiff
path: root/src/main_window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main_window.c')
-rw-r--r--src/main_window.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/main_window.c b/src/main_window.c
index 048de51..bf1f50d 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -4,15 +4,13 @@
#include <stdlib.h>
#include <stdbool.h>
#include <gtk-3.0/gtk/gtk.h>
-#include "auth.h"
-#include "http.h"
-#include "timeline.h"
+#include <gs.h>
#include "log.h"
#include "config.h"
#include "login_window.h"
-#include "string-util.h"
static GtkWidget *window, *scrolled, *list_box;
+static GSClient *gs_client = NULL;
static gchar *html_to_pango(const char *content)
{
@@ -61,7 +59,7 @@ static gchar *html_to_pango(const char *content)
static gboolean timeline_loaded(gpointer data)
{
- struct timeline *t = data;
+ struct gs_timeline *t = data;
for (size_t i = 0; i < t->size; i++) {
GtkBuilder *post_builder;
GObject *post_box, *post_content_label;
@@ -116,24 +114,28 @@ static gboolean timeline_loaded(gpointer data)
gtk_widget_show_all(GTK_WIDGET(post_box));
}
/* gtk_spinner_stop(GTK_SPINNER(spinner)); */
- timeline_free(t);
+ gs_timeline_free(t);
return G_SOURCE_REMOVE;
}
static gpointer load_timeline(gpointer data)
{
- struct timeline *t;
- t = get_timeline(NULL, NULL, NULL, 20);
+ struct gs_timeline *t;
+
+ t = gs_timeline_get(gs_client, NULL, NULL, NULL, 20);
if (!t) {
log_msg(LOG_WARNING, "load_timeline", "failed");
return NULL;
}
+
gdk_threads_add_idle(timeline_loaded, t);
return NULL;
}
void create_main_window(GtkApplication *app, gpointer user_data)
{
+ gs_client = user_data;
+
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_application(GTK_WINDOW(window), GTK_APPLICATION(app));
gtk_window_set_title(GTK_WINDOW(window), "ap_client");
@@ -156,12 +158,14 @@ void create_main_window(GtkApplication *app, gpointer user_data)
gtk_container_add(GTK_CONTAINER(scrolled), list_box);
gtk_widget_show_all(window);
- if (!is_logged_in()) {
+
+ if (!gs_auth_is_logged_in(client)) {
create_login_dialog();
}
- if (!is_logged_in()) {
+ if (!gs_auth_is_logged_in(client)) {
log_msg(LOG_ERROR, "create_main_window",
"login is required to view timeline");
}
- g_thread_new("load_timeline_thread", &load_timeline, NULL);
+
+ g_thread_new("load_timeline_thread", &load_timeline, client);
}