[525] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: giving focus to windows

daemon@ATHENA.MIT.EDU (Owen Taylor)
Fri Jul 25 11:21:38 1997

To: gtk-list@redhat.com
From: Owen Taylor <owt1@cornell.edu>
Date: 25 Jul 1997 11:21:55 -0400
In-Reply-To: Hoek's message of Fri, 25 Jul 1997 16:52:03 +0200 (MET DST)
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com


Hoek <hoek@pcjeroen.ubu.ruu.nl> writes:

> When you select an option in a menu and a window pops up, and you go to
> another window, the first window looses focus.  What I want is that if
> you select the same option in the menu again, that window will get the focus
> again.  I've looked all day in several sources and tried a lot, but I didn't
> find a solution.

I'm not sure about focus, if by that you mean keyboard focus -
generally the control over which toplevel has the keyboard focus
is left up to the window manager. (People might become upset if 
it changed in unexpected manners.) But one nice thing you can do
in this regard is to raise the window when the item is selected
again. (I think this should be done to all of the GIMP's dialogs.)

An example of doing this follows. (gtk_input_dialog is a widget
for controlling XInput devices.)

Regards,
                                        Owen

void
dialogs_input_devices_cmd_callback (GtkWidget *widget,
				    gpointer   client_data)
{
  static GtkWidget *inputd = NULL;

  if (!inputd)
    {
      inputd = gtk_input_dialog_new();
  
      gtk_signal_connect (GTK_OBJECT(inputd), "destroy",
			  (GtkSignalFunc)input_dialog_destroy_callback, 
			  &inputd);
      gtk_widget_show (inputd);
    }
  else
    {
      if (!GTK_WIDGET_MAPPED(inputd))
	gtk_widget_show(inputd);
      else
	gdk_window_raise(inputd->window);
    }
}

void
input_dialog_destroy_callback (GtkWidget *w, 
			       gpointer call_data)
{
  *((GtkWidget **)call_data) = NULL;
}

--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post