[Glade-devel] [patch, glade3] bug on placeholder selection



--=-ihENxsT/MJECcB8+7XSv
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi!

I think I tracked down one of the problems we have when selecting a
placeholder:
on a placeholder we draw the selection nodes when the user click on it;
on a widget, instead, we draw the selection nodes during the expose
event callback, and we continue to redraw them as long the widget is
flagged as selected.
This way when clicking on a placeholder the selection nodes are drawn on
it, but also keep to be drawn on the parent widget.
The attached patch fixes it, but looks a bit hackish to me since it just
fixes the symptom... probably things need to be reworked more.

Comments? Suggestion? Better ideas to fix it?
What is the right time to draw the selcetion nodes on your opinion?

Note also that the drawing code has other problems, e.g if you nest
various vboxs and tables and try to randomly click on the placeholders
sometimes the wrong one is highlighted. Beside the 3 function to draw
and delete the selection nodes are almost identical (before this patch)
in glade_widget.c and glade-placeholder.c, so they probably should be
consolidated.


ciao
        paolo

--=-ihENxsT/MJECcB8+7XSv
Content-Disposition: attachment; filename=selection.patch
Content-Type: text/x-patch; name=selection.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -upr gnome2/glade3/src/glade-placeholder.c glade3/src/glade-placeholder.c
--- gnome2/glade3/src/glade-placeholder.c       2003-05-24 17:41:46.000000000 +0200
+++ glade3/src/glade-placeholder.c      2003-05-28 13:10:05.000000000 +0200
@@ -196,6 +196,7 @@ static void
 glade_placeholder_draw_selection_nodes (GladePlaceholder *placeholder)
 {
        GtkWidget *widget, *paint_widget;
+       GladeWidget *parent;
        GdkWindow *window;
        GdkGC *gc;
        gint x, y, w, h;
@@ -243,6 +244,12 @@ glade_placeholder_draw_selection_nodes (
        gdk_draw_rectangle (window, gc, FALSE, x, y, width - 1, height - 1);
        
        gdk_gc_set_subwindow (gc, GDK_CLIP_BY_CHILDREN);
+
+       /* hack hack... we set the parent GladeWidget unselected so selection
+        * nodes are not drawn on it
+        */
+       parent = glade_placeholder_get_parent (placeholder);
+       glade_widget_flag_unselected (parent);
 }
 
 static void
diff -upr gnome2/glade3/src/glade-widget.c glade3/src/glade-widget.c
--- gnome2/glade3/src/glade-widget.c    2003-05-24 17:41:46.000000000 +0200
+++ glade3/src/glade-widget.c   2003-05-28 13:21:09.000000000 +0200
@@ -1132,7 +1132,7 @@ glade_widget_select (GladeWidget *widget
 }
 
 static void
-glade_widget_clear_draw_selection (GladeWidget *widget)
+glade_widget_clear_selection_nodes (GladeWidget *widget)
 {
        GdkWindow *window;
        
@@ -1161,11 +1161,12 @@ glade_widget_clear_draw_selection (Glade
 void
 glade_widget_flag_unselected (GladeWidget *widget)
 {
-       g_return_if_fail (widget->selected);
+       g_return_if_fail (GLADE_IS_WIDGET (widget));
 
+       if (widget->selected == TRUE)
+               glade_widget_clear_selection_nodes (widget);
+       
        widget->selected = FALSE;
-
-       glade_widget_clear_draw_selection (widget);
 }
 
 /**
@@ -1177,7 +1178,7 @@ glade_widget_flag_unselected (GladeWidge
 void
 glade_widget_flag_selected (GladeWidget *widget)
 {
-       g_return_if_fail (!widget->selected);
+       g_return_if_fail (GLADE_IS_WIDGET (widget));
 
        widget->selected = TRUE;
        gtk_widget_queue_draw (widget->widget);

--=-ihENxsT/MJECcB8+7XSv--





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