/* MediaImageWidget.c generated by valac 0.26.2, the Vala compiler
 * generated from MediaImageWidget.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>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <glib/gi18n-lib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gio/gio.h>


#define TYPE_MEDIA_IMAGE_WIDGET (media_image_widget_get_type ())
#define MEDIA_IMAGE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MEDIA_IMAGE_WIDGET, MediaImageWidget))
#define MEDIA_IMAGE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MEDIA_IMAGE_WIDGET, MediaImageWidgetClass))
#define IS_MEDIA_IMAGE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MEDIA_IMAGE_WIDGET))
#define IS_MEDIA_IMAGE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MEDIA_IMAGE_WIDGET))
#define MEDIA_IMAGE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MEDIA_IMAGE_WIDGET, MediaImageWidgetClass))

typedef struct _MediaImageWidget MediaImageWidget;
typedef struct _MediaImageWidgetClass MediaImageWidgetClass;
typedef struct _MediaImageWidgetPrivate MediaImageWidgetPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _MediaImageWidget {
	GtkScrolledWindow parent_instance;
	MediaImageWidgetPrivate * priv;
};

struct _MediaImageWidgetClass {
	GtkScrolledWindowClass parent_class;
};

struct _MediaImageWidgetPrivate {
	GtkImage* image;
	GtkMenu* image_context_menu;
	gchar* path;
	gdouble dnd_x;
	gdouble dnd_y;
};


static gpointer media_image_widget_parent_class = NULL;

GType media_image_widget_get_type (void) G_GNUC_CONST;
#define MEDIA_IMAGE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MEDIA_IMAGE_WIDGET, MediaImageWidgetPrivate))
enum  {
	MEDIA_IMAGE_WIDGET_DUMMY_PROPERTY
};
MediaImageWidget* media_image_widget_new (const gchar* path);
MediaImageWidget* media_image_widget_construct (GType object_type, const gchar* path);
static gboolean media_image_widget_button_press_event_cb (MediaImageWidget* self, GdkEventButton* evt);
static gboolean _media_image_widget_button_press_event_cb_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static gboolean media_image_widget_event_box_motion_notify_cb (MediaImageWidget* self, GdkEventMotion* evt);
static gboolean _media_image_widget_event_box_motion_notify_cb_gtk_widget_motion_notify_event (GtkWidget* _sender, GdkEventMotion* event, gpointer self);
static gboolean media_image_widget_event_box_button_press_cb (MediaImageWidget* self, GdkEventButton* evt);
static gboolean _media_image_widget_event_box_button_press_cb_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static void media_image_widget_save_item_activated_cb (MediaImageWidget* self);
static void _media_image_widget_save_item_activated_cb_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
gchar* utils_get_file_name (const gchar* path);
static void media_image_widget_finalize (GObject* obj);


static gboolean _media_image_widget_button_press_event_cb_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = media_image_widget_button_press_event_cb ((MediaImageWidget*) self, event);
	return result;
}


static gboolean _media_image_widget_event_box_motion_notify_cb_gtk_widget_motion_notify_event (GtkWidget* _sender, GdkEventMotion* event, gpointer self) {
	gboolean result;
	result = media_image_widget_event_box_motion_notify_cb ((MediaImageWidget*) self, event);
	return result;
}


static gboolean _media_image_widget_event_box_button_press_cb_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = media_image_widget_event_box_button_press_cb ((MediaImageWidget*) self, event);
	return result;
}


static void _media_image_widget_save_item_activated_cb_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
	media_image_widget_save_item_activated_cb ((MediaImageWidget*) self);
}


MediaImageWidget* media_image_widget_construct (GType object_type, const gchar* path) {
	MediaImageWidget * self = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	GtkImage* _tmp2_ = NULL;
	GtkEventBox* event_box = NULL;
	GtkEventBox* _tmp3_ = NULL;
	GtkEventBox* _tmp4_ = NULL;
	GtkImage* _tmp5_ = NULL;
	GtkEventBox* _tmp6_ = NULL;
	GtkEventBox* _tmp7_ = NULL;
	GtkEventBox* _tmp8_ = NULL;
	GtkMenu* _tmp9_ = NULL;
	GtkMenuItem* save_as_item = NULL;
	GtkMenuItem* _tmp10_ = NULL;
	GtkMenuItem* _tmp11_ = NULL;
	const gchar* _tmp12_ = NULL;
	GtkMenuItem* _tmp13_ = NULL;
	GtkMenuItem* _tmp14_ = NULL;
	GtkMenu* _tmp15_ = NULL;
	GtkMenuItem* _tmp16_ = NULL;
	GdkPixbuf* pixbuf = NULL;
	gint img_width = 0;
	GdkPixbuf* _tmp35_ = NULL;
	gint _tmp36_ = 0;
	gint img_height = 0;
	GdkPixbuf* _tmp37_ = NULL;
	gint _tmp38_ = 0;
	gint win_width = 0;
	gint win_height = 0;
	gint _tmp39_ = 0;
	gint _tmp40_ = 0;
	gint _tmp42_ = 0;
	gint _tmp43_ = 0;
	gboolean _tmp45_ = FALSE;
	gint _tmp46_ = 0;
	gboolean _tmp52_ = FALSE;
	gint _tmp53_ = 0;
	gint _tmp59_ = 0;
	gint _tmp60_ = 0;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (path != NULL, NULL);
	self = (MediaImageWidget*) g_object_new (object_type, NULL);
	_tmp0_ = path;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->path);
	self->priv->path = _tmp1_;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _media_image_widget_button_press_event_cb_gtk_widget_button_press_event, self, 0);
	_tmp2_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->image);
	self->priv->image = _tmp2_;
	_tmp3_ = (GtkEventBox*) gtk_event_box_new ();
	g_object_ref_sink (_tmp3_);
	event_box = _tmp3_;
	_tmp4_ = event_box;
	_tmp5_ = self->priv->image;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_widget_get_type (), GtkWidget));
	_tmp6_ = event_box;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget), "motion-notify-event", (GCallback) _media_image_widget_event_box_motion_notify_cb_gtk_widget_motion_notify_event, self, 0);
	_tmp7_ = event_box;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget), "button-press-event", (GCallback) _media_image_widget_event_box_button_press_cb_gtk_widget_button_press_event, self, 0);
	_tmp8_ = event_box;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget));
	_tmp9_ = (GtkMenu*) gtk_menu_new ();
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->image_context_menu);
	self->priv->image_context_menu = _tmp9_;
	_tmp10_ = (GtkMenuItem*) gtk_menu_item_new ();
	g_object_ref_sink (_tmp10_);
	save_as_item = _tmp10_;
	_tmp11_ = save_as_item;
	_tmp12_ = _ ("Save Image");
	gtk_menu_item_set_label (_tmp11_, _tmp12_);
	_tmp13_ = save_as_item;
	g_signal_connect_object (_tmp13_, "activate", (GCallback) _media_image_widget_save_item_activated_cb_gtk_menu_item_activate, self, 0);
	_tmp14_ = save_as_item;
	gtk_widget_show (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget));
	_tmp15_ = self->priv->image_context_menu;
	_tmp16_ = save_as_item;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_widget_get_type (), GtkWidget));
	pixbuf = NULL;
	{
		GdkPixbuf* _tmp17_ = NULL;
		const gchar* _tmp18_ = NULL;
		GdkPixbuf* _tmp19_ = NULL;
		GdkPixbuf* _tmp20_ = NULL;
		_tmp18_ = path;
		_tmp19_ = gdk_pixbuf_new_from_file (_tmp18_, &_inner_error_);
		_tmp17_ = _tmp19_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch56_g_error;
		}
		_tmp20_ = _tmp17_;
		_tmp17_ = NULL;
		_g_object_unref0 (pixbuf);
		pixbuf = _tmp20_;
		_g_object_unref0 (_tmp17_);
	}
	goto __finally56;
	__catch56_g_error:
	{
		GError* e = NULL;
		GError* _tmp21_ = NULL;
		const gchar* _tmp22_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp21_ = e;
		_tmp22_ = _tmp21_->message;
		g_critical ("MediaImageWidget.vala:51: %s", _tmp22_);
		_g_error_free0 (e);
	}
	__finally56:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (pixbuf);
		_g_object_unref0 (save_as_item);
		_g_object_unref0 (event_box);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	{
		const gchar* _tmp23_ = NULL;
		gboolean _tmp24_ = FALSE;
		_tmp23_ = path;
		_tmp24_ = g_str_has_suffix (_tmp23_, "gif");
		if (_tmp24_) {
			GdkPixbufAnimation* _tmp25_ = NULL;
			const gchar* _tmp26_ = NULL;
			GdkPixbufAnimation* _tmp27_ = NULL;
			GtkImage* _tmp28_ = NULL;
			_tmp26_ = path;
			_tmp27_ = gdk_pixbuf_animation_new_from_file (_tmp26_, &_inner_error_);
			_tmp25_ = _tmp27_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				goto __catch57_g_error;
			}
			_tmp28_ = self->priv->image;
			g_object_set (_tmp28_, "pixbuf-animation", _tmp25_, NULL);
			_g_object_unref0 (_tmp25_);
		} else {
			GdkPixbuf* _tmp29_ = NULL;
			const gchar* _tmp30_ = NULL;
			GdkPixbuf* _tmp31_ = NULL;
			GtkImage* _tmp32_ = NULL;
			_tmp30_ = path;
			_tmp31_ = gdk_pixbuf_new_from_file (_tmp30_, &_inner_error_);
			_tmp29_ = _tmp31_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				goto __catch57_g_error;
			}
			_tmp32_ = self->priv->image;
			g_object_set (_tmp32_, "pixbuf", _tmp29_, NULL);
			_g_object_unref0 (_tmp29_);
		}
	}
	goto __finally57;
	__catch57_g_error:
	{
		GError* e = NULL;
		GError* _tmp33_ = NULL;
		const gchar* _tmp34_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp33_ = e;
		_tmp34_ = _tmp33_->message;
		g_critical ("MediaImageWidget.vala:59: %s", _tmp34_);
		_g_error_free0 (e);
		_g_object_unref0 (pixbuf);
		_g_object_unref0 (save_as_item);
		_g_object_unref0 (event_box);
		return self;
	}
	__finally57:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (pixbuf);
		_g_object_unref0 (save_as_item);
		_g_object_unref0 (event_box);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp35_ = pixbuf;
	_tmp36_ = gdk_pixbuf_get_width (_tmp35_);
	img_width = _tmp36_;
	_tmp37_ = pixbuf;
	_tmp38_ = gdk_pixbuf_get_height (_tmp37_);
	img_height = _tmp38_;
	win_width = 800;
	win_height = 600;
	_tmp39_ = img_width;
	_tmp40_ = gdk_screen_width ();
	if (((gdouble) _tmp39_) <= (_tmp40_ * 0.7)) {
		gint _tmp41_ = 0;
		_tmp41_ = img_width;
		win_width = _tmp41_;
		g_object_set (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_scrolled_window_get_type (), GtkScrolledWindow), "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	}
	_tmp42_ = img_height;
	_tmp43_ = gdk_screen_height ();
	if (((gdouble) _tmp42_) <= (_tmp43_ * 0.7)) {
		gint _tmp44_ = 0;
		_tmp44_ = img_height;
		win_height = _tmp44_;
		g_object_set (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_scrolled_window_get_type (), GtkScrolledWindow), "vscrollbar-policy", GTK_POLICY_NEVER, NULL);
	}
	_tmp46_ = win_width;
	if (_tmp46_ < 800) {
		gint _tmp47_ = 0;
		_tmp47_ = win_height;
		_tmp45_ = _tmp47_ == 600;
	} else {
		_tmp45_ = FALSE;
	}
	if (_tmp45_) {
		gint add_width = 0;
		GtkWidget* _tmp48_ = NULL;
		gint _tmp49_ = 0;
		gint _tmp50_ = 0;
		gint _tmp51_ = 0;
		_tmp48_ = gtk_scrolled_window_get_vscrollbar (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_scrolled_window_get_type (), GtkScrolledWindow));
		gtk_widget_get_preferred_width (_tmp48_, NULL, &_tmp49_);
		add_width = _tmp49_;
		_tmp50_ = win_width;
		_tmp51_ = add_width;
		win_width = _tmp50_ + _tmp51_;
	}
	_tmp53_ = win_width;
	if (_tmp53_ == 800) {
		gint _tmp54_ = 0;
		_tmp54_ = win_height;
		_tmp52_ = _tmp54_ < 600;
	} else {
		_tmp52_ = FALSE;
	}
	if (_tmp52_) {
		gint add_height = 0;
		GtkWidget* _tmp55_ = NULL;
		gint _tmp56_ = 0;
		gint _tmp57_ = 0;
		gint _tmp58_ = 0;
		_tmp55_ = gtk_scrolled_window_get_hscrollbar (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_scrolled_window_get_type (), GtkScrolledWindow));
		gtk_widget_get_preferred_width (_tmp55_, NULL, &_tmp56_);
		add_height = _tmp56_;
		_tmp57_ = win_height;
		_tmp58_ = add_height;
		win_height = _tmp57_ + _tmp58_;
	}
	_tmp59_ = win_width;
	_tmp60_ = win_height;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp59_, _tmp60_);
	_g_object_unref0 (pixbuf);
	_g_object_unref0 (save_as_item);
	_g_object_unref0 (event_box);
	return self;
}


MediaImageWidget* media_image_widget_new (const gchar* path) {
	return media_image_widget_construct (TYPE_MEDIA_IMAGE_WIDGET, path);
}


static gboolean media_image_widget_event_box_motion_notify_cb (MediaImageWidget* self, GdkEventMotion* evt) {
	gboolean result = FALSE;
	GdkEventMotion* _tmp0_ = NULL;
	GdkModifierType _tmp1_ = 0;
	g_return_val_if_fail (IS_MEDIA_IMAGE_WIDGET (self), FALSE);
	g_return_val_if_fail (evt != NULL, FALSE);
	_tmp0_ = evt;
	_tmp1_ = _tmp0_->state;
	if ((_tmp1_ & GDK_MODIFIER_MASK) >= GDK_BUTTON2_MASK) {
		gdouble diff_x = 0.0;
		gdouble _tmp2_ = 0.0;
		GdkEventMotion* _tmp3_ = NULL;
		gdouble _tmp4_ = 0.0;
		gdouble diff_y = 0.0;
		gdouble _tmp5_ = 0.0;
		GdkEventMotion* _tmp6_ = NULL;
		gdouble _tmp7_ = 0.0;
		GtkAdjustment* _tmp8_ = NULL;
		GtkAdjustment* _tmp9_ = NULL;
		GtkAdjustment* _tmp10_ = NULL;
		GtkAdjustment* _tmp11_ = NULL;
		gdouble _tmp12_ = 0.0;
		gdouble _tmp13_ = 0.0;
		gdouble _tmp14_ = 0.0;
		GtkAdjustment* _tmp15_ = NULL;
		GtkAdjustment* _tmp16_ = NULL;
		GtkAdjustment* _tmp17_ = NULL;
		GtkAdjustment* _tmp18_ = NULL;
		gdouble _tmp19_ = 0.0;
		gdouble _tmp20_ = 0.0;
		gdouble _tmp21_ = 0.0;
		_tmp2_ = self->priv->dnd_x;
		_tmp3_ = evt;
		_tmp4_ = _tmp3_->x;
		diff_x = _tmp2_ - _tmp4_;
		_tmp5_ = self->priv->dnd_y;
		_tmp6_ = evt;
		_tmp7_ = _tmp6_->y;
		diff_y = _tmp5_ - _tmp7_;
		_tmp8_ = gtk_scrolled_window_get_vadjustment (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_scrolled_window_get_type (), GtkScrolledWindow));
		_tmp9_ = _tmp8_;
		_tmp10_ = gtk_scrolled_window_get_vadjustment (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_scrolled_window_get_type (), GtkScrolledWindow));
		_tmp11_ = _tmp10_;
		_tmp12_ = gtk_adjustment_get_value (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = diff_y;
		gtk_adjustment_set_value (_tmp11_, _tmp13_ + _tmp14_);
		_tmp15_ = gtk_scrolled_window_get_hadjustment (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_scrolled_window_get_type (), GtkScrolledWindow));
		_tmp16_ = _tmp15_;
		_tmp17_ = gtk_scrolled_window_get_hadjustment (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_scrolled_window_get_type (), GtkScrolledWindow));
		_tmp18_ = _tmp17_;
		_tmp19_ = gtk_adjustment_get_value (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = diff_x;
		gtk_adjustment_set_value (_tmp18_, _tmp20_ + _tmp21_);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


static gboolean media_image_widget_event_box_button_press_cb (MediaImageWidget* self, GdkEventButton* evt) {
	gboolean result = FALSE;
	GdkEventButton* _tmp0_ = NULL;
	guint _tmp1_ = 0U;
	g_return_val_if_fail (IS_MEDIA_IMAGE_WIDGET (self), FALSE);
	g_return_val_if_fail (evt != NULL, FALSE);
	_tmp0_ = evt;
	_tmp1_ = _tmp0_->button;
	if (_tmp1_ == ((guint) 2)) {
		GdkEventButton* _tmp2_ = NULL;
		gdouble _tmp3_ = 0.0;
		GdkEventButton* _tmp4_ = NULL;
		gdouble _tmp5_ = 0.0;
		_tmp2_ = evt;
		_tmp3_ = _tmp2_->x;
		self->priv->dnd_x = _tmp3_;
		_tmp4_ = evt;
		_tmp5_ = _tmp4_->y;
		self->priv->dnd_y = _tmp5_;
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


static void media_image_widget_save_item_activated_cb (MediaImageWidget* self) {
	GtkFileChooserDialog* file_dialog = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	GtkFileChooserDialog* _tmp3_ = NULL;
	gchar* filename = NULL;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	GtkFileChooserDialog* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	gint response = 0;
	GtkFileChooserDialog* _tmp8_ = NULL;
	gint _tmp9_ = 0;
	gint _tmp10_ = 0;
	GError * _inner_error_ = NULL;
	g_return_if_fail (IS_MEDIA_IMAGE_WIDGET (self));
	_tmp0_ = _ ("Save image");
	_tmp1_ = _ ("Cancel");
	_tmp2_ = _ ("Save");
	_tmp3_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new (_tmp0_, NULL, GTK_FILE_CHOOSER_ACTION_SAVE, _tmp1_, GTK_RESPONSE_CANCEL, _tmp2_, GTK_RESPONSE_ACCEPT, NULL);
	g_object_ref_sink (_tmp3_);
	file_dialog = _tmp3_;
	_tmp4_ = self->priv->path;
	_tmp5_ = utils_get_file_name (_tmp4_);
	filename = _tmp5_;
	_tmp6_ = file_dialog;
	_tmp7_ = filename;
	gtk_file_chooser_set_current_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GTK_TYPE_FILE_CHOOSER, GtkFileChooser), _tmp7_);
	_tmp8_ = file_dialog;
	_tmp9_ = gtk_dialog_run (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_dialog_get_type (), GtkDialog));
	response = _tmp9_;
	_tmp10_ = response;
	if (_tmp10_ == ((gint) GTK_RESPONSE_ACCEPT)) {
		GFile* dest = NULL;
		GtkFileChooserDialog* _tmp11_ = NULL;
		gchar* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		GFile* _tmp14_ = NULL;
		GFile* _tmp15_ = NULL;
		const gchar* _tmp16_ = NULL;
		GtkFileChooserDialog* _tmp17_ = NULL;
		gchar* _tmp18_ = NULL;
		gchar* _tmp19_ = NULL;
		GFile* source = NULL;
		const gchar* _tmp20_ = NULL;
		GFile* _tmp21_ = NULL;
		GtkFileChooserDialog* _tmp26_ = NULL;
		_tmp11_ = file_dialog;
		_tmp12_ = gtk_file_chooser_get_uri (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GTK_TYPE_FILE_CHOOSER, GtkFileChooser));
		_tmp13_ = _tmp12_;
		_tmp14_ = g_file_new_for_uri (_tmp13_);
		_tmp15_ = _tmp14_;
		_g_free0 (_tmp13_);
		dest = _tmp15_;
		_tmp16_ = self->priv->path;
		g_debug ("MediaImageWidget.vala:126: Source: %s", _tmp16_);
		_tmp17_ = file_dialog;
		_tmp18_ = gtk_file_chooser_get_uri (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, GTK_TYPE_FILE_CHOOSER, GtkFileChooser));
		_tmp19_ = _tmp18_;
		g_debug ("MediaImageWidget.vala:127: Destin: %s", _tmp19_);
		_g_free0 (_tmp19_);
		_tmp20_ = self->priv->path;
		_tmp21_ = g_file_new_for_path (_tmp20_);
		source = _tmp21_;
		{
			GFile* _tmp22_ = NULL;
			GFile* _tmp23_ = NULL;
			_tmp22_ = source;
			_tmp23_ = dest;
			g_file_copy (_tmp22_, _tmp23_, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &_inner_error_);
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				goto __catch58_g_error;
			}
		}
		goto __finally58;
		__catch58_g_error:
		{
			GError* e = NULL;
			GError* _tmp24_ = NULL;
			const gchar* _tmp25_ = NULL;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp24_ = e;
			_tmp25_ = _tmp24_->message;
			g_critical ("MediaImageWidget.vala:132: %s", _tmp25_);
			_g_error_free0 (e);
		}
		__finally58:
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (source);
			_g_object_unref0 (dest);
			_g_free0 (filename);
			_g_object_unref0 (file_dialog);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_tmp26_ = file_dialog;
		gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp26_, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (source);
		_g_object_unref0 (dest);
	} else {
		gint _tmp27_ = 0;
		_tmp27_ = response;
		if (_tmp27_ == ((gint) GTK_RESPONSE_CANCEL)) {
			GtkFileChooserDialog* _tmp28_ = NULL;
			_tmp28_ = file_dialog;
			gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, gtk_widget_get_type (), GtkWidget));
		}
	}
	_g_free0 (filename);
	_g_object_unref0 (file_dialog);
}


static gboolean media_image_widget_button_press_event_cb (MediaImageWidget* self, GdkEventButton* evt) {
	gboolean result = FALSE;
	GdkEventButton* _tmp0_ = NULL;
	guint _tmp1_ = 0U;
	g_return_val_if_fail (IS_MEDIA_IMAGE_WIDGET (self), FALSE);
	g_return_val_if_fail (evt != NULL, FALSE);
	_tmp0_ = evt;
	_tmp1_ = _tmp0_->button;
	if (_tmp1_ == ((guint) 3)) {
		GtkMenu* _tmp2_ = NULL;
		GdkEventButton* _tmp3_ = NULL;
		guint _tmp4_ = 0U;
		GdkEventButton* _tmp5_ = NULL;
		guint32 _tmp6_ = 0U;
		_tmp2_ = self->priv->image_context_menu;
		_tmp3_ = evt;
		_tmp4_ = _tmp3_->button;
		_tmp5_ = evt;
		_tmp6_ = _tmp5_->time;
		gtk_menu_popup (_tmp2_, NULL, NULL, NULL, NULL, _tmp4_, _tmp6_);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


static void media_image_widget_class_init (MediaImageWidgetClass * klass) {
	media_image_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (MediaImageWidgetPrivate));
	G_OBJECT_CLASS (klass)->finalize = media_image_widget_finalize;
}


static void media_image_widget_instance_init (MediaImageWidget * self) {
	self->priv = MEDIA_IMAGE_WIDGET_GET_PRIVATE (self);
}


static void media_image_widget_finalize (GObject* obj) {
	MediaImageWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MEDIA_IMAGE_WIDGET, MediaImageWidget);
	_g_object_unref0 (self->priv->image);
	_g_object_unref0 (self->priv->image_context_menu);
	_g_free0 (self->priv->path);
	G_OBJECT_CLASS (media_image_widget_parent_class)->finalize (obj);
}


GType media_image_widget_get_type (void) {
	static volatile gsize media_image_widget_type_id__volatile = 0;
	if (g_once_init_enter (&media_image_widget_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MediaImageWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) media_image_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MediaImageWidget), 0, (GInstanceInitFunc) media_image_widget_instance_init, NULL };
		GType media_image_widget_type_id;
		media_image_widget_type_id = g_type_register_static (gtk_scrolled_window_get_type (), "MediaImageWidget", &g_define_type_info, 0);
		g_once_init_leave (&media_image_widget_type_id__volatile, media_image_widget_type_id);
	}
	return media_image_widget_type_id__volatile;
}



