URL: http://bugs.freeciv.org/Ticket/Display.html?id=40315
Jason Dorje Short wrote:
URL: http://bugs.freeciv.org/Ticket/Display.html?id=40315
Every time the text on the left panel (generally the terrain text)
changes the panel resizes itself. This leads to a redraw of the main
screen. The end effect is to basically make the game unplayable.
The left panel should never automatically shrink itself. It can
automatically enlarge itself if necessary. There should be a GTK option
for this.
This obnoxious hack fixes the problem. I have the very strong feeling
there is some simple gtk setting to control this but i have no idea what
it is. Regardless, with this patch the game is far far more playable.
-jason
Index: client/gui-gtk-2.0/gui_main.c
===
--- client/gui-gtk-2.0/gui_main.c (revision 14862)
+++ client/gui-gtk-2.0/gui_main.c (working copy)
@@ -1206,6 +1206,7 @@
unit_info_frame = gtk_frame_new();
gtk_box_pack_start(GTK_BOX(unit_info_box), unit_info_frame, FALSE, FALSE, 0);
+ gtk_widget_set_no_shrink(unit_info_frame);
unit_info_label = gtk_label_new(\n\n\n);
gtk_container_add(GTK_CONTAINER(unit_info_frame), unit_info_label);
Index: client/gui-gtk-2.0/gui_stuff.c
===
--- client/gui-gtk-2.0/gui_stuff.c (revision 14862)
+++ client/gui-gtk-2.0/gui_stuff.c (working copy)
@@ -996,3 +996,31 @@
}
}
+/**
+ Handle a size request and make sure the widget GROWS only, no shrinking.
+**/
+static void size_request_no_shrink(GtkWidget *widget,
+ GtkRequisition *req,
+ gpointer user_data)
+{
+ int width, height;
+
+ gtk_widget_get_size_request(widget, width, height);
+ gtk_widget_set_size_request(widget,
+ MAX(width, req-width), MAX(height, req-height));
+}
+
+/**
+ This function is a major hack and probably easily accomplished via some
+ simple GTK setting. The goal is to make sure a particular widget will
+ only grow; never shrink. For instance the unit info panel sometimes gets
+ test too big for it. This text makes the panel grow. When moving to the
+ next unit, the panel would typlically then shrink again causing the entire
+ mapview to resize itself obnoxiously. With this setting the unit info
+ panel will never shrink.
+**/
+void gtk_widget_set_no_shrink(GtkWidget *widget)
+{
+ g_signal_connect(widget, size-request,
+ G_CALLBACK(size_request_no_shrink), NULL);
+}
Index: client/gui-gtk-2.0/gui_stuff.h
===
--- client/gui-gtk-2.0/gui_stuff.h (revision 14862)
+++ client/gui-gtk-2.0/gui_stuff.h (working copy)
@@ -123,4 +123,6 @@
struct client_option;
void gui_update_font_from_option(struct client_option *o);
+void gtk_widget_set_no_shrink(GtkWidget *widget);
+
#endif /* FC__GUI_STUFF_H */
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev