Pixmaps - strange blinks



Hello all.
I made a routine in my application that make a pixmap to blink (this
swap two pixmaps with same picture but diferent colors in a time
interval when a function is triggered), to make this I used
gtk_timeout_add, but when the program is running, sometimes (randon) the
pixmap blink quickly (appears as a "bad contact"), now I optmize these
functions but the results is the same problem, I believe that this
happens when the system do something (reading HD, I don't know) while
loading pixmap file, if I do this in a thread that make this will work
well ???

Very thanks for any help and excuse-me for my bad english.


.
.
.

int
dispara_pisca_ligada(gpointer user_data, gchar *nome_pixmap, gchar
*file_pixmap)
{

  if(piscando != TRUE)
    {
      troca_pixmap(user_data, nome_pixmap, file_pixmap);
#if PISCA_YES == 1
      gtk_timeout_remove(t_inverte);
      t_inverte = gtk_timeout_add( TEMPO_PISCA, time_out_inverte,
user_data );
#endif
    }
      return 0;
}



gint
time_out_inverte(gpointer dados)
{
      if(pisca_ligado == TRUE)
	{
	  troca_pixmap(dados, "pixmap_operacao", "ihm_princ/operacao_brc.xpm");
	  pisca_ligado = FALSE;
	}
      else
	{
	  troca_pixmap(dados, "pixmap_operacao", "ihm_princ/operacao.xpm");
	  pisca_ligado = TRUE;
	}
      return TRUE;
}

/* troca_pixmap( ) - function based in create_pixmap( ) from support.c
by Glade */
/* thanks by Glade */

int
troca_pixmap(gpointer user_data, char *nome_pixmap, char *filename)
{

  GtkWidget *pixmap;
  GdkColormap *colormap;
  GdkPixmap *gdkpixmap;
  GdkBitmap *mask;
  gchar *pathname;

  pixmap = lookup_widget(user_data, nome_pixmap);

  if (!filename || !filename[0])
      return -1;

  pathname = gnome_pixmap_file (filename);
  if (!pathname)
    {
      g_warning (_("Couldn't find pixmap file: %s"), filename);
      return -1;
    }

  colormap = gtk_widget_get_colormap (user_data);
  gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap,
&mask,
                                                   NULL, pathname);
  if (gdkpixmap == NULL)
    {
      g_warning (_("Couldn't create pixmap from file: %s"), pathname);
      g_free (pathname);
      return -1;
    }
  g_free (pathname);

  gtk_pixmap_set(GTK_PIXMAP(pixmap), gdkpixmap, mask);
  gdk_pixmap_unref (gdkpixmap);
  gdk_bitmap_unref (mask);
  return 1;
}

.
.
.




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