Re: gtk_ctree_is_hot_spot with GtkTreeView
- From: John Ellis <johne verizon net>
- To: gtk-list <gtk-list gnome org>
- Subject: Re: gtk_ctree_is_hot_spot with GtkTreeView
- Date: Fri, 21 May 2004 16:31:05 -0400
"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 verizon net>
http://gqview.sourceforge.net <GQview> | http://gqapplets.sourceforge.net
http://gqmpeg.sourceforge.net <GQmpeg> | <panel applets>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]