Re: gtk_ctree_is_hot_spot with GtkTreeView

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

 



"Ian King [ES]" wrote:
> 
> Hi,
> 
> Is it possible to replicate the behavior of gtk_ctree_is_hot_spot with a
> GtkTreeView, I would like to know if a button press event  has occurred
> on the expander in a GtkTreeView.


In GQview I use something like this:


gint vdtree_clicked_on_expander(GtkTreeView *treeview, GtkTreePath *tpath,
                                GtkTreeViewColumn *column,
                                gint x, gint y, gint *left_of_expander)
{
  gint depth;
  gint size = 0;
  gint sep = 0;
  gint exp_width;

  if (column != gtk_tree_view_get_expander_column(treeview)) return FALSE;

  gtk_widget_style_get(GTK_WIDGET(treeview),
                       "expander-size", &size,
                       "horizontal-separator", &sep,
                       NULL);
  depth = gtk_tree_path_get_depth(tpath);

  exp_width = sep + size + sep;

  if (x <= depth * exp_width)
    {
    if (left_of_expander)
      {
      *left_of_expander = !(x >= (depth - 1) * exp_width);
      }
    return TRUE;
    }

  return FALSE;
}

/* button_press_event handler */
gint vdtree_press_cb(GtkWidget *widget,
                     GdkEventButton *bevent, gpointer data)
{
  GtkTreePath *tpath;
  GtkTreeViewColumn *column;

  if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
                                    bevent->x, bevent->y,
                                    &tpath, &column, NULL, NULL))
    {
    gint on_expander;
    gint left_of;

    on_expander = vdtree_clicked_on_expander(GTK_TREE_VIEW(widget),
                                             tpath, column,
                                             bevent->x, bevent->y,
                                             &left_of);

    if (on_expander && !left_of) printf("on expander\n");
    if (on_expander && left_of) printf("on expander region, but left of
expander\n);
    }
}


Greetings,
John


-- 
John Ellis <johne@xxxxxxxxxxx>

http://gqview.sourceforge.net <GQview> | http://gqapplets.sourceforge.net
http://gqmpeg.sourceforge.net <GQmpeg> |                  <panel applets>
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux