diff --git a/gb.gtk/src/gcontrol.cpp b/gb.gtk/src/gcontrol.cpp index 0cfffe263..ebb470e5a 100644 --- a/gb.gtk/src/gcontrol.cpp +++ b/gb.gtk/src/gcontrol.cpp @@ -329,7 +329,6 @@ void gControl::initAll(gContainer *parent) _inverted = false; _accept_drops = false; _dragging = false; - _drag_get_data = false; frame_border = 0; frame_padding = 0; _bg_set = false; @@ -649,13 +648,8 @@ static void send_configure(gControl *control) widget = control->border; -#if GTK_CHECK_VERSION(2, 20, 0) if (!gtk_widget_get_realized(widget)) return; -#else - if (!GTK_WIDGET_REALIZED(widget)) - return; -#endif // if (control->isWindow()) // g_debug("send configure to window: %s", control->name()); @@ -1531,6 +1525,36 @@ Drag & Drop **********************************************************************/ +/*static void print_full_name(gControl *ctrl) +{ + if (ctrl->parent()) + { + print_full_name(ctrl->parent()); + fprintf(stderr, ">"); + } + + fprintf(stderr, "%s", ctrl->name() ? ctrl->name() : "?"); +}*/ + +void gControl::updateAcceptDrops() +{ + GtkWidget *w = _scroll ? widget : border; + + if (_accept_drops) + { + gtk_drag_dest_set(w, (GtkDestDefaults)0, NULL, 0, (GdkDragAction)(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)); + gtk_drag_dest_set_track_motion(w, TRUE); + } + else + { + gtk_drag_dest_unset(w); + } + + /*fprintf(stderr, "updateAcceptDrops: "); + print_full_name(this); + fprintf(stderr, " -> %d\n", _accept_drops);*/ +} + bool gControl::acceptDrops() const { if (_proxy) @@ -1541,8 +1565,6 @@ bool gControl::acceptDrops() const void gControl::setAcceptDrops(bool vl) { - GtkWidget *w; - if (_proxy) { _proxy->setAcceptDrops(vl); @@ -1553,12 +1575,7 @@ void gControl::setAcceptDrops(bool vl) return; _accept_drops = vl; - - w = _scroll ? widget : border; - if (vl) - gtk_drag_dest_set(w, (GtkDestDefaults)0, NULL, 0, (GdkDragAction)(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)); - else - gtk_drag_dest_unset(w); + updateAcceptDrops(); } /********************************************************************* @@ -1969,7 +1986,6 @@ void gControl::realize(bool draw_frame) #endif updateEventMask(); - registerControl(); updateFont(); } @@ -2960,6 +2976,8 @@ void gControl::createBorder(GtkWidget *new_border, bool keep_widget) _no_delete = false; createWidget(); } + + updateAcceptDrops(); } int gControl::actualDirection() const diff --git a/gb.gtk/src/gcontrol.h b/gb.gtk/src/gcontrol.h index b157dda6c..48cb491f4 100644 --- a/gb.gtk/src/gcontrol.h +++ b/gb.gtk/src/gcontrol.h @@ -115,6 +115,7 @@ public: bool acceptDrops() const; void setAcceptDrops(bool vl); + void updateAcceptDrops(); const char *name() const { return _name; } void setName(char *name); @@ -263,21 +264,21 @@ public: unsigned _accept_drops : 1; // If the control accepts drops unsigned _dragging : 1; // if the control is being dragged - unsigned _drag_get_data : 1; // If we got information on the dragged data unsigned _tracking : 1; // If we are tracking mouse move even if no mouse button is pressed unsigned _old_tracking : 1; // real value when Tracking is false unsigned _bg_set : 1; // Have a private background unsigned _fg_set : 1; // Have a private foreground unsigned have_cursor : 1; // If gApplication::setBusy() must update the cursor - unsigned use_base : 1; // Use base and text color for foreground and background + unsigned _visible : 1; // A control can be hidden if its width or height is zero unsigned _no_delete : 1; // Do not delete on destroy signal unsigned _scrollbar : 2; unsigned _dirty_pos : 1; // If the position of the widget has changed unsigned _dirty_size : 1; // If the size of the widget has changed unsigned _inside : 1; // if we got an enter event, but not a leave event yet. - + unsigned _has_border : 1; // if the control has a border + unsigned _locked : 4; // For locking events unsigned frame_border : 4; @@ -286,22 +287,22 @@ public: unsigned _has_input_method : 1; // Has its own input method management unsigned _no_default_mouse_event : 1; // No default mouse events unsigned _grab : 1; // control is currently grabbing mouse and keyboard - unsigned _has_border : 1; // if the control has a border unsigned _no_tab_focus : 1; // Don't put inside focus chain unsigned _no_auto_grab : 1; // do not automatically grab widget on button press event unsigned _no_background : 1; // Don't draw the background automatically unsigned _use_wheel : 1; // Do not propagate the mouse wheel event + unsigned _has_native_popup : 1; // I have a native popup menu unsigned _is_container : 1; // I am a container unsigned _is_window : 1; // I am a window unsigned _is_button : 1; // I am a button unsigned _is_drawingarea : 1; // I am a drawing area - unsigned _has_native_popup : 1; // I have a native popup menu unsigned _eat_return_key : 1; // If the control eats the return key unsigned _minimum_size_set : 1; // If minimum size has been computed + unsigned _direction : 2; // Text direction + unsigned _allow_show : 1; // Allowed to be visible (after the first resize) - unsigned _direction : 2; // Text direction #ifdef GTK3 unsigned _style_dirty : 1; // If the style must be refreshed diff --git a/gb.gtk/src/gmenu.cpp b/gb.gtk/src/gmenu.cpp index d6838e21b..3ddb10bb7 100644 --- a/gb.gtk/src/gmenu.cpp +++ b/gb.gtk/src/gmenu.cpp @@ -143,11 +143,10 @@ static gboolean cb_map(GtkWidget *menu, gMenu *data) data->_mapping = true; - data->hideSeparators(); - //gtk_menu_reposition(GTK_MENU(menu)); - gtk_widget_hide(gtk_widget_get_parent(menu)); + data->hideSeparators(); gtk_widget_show(gtk_widget_get_parent(menu)); + gtk_menu_reposition(GTK_MENU(menu)); data->_mapping = false; @@ -164,7 +163,7 @@ static gboolean cb_unmap(GtkWidget *menu, gMenu *data) data->_opened = false; CB_menu_hide(data); - gtk_widget_set_size_request(menu, -1, -1); + //gtk_widget_set_size_request(menu, -1, -1); //fprintf(stderr, "cb_unmap: <<<\n"); return false; diff --git a/gb.gtk/src/gsignals.cpp b/gb.gtk/src/gsignals.cpp index f4f39a7bd..018f46a15 100644 --- a/gb.gtk/src/gsignals.cpp +++ b/gb.gtk/src/gsignals.cpp @@ -32,7 +32,7 @@ #include "gdrag.h" #include "gdesktop.h" -//#define DEBUG_DND 1 +#define DEBUG_DND 1 static void cb_destroy(GtkWidget *object, gControl *data) { @@ -308,7 +308,6 @@ static gboolean cb_drag_drop(GtkWidget *widget, GdkDragContext *context, gint x, gDrag::setDropData(gDrag::getAction(), x, y, source, data); context = gDrag::enable(context, data, time); - data->_drag_get_data = true; while (data) { @@ -324,7 +323,6 @@ static gboolean cb_drag_drop(GtkWidget *widget, GdkDragContext *context, gint x, gtk_drag_finish(context, true, false, time); //data->_drag_enter = false; - data->_drag_get_data = false; return true; } diff --git a/gb.gtk/src/gtools.h b/gb.gtk/src/gtools.h index 585a565ac..f1726c08b 100644 --- a/gb.gtk/src/gtools.h +++ b/gb.gtk/src/gtools.h @@ -241,4 +241,9 @@ void gt_widget_update_css(GtkWidget *widget, gFont *font, gColor bg, gColor fg); void gt_define_style_sheet(GtkStyleProvider **provider, GString *css); #endif +#if GTK_CHECK_VERSION(2, 20, 0) +#else +#define gtk_widget_get_realized(_widget) GTK_WIDGET_REALIZED(_widget) +#endif + #endif