/* searchresults-widget.c generated by valac 0.20.1, the Vala compiler
 * generated from searchresults-widget.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; intend-tabs-mode: t -*- */
/* alm
 *
 * Copyright (C) 2012 Canonical
 *		  Authored by: Didier Roche <didrocks@ubuntu.com>
 *
 * alm is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * alm 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.";
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <pango/pango.h>


#define ALM_TYPE_SEARCH_RESULTS_WIDGET (alm_search_results_widget_get_type ())
#define ALM_SEARCH_RESULTS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ALM_TYPE_SEARCH_RESULTS_WIDGET, AlmSearchResultsWidget))
#define ALM_SEARCH_RESULTS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ALM_TYPE_SEARCH_RESULTS_WIDGET, AlmSearchResultsWidgetClass))
#define ALM_IS_SEARCH_RESULTS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ALM_TYPE_SEARCH_RESULTS_WIDGET))
#define ALM_IS_SEARCH_RESULTS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ALM_TYPE_SEARCH_RESULTS_WIDGET))
#define ALM_SEARCH_RESULTS_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ALM_TYPE_SEARCH_RESULTS_WIDGET, AlmSearchResultsWidgetClass))

typedef struct _AlmSearchResultsWidget AlmSearchResultsWidget;
typedef struct _AlmSearchResultsWidgetClass AlmSearchResultsWidgetClass;
typedef struct _AlmSearchResultsWidgetPrivate AlmSearchResultsWidgetPrivate;

#define ALM_SEARCH_RESULTS_WIDGET_TYPE_REMOTE_CONTENT (alm_search_results_widget_remote_content_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _AlmSearchResultsWidget {
	GtkBox parent_instance;
	AlmSearchResultsWidgetPrivate * priv;
};

struct _AlmSearchResultsWidgetClass {
	GtkBoxClass parent_class;
};

typedef enum  {
	ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_ALL,
	ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_NONE
} AlmSearchResultsWidgetRemoteContent;

struct _AlmSearchResultsWidgetPrivate {
	GSettings* gp_settings;
	GtkSwitch* commercial_suggestion;
	AlmSearchResultsWidgetRemoteContent _remote_content_search;
};


static gpointer alm_search_results_widget_parent_class = NULL;

GType alm_search_results_widget_get_type (void) G_GNUC_CONST;
GType alm_search_results_widget_remote_content_get_type (void) G_GNUC_CONST;
#define ALM_SEARCH_RESULTS_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ALM_TYPE_SEARCH_RESULTS_WIDGET, AlmSearchResultsWidgetPrivate))
enum  {
	ALM_SEARCH_RESULTS_WIDGET_DUMMY_PROPERTY,
	ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_SEARCH
};
#define ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_KEY "remote-content-search"
AlmSearchResultsWidget* alm_search_results_widget_new (void);
AlmSearchResultsWidget* alm_search_results_widget_construct (GType object_type);
void alm_search_results_widget_set_up_ui (AlmSearchResultsWidget* self);
AlmSearchResultsWidgetRemoteContent alm_search_results_widget_get_remote_content_search (AlmSearchResultsWidget* self);
void alm_search_results_widget_on_commercial_suggestion_activated (AlmSearchResultsWidget* self);
static void _alm_search_results_widget_on_commercial_suggestion_activated_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
void alm_search_results_widget_set_remote_content_search (AlmSearchResultsWidget* self, AlmSearchResultsWidgetRemoteContent value);
static void alm_search_results_widget_finalize (GObject* obj);
static void _vala_alm_search_results_widget_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_alm_search_results_widget_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


GType alm_search_results_widget_remote_content_get_type (void) {
	static volatile gsize alm_search_results_widget_remote_content_type_id__volatile = 0;
	if (g_once_init_enter (&alm_search_results_widget_remote_content_type_id__volatile)) {
		static const GEnumValue values[] = {{ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_ALL, "ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_ALL", "all"}, {ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_NONE, "ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_NONE", "none"}, {0, NULL, NULL}};
		GType alm_search_results_widget_remote_content_type_id;
		alm_search_results_widget_remote_content_type_id = g_enum_register_static ("AlmSearchResultsWidgetRemoteContent", values);
		g_once_init_leave (&alm_search_results_widget_remote_content_type_id__volatile, alm_search_results_widget_remote_content_type_id);
	}
	return alm_search_results_widget_remote_content_type_id__volatile;
}


AlmSearchResultsWidget* alm_search_results_widget_construct (GType object_type) {
	AlmSearchResultsWidget * self = NULL;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	self = (AlmSearchResultsWidget*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, NULL);
	gtk_box_set_spacing ((GtkBox*) self, 0);
	gtk_container_set_border_width ((GtkContainer*) self, (guint) 12);
	_tmp0_ = g_settings_new ("com.canonical.Unity.Lenses");
	_g_object_unref0 (self->priv->gp_settings);
	self->priv->gp_settings = _tmp0_;
	_tmp1_ = self->priv->gp_settings;
	g_settings_bind (_tmp1_, ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_KEY, (GObject*) self, "remote-content-search", G_SETTINGS_BIND_DEFAULT);
	alm_search_results_widget_set_up_ui (self);
	return self;
}


AlmSearchResultsWidget* alm_search_results_widget_new (void) {
	return alm_search_results_widget_construct (ALM_TYPE_SEARCH_RESULTS_WIDGET);
}


static void _alm_search_results_widget_on_commercial_suggestion_activated_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	alm_search_results_widget_on_commercial_suggestion_activated (self);
}


void alm_search_results_widget_set_up_ui (AlmSearchResultsWidget* self) {
	GtkBox* _tmp0_;
	GtkBox* top_box;
	GtkBox* _tmp1_;
	GtkBox* _tmp2_;
	GtkBox* _tmp3_;
	GtkBox* text_box;
	GtkLabel* _tmp4_;
	GtkLabel* header;
	GtkLabel* _tmp5_;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkBox* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	GtkLabel* label;
	GtkLabel* _tmp14_;
	const gchar* _tmp15_ = NULL;
	gchar* _tmp16_ = NULL;
	gchar* _tmp17_;
	GtkLabel* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	GtkBox* _tmp21_;
	GtkLabel* _tmp22_;
	GtkBox* _tmp23_;
	GtkBox* _tmp24_;
	GtkSwitch* _tmp25_;
	AlmSearchResultsWidgetRemoteContent _tmp26_;
	GtkSwitch* _tmp28_;
	GtkBox* _tmp29_;
	GtkBox* temp_box;
	GtkLabel* _tmp30_;
	GtkLabel* _tmp31_;
	GtkSwitch* _tmp32_;
	GtkLabel* _tmp33_;
	GtkLabel* _tmp34_;
	GtkBox* _tmp35_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 21);
	g_object_ref_sink (_tmp0_);
	top_box = _tmp0_;
	_tmp1_ = top_box;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp1_, 9);
	_tmp2_ = top_box;
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp2_, FALSE, FALSE, (guint) 0);
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp3_);
	text_box = _tmp3_;
	_tmp4_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp4_);
	header = _tmp4_;
	_tmp5_ = header;
	_tmp6_ = _ ("When searching in the Dash:");
	_tmp7_ = g_strdup_printf ("<b>%s</b>", _tmp6_);
	_tmp8_ = _tmp7_;
	gtk_label_set_markup (_tmp5_, _tmp8_);
	_g_free0 (_tmp8_);
	_tmp9_ = header;
	gtk_misc_set_alignment ((GtkMisc*) _tmp9_, (gfloat) 0, (gfloat) 0.5);
	_tmp10_ = header;
	gtk_misc_set_padding ((GtkMisc*) _tmp10_, 0, 0);
	_tmp11_ = text_box;
	_tmp12_ = header;
	gtk_box_pack_start (_tmp11_, (GtkWidget*) _tmp12_, FALSE, FALSE, (guint) 0);
	_tmp13_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp13_);
	label = _tmp13_;
	_tmp14_ = label;
	_tmp15_ = _ ("Include online search results");
	_tmp16_ = g_strdup_printf ("%s", _tmp15_);
	_tmp17_ = _tmp16_;
	gtk_label_set_markup (_tmp14_, _tmp17_);
	_g_free0 (_tmp17_);
	_tmp18_ = label;
	gtk_label_set_line_wrap (_tmp18_, TRUE);
	_tmp19_ = label;
	gtk_label_set_line_wrap_mode (_tmp19_, PANGO_WRAP_WORD);
	_tmp20_ = label;
	gtk_misc_set_alignment ((GtkMisc*) _tmp20_, (gfloat) 0, 0.5f);
	_tmp21_ = text_box;
	_tmp22_ = label;
	gtk_box_pack_start (_tmp21_, (GtkWidget*) _tmp22_, FALSE, FALSE, (guint) 6);
	_tmp23_ = top_box;
	_tmp24_ = text_box;
	gtk_box_pack_start (_tmp23_, (GtkWidget*) _tmp24_, FALSE, FALSE, (guint) 0);
	_tmp25_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp25_);
	_g_object_unref0 (self->priv->commercial_suggestion);
	self->priv->commercial_suggestion = _tmp25_;
	_tmp26_ = self->priv->_remote_content_search;
	if (_tmp26_ == ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_ALL) {
		GtkSwitch* _tmp27_;
		_tmp27_ = self->priv->commercial_suggestion;
		gtk_switch_set_active (_tmp27_, TRUE);
	}
	_tmp28_ = self->priv->commercial_suggestion;
	g_signal_connect_object ((GObject*) _tmp28_, "notify::active", (GCallback) _alm_search_results_widget_on_commercial_suggestion_activated_g_object_notify, self, 0);
	_tmp29_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp29_);
	temp_box = _tmp29_;
	_tmp30_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp30_);
	_tmp31_ = _tmp30_;
	gtk_box_pack_start (temp_box, (GtkWidget*) _tmp31_, TRUE, TRUE, (guint) 0);
	_g_object_unref0 (_tmp31_);
	_tmp32_ = self->priv->commercial_suggestion;
	gtk_box_pack_start (temp_box, (GtkWidget*) _tmp32_, FALSE, FALSE, (guint) 0);
	_tmp33_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp33_);
	_tmp34_ = _tmp33_;
	gtk_box_pack_start (temp_box, (GtkWidget*) _tmp34_, TRUE, TRUE, (guint) 0);
	_g_object_unref0 (_tmp34_);
	_tmp35_ = top_box;
	gtk_box_pack_end (_tmp35_, (GtkWidget*) temp_box, FALSE, FALSE, (guint) 0);
	_g_object_unref0 (temp_box);
	_g_object_unref0 (label);
	_g_object_unref0 (header);
	_g_object_unref0 (text_box);
	_g_object_unref0 (top_box);
}


void alm_search_results_widget_on_commercial_suggestion_activated (AlmSearchResultsWidget* self) {
	GtkSwitch* _tmp0_;
	gboolean _tmp1_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->commercial_suggestion;
	_tmp1_ = gtk_switch_get_active (_tmp0_);
	if (_tmp1_) {
		alm_search_results_widget_set_remote_content_search (self, ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_ALL);
	} else {
		alm_search_results_widget_set_remote_content_search (self, ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_NONE);
	}
}


AlmSearchResultsWidgetRemoteContent alm_search_results_widget_get_remote_content_search (AlmSearchResultsWidget* self) {
	AlmSearchResultsWidgetRemoteContent result;
	AlmSearchResultsWidgetRemoteContent _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_remote_content_search;
	result = _tmp0_;
	return result;
}


void alm_search_results_widget_set_remote_content_search (AlmSearchResultsWidget* self, AlmSearchResultsWidgetRemoteContent value) {
	AlmSearchResultsWidgetRemoteContent _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_remote_content_search = _tmp0_;
	g_object_notify ((GObject *) self, "remote-content-search");
}


static void alm_search_results_widget_class_init (AlmSearchResultsWidgetClass * klass) {
	alm_search_results_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (AlmSearchResultsWidgetPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_alm_search_results_widget_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_alm_search_results_widget_set_property;
	G_OBJECT_CLASS (klass)->finalize = alm_search_results_widget_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_SEARCH, g_param_spec_enum ("remote-content-search", "remote-content-search", "remote-content-search", ALM_SEARCH_RESULTS_WIDGET_TYPE_REMOTE_CONTENT, ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_ALL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void alm_search_results_widget_instance_init (AlmSearchResultsWidget * self) {
	self->priv = ALM_SEARCH_RESULTS_WIDGET_GET_PRIVATE (self);
	self->priv->_remote_content_search = ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_ALL;
}


static void alm_search_results_widget_finalize (GObject* obj) {
	AlmSearchResultsWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ALM_TYPE_SEARCH_RESULTS_WIDGET, AlmSearchResultsWidget);
	_g_object_unref0 (self->priv->gp_settings);
	_g_object_unref0 (self->priv->commercial_suggestion);
	G_OBJECT_CLASS (alm_search_results_widget_parent_class)->finalize (obj);
}


GType alm_search_results_widget_get_type (void) {
	static volatile gsize alm_search_results_widget_type_id__volatile = 0;
	if (g_once_init_enter (&alm_search_results_widget_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (AlmSearchResultsWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) alm_search_results_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AlmSearchResultsWidget), 0, (GInstanceInitFunc) alm_search_results_widget_instance_init, NULL };
		GType alm_search_results_widget_type_id;
		alm_search_results_widget_type_id = g_type_register_static (GTK_TYPE_BOX, "AlmSearchResultsWidget", &g_define_type_info, 0);
		g_once_init_leave (&alm_search_results_widget_type_id__volatile, alm_search_results_widget_type_id);
	}
	return alm_search_results_widget_type_id__volatile;
}


static void _vala_alm_search_results_widget_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	AlmSearchResultsWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ALM_TYPE_SEARCH_RESULTS_WIDGET, AlmSearchResultsWidget);
	switch (property_id) {
		case ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_SEARCH:
		g_value_set_enum (value, alm_search_results_widget_get_remote_content_search (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_alm_search_results_widget_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	AlmSearchResultsWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, ALM_TYPE_SEARCH_RESULTS_WIDGET, AlmSearchResultsWidget);
	switch (property_id) {
		case ALM_SEARCH_RESULTS_WIDGET_REMOTE_CONTENT_SEARCH:
		alm_search_results_widget_set_remote_content_search (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



