/* ITwitterItem.c generated by valac 0.26.2, the Vala compiler
 * generated from ITwitterItem.vala, do not modify */

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  corebird is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>


#define TYPE_ITWITTER_ITEM (itwitter_item_get_type ())
#define ITWITTER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ITWITTER_ITEM, ITwitterItem))
#define IS_ITWITTER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ITWITTER_ITEM))
#define ITWITTER_ITEM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_ITWITTER_ITEM, ITwitterItemIface))

typedef struct _ITwitterItem ITwitterItem;
typedef struct _ITwitterItemIface ITwitterItemIface;

struct _ITwitterItemIface {
	GTypeInterface parent_iface;
	gint (*update_time_delta) (ITwitterItem* self, GDateTime* now);
	gint64 (*get_sort_factor) (ITwitterItem* self);
	gboolean (*get_seen) (ITwitterItem* self);
	void (*set_seen) (ITwitterItem* self, gboolean value);
};



GType itwitter_item_get_type (void) G_GNUC_CONST;
gint itwitter_item_sort_func (GtkListBoxRow* a, GtkListBoxRow* b);
gint64 itwitter_item_get_sort_factor (ITwitterItem* self);
gint itwitter_item_sort_func_inv (GtkListBoxRow* a, GtkListBoxRow* b);
gint itwitter_item_update_time_delta (ITwitterItem* self, GDateTime* now);
gboolean itwitter_item_get_seen (ITwitterItem* self);
void itwitter_item_set_seen (ITwitterItem* self, gboolean value);


gint itwitter_item_sort_func (GtkListBoxRow* a, GtkListBoxRow* b) {
	gint result = 0;
	GtkListBoxRow* _tmp0_ = NULL;
	gint64 _tmp1_ = 0LL;
	gint64 _tmp2_ = 0LL;
	GtkListBoxRow* _tmp3_ = NULL;
	gint64 _tmp4_ = 0LL;
	gint64 _tmp5_ = 0LL;
	g_return_val_if_fail (GTK_IS_LIST_BOX_ROW (a), 0);
	g_return_val_if_fail (GTK_IS_LIST_BOX_ROW (b), 0);
	_tmp0_ = a;
	_tmp1_ = itwitter_item_get_sort_factor (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, TYPE_ITWITTER_ITEM, ITwitterItem));
	_tmp2_ = _tmp1_;
	_tmp3_ = b;
	_tmp4_ = itwitter_item_get_sort_factor (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, TYPE_ITWITTER_ITEM, ITwitterItem));
	_tmp5_ = _tmp4_;
	if (_tmp2_ < _tmp5_) {
		result = 1;
		return result;
	}
	result = -1;
	return result;
}


gint itwitter_item_sort_func_inv (GtkListBoxRow* a, GtkListBoxRow* b) {
	gint result = 0;
	GtkListBoxRow* _tmp0_ = NULL;
	gint64 _tmp1_ = 0LL;
	gint64 _tmp2_ = 0LL;
	GtkListBoxRow* _tmp3_ = NULL;
	gint64 _tmp4_ = 0LL;
	gint64 _tmp5_ = 0LL;
	g_return_val_if_fail (GTK_IS_LIST_BOX_ROW (a), 0);
	g_return_val_if_fail (GTK_IS_LIST_BOX_ROW (b), 0);
	_tmp0_ = a;
	_tmp1_ = itwitter_item_get_sort_factor (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, TYPE_ITWITTER_ITEM, ITwitterItem));
	_tmp2_ = _tmp1_;
	_tmp3_ = b;
	_tmp4_ = itwitter_item_get_sort_factor (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, TYPE_ITWITTER_ITEM, ITwitterItem));
	_tmp5_ = _tmp4_;
	if (_tmp2_ < _tmp5_) {
		result = -1;
		return result;
	}
	result = 1;
	return result;
}


/**
   * Updates the time delta label found in various ITwitterItem subclasses.
   *
   * @param now The current time.
   *
   * @return The seconds between the creation time and now.
   */
gint itwitter_item_update_time_delta (ITwitterItem* self, GDateTime* now) {
	g_return_val_if_fail (IS_ITWITTER_ITEM (self), 0);
	return ITWITTER_ITEM_GET_INTERFACE (self)->update_time_delta (self, now);
}


gint64 itwitter_item_get_sort_factor (ITwitterItem* self) {
	g_return_val_if_fail (IS_ITWITTER_ITEM (self), 0LL);
	return ITWITTER_ITEM_GET_INTERFACE (self)->get_sort_factor (self);
}


gboolean itwitter_item_get_seen (ITwitterItem* self) {
	g_return_val_if_fail (IS_ITWITTER_ITEM (self), FALSE);
	return ITWITTER_ITEM_GET_INTERFACE (self)->get_seen (self);
}


void itwitter_item_set_seen (ITwitterItem* self, gboolean value) {
	g_return_if_fail (IS_ITWITTER_ITEM (self));
	ITWITTER_ITEM_GET_INTERFACE (self)->set_seen (self, value);
}


static void itwitter_item_base_init (ITwitterItemIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		g_object_interface_install_property (iface, g_param_spec_int64 ("sort-factor", "sort-factor", "sort-factor", G_MININT64, G_MAXINT64, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
		g_object_interface_install_property (iface, g_param_spec_boolean ("seen", "seen", "seen", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	}
}


GType itwitter_item_get_type (void) {
	static volatile gsize itwitter_item_type_id__volatile = 0;
	if (g_once_init_enter (&itwitter_item_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ITwitterItemIface), (GBaseInitFunc) itwitter_item_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType itwitter_item_type_id;
		itwitter_item_type_id = g_type_register_static (G_TYPE_INTERFACE, "ITwitterItem", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (itwitter_item_type_id, gtk_widget_get_type ());
		g_once_init_leave (&itwitter_item_type_id__volatile, itwitter_item_type_id);
	}
	return itwitter_item_type_id__volatile;
}



