RE: global cursor setting?



Havoc,

Thanks for pointing out the memory leak, I had written the code this way to
ensure that my problem wasn't due to a variable not being set properly.
Here is the code segement where I set the cursor in file gtkfilesel.c.  

static void
gtk_file_selection_populate (GtkFileSelection *fs,
			     gchar            *rel_path,
			     gint              try_complete)
{
  CompletionState *cmpl_state;
  PossibleCompletion* poss;
  gchar* filename;
  gint row;
  gchar* rem_path = rel_path;
  gchar* sel_text;
  gchar* text[2];
  gint did_recurse = FALSE;
  gint possible_count = 0;
  gint selection_index = -1;
  gint file_list_width;
  gint dir_list_width;
  
  g_return_if_fail (fs != NULL);
  g_return_if_fail (GTK_IS_FILE_SELECTION (fs));
  
  /* Changing cursor to let user know application is busy */
  if ( GTK_WIDGET(fs)->window != NULL )
	gdk_window_set_cursor(GTK_WIDGET(fs)->window,
gdk_cursor_new(GDK_WATCH));

  cmpl_state = (CompletionState*) fs->cmpl_state;
  poss = cmpl_completion_matches (rel_path, &rem_path, cmpl_state);

  ...

  if (!did_recurse)
    {
  /* Changing cursor to let user know application is ready */
  if ( GTK_WIDGET(fs)->window != NULL )
	gdk_window_set_cursor(GTK_WIDGET(fs)->window, 0);
    }


					-- Stupid Genius
> ----------
> From: 	Havoc Pennington[SMTP:hp redhat com]
> Sent: 	Thursday, January 11, 2001 11:27 PM
> To: 	Dugas, Alan
> Cc: 	gtk-app-devel-list gnome org; gtk-list gnome org
> Subject: 	Re: global cursor setting?
> 
> 
> "Dugas, Alan" <alan dugas analog com> writes:
> > Does anyone know how to go about setting a window containing multple
> widgets
> > to have a single cursor?  I am currently trying to modify the
> gtkfilesel.c
> > file to change the cursor to a GDK_WATCH regardless of which widget the
> > cursor is over while performing filename completion stuff using;
> > 
> > gdk_window_set_cursor(GTK_WIDGET(fs)->window,
> > gdk_cursor_new(GDK_WATCH));
> 
> Note the memory leak there; unlike GtkObject subclasses, there is no
> "floating" flag on a GdkCursor. You need to gdk_cursor_destroy() the
> cursor after you pass it to set_cursor.
> 
> > The code compiles fine, but the cursor does not change at all when I run
> the
> > code?!?!?  Any suggestions would be greatly appreciated.
> > 
> 
> Hard to say without seeing the code - are you doing this in the
> _realize function? Do any other widgets set an explicit cursor
> (e.g. GtkEntry sets the I-beam)? If so you have to explicitly change
> the cursor for those widgets to NULL (NULL means "use cursor from
> parent").
> 
> Havoc
> 




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