Started adding meta stuff as struct

This commit is contained in:
Markus Koch 2016-06-04 18:33:45 +02:00
parent 59af4da430
commit 5244701c7b
5 changed files with 30 additions and 68 deletions

View File

@ -4,7 +4,7 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(PC_LIBSOUP REQUIRED libsoup-2.4)
include_directories(${GTK3_INCLUDE_DIRS} ${PC_LIBSOUP_INCLUDE_DIRS})
include_directories(${GTK3_INCLUDE_DIRS} ${PC_LIBSOUP_INCLUDE_DIRS} ../libkonaclient)
link_directories(${GTK3_LIBRARY_DIRS} ${PC_LIBSOUP_LIBRARY_DIRS} libkonaclient)
add_definitions(${GTK3_CFLAGS_OTHER})

View File

@ -1,40 +0,0 @@
#include "kona_search.h"
kona_search *kona_search_session_new() {
kona_search *search;
search = malloc(sizeof(kona_search));
if (search) {
search->session = soup_session_new();
search->msg = NULL;
}
return search;
}
int kona_search_new(kona_search *ks, gchar *tags) {
GString *url;
url = g_string_new("http://konachan.com/post.json?tags=");
g_string_append(url, tags);
if (ks->msg == NULL) {
g_print("Message creating\n");
ks->msg = soup_message_new ("GET", url);
g_print("Message created\n");
soup_session_send_async (ks->session,
ks->msg,
NULL, // TODO?
kona_search_callback,
NULL);
g_print("Message sent\n");
}
g_string_free(url, TRUE);
}
static void kona_search_callback (GObject *object, GAsyncResult *result, gpointer user_data)
{
GInputStream *stream;
GError *error = NULL;
stream = soup_session_send_finish (SOUP_SESSION (object), result, &error);
g_print(stream);
}

View File

@ -1,20 +0,0 @@
#ifndef KONA_SEARCH_H
#define KONA_SEARCH_H
#include <libsoup/soup.h>
#include <stdlib.h>
typedef struct _kona_search kona_search;
struct _kona_search {
SoupSession *session;
SoupMessage *msg;
};
// PUBLIC
kona_search *kona_search_session_new();
int kona_search_new(kona_search *ks, gchar *tags);
// DO NOT CALL
static void kona_search_callback (GObject *object, GAsyncResult *result, gpointer user_data);
#endif // KONA_SEARCH_H

View File

@ -2,7 +2,7 @@
#include <gtk/gtk.h>
#include "previewwidget.h"
#include "kona_search.h"
#include "konaimage.h"
int buildWindow();
@ -17,10 +17,10 @@ int buildWindow() {
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "glade/mainWindow.glade", NULL);
mainWindow = GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(builder), "mainWindow"));
mainWindow = GTK_WINDOW(gtk_builder_get_object(GTK_BUILDER(builder), "mainWindow"));
gtk_builder_connect_signals(builder, NULL);
previewContainer = gtk_builder_get_object(GTK_BUILDER(builder), "viewportPreview");
previewContainer = GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(builder), "viewportPreview"));
previewLayout = gtk_flow_box_new();
gtk_flow_box_set_max_children_per_line(GTK_FLOW_BOX(previewLayout), 200);
@ -44,12 +44,32 @@ int buildWindow() {
gtk_widget_show(GTK_WIDGET(mainWindow));
/*** TESTING LIB ***/
GValue val = G_VALUE_INIT;
KonaImage *ki;
kona_image_meta meta;
ki = kona_image_new();
g_value_init(&val, G_TYPE_POINTER);
// TTESTT
kona_search *search;
search = kona_search_session_new();
//kona_search_new(search, "yuri");
meta.height = 100;
meta.width = 200;
meta.image_url = "MEOWMEOWMEOW";
g_value_set_pointer(&val, (gpointer) &meta);
g_object_set_property((GObject*) ki, "meta", &val);
g_value_reset(&val);
meta.height = 0;
meta.width = 1;
// Read back
g_object_get_property((GObject*) ki, "meta", &val);
kona_image_meta *metret;
metret = g_value_get_pointer(&val);
printf("WIDTH=%i\n", metret->width);
printf("HEIGHT=%i\n", metret->height);
}
int main(int argc, char **argv)

View File

@ -27,6 +27,8 @@ struct _PreviewWidgetClass {
GType PreviewWidget_get_type (void) G_GNUC_CONST;
GtkWidget* PreviewWidget_new (void);
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url);
G_END_DECLS
#endif // PREVIEWWIDGET_H