[gimp] app: Add and use gimp_highlight_widget()



commit e4e7bf8471294892aca5b10824c1a6d1426699f8
Author: Martin Nordholts <martinn src gnome org>
Date:   Sat Nov 28 19:12:39 2009 +0100

    app: Add and use gimp_highlight_widget()
    
    Add gimp_highlight_widget() so we can simplify
    gimp_dockbook_tab_drag_motion() a bit.

 app/widgets/gimpdockbook.c      |   16 +++++-----------
 app/widgets/gimpwidgets-utils.c |   20 ++++++++++++++++++++
 app/widgets/gimpwidgets-utils.h |    3 +++
 3 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index e38cd04..c5e3e04 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -752,7 +752,7 @@ gimp_dockbook_tab_drag_leave (GtkWidget      *widget,
 
   gimp_dockbook_remove_tab_timeout (dockbook);
 
-  gtk_drag_unhighlight (widget);
+  gimp_highlight_widget (widget, FALSE);
 }
 
 static gboolean
@@ -766,6 +766,7 @@ gimp_dockbook_tab_drag_motion (GtkWidget      *widget,
   GimpDockbook  *dockbook = dockable->dockbook;
   GtkTargetList *target_list;
   GdkAtom        target_atom;
+  gboolean       target_exists;
 
   if (! dockbook->p->tab_hover_timeout ||
       dockbook->p->tab_hover_dockable != dockable)
@@ -784,16 +785,9 @@ gimp_dockbook_tab_drag_motion (GtkWidget      *widget,
   target_list = gtk_drag_dest_get_target_list (widget);
   target_atom = gtk_drag_dest_find_target (widget, context, target_list);
 
-  if (gtk_target_list_find (target_list, target_atom, NULL))
-    {
-      gdk_drag_status (context, GDK_ACTION_MOVE, time);
-      gtk_drag_highlight (widget);
-    }
-  else
-    {
-      gdk_drag_status (context, 0, time);
-      gtk_drag_unhighlight (widget);
-    }
+  target_exists = gtk_target_list_find (target_list, target_atom, NULL);
+  gdk_drag_status (context, target_exists ? GDK_ACTION_MOVE : 0, time);
+  gimp_highlight_widget (widget, target_exists);
 
   /*  always return TRUE so drag_leave() is called  */
   return TRUE;
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 4713587..a43a030 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1166,3 +1166,23 @@ gimp_pango_layout_set_weight (PangoLayout *layout,
   pango_layout_set_attributes (layout, attrs);
   pango_attr_list_unref (attrs);
 }
+
+/**
+ * gimp_highlight_widget:
+ * @widget:
+ * @highlight:
+ *
+ * Calls gtk_drag_highlight() on @widget if @highlight is %TRUE,
+ * calls gtk_drag_unhighlight() otherwise.
+ **/
+void
+gimp_highlight_widget (GtkWidget *widget,
+                       gboolean   highlight)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  if (highlight)
+    gtk_drag_highlight (widget);
+  else
+    gtk_drag_unhighlight (widget);
+}
diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h
index 7c14256..b24ba44 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -87,6 +87,9 @@ void              gimp_pango_layout_set_scale      (PangoLayout          *layout
                                                     double                scale);
 void              gimp_pango_layout_set_weight     (PangoLayout          *layout,
                                                     PangoWeight           weight);
+void              gimp_highlight_widget            (GtkWidget            *widget,
+                                                    gboolean              highlight);
+
 
 
 #endif /* __GIMP_WIDGETS_UTILS_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]