RE: gtk_window_move

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

 



You are misunderstanding one of the basic principles of event driven
programming.  None of the events (window show, window move, user button
click, etc...) are processed until gtk_main() starts the event loop.
Each event is handled in one iteration of the event loop.  Your code is
queuing some shows and moves with sleeps in between, then it calls
gtk_main() to start processing events.  So, it is quickly processing
your queued events one after the other.

There are a few ways to get the behavior you desire.  Here is one
pseudo-code-ish solution:

bool timeoutCb() {
  gtk_window_move();
  if(done annoying the user)
    return false;
  return true;
}

main() {
  ...
  gtk_window_show();
  g_timeout_add(5000, &timeoutCb);
  gtk_main();
}

-Anthony Vallone


-----Original Message-----
From: gtk-list-bounces@xxxxxxxxx [mailto:gtk-list-bounces@xxxxxxxxx] On
Behalf Of Craig Harding
Sent: Wednesday, June 18, 2008 7:07 AM
To: gtk-list@xxxxxxxxx
Subject: gtk_window_move

I'm trying to move a gtk window multiple times within a period of time
but it seems that it doesn't update the window position for each window
move until gtk_main() is called and then all window moves are done at
once it seems. I want to move a window with a usleep call inbetween
window moves.

Can any provide me with some guidance? Is there a flush or update call
I'm missing?

Below is my code..

#include <gdk/gdk.h>
#include <gtk/gtk.h>

int main (int argc, char **argv) {

   GtkWidget *window;
   int w=200, h=200;
   int x, y;

   x=100;
   y=50;

   gtk_init(&argc, &argv);
   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_widget_show_all(window);
   g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit,
NULL);
   usleep(500000);
   printf("sleep fnished\n");
   gtk_widget_show(window);
   gtk_window_resize (GTK_WINDOW (window), w, h);
   usleep(500000);
   printf("sleep fnished\n");
   gtk_window_move (GTK_WINDOW (window), x, y);

   usleep(500000);
   gtk_widget_show(window);
   gtk_window_resize (GTK_WINDOW (window), w+300, h);

   printf("gtk_main()\n");
   gtk_main();

   return 0;
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux