GtkTreeView "activate" signal patch
- From: Mikael Hermansson <tyan linux se>
- To: gtk-devel-list gnome org
- Cc: jrb redhat com
- Subject: GtkTreeView "activate" signal patch
- Date: Fri, 16 Mar 2001 15:00:33 +0100
I proposed to add a signal when doubleclick on an treeitem.
Reason:
To make it simple for the application programmer
to do what he/she wants when doubleclick an item instead
of using the hard way by connect to "button_press_event"
Here is a patch implementing this by adding a "activate"
signal. There should probadly also be an keybinding signal
for this but I am not sure how this could be implemented.
Looks like GtkBinding only takes signals as arguments
but this leads to an problem because I need to check
if there is an item selected before the "activate" signal is
emited?
Is this patch ok to submit?
Index: gtk+/gtk/gtktreeview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktreeview.c,v
retrieving revision 1.56
diff -u -r1.56 gtktreeview.c
--- gtk+/gtk/gtktreeview.c 2001/03/15 23:21:39 1.56
+++ gtk+/gtk/gtktreeview.c 2001/03/16 12:52:12
@@ -59,6 +59,12 @@
gint y;
};
+enum
+{
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
enum {
PROP_0,
@@ -239,7 +245,9 @@
GdkEventMotion
*event);
static void _gtk_tree_view_update_col_width (GtkTreeView
*tree_view);
+static void gtk_tree_view_activate(GtkTreeView *tree_view);
+static guint tree_view_signals[LAST_SIGNAL] = { 0 };
static GtkContainerClass *parent_class = NULL;
@@ -319,6 +327,7 @@
container_class->remove = gtk_tree_view_remove;
container_class->focus = gtk_tree_view_focus;
+ class->activate = NULL;
class->set_scroll_adjustments = gtk_tree_view_set_adjustments;
g_object_class_install_property (o_class,
@@ -387,6 +396,13 @@
gtk_marshal_VOID__OBJECT_OBJECT,
GTK_TYPE_NONE, 2,
GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
+
+ gtk_signal_new ("activate",
+ GTK_RUN_LAST | GTK_RUN_ACTION,
+ GTK_CLASS_TYPE (object_class),
+ GTK_SIGNAL_OFFSET (GtkTreeViewClass, activate),
+ gtk_marshal_VOID__VOID,
+ GTK_TYPE_NONE, 0);
}
static void
@@ -506,6 +522,20 @@
}
static void
+gtk_tree_view_activate (GtkTreeView *tree_view)
+{
+ GtkTreeIter dummyiter;
+ g_return_if_fail (tree_view != NULL);
+ g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
+
+ /* TODO: How about implementing an gtk_tree_selection_n_selected which
returns num of items selected */
+ if (!tree_view->priv->selection || !gtk_tree_selection_get_selected
(tree_view->priv->selection, NULL, &dummyiter))
+ return ;
+
+ g_signal_emit (G_OBJECT(tree_view), tree_view_signals[ACTIVATE], NULL);
+}
+
+static void
gtk_tree_view_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -1828,6 +1858,9 @@
}
}
+ if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
+ gtk_tree_view_activate (tree_view);
+
/* Save press to possibly begin a drag
*/
if (tree_view->priv->pressed_button < 0)
@@ -1881,7 +1914,9 @@
tree_view->priv->drag_pos = i;
tree_view->priv->x_drag = (column->button->allocation.x +
column->button->allocation.width);
}
+
}
+
return TRUE;
}
Greets
M.H.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]