Re: [gtk-list] giving focus to windows




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;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]