Re: [gtk-list] signals, objects, user_data and stuff.



On 28 Mar 2000, Thomas Mailund wrote:

> 
> Hi all.
> 
> static void
> connector_moved (Connector *conn, gdouble dx, gdouble dy)
> {
>   <<move "the right" point>>
> }
> 
> (here the (dx,dy) are parameters from the nodes "moved" signal).
> 
> Of course, getting "the right point" is the tricky one.  If I only
> have two points on a connector, i.e. connectors are straight lines
> between nodes, I can hack it doing something like
> 
>   gtk_signal_connect_object (GTK_OBJECT (node1), "moved",
> 			     GTK_SIGNAL_FUNC (connector_moved1),
> 			     GTK_OBJECT (connector));
>   gtk_signal_connect_object (GTK_OBJECT (node2), "moved",
> 			     GTK_SIGNAL_FUNC (connector_moved2),
> 			     GTK_OBJECT (connector));
> 
> static void
> connector_moved1 (Connector *conn, gdouble dx, gdouble dy)
> {
>   connector_move_point (conn, 1);
> }
> 
> static void
> connector_moved2 (Connector *conn, gdouble dx, gdouble dy)
> {
>   connector_move_point (conn, 2);
> }

i'm not sure this solves your problem, but even for connect_object handlers,
you get a gpointer data; argument. it's the object that the signal is
emitted upon, so if you already have a nodeX->intX association, you're set:

  gtk_signal_connect_object (GTK_OBJECT (node1), "moved",
			     GTK_SIGNAL_FUNC (connector_moved1),
			     GTK_OBJECT (connector));
  gtk_signal_connect_object (GTK_OBJECT (node2), "moved",
			     GTK_SIGNAL_FUNC (connector_moved2),
			     GTK_OBJECT (connector));

static void
connector_moved1 (Connector *conn, gdouble dx, gdouble dy, Node *node1)
{
  connector_move_point (conn, get_connection_id (conn, node1));
}

static void
connector_moved2 (Connector *conn, gdouble dx, gdouble dy, Node *node2)
{
  connector_move_point (conn, get_connection_id (conn, node2));
}


---
ciaoTJ



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