[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Denemo-devel] denemo too large for my screen
From: |
Benoit Rouits |
Subject: |
Re: [Denemo-devel] denemo too large for my screen |
Date: |
Sat, 26 Jan 2008 04:28:26 +0100 |
GLib provides a simple way to store configuration in .ini files
We can use it to store the last window state and reap it on the next
launch. Basically, the state.ini file can be :
[State]
width=600
heigth=200
maximised=false
We can store/generate it with things like:
GKeyFile *keyfile;
keyfile = g_key_file_new ();
g_key_file_set_integer (keyfile, "State", "width", gui->width);
g_key_file_set_integer (keyfile, "State", "height", gui->height);
g_key_file_set_boolean (keyfile, "State", "maximised", gui->maximized);
contents = g_key_file_to_data (keyfile, NULL, NULL);
g_key_file_free (keyfile);
filename = g_build_filename (denemo_dot_dir (), "state.ini", NULL);
g_file_set_contents (filename, contents, -1, NULL);
g_free (filename);
g_free (contents);
And reap it with something like:
filename = g_build_filename (locatedotdenemo (), "state.ini", NULL);
keyfile = g_key_file_new ();
if (g_key_file_load_from_file (keyfile, filename,
G_KEY_FILE_NONE, NULL) == FALSE) {
w = INITIAL_WIDTH;
h = INITIAL_HEIGHT;
g_free (filename);
} else {
g_free (filename);
w = g_key_file_get_integer (keyfile, "State", "width", &err);
if (err != NULL) {
w = 0;
g_error_free (err);
err = NULL;
}
h = g_key_file_get_integer (keyfile, "State", "heigth", &err);
if (err != NULL) {
h = 0;
g_error_free (err);
err = NULL;
}
maximised = g_key_file_get_boolean (keyfile, "State",
"maximised", &err);
if (err != NULL) {
g_error_free (err);
err = NULL;
}
g_key_file_free (keyfile);
if (w > 0 && h > 0 && maximised == FALSE) {
gtk_window_set_default_size (GTK_WINDOW (gui->window),
w, h);
gui->width = w;
gui->heigth = h;
} else if (gui->maximised != FALSE) {
gtk_window_maximize (GTK_WINDOW (gui->window));
}
I think it's understandable...
... all that in view.c, which manage the main window.
Le vendredi 25 janvier 2008 à 10:20 -0600, Jeremiah Benham a écrit :
> Every time I launch denemo now the application window is larger then my
> screen. I tried resizing it and then reopening it thinking it would
> remember the size and shape but it does not. What would it take to fix
> this?
>
> Thanks,
> Jeremiah