glom r1585 - in trunk: . glom/mode_data glom/utility_widgets
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1585 - in trunk: . glom/mode_data glom/utility_widgets
- Date: Tue, 22 Apr 2008 14:04:12 +0100 (BST)
Author: jhs
Date: Tue Apr 22 13:04:12 2008
New Revision: 1585
URL: http://svn.gnome.org/viewvc/glom?rev=1585&view=rev
Log:
2008-04-22 Johannes Schmid <johannes schmid openismus com>
* glom/mode_data/flowtablewithfields.cc:
(set_design_mode): Call FlowTableDnd::set_design_mode() if appropriate
* glom/utility_widgets/flowtable.cc:
* glom/utility_widgets/flowtable.h:
(forall), (container_forall_callback):
Implement forall() with is not implement for Gtk::Container
(setup_dnd): Remove this and do all dnd stuff in flowtable_dnd
* glom/utility_widgets/flowtable_dnd.cc:
* glom/utility_widgets/flowtable_dnd.h:
(set_design_mode), (start_dnd), (stop_dnd):
Override set_design_mode() and call start_dnd() and stop_dnd() there.
Preparation for moving items around and setting them as drag source.
Modified:
trunk/ChangeLog
trunk/glom/mode_data/flowtablewithfields.cc
trunk/glom/utility_widgets/flowtable.cc
trunk/glom/utility_widgets/flowtable.h
trunk/glom/utility_widgets/flowtable_dnd.cc
trunk/glom/utility_widgets/flowtable_dnd.h
Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc (original)
+++ trunk/glom/mode_data/flowtablewithfields.cc Tue Apr 22 13:04:12 2008
@@ -990,7 +990,11 @@
void FlowTableWithFields::set_design_mode(bool value)
{
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ FlowTableDnd::set_design_mode(value);
+#else
FlowTable::set_design_mode(value);
+#endif
//Set the mode in the sub-flowtables:
for(type_sub_flow_tables::iterator iter = m_sub_flow_tables.begin(); iter != m_sub_flow_tables.end(); ++iter)
Modified: trunk/glom/utility_widgets/flowtable.cc
==============================================================================
--- trunk/glom/utility_widgets/flowtable.cc (original)
+++ trunk/glom/utility_widgets/flowtable.cc Tue Apr 22 13:04:12 2008
@@ -252,15 +252,35 @@
namespace Glom
{
+static void container_forall_callback(GtkWidget* widget_gobj, void* data)
+{
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ FlowTable::ForallSlot& slot = *static_cast<FlowTable::ForallSlot*>(data);
+ Gtk::Widget *const widget = Glib::wrap(widget_gobj);
+
+ g_return_if_fail(widget != 0);
+
+ slot(*widget);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
+
FlowTable::FlowTableItem::FlowTableItem(Gtk::Widget* first, FlowTable* flowtable)
: m_first(first),
m_second(0),
m_expand_first_full(false),
m_expand_second(false)
{
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- flowtable->setup_dnd (*m_first);
-#endif /* GLOM_ENABLE_CLIENT_ONLY */
+
}
FlowTable::FlowTableItem::FlowTableItem(Gtk::Widget* first, Gtk::Widget* second, FlowTable* flowtable)
@@ -269,10 +289,7 @@
m_expand_first_full(false),
m_expand_second(false)
{
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- flowtable->setup_dnd (*m_first);
- flowtable->setup_dnd (*m_second);
-#endif /* GLOM_ENABLE_CLIENT_ONLY */
+
}
@@ -443,11 +460,6 @@
}
}
-void FlowTable::setup_dnd (Gtk::Widget& child)
-{
- // override this when you need drag and drop support
-}
-
void FlowTable::set_columns_count(guint value)
{
//Silently correct an invalid value:
@@ -999,6 +1011,12 @@
}
}
+void FlowTable::forall(const ForallSlot& slot)
+{
+ ForallSlot slot_copy (slot);
+ gtk_container_forall(gobj(), &container_forall_callback, &slot_copy);
+}
+
/** Sets the padding to put between the child widgets.
*/
void FlowTable::set_padding(guint padding)
Modified: trunk/glom/utility_widgets/flowtable.h
==============================================================================
--- trunk/glom/utility_widgets/flowtable.h (original)
+++ trunk/glom/utility_widgets/flowtable.h Tue Apr 22 13:04:12 2008
@@ -54,6 +54,9 @@
void remove_all();
+ // Implement forall which is not implemented in gtkmm
+ typedef sigc::slot<void, Widget&> ForallSlot;
+ void forall(const ForallSlot& slot);
protected:
#ifndef GLIBMM_VFUNCS_ENABLED
@@ -143,9 +146,6 @@
//For drawing:
Glib::RefPtr<Gdk::Window> m_refGdkWindow;
Glib::RefPtr<Gdk::GC> m_refGC;
-
- // Dnd
- virtual void setup_dnd (Gtk::Widget& child);
};
} //namespace Glom
Modified: trunk/glom/utility_widgets/flowtable_dnd.cc
==============================================================================
--- trunk/glom/utility_widgets/flowtable_dnd.cc (original)
+++ trunk/glom/utility_widgets/flowtable_dnd.cc Tue Apr 22 13:04:12 2008
@@ -44,7 +44,7 @@
}
-void FlowTableDnd::setup_dnd (Gtk::Widget& child)
+void FlowTableDnd::start_dnd (Gtk::Widget& child)
{
if (dynamic_cast<PlaceholderGlom*>(&child) ||
dynamic_cast<FlowTableDnd*>(&child))
@@ -59,13 +59,14 @@
for (CI cur_child = children.begin(); cur_child != children.end();
++cur_child)
{
- setup_dnd (*(*cur_child));
+ start_dnd (*(*cur_child));
}
}
if (!(child.get_flags() & Gtk::NO_WINDOW))
{
std::list<Gtk::TargetEntry> new_targets;
- new_targets.push_back(Gtk::TargetEntry(egg_tool_palette_get_drag_target_item()));
+ Gtk::TargetEntry target(egg_tool_palette_get_drag_target_item());
+ new_targets.push_back(target);
Glib::RefPtr<Gtk::TargetList> targets =
child.drag_dest_get_target_list ();
// The widget has already a default drag destination - add more targets
@@ -77,12 +78,41 @@
else
child.drag_dest_set(new_targets, Gtk::DEST_DEFAULT_ALL,
Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
-
+
+ // Needed to move items around
+ //child.drag_source_set (new_targets, Gdk::BUTTON1_MASK|Gdk::BUTTON3_MASK,
+ // Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
+
// It's important to connect this one BEFORE
child.signal_drag_motion().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_motion), &child),
false);
child.signal_drag_data_received().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_data_received), &child));
child.signal_drag_leave().connect (sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_leave));
+ child.signal_drag_data_get().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_data_get), &child));
+ }
+}
+
+void FlowTableDnd::stop_dnd (Gtk::Widget& child)
+{
+ if (dynamic_cast<PlaceholderGlom*>(&child) ||
+ dynamic_cast<FlowTableDnd*>(&child))
+ return;
+
+ // Call this method recursive for all (real) children
+ Gtk::Container* container = dynamic_cast<Gtk::Container*>(&child);
+ if (container)
+ {
+ typedef Glib::ListHandle<Gtk::Widget*>::const_iterator CI;
+ Glib::ListHandle<Gtk::Widget*> children = container->get_children();
+ for (CI cur_child = children.begin(); cur_child != children.end();
+ ++cur_child)
+ {
+ stop_dnd (*(*cur_child));
+ }
+ }
+ if (!(child.get_flags() & Gtk::NO_WINDOW))
+ {
+ child.drag_source_unset();
}
}
@@ -286,6 +316,27 @@
on_drag_data_received (drag_context, x, y, selection_data, info, time);
}
+void FlowTableDnd::on_child_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& drag_context,
+ const Gtk::SelectionData& selection_data, guint, guint time,
+ Gtk::Widget* child)
+{
+ std::cout << __FUNCTION__ << std::endl;
+}
+
+void FlowTableDnd::set_design_mode(bool value)
+{
+ FlowTable::set_design_mode(value);
+ // We only want to enable drag and drop when in design mode
+ if (value)
+ {
+ forall (sigc::mem_fun(*this, &FlowTableDnd::start_dnd));
+ }
+ else
+ {
+ forall (sigc::mem_fun(*this, &FlowTableDnd::stop_dnd));
+ }
+}
+
/* This is a hack. The problem is that when you move the mouse down to the last
item, the item gets the "drag-motion" signal but in the same moment, the placeholder
is removed and the mouse pointer is no longer over the widget. Thus, it gets
Modified: trunk/glom/utility_widgets/flowtable_dnd.h
==============================================================================
--- trunk/glom/utility_widgets/flowtable_dnd.h (original)
+++ trunk/glom/utility_widgets/flowtable_dnd.h Tue Apr 22 13:04:12 2008
@@ -46,8 +46,14 @@
virtual void on_child_drag_leave(const Glib::RefPtr<Gdk::DragContext>& drag_context, guint time);
virtual void on_child_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& drag_context, int, int,
const Gtk::SelectionData& selection_data, guint, guint time, Gtk::Widget* child);
- virtual void setup_dnd (Gtk::Widget& child); // overwritten
-
+ virtual void on_child_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& drag_context,
+ const Gtk::SelectionData& selection_data, guint, guint time, Gtk::Widget* child);
+
+ virtual void start_dnd (Gtk::Widget& child);
+ virtual void stop_dnd (Gtk::Widget& child);
+
+ virtual void set_design_mode(bool value = true);
+
// Methods for the different layout object
virtual void on_dnd_add_layout_item_field (LayoutWidgetBase* above) = 0;
virtual void on_dnd_add_layout_group(LayoutWidgetBase* above) = 0;
@@ -63,7 +69,7 @@
FlowTableItem* dnd_item_at_position(int x, int y);
LayoutWidgetBase* dnd_datawidget_from_item();
-
+
private:
FlowTableItem* m_current_dnd_item;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]