From 4d4af2941ea53aea1b2246a1e2e4091f05867e21 Mon Sep 17 00:00:00 2001 From: Jonathan Blandford Date: Fri, 16 Mar 2001 22:59:24 +0000 Subject: [PATCH] s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN Fri Mar 16 18:01:17 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.[ch]: s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN * gtk/gtktreeview.c (gtk_tree_view_row_activated): New signal. * gtk/gtktreeview.c (gtk_tree_view_destroy): moved pretty much everything into the ::destroy function, and freed a lot more. --- ChangeLog | 9 ++ ChangeLog.pre-2-0 | 9 ++ ChangeLog.pre-2-10 | 9 ++ ChangeLog.pre-2-2 | 9 ++ ChangeLog.pre-2-4 | 9 ++ ChangeLog.pre-2-6 | 9 ++ ChangeLog.pre-2-8 | 9 ++ .../reference/gdk-pixbuf/gdk-pixbuf.hierarchy | 1 + gtk/gtktreeview.c | 139 +++++++++++++----- gtk/gtktreeview.h | 13 +- gtk/gtktreeviewcolumn.c | 2 +- gtk/gtktreeviewcolumn.h | 10 +- tests/testtreefocus.c | 4 +- 13 files changed, 184 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3fe552d39..c062c2593d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Mar 16 18:01:17 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.[ch]: s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN + + * gtk/gtktreeview.c (gtk_tree_view_row_activated): New signal. + + * gtk/gtktreeview.c (gtk_tree_view_destroy): moved pretty much + everything into the ::destroy function, and freed a lot more. + 2001-03-16 Havoc Pennington * gtk/gtkwidget.h (struct _GtkWidgetAuxInfo): change to use gint diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index d3fe552d39..c062c2593d 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,12 @@ +Fri Mar 16 18:01:17 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.[ch]: s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN + + * gtk/gtktreeview.c (gtk_tree_view_row_activated): New signal. + + * gtk/gtktreeview.c (gtk_tree_view_destroy): moved pretty much + everything into the ::destroy function, and freed a lot more. + 2001-03-16 Havoc Pennington * gtk/gtkwidget.h (struct _GtkWidgetAuxInfo): change to use gint diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d3fe552d39..c062c2593d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,12 @@ +Fri Mar 16 18:01:17 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.[ch]: s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN + + * gtk/gtktreeview.c (gtk_tree_view_row_activated): New signal. + + * gtk/gtktreeview.c (gtk_tree_view_destroy): moved pretty much + everything into the ::destroy function, and freed a lot more. + 2001-03-16 Havoc Pennington * gtk/gtkwidget.h (struct _GtkWidgetAuxInfo): change to use gint diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index d3fe552d39..c062c2593d 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,12 @@ +Fri Mar 16 18:01:17 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.[ch]: s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN + + * gtk/gtktreeview.c (gtk_tree_view_row_activated): New signal. + + * gtk/gtktreeview.c (gtk_tree_view_destroy): moved pretty much + everything into the ::destroy function, and freed a lot more. + 2001-03-16 Havoc Pennington * gtk/gtkwidget.h (struct _GtkWidgetAuxInfo): change to use gint diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index d3fe552d39..c062c2593d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,12 @@ +Fri Mar 16 18:01:17 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.[ch]: s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN + + * gtk/gtktreeview.c (gtk_tree_view_row_activated): New signal. + + * gtk/gtktreeview.c (gtk_tree_view_destroy): moved pretty much + everything into the ::destroy function, and freed a lot more. + 2001-03-16 Havoc Pennington * gtk/gtkwidget.h (struct _GtkWidgetAuxInfo): change to use gint diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d3fe552d39..c062c2593d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,12 @@ +Fri Mar 16 18:01:17 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.[ch]: s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN + + * gtk/gtktreeview.c (gtk_tree_view_row_activated): New signal. + + * gtk/gtktreeview.c (gtk_tree_view_destroy): moved pretty much + everything into the ::destroy function, and freed a lot more. + 2001-03-16 Havoc Pennington * gtk/gtkwidget.h (struct _GtkWidgetAuxInfo): change to use gint diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d3fe552d39..c062c2593d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,12 @@ +Fri Mar 16 18:01:17 2001 Jonathan Blandford + + * gtk/gtktreeviewcolumn.[ch]: s/GTK_TREE_COLUMN/GTK_TREE_VIEW_COLUMN + + * gtk/gtktreeview.c (gtk_tree_view_row_activated): New signal. + + * gtk/gtktreeview.c (gtk_tree_view_destroy): moved pretty much + everything into the ::destroy function, and freed a lot more. + 2001-03-16 Havoc Pennington * gtk/gtkwidget.h (struct _GtkWidgetAuxInfo): change to use gint diff --git a/docs/reference/gdk-pixbuf/gdk-pixbuf.hierarchy b/docs/reference/gdk-pixbuf/gdk-pixbuf.hierarchy index 9751e84164..3b8038b7dd 100644 --- a/docs/reference/gdk-pixbuf/gdk-pixbuf.hierarchy +++ b/docs/reference/gdk-pixbuf/gdk-pixbuf.hierarchy @@ -4,4 +4,5 @@ GObject GdkDrawableImplX11 GdkWindowImplX11 GdkColormap + GtkRcStyle GdkPixbufLoader diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index fa0a395643..f4e7cf83cd 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -59,6 +59,12 @@ struct _GtkTreeViewChild gint y; }; +enum +{ + ROW_ACTIVATED, + LAST_SIGNAL +}; + enum { PROP_0, @@ -238,10 +244,11 @@ static void gtk_tree_view_clamp_node_visible (GtkTreeView *tree_view, static gboolean gtk_tree_view_maybe_begin_dragging_row (GtkTreeView *tree_view, GdkEventMotion *event); static void _gtk_tree_view_update_col_width (GtkTreeView *tree_view); - +static void gtk_tree_view_row_activated (GtkTreeView *tree_view, + GtkTreeViewColumn *column); static GtkContainerClass *parent_class = NULL; - +static guint tree_view_signals[LAST_SIGNAL] = { 0 }; /* Class Functions */ GtkType @@ -387,6 +394,15 @@ gtk_tree_view_class_init (GtkTreeViewClass *class) gtk_marshal_VOID__OBJECT_OBJECT, GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); + + tree_view_signals[ROW_ACTIVATED] = gtk_signal_new ("row_activated", + GTK_RUN_LAST | GTK_RUN_ACTION, + GTK_CLASS_TYPE (object_class), + GTK_SIGNAL_OFFSET (GtkTreeViewClass, row_activated), + gtk_marshal_VOID__OBJECT, + GTK_TYPE_NONE, 1, + GTK_TYPE_TREE_VIEW_COLUMN); + } static void @@ -428,22 +444,8 @@ gtk_tree_view_finalize (GObject *object) { GtkTreeView *tree_view = (GtkTreeView *) object; - if (tree_view->priv->tree) - _gtk_rbtree_free (tree_view->priv->tree); - - if (tree_view->priv->scroll_to_path != NULL) - gtk_tree_path_free (tree_view->priv->scroll_to_path); - - if (tree_view->priv->drag_dest_row) - gtk_tree_row_reference_free (tree_view->priv->drag_dest_row); - - if (tree_view->priv->anchor) - gtk_tree_row_reference_free (tree_view->priv->anchor); - - if (tree_view->priv->cursor) - gtk_tree_row_reference_free (tree_view->priv->cursor); - g_free (tree_view->priv); + if (G_OBJECT_CLASS (parent_class)->finalize) (* G_OBJECT_CLASS (parent_class)->finalize) (object); } @@ -454,15 +456,61 @@ gtk_tree_view_destroy (GtkObject *object) GtkTreeView *tree_view = (GtkTreeView *) object; GList *list; - if (tree_view->priv->model) - g_object_unref (G_OBJECT (tree_view->priv->model)); - gtk_tree_view_unref_tree (tree_view, tree_view->priv->tree); - for (list = tree_view->priv->columns; list; list = list->next) - g_object_unref (G_OBJECT (list->data)); + if (tree_view->priv->tree != NULL) + { + gtk_tree_view_unref_tree (tree_view, tree_view->priv->tree); + _gtk_rbtree_free (tree_view->priv->tree); + tree_view->priv->tree = NULL; + } - _gtk_tree_selection_set_tree_view (tree_view->priv->selection, NULL); - g_object_unref (tree_view->priv->selection); + if (tree_view->priv->model != NULL) + { + g_object_unref (G_OBJECT (tree_view->priv->model)); + tree_view->priv->model = NULL; + } + + if (tree_view->priv->columns != NULL) + { + for (list = tree_view->priv->columns; list; list = list->next) + g_object_unref (G_OBJECT (list->data)); + g_list_free (tree_view->priv->columns); + tree_view->priv->columns = NULL; + } + + if (tree_view->priv->selection != NULL) + { + _gtk_tree_selection_set_tree_view (tree_view->priv->selection, NULL); + g_object_unref (tree_view->priv->selection); + tree_view->priv->selection = NULL; + } + + if (tree_view->priv->anchor != NULL) + { + gtk_tree_row_reference_free (tree_view->priv->anchor); + tree_view->priv->anchor = NULL; + } + + if (tree_view->priv->scroll_to_path != NULL) + { + gtk_tree_path_free (tree_view->priv->scroll_to_path); + tree_view->priv->scroll_to_path = NULL; + } + + if (tree_view->priv->drag_dest_row != NULL) + { + gtk_tree_row_reference_free (tree_view->priv->drag_dest_row); + tree_view->priv->drag_dest_row = NULL; + } + + if (tree_view->priv->cursor) + { + gtk_tree_row_reference_free (tree_view->priv->cursor); + tree_view->priv->cursor = NULL; + } + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } /* Property handlers @@ -1704,7 +1752,7 @@ gtk_tree_view_button_press (GtkWidget *widget, { GtkTreeView *tree_view; GList *list; - GtkTreeViewColumn *column; + GtkTreeViewColumn *column = NULL; gint i; GdkRectangle background_area; GdkRectangle cell_area; @@ -1724,6 +1772,7 @@ gtk_tree_view_button_press (GtkWidget *widget, gint depth; gint new_y; gint y_offset; + GtkTreeViewColumn *column = NULL; if (!GTK_WIDGET_HAS_FOCUS (widget)) gtk_widget_grab_focus (widget); @@ -1768,10 +1817,12 @@ gtk_tree_view_button_press (GtkWidget *widget, for (i = 0, list = tree_view->priv->columns; i < tree_view->priv->n_columns; i++, list = list->next) { - GtkTreeViewColumn *column = list->data; GtkCellRenderer *cell; GtkTreeIter iter; gboolean visible; + gboolean can_activate; + + column = list->data; if (!column->visible) continue; @@ -1809,14 +1860,16 @@ gtk_tree_view_button_press (GtkWidget *widget, path_string = gtk_tree_path_to_string (path); - g_object_get (G_OBJECT (cell), "visible", &visible, NULL); - if (visible && gtk_cell_renderer_event (cell, - (GdkEvent *)event, - widget, - path_string, - &background_area, - &cell_area, - 0)) + g_object_get (G_OBJECT (cell), + "visible", &visible, + "can_activate", &can_activate, + NULL); + if (visible && + can_activate && + gtk_cell_renderer_event (cell, (GdkEvent *)event, + widget, path_string, + &background_area, + &cell_area, 0)) { g_free (path_string); gtk_tree_path_free (path); @@ -1829,6 +1882,9 @@ gtk_tree_view_button_press (GtkWidget *widget, } } + if (column == NULL) + return FALSE; + /* Save press to possibly begin a drag */ if (tree_view->priv->pressed_button < 0) @@ -1849,6 +1905,11 @@ gtk_tree_view_button_press (GtkWidget *widget, path, event->state); gtk_tree_path_free (path); + + if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) + { + gtk_tree_view_row_activated (tree_view, column ); + } return TRUE; } @@ -2627,6 +2688,16 @@ gtk_tree_view_forall (GtkContainer *container, } } +static void +gtk_tree_view_row_activated (GtkTreeView *tree_view, + GtkTreeViewColumn *column) +{ + g_return_if_fail (tree_view != NULL); + g_return_if_fail (GTK_IS_TREE_VIEW (tree_view)); + + g_signal_emit (G_OBJECT(tree_view), tree_view_signals[ROW_ACTIVATED], 0, column); +} + /* TreeModel Callbacks */ diff --git a/gtk/gtktreeview.h b/gtk/gtktreeview.h index 49ae1a4a82..00b998ae16 100644 --- a/gtk/gtktreeview.h +++ b/gtk/gtktreeview.h @@ -65,11 +65,14 @@ struct _GtkTreeViewClass { GtkContainerClass parent_class; - void (*set_scroll_adjustments) (GtkTreeView *tree_view, - GtkAdjustment *hadjustment, - GtkAdjustment *vadjustment); - gint (*expand_row) (GtkTreeView *tree_view, - GtkTreeIter *iter); + void (* set_scroll_adjustments) (GtkTreeView *tree_view, + GtkAdjustment *hadjustment, + GtkAdjustment *vadjustment); + void (* row_activated) (GtkTreeView *tree_view, + GtkTreeViewColumn *column); + gint (* expand_row) (GtkTreeView *tree_view, + GtkTreeIter *iter); + }; GtkType gtk_tree_view_get_type (void); diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 76ced1d85e..e7347ce07f 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -606,7 +606,7 @@ gtk_tree_view_column_new (void) { GtkTreeViewColumn *retval; - retval = GTK_TREE_VIEW_COLUMN (gtk_type_new (GTK_TYPE_TREE_COLUMN)); + retval = GTK_TREE_VIEW_COLUMN (gtk_type_new (GTK_TYPE_TREE_VIEW_COLUMN)); return retval; } diff --git a/gtk/gtktreeviewcolumn.h b/gtk/gtktreeviewcolumn.h index e59cd3c14b..5de559147d 100644 --- a/gtk/gtktreeviewcolumn.h +++ b/gtk/gtktreeviewcolumn.h @@ -29,11 +29,11 @@ extern "C" { #endif /* __cplusplus */ -#define GTK_TYPE_TREE_COLUMN (gtk_tree_view_column_get_type ()) -#define GTK_TREE_VIEW_COLUMN(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TREE_COLUMN, GtkTreeViewColumn)) -#define GTK_TREE_VIEW_COLUMN_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_COLUMN, GtkTreeViewColumnClass)) -#define GTK_IS_TREE_VIEW_COLUMN(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TREE_COLUMN)) -#define GTK_IS_TREE_VIEW_COLUMN_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TREE_COLUMN)) +#define GTK_TYPE_TREE_VIEW_COLUMN (gtk_tree_view_column_get_type ()) +#define GTK_TREE_VIEW_COLUMN(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TREE_VIEW_COLUMN, GtkTreeViewColumn)) +#define GTK_TREE_VIEW_COLUMN_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_VIEW_COLUMN, GtkTreeViewColumnClass)) +#define GTK_IS_TREE_VIEW_COLUMN(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TREE_VIEW_COLUMN)) +#define GTK_IS_TREE_VIEW_COLUMN_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TREE_VIEW_COLUMN)) typedef enum { diff --git a/tests/testtreefocus.c b/tests/testtreefocus.c index c768a70d54..5df51eb375 100644 --- a/tests/testtreefocus.c +++ b/tests/testtreefocus.c @@ -266,7 +266,6 @@ tim_toggled (GtkCellRendererToggle *cell, gtk_tree_path_free (path); } - int main (int argc, char *argv[]) { @@ -370,10 +369,9 @@ main (int argc, char *argv[]) gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50); g_object_unref (renderer); - gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view); - gtk_widget_show_all (window); + gtk_widget_show_all (window); gtk_main (); return 0;