1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# fix for incorrect handling of country maps
--- src/gui_countrymap.c.orig 2009-01-14 08:32:47.000000000 +0100
+++ src/gui_countrymap.c 2009-01-14 08:29:54.000000000 +0100
@@ -29,13 +29,15 @@
GtkWidget *countrymap = NULL;
static GdkPixmap *pm = NULL;
-
-extern gchar *prefixformaps;
+static gchar *pxformaps = NULL;
+static gint savew = -1, saveh = -1;
static gboolean
map_delete (GtkWidget * widget, GdkEvent *event, gpointer user_data)
{
countrymap = NULL;
+ g_free (pxformaps);
+ pxformaps = NULL;
return FALSE;
}
@@ -60,14 +62,14 @@
pm = gdk_pixmap_new(da->window, da->allocation.width, da->allocation.height, -1);
gdk_draw_rectangle(pm, da->style->white_gc, TRUE, 0, 0,
da->allocation.width, da->allocation.height);
- if (prefixformaps)
+ if (pxformaps)
{
#ifdef G_OS_WIN32
gchar *map_location = g_strconcat
- ("maps", G_DIR_SEPARATOR_S, prefixformaps, ".png", NULL);
+ ("maps", G_DIR_SEPARATOR_S, pxformaps, ".png", NULL);
#else
gchar *map_location = g_strconcat (XLOG_DATADIR, G_DIR_SEPARATOR_S,
- "maps", G_DIR_SEPARATOR_S, prefixformaps, ".png", NULL);
+ "maps", G_DIR_SEPARATOR_S, pxformaps, ".png", NULL);
#endif
GdkPixbuf *background = gdk_pixbuf_new_from_file (map_location, NULL);
g_free (map_location);
@@ -92,6 +94,8 @@
void countrymap_refresh (gchar *px)
{
+ if (!g_ascii_strcasecmp(px, pxformaps)) return;
+ pxformaps = g_strdup (px);
#ifdef G_OS_WIN32
gchar *map_location = g_strconcat
("maps", G_DIR_SEPARATOR_S, px, ".png", NULL);
@@ -101,7 +105,20 @@
#endif
gint width, height;
GdkPixbufFormat *f = gdk_pixbuf_get_file_info (map_location, &width, &height);
- if (f) gdk_window_resize (countrymap->window, width, height);
+ if (f)
+ {
+ if (width != savew || height != saveh)
+ {
+ gdk_window_resize (countrymap->window, width, height);
+ savew = width;
+ saveh = height;
+ }
+ else
+ {
+ GtkWidget *da = lookup_widget (countrymap, "da");
+ map_configure (da, NULL, NULL);
+ }
+ }
g_free (map_location);
}
@@ -128,18 +145,7 @@
gtk_container_add (GTK_CONTAINER(countrymap), da);
g_signal_connect (da, "expose_event", G_CALLBACK (map_expose), NULL);
g_signal_connect (da, "configure_event", G_CALLBACK (map_configure), NULL);
-
+ GLADE_HOOKUP_OBJECT (countrymap, da, "da");
+ pxformaps = g_strdup ("");
gtk_widget_show_all (countrymap);
-
-#ifdef G_OS_WIN32
- gchar *map_location = g_strconcat
- ("maps", G_DIR_SEPARATOR_S, prefixformaps, ".png", NULL);
-#else
- gchar *map_location = g_strconcat (XLOG_DATADIR, G_DIR_SEPARATOR_S,
- "maps", G_DIR_SEPARATOR_S, prefixformaps, ".png", NULL);
-#endif
- gint width, height;
- GdkPixbufFormat *f = gdk_pixbuf_get_file_info (map_location, &width, &height);
- if (f) gdk_window_resize (countrymap->window, width, height);
- g_free (map_location);
}
|