diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2006-03-22 21:09:01 +0000 |
---|---|---|
committer | Carlos Garnacho <carlosg@src.gnome.org> | 2006-03-22 21:09:01 +0000 |
commit | 502d44e50369ccd1ee70823f0c7125ef3f2537f4 (patch) | |
tree | f61227cfd37e3e1839a7632a4f6dd542f9d29d5b | |
parent | 8f069d7bfcbf33ba1aef39d599ab159ba451f4f8 (diff) | |
download | gdk-pixbuf-502d44e50369ccd1ee70823f0c7125ef3f2537f4.tar.gz |
Make it to expand when hovering during DnD
2006-03-22 Carlos Garnacho <carlosg@gnome.org>
* gtk/gtkexpander.c: Make it to expand when hovering during DnD
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 4 | ||||
-rw-r--r-- | gtk/gtkexpander.c | 68 |
3 files changed, 75 insertions, 1 deletions
@@ -1,3 +1,7 @@ +2006-03-22 Carlos Garnacho <carlosg@gnome.org> + + * gtk/gtkexpander.c: Make it to expand when hovering during DnD + 2006-03-22 Matthias Clasen <mclasen@redhat.com> Improved DND support for GtkNotebook (#332991, Carlos Garnacho) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f66998098..506a69138 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,7 @@ +2006-03-22 Carlos Garnacho <carlosg@gnome.org> + + * gtk/gtkexpander.c: Make it to expand when hovering during DnD + 2006-03-22 Matthias Clasen <mclasen@redhat.com> Improved DND support for GtkNotebook (#332991, Carlos Garnacho) diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index a5688806c..c658340b7 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -33,6 +33,7 @@ #include "gtkprivate.h" #include <gdk/gdkkeysyms.h> #include "gtkalias.h" +#include "gtkdnd.h" #define GTK_EXPANDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_EXPANDER, GtkExpanderPrivate)) @@ -58,6 +59,7 @@ struct _GtkExpanderPrivate GtkExpanderStyle expander_style; guint animation_timeout; + guint expand_timer; guint expanded : 1; guint use_underline : 1; @@ -104,6 +106,14 @@ static void gtk_expander_grab_notify (GtkWidget *widget, gboolean was_grabbed); static void gtk_expander_state_changed (GtkWidget *widget, GtkStateType previous_state); +static gboolean gtk_expander_drag_motion (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + guint time); +static void gtk_expander_drag_leave (GtkWidget *widget, + GdkDragContext *context, + guint time); static void gtk_expander_add (GtkContainer *container, GtkWidget *widget); @@ -183,6 +193,8 @@ gtk_expander_class_init (GtkExpanderClass *klass) widget_class->focus = gtk_expander_focus; widget_class->grab_notify = gtk_expander_grab_notify; widget_class->state_changed = gtk_expander_state_changed; + widget_class->drag_motion = gtk_expander_drag_motion; + widget_class->drag_leave = gtk_expander_drag_leave; container_class->add = gtk_expander_add; container_class->remove = gtk_expander_remove; @@ -292,6 +304,10 @@ gtk_expander_init (GtkExpander *expander) priv->use_markup = FALSE; priv->button_down = FALSE; priv->prelight = FALSE; + priv->expand_timer = 0; + + gtk_drag_dest_set (GTK_WIDGET (expander), 0, NULL, 0, 0); + gtk_drag_dest_set_track_motion (GTK_WIDGET (expander), TRUE); } static void @@ -978,6 +994,57 @@ gtk_expander_leave_notify (GtkWidget *widget, return FALSE; } +static gboolean +expand_timeout (gpointer data) +{ + GtkExpander *expander = GTK_EXPANDER (data); + GtkExpanderPrivate *priv = expander->priv; + + priv->expand_timer = 0; + gtk_expander_set_expanded (expander, TRUE); + + return FALSE; +} + +static gboolean +gtk_expander_drag_motion (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + guint time) +{ + GtkExpander *expander = GTK_EXPANDER (widget); + GtkExpanderPrivate *priv = expander->priv; + + if (!priv->expanded && !priv->expand_timer) + { + GtkSettings *settings; + guint timeout; + + settings = gtk_widget_get_settings (widget); + g_object_get (settings, "gtk-timeout-expand", &timeout, NULL); + + priv->expand_timer = g_timeout_add (timeout, (GSourceFunc) expand_timeout, expander); + } + + return TRUE; +} + +static void +gtk_expander_drag_leave (GtkWidget *widget, + GdkDragContext *context, + guint time) +{ + GtkExpander *expander = GTK_EXPANDER (widget); + GtkExpanderPrivate *priv = expander->priv; + + if (priv->expand_timer) + { + g_source_remove (priv->expand_timer); + priv->expand_timer = 0; + } +} + typedef enum { FOCUS_NONE, @@ -1181,7 +1248,6 @@ gtk_expander_activate (GtkExpander *expander) gtk_expander_set_expanded (expander, !expander->priv->expanded); } - /** * gtk_expander_new: * @label: the text of the label |