1 /*
2 * mape - C4 Landscape.txt editor
3 *
4 * Copyright (c) 2005-2009, Armin Burgmeier
5 *
6 * Distributed under the terms of the ISC license; see accompanying file
7 * "COPYING" for details.
8 *
9 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
10 * See accompanying file "TRADEMARK" for details.
11 *
12 * To redistribute this file separately, substitute the full license texts
13 * for the above references.
14 */
15
16 #include <stdlib.h>
17 #include <gtk/gtk.h>
18 #include "mape/preview.h"
19 #include "mape/preferences.h"
20
mape_pre_view_new(MapeMatTexView * mat_tex,GError ** error)21 MapePreView* mape_pre_view_new(MapeMatTexView* mat_tex,
22 GError** error)
23 {
24 MapePreView* view;
25 view = malloc(sizeof(MapePreView) );
26
27 view->mat_tex = mat_tex;
28
29 view->image = gtk_image_new();
30 gtk_widget_show(view->image);
31
32 view->event_box = gtk_event_box_new();
33 gtk_container_add(GTK_CONTAINER(view->event_box), view->image);
34 gtk_widget_add_events(view->event_box, GDK_BUTTON_PRESS_MASK);
35 gtk_widget_show(view->event_box);
36
37 view->frame = gtk_frame_new(NULL);/*"Landscape preview");*/
38 gtk_frame_set_shadow_type(GTK_FRAME(view->frame), GTK_SHADOW_IN);
39 gtk_container_add(GTK_CONTAINER(view->frame), view->event_box);
40 gtk_widget_show(view->frame);
41
42 /*gtk_widget_set_size_request(view->image, preferences->map_width, preferences->map_height);*/
43
44 return view;
45 }
46
mape_pre_view_destroy(MapePreView * view)47 void mape_pre_view_destroy(MapePreView* view)
48 {
49 free(view);
50 }
51
mape_pre_view_update(MapePreView * view,GdkPixbuf * pixbuf)52 void mape_pre_view_update(MapePreView* view,
53 GdkPixbuf* pixbuf)
54 {
55 /* TODO: Unref old pixbuf */
56 /* TODO: ref new pixbuf? */
57 gtk_image_set_from_pixbuf(GTK_IMAGE(view->image), pixbuf);
58
59 /* Update size from image, in case Map.c specifies different map dimensions */
60 if(pixbuf != NULL)
61 gtk_widget_set_size_request(view->image, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
62 }
63
mape_pre_view_apply_preferences(MapePreView * view,MapePreferences * preferences)64 void mape_pre_view_apply_preferences(MapePreView* view,
65 MapePreferences* preferences)
66 {
67 gtk_widget_set_size_request(view->image, preferences->map_width, preferences->map_height);
68 }
69
70