Compare commits

..

No commits in common. "a897006a56d43127af36b23d0ac243bba1f72067" and "5244701c7b69877a3d2fffe139fb5a26b794e017" have entirely different histories.

6 changed files with 50 additions and 128 deletions

View File

@ -1,53 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkBox" id="previewWidget">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="image">
<property name="width_request">200</property>
<property name="height_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">Screenshot from 2015-10-22 18-13-07.png</property>
<property name="use_fallback">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="spinner">
<property name="width_request">200</property>
<property name="height_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button">
<property name="label" translatable="yes">Download @ 0000 x 0000</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="kona_download_image" object="previewWidget" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>

View File

@ -14,8 +14,6 @@ int buildWindow() {
GtkWidget *previewContainer;
GtkWidget *temp;
KonaImage *ki;
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "glade/mainWindow.glade", NULL);
@ -28,9 +26,7 @@ int buildWindow() {
gtk_flow_box_set_max_children_per_line(GTK_FLOW_BOX(previewLayout), 200);
for (int i = 0; i < 100; ++i) {
// CUSTOM!!!!!
ki = kona_image_new();
temp = PreviewWidget_new(ki);
temp = PreviewWidget_new();
gtk_flow_box_insert(GTK_FLOW_BOX(previewLayout),temp,0);
gtk_widget_show(temp);
// -------------------
@ -50,8 +46,7 @@ int buildWindow() {
/*** TESTING LIB ***/
GValue val = G_VALUE_INIT;
GValue sval = G_VALUE_INIT;
KonaImage *ki;
kona_image_meta meta;
ki = kona_image_new();
g_value_init(&val, G_TYPE_POINTER);
@ -65,14 +60,7 @@ int buildWindow() {
g_object_set_property((GObject*) ki, "meta", &val);
g_value_init(&sval, G_TYPE_STRING);
g_value_set_string(&sval, "Hello world!");
g_object_set_property((GObject*) ki, "fullFile", &sval);
g_value_reset(&val);
g_value_reset(&sval);
meta.height = 0;
meta.width = 1;
@ -82,10 +70,6 @@ int buildWindow() {
metret = g_value_get_pointer(&val);
printf("WIDTH=%i\n", metret->width);
printf("HEIGHT=%i\n", metret->height);
g_object_get_property((GObject*) ki, "fullFile", &sval);
printf("STRING=%s\n", g_value_get_string(&sval));
}
int main(int argc, char **argv)

View File

@ -1,30 +1,23 @@
#include "previewwidget.h"
G_DEFINE_TYPE(PreviewWidget, PreviewWidget, GTK_TYPE_BIN)
void kona_download_image( GtkWidget *widget, gpointer data )
{
PreviewWidget_set_image(data, "/home/kurisu/Pictures/a.xpm"); // DEBUG ONLY!
PreviewWidget_set_image(data, ""); // DEBUG ONLY!
}
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
GtkWidget *w;
GtkWidget *spinner;
GList *widgets;
widgets = gtk_container_get_children(GTK_CONTAINER(widget));
w = widgets->data; // Grab GtkImage
spinner = widgets->data;
gtk_widget_set_visible(spinner, TRUE);
GdkPixbuf *p;
p = gdk_pixbuf_new_from_file(url, NULL);
p = gdk_pixbuf_scale_simple(p, 200, 150, GDK_INTERP_BILINEAR);
gtk_image_set_from_pixbuf(GTK_IMAGE(w), p);
gtk_widget_set_visible(w, TRUE);
w = g_list_next(widgets)->data; // Grab Spinner
gtk_widget_set_visible(w, FALSE);
spinner = g_list_next(widgets)->data;
gtk_widget_set_visible(spinner, FALSE);
}
@ -54,7 +47,7 @@ void PreviewWidget_init(PreviewWidget *klass)
g_object_unref(G_OBJECT(builder));
}
GtkWidget *PreviewWidget_new(KonaImage* ki)
GtkWidget *PreviewWidget_new()
{
return g_object_new (TYPE_PREVIEWWIDGET, NULL);
}

View File

@ -2,9 +2,8 @@
#define PREVIEWWIDGET_H
#include <gtk/gtk.h>
#include <glib.h>
#include "konaimage.h"
#include <glib.h>
G_BEGIN_DECLS
@ -26,7 +25,7 @@ struct _PreviewWidgetClass {
};
GType PreviewWidget_get_type (void) G_GNUC_CONST;
GtkWidget* PreviewWidget_new (KonaImage* ki);
GtkWidget* PreviewWidget_new (void);
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url);

View File

@ -1,6 +1,5 @@
#include "konaimage.h"
#include <stdio.h>
#include <string.h>
typedef struct {
guint64 test;
@ -8,18 +7,18 @@ typedef struct {
struct _KonaImage {
GObject parent_instance; // struct of parent (inherit)
kona_image_meta meta;
GString* preview_url;
GString* full_url;
guint64 id;
GList *tags;
GString *url;
};
G_DEFINE_TYPE_WITH_PRIVATE(KonaImage, kona_image, G_TYPE_OBJECT)
enum {
PROP_META=1,
PROP_FILE_PREVIEW,
PROP_FILE_FULL,
PROP_ID = 1,
PROP_TAGS,
PROP_URL,
PROP_COUNT
};
@ -29,15 +28,14 @@ static void kona_image_get_property(GObject *object, guint prop_id, GValue *valu
KonaImage *self = (KonaImage*)object;
switch (prop_id) {
case PROP_FILE_PREVIEW:
g_value_set_string(value, (const gchar*) self->preview_url);
case PROP_ID:
g_value_set_uint64(value, *kona_image_get_id(self));
break;
case PROP_FILE_FULL:
g_value_set_string(value, (const gchar*) self->full_url);
break;
case PROP_META:
g_value_set_pointer(value, &self->meta);
case PROP_TAGS:
g_value_set_gtype(value, (GType) self->tags); // Returning the pointer itself may be dangerous... Rather copy it to the target value?
break;
case PROP_URL:
g_value_set_string(value, (const gchar*) self->url);
default:
break;
}
@ -47,16 +45,16 @@ static void kona_image_set_property(GObject *object, guint prop_id, const GValue
KonaImage *self = (KonaImage*)object;
switch (prop_id) {
case PROP_FILE_FULL:
g_free(self->full_url);
self->full_url = (GString*) g_strdup(g_value_get_string(value));
case PROP_ID:
kona_image_set_id(self, g_value_get_uint64(value));
break;
case PROP_FILE_PREVIEW:
g_free(self->preview_url);
self->preview_url = (GString*) g_strdup(g_value_get_string(value));
case PROP_TAGS:
g_list_free(self->tags);
self->tags = g_list_copy((GList*) g_value_get_gtype(value));
break;
case PROP_META:
memcpy(&self->meta, g_value_get_pointer(value), sizeof(kona_image_meta));
case PROP_URL:
g_free(self->url);
self->url = (GString*) g_strdup(g_value_get_string(value));
break;
default:
break;
@ -69,14 +67,14 @@ static void kona_image_class_init(KonaImageClass *klass) {
object_class->set_property = kona_image_set_property;
object_class->get_property = kona_image_get_property;
properties [PROP_META] =
g_param_spec_pointer("meta", "meta", "Meta info struct", G_PARAM_READWRITE);
properties [PROP_ID] =
g_param_spec_uint64("id", "id", "The ID of the image.", 0, G_MAXINT64, 22, G_PARAM_READWRITE);
properties [PROP_FILE_FULL] =
g_param_spec_string("fullFile", "fullFile", "Local URL to the file", "", G_PARAM_READWRITE);
properties [PROP_TAGS] =
g_param_spec_gtype("tags", "tags", "A list of tags.", G_TYPE_NONE, G_PARAM_READWRITE); // TODO: G_TYPE_NONE for a GList(GString) a parameter?
properties [PROP_FILE_PREVIEW] =
g_param_spec_string("previewFile", "previewFile", "Local URL to the preview file", "", G_PARAM_READWRITE);
properties [PROP_URL] =
g_param_spec_string("url", "url", "The URL to the full picture.", "", G_PARAM_READWRITE);
g_object_class_install_properties(object_class, PROP_COUNT, properties);
}
@ -92,12 +90,20 @@ static void kona_image_dispose(KonaImage *self) {
static void kona_image_finalize(KonaImage *self) {
// Clear public vars here
g_free(self->meta.image_url);
g_free(self->meta.preview_url);
g_free(self->meta.tags);
g_free(self->tags);
G_OBJECT_CLASS (kona_image_parent_class)->finalize ((GObject*) self);
}
const guint64 *kona_image_get_id(KonaImage *self)
{
return &(self->id);
}
void kona_image_set_id(KonaImage *self, const guint64 id)
{
self->id = id;
}
KonaImage *kona_image_new()
{

View File

@ -11,15 +11,8 @@ G_DECLARE_FINAL_TYPE (KonaImage, kona_image, KONA, IMAGE, GObject) // Struct nam
KonaImage *kona_image_new (void);
struct kona_image_meta_struct {
int id;
GList *tags;
char* preview_url;
char* image_url;
int width;
int height;
};
typedef struct kona_image_meta_struct kona_image_meta;
const guint64 *kona_image_get_id(KonaImage *self);
void kona_image_set_id(KonaImage *self, const guint64 id);
G_END_DECLS