tBetter handling of modal dialogs in Win32 client - vaccinewars - be a doctor and try to vaccinate the world
(HTM) git clone git://src.adamsgaard.dk/vaccinewars
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit d84f46d131db94637615682f63fd7fa2b3a1ea62
(DIR) parent 4a3ce3af455ee57661a4722045e6ef8b0985ca90
(HTM) Author: Ben Webb <ben@salilab.org>
Date: Wed, 13 Dec 2000 10:12:07 +0000
Better handling of modal dialogs in Win32 client
Diffstat:
M src/gtk.c | 35 +++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 9 deletions(-)
---
(DIR) diff --git a/src/gtk.c b/src/gtk.c
t@@ -1243,7 +1243,7 @@ void gtk_editable_insert_text(GtkEditable *editable,const gchar *new_text,
gint new_text_length,gint *position) {
GtkWidget *widget=GTK_WIDGET(editable);
HWND hWnd;
- gint i,textlen;
+ gint i;
gtk_editable_sync_text(editable);
g_string_insert(editable->text,*position,new_text);
t@@ -1373,14 +1373,30 @@ void gtk_box_destroy(GtkWidget *widget) {
g_list_free(GTK_BOX(widget)->children);
}
+static void EnableParent(GtkWindow *window) {
+ GSList *list;
+ GtkWidget *parent;
+ GtkWindow *listwin;
+
+ parent=GTK_WIDGET(window)->parent;
+ if (window->modal && parent) {
+ for (list=WindowList;list;list=g_slist_next(list)) {
+ listwin=GTK_WINDOW(list->data);
+ if (listwin!=window && listwin->modal &&
+ GTK_WIDGET_VISIBLE(GTK_WIDGET(listwin)) &&
+ GTK_WIDGET(listwin)->parent==parent) return;
+ }
+ gtk_widget_set_sensitive(parent,TRUE);
+ }
+}
+
void gtk_window_destroy(GtkWidget *widget) {
GtkWindow *window=GTK_WINDOW(widget);
// g_print("gtk_window_destroy on widget %p\n",widget);
- WindowList=g_slist_remove(WindowList,(gpointer)widget->hWnd);
+ WindowList=g_slist_remove(WindowList,(gpointer)window);
gtk_container_destroy(widget);
g_free(GTK_WINDOW(widget)->title);
- if (window->modal && widget->parent)
- gtk_widget_set_sensitive(widget->parent,TRUE);
+ EnableParent(window);
if (widget->hWnd) DestroyWindow(widget->hWnd);
widget->hWnd=NULL;
}
t@@ -1393,8 +1409,7 @@ void gtk_window_show(GtkWidget *widget) {
void gtk_window_hide(GtkWidget *widget) {
GtkWindow *window=GTK_WINDOW(widget);
- if (window->modal && widget->parent)
- gtk_widget_set_sensitive(widget->parent,TRUE);
+ EnableParent(window);
}
void gtk_hbox_size_request(GtkWidget *widget,
t@@ -1551,7 +1566,7 @@ void gtk_window_realize(GtkWidget *widget) {
widget->allocation.width,widget->allocation.height,
Parent,NULL,hInst,NULL);
if (win->type==GTK_WINDOW_TOPLEVEL && !TopLevel) TopLevel=widget->hWnd;
- WindowList=g_slist_append(WindowList,(gpointer)widget->hWnd);
+ WindowList=g_slist_append(WindowList,(gpointer)win);
gtk_set_default_font(widget->hWnd);
/* g_print("Window window %p created\n",widget->hWnd);*/
gtk_container_realize(widget);
t@@ -2393,10 +2408,12 @@ void gtk_main() {
while (GetMessage(&msg,NULL,0,0)) {
MsgDone=FALSE;
- widget=GTK_WIDGET(GetWindowLong(msg.hwnd,GWL_USERDATA));
for (list=WindowList;list && !MsgDone;list=g_slist_next(list)) {
- if ((MsgDone=IsDialogMessage((HWND)list->data,&msg))==TRUE) break;
+ widget=GTK_WIDGET(list->data);
+ if (widget && widget->hWnd &&
+ (MsgDone=IsDialogMessage(widget->hWnd,&msg))==TRUE) break;
}
+ widget=GTK_WIDGET(GetWindowLong(msg.hwnd,GWL_USERDATA));
if (!MsgDone && widget && GTK_OBJECT(widget)->klass==&GtkWindowClass) {
hAccel=GTK_WINDOW(widget)->hAccel;
if (hAccel) MsgDone=TranslateAccelerator(widget->hWnd,hAccel,&msg);