Problem with gtk_window_set_geometry_hints and vbox
- From: "Guillaume Duhamel" <guillaume duhamel gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Problem with gtk_window_set_geometry_hints and vbox
- Date: Sun, 4 Jun 2006 19:37:45 +0200
Hi,
I'm writing a gtk interface for my Sega Saturn emulator. It's using a
GtkDrawingArea and GtkGlExt to display an OpenGL window. I want the
drawing area size to respect some constraint to match the Saturn
resolution. It looks like gtk_window_set_geometry_hints does what I
need but I have some issues when using it : my drawing area is packed
in a vbox with the menu and when I ask a size for the drawing area, I
got that size + the size of the menu. For instance, if I want a
drawing area size of 320 and the size of the menu is 65, I got a size
of 385 for the drawing area.
What am I doing wrong? I'm including some example code:
#include <gtk/gtk.h>
gboolean resize (GtkWidget * w, GdkEventConfigure * e, gpointer d) {
g_print("got: %d x %d\n", e->width, e->height);
}
int main(int argc, char ** argv) {
GtkWidget * window, * box, * menu, * area;
GdkGeometry hints;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
box = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), box);
menu = gtk_menu_bar_new();
gtk_container_add(GTK_CONTAINER(menu),
gtk_menu_item_new_with_mnemonic("Dummy"));
gtk_box_pack_start(GTK_BOX(box), menu, FALSE, FALSE, 0);
area = gtk_drawing_area_new();
gtk_box_pack_start(GTK_BOX(box), area, TRUE, TRUE, 0);
g_signal_connect(GTK_OBJECT(area), "configure_event",
GTK_SIGNAL_FUNC(resize), 0);
hints.min_width = 320;
hints.min_height = 200;
g_print("asking: %d x %d\n", hints.min_width, hints.min_height);
gtk_window_set_geometry_hints(GTK_WINDOW(window), area,
&hints, GDK_HINT_MIN_SIZE);
gtk_widget_show_all(window);
gtk_main();
}
Guillaume
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]