De-select a tree_view's line with cursor



Dear,

I made a function that allow to deselect a line by clicking in a blank area.
Don't you think it's a good idea to allow that by default ?
Plus, I don't know where to put that in the source.

Actually, I do :

<signal name="button-press-event" handler="common_gtk_treeview_button_press_unselect"/>



gboolean common_gtk_treeview_button_press_unselect (GtkTreeView *widget, GdkEvent *event, Projet *p)
{
  if (event->type == GDK_BUTTON_PRESS)
    {
      GdkEventButton *event_button = (GdkEventButton *) event;

      if (!gtk_tree_view_get_path_at_pos (widget, (gint) event_button->x, (gint) event_button->y, NULL, NULL, NULL, NULL))
        {
          GtkTreeIter Iter;
          if (gtk_tree_selection_get_mode (gtk_tree_view_get_selection (widget)) == GTK_SELECTION_MULTIPLE)
            gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (widget));
          else if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (widget), NULL, &Iter))
            gtk_tree_selection_unselect_iter (gtk_tree_view_get_selection (widget), &Iter);
        }
    }

  return FALSE;
}



Regards,
Vincent.


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