/* The options we understand. */
static struct argp_option argp_options[] = {
{"debug", 'd', "level", 0, "Produce debugging output", 0},
+ {"geometry", 'g', "pos", 0, "Set geometry", 0},
{"pram", 'p', "size", 0, "Set program memory size", 0},
{"xram", 'x', "size", 0,
"Set external ram size (default is 1024)", 0},
case 'd':
decode_debug_option(arg, state);
break;
+ case 'g':
+ options.g = arg;
+ break;
case 'i':
decode_memory_size(arg, state, INT_MEM_ID);
break;
/* Setting default values. */
options.filename = NULL;
+ options.g = NULL;
options.pram_size = PGM_MEM_DEFAULT_SIZE;
options.iram_size = INT_MEM_MAX_SIZE;
options.xram_size = EXT_MEM_DEFAULT_SIZE;
}
}
+static void
+emugtk_set_geometry_hints(GtkWidget *window)
+{
+ GdkGeometry hints;
+
+ hints.min_width = 100;
+ hints.min_height = 100;
+
+ /* Set reference point to top left corner */
+ hints.win_gravity = GDK_GRAVITY_NORTH_WEST;
+
+ gtk_window_set_geometry_hints(GTK_WINDOW(window), window, &hints,
+ GDK_HINT_MIN_SIZE);
+}
+
/*
* mainwin
* +---------------------------------------------------------------------+
static void
emugtk_window_init(void)
{
+ int geometry_ok = false;
int id;
GtkWidget *vbox;
GtkWidget *menu_bar;
mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(mainwin), PACKAGE_NAME);
- gtk_window_set_default_size(GTK_WINDOW(mainwin),
- cfg->win_width, cfg->win_height);
gtk_container_set_border_width(GTK_CONTAINER(mainwin), 0);
/* Window DESTROY event. */
g_signal_connect(mainwin, "destroy", G_CALLBACK(emugtk_quit_gui), NULL);
+ emugtk_set_geometry_hints(mainwin);
+
+ /*
+ * If either a size or a position can be extracted from the geometry
+ * string, gtk_window_parse_geometry() returns TRUE and calls
+ * gtk_window_set_default_size() and/or gtk_window_move() to resize/move
+ * the window.
+ */
+ if (options.g != NULL) {
+ geometry_ok = gtk_window_parse_geometry(GTK_WINDOW(mainwin),
+ options.g);
+ if (!geometry_ok)
+ log_err("Failed to parse geometry argument: %s",
+ options.g);
+ }
+
+ /*
+ * If geometry was not specified, or was improperly parsed, use
+ * saved window size.
+ */
+ if (geometry_ok == false) {
+ log_err("Use saved window size");
+ gtk_window_set_default_size(GTK_WINDOW(mainwin),
+ cfg->win_width, cfg->win_height);
+ }
+
gtk_widget_show_all(mainwin);
emugtk_window_init_complete = true;