Re: Getting the "busy" cursor to display.



On 10 April 2012 18:33, James Tappin <jtappin gmail com> wrote:
Thanks for the suggestion. Unfortunately in this case it doesn't help. (I
have also tried gdk_display_flush and gdk_window_flush, but still the same
story).

Here's a tiny test program that works for me with gtk2. It just uses:

  gdk_window_set_cursor( win->window, busy_cursor );
  gdk_flush();

J

-------
/* compile with
 *      gcc try80.c `pkg-config gtk+-2.0 --cflags --libs`
 */

#include <gtk/gtk.h>

GdkCursor *busy_cursor = NULL;

void
on_close_clicked (GtkButton * button, gpointer user_data)
{
  GtkWidget *win = GTK_WIDGET (user_data);

  gtk_widget_destroy (win);
}

void
on_open_clicked (GtkButton * button, gpointer user_data)
{
  GtkWidget *win = GTK_WIDGET (user_data);

  gdk_window_set_cursor (win->window, busy_cursor);
  gdk_flush ();
  sleep (1);
  gdk_window_set_cursor (win->window, NULL);
}

GtkWidget *
create_window1 (void)
{
  GtkWidget *win;
  GtkWidget *but;
  GtkWidget *align;
  GtkWidget *hbox;

  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (win), 200, 200);

  align = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_container_add (GTK_CONTAINER (win), align);
  gtk_widget_show (align);

  hbox = gtk_hbox_new (FALSE, 2);
  gtk_container_add (GTK_CONTAINER (align), hbox);
  gtk_widget_show (hbox);

  but = gtk_button_new_from_stock (GTK_STOCK_OPEN);
  gtk_box_pack_start (GTK_BOX (hbox), but, FALSE, FALSE, 2);
  g_signal_connect (but, "clicked", G_CALLBACK (on_open_clicked), win);
  gtk_widget_show (but);

  but = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
  gtk_box_pack_start (GTK_BOX (hbox), but, FALSE, FALSE, 2);
  g_signal_connect (but, "clicked", G_CALLBACK (on_close_clicked), win);
  gtk_widget_show (but);

  return win;
}

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

  gtk_init (&argc, &argv);

  busy_cursor = gdk_cursor_new (GDK_WATCH);

  window1 = create_window1 ();
  gtk_widget_show (window1);
  g_signal_connect (window1, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  gtk_main ();

  return 0;
}
-----------------



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