[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Quasi modal application window
- From: Kent Schumacher <kent structural-wood com>
- To: gtk-app-devel-list redhat com
- Subject: Re: Quasi modal application window
- Date: Tue, 03 Aug 1999 07:27:43 -0500
Havoc Pennington wrote:
> On Mon, 2 Aug 1999, Kent Schumacher wrote:
> >
> > I would also like to have a single 'stop' button that is active - the pointer should turn back to an 'active'
> > pointer when positioned over this button. All of the rest of the gui for the applications window should not
> > respond to mouse clicks
> >
> > Any thoughts on how to achieve this behavior?
> >
>
> Just gtk_grab_add() the stop button.
>
> Havoc
I'm seeing an odd thing with gtk_grab_add. After grabbing the
stop button, I can click on another gtk button in the application and
nothing happens (which is what I want). If I then move to a third button,
it changes color, and if I click on it it sends the 'clicked' signal.
This is definitely not what I want.
Here is a demo app: To demonstrate the problem, click on 'locker',
click on 'button 1', click on 'button 2'. Button 2 will light up and
emit a 'clicked' signal.
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
static int locked_=0;
static void click_cb(GtkWidget *w, gpointer data) {
fprintf(stderr,"click_cb: %s clicked\n",data);
if (strcmp(data,"locker") == 0) {
if (locked_) {
fprintf(stderr,"click_cb: Removing grab\n");
gtk_grab_remove(w);
} else {
fprintf(stderr,"click_cb: Adding grab\n");
gtk_grab_add(w);
}
locked_ = (! locked_);
}
}
int main(int argc, char *argv[]) {
GtkWidget *window,*hbox,*button,*locker;
gtk_init(&argc,&argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window),"delete_event",gtk_main_quit,NULL);
hbox = gtk_hbox_new(0,5);
locker = gtk_button_new_with_label("Locker");
gtk_widget_show(locker);
gtk_box_pack_start(GTK_BOX(hbox),locker,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(locker),"clicked",click_cb,"locker");
button = gtk_button_new_with_label("button 1");
gtk_widget_show(button);
gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(button),"clicked",click_cb,"button 1");
button = gtk_button_new_with_label("button 2");
gtk_widget_show(button);
gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(button),"clicked",click_cb,"button 2");
gtk_container_add(GTK_CONTAINER(window),hbox);
gtk_widget_show(hbox);
gtk_widget_show(window);
gtk_main();
return(1);
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]