1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#define _POSIX_C_SOURCE 200809L
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <gtk-3.0/gtk/gtk.h>
#include "auth.h"
#include "http.h"
#include "timeline.h"
#include "log.h"
static GtkWidget *window;
static GtkWidget *box;
static GtkWidget *label;
static void timeline_callback(bool success, struct timeline *t)
{
for (size_t i = 0; i < t->size; i++) {
printf("status id: %s\n", t->statuses[i]->id);
printf("content: %s\n", t->statuses[i]->content);
printf("reblog count: %d\n", t->statuses[i]->reblogs_count);
printf("fav count: %d\n", t->statuses[i]->favourites_count);
printf("\n");
}
}
static void load_timeline()
{
if (get_timeline(NULL, NULL, NULL, 20, &timeline_callback)) {
log_msg(LOG_ERROR, "load_timeline", "failed");
return;
}
return;
}
void create_timeline_window(GtkApplication *app, gpointer user_data)
{
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "ap_client");
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_set_valign(GTK_WIDGET(box), GTK_ALIGN_CENTER);
gtk_widget_set_halign(GTK_WIDGET(box), GTK_ALIGN_CENTER);
label = gtk_label_new("timeline");
gtk_container_add(GTK_CONTAINER(window), box);
gtk_container_add(GTK_CONTAINER(box), label);
gtk_widget_show_all(window);
load_timeline();
}
|