static gboolean gossip_cell_renderer_expander_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path_string, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) { GossipCellRendererExpander *expander; GossipCellRendererExpanderPriv *priv; GtkTreePath *path; gboolean animate; gboolean expanding; expander = GOSSIP_CELL_RENDERER_EXPANDER (cell); priv = GET_PRIV (cell); if (!GTK_IS_TREE_VIEW (widget) || !priv->activatable) return FALSE; path = gtk_tree_path_new_from_string (path_string); if (gtk_tree_path_get_depth (path) > 1) { gtk_tree_path_free (path); return TRUE; } g_object_get (gtk_widget_get_settings (GTK_WIDGET (widget)), "gtk-enable-animations", &animate, NULL); if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) { gtk_tree_view_collapse_row (GTK_TREE_VIEW (widget), path); expanding = FALSE; } else { gtk_tree_view_expand_row (GTK_TREE_VIEW (widget), path, FALSE); expanding = TRUE; } if (animate) { gossip_cell_renderer_expander_start_animation (expander, GTK_TREE_VIEW (widget), path, expanding, background_area); } gtk_tree_path_free (path); return TRUE; }
static gboolean gossip_cell_renderer_expander_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path_string, const GdkRectangle *background_area, const GdkRectangle *cell_area, GtkCellRendererState flags) { GossipCellRendererExpander *expander; GossipCellRendererExpanderPriv *priv; GtkTreePath *path; GtkSettings *settings; gboolean animate = FALSE; gboolean expanding; gboolean in_cell; int mouse_x; int mouse_y; expander = GOSSIP_CELL_RENDERER_EXPANDER (cell); priv = GET_PRIV (cell); if (!GTK_IS_TREE_VIEW (widget) || !priv->activatable) return FALSE; path = gtk_tree_path_new_from_string (path_string); gtk_widget_get_pointer (widget, &mouse_x, &mouse_y); gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget), mouse_x, mouse_y, &mouse_x, &mouse_y); /* check if click is within the cell */ if (mouse_x - cell_area->x >= 0 && mouse_x - cell_area->x <= cell_area->width) { in_cell = TRUE; } else { in_cell = FALSE; } if (! in_cell) { return FALSE; } #if 0 if (gtk_tree_path_get_depth (path) > 1) { gtk_tree_path_free (path); return TRUE; } #endif settings = gtk_widget_get_settings (GTK_WIDGET (widget)); if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings), "gtk-enable-animations")) { g_object_get (settings, "gtk-enable-animations", &animate, NULL); } if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) { gtk_tree_view_collapse_row (GTK_TREE_VIEW (widget), path); expanding = FALSE; } else { gtk_tree_view_expand_row (GTK_TREE_VIEW (widget), path, FALSE); expanding = TRUE; } if (animate) { gossip_cell_renderer_expander_start_animation (expander, GTK_TREE_VIEW (widget), path, expanding, background_area); } gtk_tree_path_free (path); return TRUE; }