gEDA-dev: [PATCH] gschem: remember dialog size and position
Ivan Stankovic
ivan.stankovic at fer.hr
Mon Apr 30 14:49:17 EDT 2007
Hi,
This patch makes gschem able to remember position and
size for all dialogs (yes, I've tested them all :)).
The information is stored in ~/.gEDA/gschem-dialog-geometry.
This functionality is enabled only if glib version >= 2.6.0 is
available, and applies cleanly on top of current CVS/git.
Here is how it works. After creating the dialog widget, set
the dialog name with a call like
gtk_object_set_data(GTK_OBJECT(dialog), "dialog-name", "whatever");
Here, "whatever" can be anything, as long as it's unique (usually,
the name will be something meaningful, like "text-find").
After that, you call
dialog_restore_geometry(dialog);
to restore dialog's last position and size (typically, this is done
just before a call to gtk_widget_show_all()).
You can save dialog's position and size with:
dialog_save_geometry(dialog);
(usually in a dialog's response routine, before the widget
is destroyed).
Please test, comments welcome.
--
Ivan Stankovic, ivan.stankovic at fer.hr
"Protect your digital freedom and privacy, eliminate DRM,
learn more at http://www.defectivebydesign.org/what_is_drm"
-------------- next part --------------
>From c4bcc010668c3eb0ad310c223a8fd051642fa39a Mon Sep 17 00:00:00 2001
From: Ivan Stankovic <ivan.stankovic at fer.hr>
Date: Mon, 30 Apr 2007 18:02:18 +0200
Subject: [PATCH] gschem: remember dialog size and position
---
gschem/src/x_dialog.c | 190 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 188 insertions(+), 2 deletions(-)
diff --git a/gschem/src/x_dialog.c b/gschem/src/x_dialog.c
index 4fa4c79..66d213d 100644
--- a/gschem/src/x_dialog.c
+++ b/gschem/src/x_dialog.c
@@ -27,6 +27,7 @@
#include <string.h>
#endif
+#include <glib/gstdio.h>
#include <libgeda/libgeda.h>
#include "../include/i_vars.h"
@@ -75,6 +76,94 @@ struct fill_type_data {
GList *objects;
};
+#if !GLIB_CHECK_VERSION(2,6,0)
+
+static inline void dialog_save_geometry(GtkWidget *dialog) { }
+static inline void dialog_restore_geometry(GtkWidget *dialog) { }
+
+#else
+
+static GKeyFile *dialog_geometry;
+
+#define DIALOG_GEOMETRY_STORE "gschem-dialog-geometry"
+
+/*! \brief Save dialog's current position and size.
+ *
+ * The dialog is referenced by its unique name which is set by a
+ * call like:
+ *
+ * gtk_object_set_data(GTK_OBJECT(dialog), "dialog-name",
+ * "text-find");
+ */
+static void dialog_save_geometry(GtkWidget *dialog)
+{
+ gint x, y, width, height;
+ gchar *name, *data, *file;
+
+ name = (gchar *) gtk_object_get_data(GTK_OBJECT(dialog), "dialog-name");
+ gtk_window_get_position(GTK_WINDOW(dialog), &x, &y);
+ gtk_window_get_size(GTK_WINDOW(dialog), &width, &height);
+
+ g_key_file_set_integer(dialog_geometry, name, "x", x);
+ g_key_file_set_integer(dialog_geometry, name, "y", y);
+ g_key_file_set_integer(dialog_geometry, name, "width", width);
+ g_key_file_set_integer(dialog_geometry, name, "height", height);
+
+ data = g_key_file_to_data(dialog_geometry, NULL, NULL);
+ file = g_build_filename(g_get_home_dir(), ".gEDA", DIALOG_GEOMETRY_STORE, NULL);
+ g_file_set_contents(file, data, -1, NULL);
+ g_free(data);
+ g_free(file);
+}
+
+
+/*! \brief Restore dialog's last position and size.
+ *
+ * If the dialog is unknown, do nothing.
+ */
+static void dialog_restore_geometry(GtkWidget *dialog)
+{
+ gchar *name;
+ gint x, y, width, height;
+
+ if(!dialog_geometry) {
+ gchar *file = g_build_filename(g_get_home_dir(), ".gEDA",
+ DIALOG_GEOMETRY_STORE, NULL);
+
+ dialog_geometry = g_key_file_new();
+
+ if(!g_file_test(file, G_FILE_TEST_EXISTS)) {
+ gchar *dir = g_build_filename(g_get_home_dir(), ".gEDA", NULL);
+ g_mkdir(dir, S_IRWXU | S_IRWXG);
+ g_free(dir);
+
+ g_file_set_contents(file, "", -1, NULL);
+ }
+
+ if(!g_key_file_load_from_file(dialog_geometry, file, G_KEY_FILE_NONE, NULL)) {
+ /* error opening key file, create an empty one and try again */
+ g_file_set_contents(file, "", -1, NULL);
+ if(!g_key_file_load_from_file(dialog_geometry, file, G_KEY_FILE_NONE, NULL)) {
+ g_free(file);
+ return;
+ }
+ }
+ g_free(file);
+ }
+
+ name = (gchar *) gtk_object_get_data(GTK_OBJECT(dialog), "dialog-name");
+ if(g_key_file_has_group(dialog_geometry, name)) {
+ x = g_key_file_get_integer(dialog_geometry, name, "x", NULL);
+ y = g_key_file_get_integer(dialog_geometry, name, "y", NULL);
+ width = g_key_file_get_integer(dialog_geometry, name, "width", NULL);
+ height = g_key_file_get_integer(dialog_geometry, name, "height", NULL);
+
+ gtk_window_move(GTK_WINDOW(dialog), x, y);
+ gtk_window_set_default_size(GTK_WINDOW(dialog), width, height);
+ }
+}
+#endif /* !GLIB_CHECK_VERSION(2,6,0) */
+
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
@@ -155,6 +244,7 @@ void text_input_dialog_response(GtkWidget * widget, gint response, TOPLEVEL *w_c
case GTK_RESPONSE_DELETE_EVENT:
i_set_state(w_current, SELECT);
i_update_toolbar(w_current);
+ dialog_save_geometry(w_current->tiwindow);
gtk_widget_destroy(w_current->tiwindow);
w_current->tiwindow=NULL;
break;
@@ -188,6 +278,10 @@ void text_input_dialog (TOPLEVEL *w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ /* set dialog name */
+ gtk_object_set_data(GTK_OBJECT(w_current->tiwindow), "dialog-name",
+ "text-input");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->tiwindow),
@@ -251,9 +345,11 @@ void text_input_dialog (TOPLEVEL *w_current)
gtk_object_set_data(GTK_OBJECT(w_current->tiwindow),
"tientry",tientry);
+ dialog_restore_geometry(w_current->tiwindow);
gtk_widget_show_all (w_current->tiwindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->tiwindow);
gtk_window_present (GTK_WINDOW(w_current->tiwindow));
}
@@ -474,6 +570,7 @@ void text_edit_dialog_response(GtkWidget * widget, gint response, TOPLEVEL *w_cu
/* clean up */
i_set_state(w_current, SELECT);
i_update_toolbar(w_current);
+ dialog_save_geometry(w_current->tewindow);
gtk_widget_destroy(w_current->tewindow);
w_current->tewindow = NULL;
}
@@ -512,6 +609,9 @@ void text_edit_dialog (TOPLEVEL *w_current, char *string, int text_size,
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->tewindow), "dialog-name",
+ "text-edit");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->tewindow),
@@ -620,10 +720,12 @@ void text_edit_dialog (TOPLEVEL *w_current, char *string, int text_size,
gtk_table_attach_defaults(GTK_TABLE(table), optionmenu, 1,2,2,3);
GLADE_HOOKUP_OBJECT(w_current->tewindow, sizeentry,"sizeentry");
+ dialog_restore_geometry(w_current->tewindow);
gtk_widget_show_all(w_current->tewindow);
}
else { /* dialog already there */
+ dialog_restore_geometry(w_current->tewindow);
gtk_window_present(GTK_WINDOW(w_current->tewindow));
}
@@ -838,6 +940,7 @@ void line_type_dialog_response(GtkWidget *widget, gint response,
i_set_state (line_type_data->toplevel, SELECT);
i_update_toolbar (line_type_data->toplevel);
+ dialog_save_geometry(line_type_data->dialog);
gtk_widget_destroy (line_type_data->dialog);
/* get ride of the list of objects but not the objects */
@@ -876,6 +979,9 @@ void line_type_dialog (TOPLEVEL *w_current, GList *objects)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(dialog), "dialog-name",
+ "line-type");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog),
@@ -1002,6 +1108,7 @@ void line_type_dialog (TOPLEVEL *w_current, GList *objects)
line_type_dialog_linetype_change(optionmenu, line_type_data);
gtk_widget_grab_focus(width_entry);
+ dialog_restore_geometry(dialog);
gtk_widget_show_all (dialog);
g_free (width_str);
@@ -1222,6 +1329,7 @@ void fill_type_dialog_response(GtkWidget *widget, gint response,
i_update_toolbar (fill_type_data->toplevel);
gtk_grab_remove (fill_type_data->dialog);
+ dialog_save_geometry(fill_type_data->dialog);
gtk_widget_destroy (fill_type_data->dialog);
/* get ride of the list of objects but not the objects */
@@ -1262,6 +1370,8 @@ void fill_type_dialog(TOPLEVEL *w_current, GList *objects)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(dialog), "dialog-name", "fill-type");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog),
@@ -1415,6 +1525,7 @@ void fill_type_dialog(TOPLEVEL *w_current, GList *objects)
fill_type_dialog_filltype_change(optionmenu, fill_type_data);
gtk_widget_grab_focus(width_entry);
+ dialog_restore_geometry(dialog);
gtk_widget_show_all (dialog);
g_free (width_str);
@@ -1456,7 +1567,7 @@ void arc_angle_dialog_response(GtkWidget *w, gint response,
default:
printf("arc_angle_dialog_response(): strange signal %d\n",response);
}
-
+ dialog_save_geometry(w_current->aawindow);
gtk_widget_destroy(w_current->aawindow);
w_current->aawindow = NULL;
w_current->event_state = DRAWARC;
@@ -1483,6 +1594,9 @@ void arc_angle_dialog (TOPLEVEL *w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->aawindow), "dialog-name",
+ "arc-angle");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->aawindow),
@@ -1537,10 +1651,12 @@ void arc_angle_dialog (TOPLEVEL *w_current)
GLADE_HOOKUP_OBJECT(w_current->aawindow, spin_start,"spin_start");
GLADE_HOOKUP_OBJECT(w_current->aawindow, spin_sweep,"spin_sweep");
+ dialog_restore_geometry(w_current->aawindow);
gtk_widget_show_all (w_current->aawindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->aawindow);
gtk_window_present (GTK_WINDOW(w_current->aawindow));
}
}
@@ -1578,6 +1694,7 @@ void translate_dialog_response(GtkWidget *widget, gint response,
i_set_state(w_current, SELECT);
i_update_toolbar(w_current);
+ dialog_save_geometry(w_current->trwindow);
gtk_widget_destroy(w_current->trwindow);
w_current->trwindow=NULL;
}
@@ -1603,6 +1720,8 @@ void translate_dialog (TOPLEVEL *w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->trwindow), "dialog-name", "translate");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->trwindow),
@@ -1636,10 +1755,12 @@ void translate_dialog (TOPLEVEL *w_current)
gtk_box_pack_start(GTK_BOX(vbox),textentry, FALSE, FALSE, 0);
GLADE_HOOKUP_OBJECT(w_current->trwindow, textentry, "textentry");
+ dialog_restore_geometry(w_current->trwindow);
gtk_widget_show_all (w_current->trwindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->trwindow);
gtk_window_present(GTK_WINDOW(w_current->trwindow));
}
}
@@ -1678,6 +1799,7 @@ void text_size_dialog_response(GtkWidget *w, gint response,
/* clean up */
i_set_state(w_current, SELECT);
i_update_toolbar(w_current);
+ dialog_save_geometry(w_current->tswindow);
gtk_widget_destroy(w_current->tswindow);
w_current->tswindow = NULL;
}
@@ -1702,6 +1824,8 @@ void text_size_dialog (TOPLEVEL *w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->tswindow), "dialog-name", "text-size");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->tswindow),
@@ -1735,10 +1859,12 @@ void text_size_dialog (TOPLEVEL *w_current)
gtk_widget_grab_focus(spin_size);
GLADE_HOOKUP_OBJECT(w_current->tswindow, spin_size, "spin_size");
+ dialog_restore_geometry(w_current->tswindow);
gtk_widget_show_all(w_current->tswindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->tswindow);
gtk_window_present(GTK_WINDOW(w_current->tswindow));
}
@@ -1784,6 +1910,7 @@ void snap_size_dialog_response(GtkWidget *w, gint response,
/* clean up */
i_set_state(w_current, SELECT);
i_update_toolbar(w_current);
+ dialog_save_geometry(w_current->tswindow);
gtk_widget_destroy(w_current->tswindow);
w_current->tswindow = NULL;
}
@@ -1808,6 +1935,9 @@ void snap_size_dialog (TOPLEVEL *w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->tswindow), "dialog-name",
+ "snap-size");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->tswindow),
@@ -1841,10 +1971,12 @@ void snap_size_dialog (TOPLEVEL *w_current)
gtk_widget_grab_focus(spin_size);
GLADE_HOOKUP_OBJECT(w_current->tswindow, spin_size, "spin_size");
+ dialog_restore_geometry(w_current->tswindow);
gtk_widget_show_all(w_current->tswindow);
}
else { /* dialog already there */
+ dialog_restore_geometry(w_current->tswindow);
gtk_window_present(GTK_WINDOW(w_current->tswindow));
}
@@ -1887,6 +2019,7 @@ void slot_edit_dialog_response(GtkWidget *widget, gint response, TOPLEVEL *w_cur
}
i_set_state(w_current, SELECT);
i_update_toolbar(w_current);
+ dialog_save_geometry(w_current->sewindow);
gtk_widget_destroy(w_current->sewindow);
w_current->sewindow = NULL;
}
@@ -1912,6 +2045,9 @@ void slot_edit_dialog (TOPLEVEL *w_current, char *string)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->sewindow), "dialog-name",
+ "slot-edit");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->sewindow),
@@ -1946,10 +2082,12 @@ void slot_edit_dialog (TOPLEVEL *w_current, char *string)
gtk_entry_set_activates_default (GTK_ENTRY(textentry),TRUE);
GLADE_HOOKUP_OBJECT(w_current->sewindow, textentry, "textentry");
+ dialog_restore_geometry(w_current->sewindow);
gtk_widget_show_all (w_current->sewindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->sewindow);
gtk_window_present (GTK_WINDOW(w_current->sewindow));
}
@@ -1982,6 +2120,7 @@ void about_dialog_response(GtkWidget *w, gint response,
printf("about_dialog_response(): strange signal %d\n",response);
}
+ dialog_save_geometry(w_current->abwindow);
gtk_widget_destroy(w_current->abwindow);
w_current->abwindow = NULL;
}
@@ -2004,6 +2143,9 @@ void about_dialog (TOPLEVEL *w_current)
GTK_RESPONSE_REJECT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->abwindow), "dialog-name",
+ "about");
+
gtk_window_position (GTK_WINDOW (w_current->abwindow),
GTK_WIN_POS_MOUSE);
@@ -2033,10 +2175,12 @@ void about_dialog (TOPLEVEL *w_current)
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
+ dialog_restore_geometry(w_current->abwindow);
gtk_widget_show_all(w_current->abwindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->abwindow);
gtk_window_present(GTK_WINDOW(w_current->abwindow));
}
}
@@ -2050,6 +2194,7 @@ void about_dialog (TOPLEVEL *w_current)
*/
void coord_dialog_response(GtkWidget *w, gint response, TOPLEVEL *w_current)
{
+ dialog_save_geometry(w_current->cowindow);
gtk_widget_destroy(w_current->cowindow);
w_current->cowindow = NULL;
w_current->coord_world = NULL;
@@ -2097,6 +2242,9 @@ void coord_dialog (TOPLEVEL *w_current, int x, int y)
GTK_RESPONSE_REJECT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->cowindow), "dialog-name",
+ "coord");
+
gtk_window_position (GTK_WINDOW (w_current->cowindow),
GTK_WIN_POS_NONE);
@@ -2129,10 +2277,12 @@ void coord_dialog (TOPLEVEL *w_current, int x, int y)
w_current->coord_world);
gtk_box_pack_start(GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+ dialog_restore_geometry(w_current->cowindow);
gtk_widget_show_all(w_current->cowindow);
}
else { /* window already creatad */
+ dialog_restore_geometry(w_current->cowindow);
gtk_window_present(GTK_WINDOW(w_current->cowindow));
}
@@ -2381,6 +2531,7 @@ void color_edit_dialog_response(GtkWidget *widget, gint response, TOPLEVEL *w_cu
switch (response) {
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_DELETE_EVENT:
+ dialog_save_geometry(w_current->clwindow);
gtk_widget_destroy(w_current->clwindow);
w_current->clwindow = NULL;
break;
@@ -2414,6 +2565,9 @@ void color_edit_dialog (TOPLEVEL *w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->clwindow), "dialog-name",
+ "color-edit");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->clwindow),
@@ -2447,10 +2601,12 @@ void color_edit_dialog (TOPLEVEL *w_current)
gtk_option_menu_set_history(GTK_OPTION_MENU (optionmenu), select_index);
gtk_box_pack_start(GTK_BOX(vbox),
optionmenu, FALSE, FALSE, 0);
+ dialog_restore_geometry(w_current->clwindow);
gtk_widget_show_all(w_current->clwindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->clwindow);
gtk_window_present(GTK_WINDOW(w_current->clwindow));
}
}
@@ -2475,6 +2631,7 @@ void x_dialog_hotkeys_response(GtkWidget *w, gint response,
printf("x_dialog_hotkeys_response(): strange signal %d\n", response);
}
/* clean up */
+ dialog_save_geometry(w_current->hkwindow);
gtk_widget_destroy(w_current->hkwindow);
w_current->hkwindow = NULL;
}
@@ -2505,6 +2662,9 @@ void x_dialog_hotkeys (TOPLEVEL *w_current)
GTK_RESPONSE_REJECT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->hkwindow), "dialog-name",
+ "hotkeys");
+
gtk_window_position (GTK_WINDOW (w_current->hkwindow),
GTK_WIN_POS_NONE);
@@ -2575,11 +2735,13 @@ void x_dialog_hotkeys (TOPLEVEL *w_current)
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
+ dialog_restore_geometry(w_current->hkwindow);
/* show all recursively */
gtk_widget_show_all(w_current->hkwindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->hkwindow);
gtk_window_present(GTK_WINDOW(w_current->hkwindow));
}
}
@@ -2789,6 +2951,8 @@ char *generic_filesel_dialog (const char *msg, const char *templ, gint flags)
NULL);
}
+ gtk_object_set_data(GTK_OBJECT(dialog), "dialog-name", "generic-filesel");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog),
@@ -2828,6 +2992,8 @@ char *generic_filesel_dialog (const char *msg, const char *templ, gint flags)
g_free (folder);
}
+ dialog_restore_geometry(dialog);
+ puts("---------------------------");
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
result = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
@@ -2838,6 +3004,8 @@ char *generic_filesel_dialog (const char *msg, const char *templ, gint flags)
}
*/
}
+
+ dialog_save_geometry(dialog);
gtk_widget_destroy (dialog);
g_free (title);
@@ -2896,6 +3064,7 @@ void find_text_dialog_response(GtkWidget *w, gint response,
printf("find_text_dialog_response(): strange signal %d\n", response);
}
if (close) {
+ dialog_save_geometry(w_current->tfindwindow);
gtk_widget_destroy(w_current->tfindwindow);
w_current->tfindwindow = NULL;
}
@@ -2931,6 +3100,9 @@ void find_text_dialog(TOPLEVEL * w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->tfindwindow), "dialog-name",
+ "find-text");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->tfindwindow),
@@ -2969,11 +3141,13 @@ void find_text_dialog(TOPLEVEL * w_current)
GLADE_HOOKUP_OBJECT(w_current->tfindwindow, textentry, "textentry");
GLADE_HOOKUP_OBJECT(w_current->tfindwindow, checkdescend, "checkdescend");
-
+
+ dialog_restore_geometry(w_current->tfindwindow);
gtk_widget_show_all(w_current->tfindwindow);
}
else { /* dialog already created */
+ dialog_restore_geometry(w_current->tfindwindow);
gtk_window_present(GTK_WINDOW(w_current->tfindwindow));
}
@@ -3009,6 +3183,7 @@ void hide_text_dialog_response(GtkWidget *w, gint response,
break;
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_DELETE_EVENT:
+ dialog_save_geometry(w_current->thidewindow);
gtk_widget_destroy(w_current->thidewindow);
w_current->thidewindow = NULL;
break;
@@ -3037,6 +3212,9 @@ void hide_text_dialog(TOPLEVEL * w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->thidewindow), "dialog-name",
+ "hide-text");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->thidewindow),
@@ -3070,10 +3248,12 @@ void hide_text_dialog(TOPLEVEL * w_current)
gtk_widget_grab_focus(textentry);
GLADE_HOOKUP_OBJECT(w_current->thidewindow, textentry, "textentry");
+ dialog_restore_geometry(w_current->thidewindow);
gtk_widget_show_all(w_current->thidewindow);
}
else { /* dialog already created, just select it */
+ dialog_restore_geometry(w_current->thidewindow);
gtk_window_present(GTK_WINDOW(w_current->thidewindow));
}
@@ -3109,6 +3289,7 @@ void show_text_dialog_response(GtkWidget *widget, gint response,
break;
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_DELETE_EVENT:
+ dialog_save_geometry(w_current->tshowwindow);
gtk_widget_destroy(w_current->tshowwindow);
w_current->tshowwindow = NULL;
break;
@@ -3137,6 +3318,9 @@ void show_text_dialog(TOPLEVEL * w_current)
GTK_RESPONSE_ACCEPT,
NULL);
+ gtk_object_set_data(GTK_OBJECT(w_current->tshowwindow), "dialog-name",
+ "show-text");
+
#if GTK_CHECK_VERSION (2,6,0)
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->tshowwindow),
@@ -3170,10 +3354,12 @@ void show_text_dialog(TOPLEVEL * w_current)
gtk_widget_grab_focus(textentry);
GLADE_HOOKUP_OBJECT(w_current->tshowwindow, textentry, "textentry");
+ dialog_restore_geometry(w_current->tshowwindow);
gtk_widget_show_all(w_current->tshowwindow);
}
else { /* dialog already created. Show it */
+ dialog_restore_geometry(w_current->tshowwindow);
gtk_window_present(GTK_WINDOW(w_current->tshowwindow));
}
--
1.5.1
More information about the geda-dev
mailing list