when are "delete_event" and "motion_notify_event" called?



Hello All,
  I am a gtk newbie working on a widget which consists of 16 toggle buttons in an hbox.  I have sucessfully stopped the emission of the "event" and button_press/release signals on the toggle buttons and set up a callback to these events which returns FALSE.  This passes the signals to parent hbox where I can trap them successfully.  The point is to allow the user to make multiple toggle buttons ACTIVE (pushed in) in one mouse stroke by dragging the mouse across the hbox, rather than clicking on each button individually.

*motion_notify_event*
  To make it work appropriately, I wanted the buttons to activate as the pointer was dragged over then, so I thought I needed a callback to "motion_notify_event".  Unfortunately it looks like the toggle buttons and hbox don't emit this signal.  Simply using "button_pressed/released_event" will force me to activate all the buttons at once.  What would list members recommend to fufill this requirement?

*delete_event*
  Since I am using events emitted from the hbox, I g_malloc() an array of the 16 toggle buttons and pass it as a parameter in the above-mentioned callbacks.  This works well, but I'm not sure where to g_free the array.  I bound a callback to "delete_event" and "destroy_event" on the hbox, but when I place a g_print() message in these callbacks, it is never written to the terminal.  Why would a widget never recieve these events, and where should I go about destroying the array? The array must be allocated so it is resident in memory as long as the widget is.

Thank you for your time! (*code snippet below*)

/* this function returns the widget which is embedded in the bay */
GtkWidget* bay_embed_widget()
{
  GtkWidget *hbox;              /* master container */
  GtkWidget **toggle;
  GdkColor col;
  gint i;
  /* allocate array of toggle button pointers */
  toggle = g_malloc(sizeof(GtkWidget *) * 16);
  /* holds the buttons */
  hbox = gtk_hbox_new(FALSE, 0);
  /* add the buttons */
  for(i=0; i<16; i++)
    {
      toggle[i] = GTK_WIDGET(gtk_toggle_button_new());
      /* disconnect toggle so that it floats to parent, the callback does emit_stop_by_name and returns false */
      g_signal_connect(G_OBJECT(toggle[i]), "event", G_CALLBACK(stepseq_block_event), "event");
      g_signal_connect(G_OBJECT(toggle[i]), "button_press_event", G_CALLBACK(stepseq_block_event), "button_press_event");
      g_signal_connect(G_OBJECT(toggle[i]), "button_release_event", G_CALLBACK(stepseq_block_event), "button_release_event");

      /* disable annoying prelight by trapping signals */
      g_signal_connect(G_OBJECT(toggle[i]), "state_changed", G_CALLBACK(stepseq_toggle_state_changed), NULL);
 
      /* set inital size etc. */
      /* place in hbox */
      gtk_box_pack_start(GTK_BOX(hbox), toggle[i], FALSE, TRUE, 0);
      gtk_widget_show(toggle[i]);
    }
  /* replace effect of toggle buttons, killed before */
  g_signal_connect(G_OBJECT(hbox), "button_press_event", G_CALLBACK(stepseq_box_button_press_event), toggle);
  g_signal_connect(G_OBJECT(hbox), "button_release_event", G_CALLBACK(stepseq_box_button_release_event), toggle);
  /* it seems that this is never called! */
  g_signal_connect(G_OBJECT(hbox), "delete_event", G_CALLBACK(stepseq_box_button_delete_event), toggle);

  return hbox;
}
-- 
______________________________________________
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze



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