Re: [gtk-list] window placement upon startup





On Tue, 28 Sep 1999, Robert Roebling wrote:

> 
>   Hi,
> 
> how do I position a dialog or window when showing
> it for the first time using GTK 1.2.3 and the 
> window manager from KDE 1.0. I have no problems
> positioing it after it gets mapped, but that
> entails that the dialog comes up just about anywhere
> in screen and then gets moved to the correct place
> (usually centered) - which, of course, looks ridiculous.
> 
> Thanks for any advice,
> 
>   Robert
> 


Hi Robert,

I am using KDE 1.1.1 (one that comes with slackware 4.0) and
glib-1.2.5/gtk+-1.2.5 and the following codes puts the main 
window exactly at (200,400) when the program starts for the 
first time. 

MKK

------------------ start of codes ------------------

#include <gtk/gtk.h>

void destroy(GtkWidget *widget, gpointer data) {
  gtk_main_quit();
}

GtkWidget* create_wnd_main () {
  GtkWidget *wnd_main; 
  GtkWidget *vbox; 
  GtkWidget *btn_OK; 

  wnd_main = gtk_window_new (GTK_WINDOW_TOPLEVEL); 
  gtk_widget_set_uposition (wnd_main, 200, 400); 
  gtk_window_set_title (GTK_WINDOW (wnd_main), "Main window"); 
  gtk_window_set_default_size (GTK_WINDOW (wnd_main), 200, 200); 

  vbox = gtk_vbox_new (FALSE, 0); 
  gtk_widget_show (vbox); 
  gtk_container_add (GTK_CONTAINER (wnd_main), vbox); 

  btn_OK = gtk_button_new_with_label ("|>> OK <<|"); 
  gtk_widget_show (btn_OK); 
  gtk_box_pack_start (GTK_BOX (vbox), btn_OK, FALSE, FALSE, 10); 
  gtk_container_set_border_width (GTK_CONTAINER (btn_OK), 30); 

  gtk_signal_connect (GTK_OBJECT (wnd_main), "destroy",
                      GTK_SIGNAL_FUNC (destroy), NULL); 
  gtk_signal_connect (GTK_OBJECT (btn_OK), "clicked",
                      GTK_SIGNAL_FUNC (destroy), NULL); 

  return wnd_main;
}

int main (int argc, char *argv[])  {
  GtkWidget *wnd_main; 

  gtk_init (&argc, &argv); 

  wnd_main = create_wnd_main (); 
  gtk_widget_show (wnd_main); 

  gtk_main (); 

  return 0;
}
-------------- end of codes ----------------



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