Re: Dialogue Screen Placement



Below is a small program demonstrating my problem.

My window manager is Gnome v2.10.0.

In the program, I have set both the main window and the dialogue window to
be positioned at the center of the screen.  Interestingly, for the main
window, this works fine; it is only for the dialogue that the position
command seems to be ignored.

Any ideas why this is behaving so?

All thoughts/input appreciated.

cheers,

richard boaz


=== BEGIN PROGRAM ==============

#include <gtk/gtk.h>
int nums[3] = {0, 1, 2};
void doDialogue(GtkButton *but, int *action)
{
  static GtkWidget *dialogue;
  GtkWidget *button;

  switch(*action)
  {
    case 0:  // make and realize dialogue widget
      if (!dialogue)
      {
        dialogue = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (dialogue, "destroy", G_CALLBACK (doDialogue), &nums[2]);
	button = gtk_button_new_with_label("Cancel");
	g_signal_connect((button), "clicked", G_CALLBACK(doDialogue), &nums[1]);
	gtk_container_add(GTK_CONTAINER (dialogue), button);
	gtk_widget_show_all(dialogue);
      }
      gtk_window_set_position(GTK_WINDOW (dialogue), GTK_WIN_POS_CENTER);
      gtk_widget_show(dialogue);
    break;

    case 1:  // hide the dialogue
      gtk_widget_hide(dialogue);
    break;

    case 2:  // dialogue has been destroyed, record
      dialogue = NULL;
    break;
  }
}

int main(int argc, char **argv)
{
  GtkWidget	*mainWin, *button;

  gtk_init(&argc, &argv);
  mainWin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (mainWin, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  button = gtk_button_new_with_label("Dialogue");
  g_signal_connect((button), "clicked", G_CALLBACK(doDialogue), &nums[0]);
  gtk_container_add(GTK_CONTAINER (mainWin), button);

  gtk_window_resize (GTK_WINDOW (mainWin), 250, 250);
  gtk_window_set_position(GTK_WINDOW (mainWin), GTK_WIN_POS_CENTER);
  gtk_widget_show_all(mainWin);

  gtk_main();
}

======== END PROGRAM ============




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