glom r1417 - in trunk: . glom/libglom glom/libglom/data_structure/layout glom/libglom/document glom/mode_data glom/utility_widgets icons/16x16
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1417 - in trunk: . glom/libglom glom/libglom/data_structure/layout glom/libglom/document glom/mode_data glom/utility_widgets icons/16x16
- Date: Mon, 18 Feb 2008 17:53:03 +0000 (GMT)
Author: jhs
Date: Mon Feb 18 17:53:02 2008
New Revision: 1417
URL: http://svn.gnome.org/viewvc/glom?rev=1417&view=rev
Log:
2008-02-18 Johannes Schmid <jhs gnome org>
* glom/libglom/connectionpool.cc:
#ifdef\'d all those annoying avahi debug messages
* glom/libglom/data_structure/layout/layoutgroup.cc:
* glom/libglom/data_structure/layout/layoutgroup.h:
Added LayoutGroup::remove_item()
* glom/libglom/document/document_glom.cc:
* glom/mode_data/dialog_layout_details.cc:
Remove default layout creation as it\'s no longer needed when you can
create your layout using drag and drop.
* glom/mode_data/flowtablewithfields.cc:
* glom/mode_data/flowtablewithfields.h:
* glom/mode_data/box_data_details.cc:
* glom/mode_data/box_data_details.h:
Fixed dragging of groups (mostly)
* glom/utility_widgets/dragbar.cc:
* glom/utility_widgets/dragbutton.cc:
* glom/utility_widgets/dragbutton.h:
Use enum instead of string to determine drag type
* glom/utility_widgets/flowtable.cc:
* glom/utility_widgets/flowtable.h:
Set default size when in developer mode
* icons/16x16/Makefile.am:
* icons/16x16/glom-notebook.png
Added notebook icon
Added:
trunk/icons/16x16/glom-notebook.png (contents, props changed)
Modified:
trunk/ChangeLog
trunk/glom/libglom/connectionpool.cc
trunk/glom/libglom/data_structure/layout/layoutgroup.cc
trunk/glom/libglom/data_structure/layout/layoutgroup.h
trunk/glom/libglom/document/document_glom.cc
trunk/glom/mode_data/box_data_details.cc
trunk/glom/mode_data/box_data_details.h
trunk/glom/mode_data/dialog_layout_details.cc
trunk/glom/mode_data/flowtablewithfields.cc
trunk/glom/mode_data/flowtablewithfields.h
trunk/glom/utility_widgets/dragbar.cc
trunk/glom/utility_widgets/dragbutton.cc
trunk/glom/utility_widgets/dragbutton.h
trunk/glom/utility_widgets/flowtable.cc
trunk/glom/utility_widgets/flowtable.h
trunk/icons/16x16/Makefile.am
Modified: trunk/glom/libglom/connectionpool.cc
==============================================================================
--- trunk/glom/libglom/connectionpool.cc (original)
+++ trunk/glom/libglom/connectionpool.cc Mon Feb 18 17:53:02 2008
@@ -63,6 +63,9 @@
static EpcProtocol publish_protocol = EPC_PROTOCOL_HTTPS;
#endif
+// Uncomment to see debug messages
+//#define AVAHI_DEBUG
+
namespace
{
std::string get_path_to_postgres_executable(const std::string& program)
@@ -336,8 +339,9 @@
cnc_string += (";DB_NAME=" + default_database);
//std::cout << "debug: connecting: cnc string: " << cnc_string << std::endl;
+#ifdef AVAHI_DEBUG
std::cout << std::endl << "Glom: trying to connect on port=" << port << std::endl;
-
+#endif
//*m_refGdaConnection = m_GdaClient->open_connection(m_GdaDataSourceInfo.get_name(), m_GdaDataSourceInfo.get_username(), m_GdaDataSourceInfo.get_password() );
//m_refGdaConnection.clear(); //Make sure any previous connection is really forgotten.
@@ -407,9 +411,10 @@
}
}
}
-
+#ifdef AVAHI_DEBUG
std::cout << " Postgres Server version: " << get_postgres_server_version() << std::endl << std::endl;
-
+#endif
+
#ifndef GLOM_ENABLE_CLIENT_ONLY
#ifndef G_OS_WIN32
//Let other clients discover this server via avahi:
@@ -436,21 +441,26 @@
catch(const Gnome::Gda::ConnectionError& ex)
{
#endif
+#ifdef AVAHI_DEBUG
std::cout << "ConnectionPool::connect() Attempt to connect to database failed on port=" << port << ", database=" << m_database << ": " << ex.what() << std::endl;
-
+#endif
+
bool bJustDatabaseMissing = false;
if(!m_database.empty())
{
+#ifdef AVAHI_DEBUG
std::cout << " ConnectionPool::connect() Attempting to connect without specifying the database." << std::endl;
-
+#endif
//If the connection failed while looking for a database,
//then try connecting without the database:
Glib::ustring cnc_string = cnc_string_main;
cnc_string += (";DB_NAME=" + default_database);
//std::cout << "debug2: connecting: cnc string: " << cnc_string << std::endl;
- std::cout << "Glom: connecting." << std::endl;
-
+#ifdef AVAHI_DEBUG
+ std::cout << "Glom: connecting." << std::endl;
+#endif
+
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
#endif
@@ -480,12 +490,12 @@
std::cerr << " ConnectionPool::connect() connection also failed when not specifying database: " << ex.what() << std::endl;
}
}
-
+#ifdef AVAHI_DEBUG
if(bJustDatabaseMissing)
std::cout << " (Connection succeeds, but not to the specific database on port=" << port << ", database=" << m_database << std::endl;
else
std::cerr << " (Could not connect even to the default database on port=" << port << ", database=" << m_database << std::endl;
-
+#endif
//handle_error(true /* cerr only */);
}
@@ -519,11 +529,13 @@
}
g_warning("ConnectionPool::connect() throwing exception.");
+#ifdef AVAHI_DEBUG
if(connection_to_default_database_possible)
std::cout << " (Connection succeeds, but not to the specific database on port=" << m_port << ", database=" << m_database << std::endl;
else
std::cerr << " (Could not connect even to the default database on any port. database=" << m_database << std::endl;
-
+#endif
+
#ifdef GLIBMM_EXCEPTIONS_ENABLED
throw ExceptionConnection(connection_to_default_database_possible ? ExceptionConnection::FAILURE_NO_DATABASE : ExceptionConnection::FAILURE_NO_SERVER);
#else
@@ -588,7 +600,9 @@
{
if(value.empty())
{
+#ifdef AVAHI_DEBUG
std::cout << "debug: ConnectionPool::set_user(): user is empty." << std::endl;
+#endif
}
m_user = value;
@@ -725,7 +739,9 @@
#endif
//TODO: dialog.set_transient_for(*get_application());
dialog.run(); //TODO: This segfaults in gtk_window_set_modal() when this method is run a second time, for instance if there are two database errors.
+#ifdef AVAHI_DEBUG
std::cout << "debug: after Internal Error dialog run()." << std::endl;
+#endif
}
return true; //There really was an error.
@@ -1422,9 +1438,10 @@
{
if(m_epc_publisher)
return;
-
+#ifdef AVAHI_DEBUG
std::cout << "debug: ConnectionPool::avahi_start_publishing" << std::endl;
-
+#endif
+
//Publish the document contents over HTTPS (discoverable via avahi):
const Document_Glom* document = get_document();
if(!document)
@@ -1462,7 +1479,9 @@
epc_publisher_run_async(m_epc_publisher, &error);
if(error)
{
+#ifdef AVAHI_DEBUG
std::cout << "Glom: ConnectionPool::avahi_start_publishing(): Error while running epc_publisher_run_async: " << error->message << std::endl;
+#endif
g_clear_error(&error);
}
}
@@ -1471,8 +1490,9 @@
{
if(!m_epc_publisher)
return;
-
+#ifdef AVAHI_DEBUG
std::cout << "debug: ConnectionPool::avahi_stop_publishing" << std::endl;
+#endif
#ifndef G_OS_WIN32
epc_publisher_quit(m_epc_publisher);
Modified: trunk/glom/libglom/data_structure/layout/layoutgroup.cc
==============================================================================
--- trunk/glom/libglom/data_structure/layout/layoutgroup.cc (original)
+++ trunk/glom/libglom/data_structure/layout/layoutgroup.cc Mon Feb 18 17:53:02 2008
@@ -121,7 +121,10 @@
sharedptr<LayoutItem> unconst = sharedptr<LayoutItem>::cast_const(position);
type_list_items::iterator iter = std::find(m_list_items.begin(), m_list_items.end(), unconst);
if(iter == m_list_items.end())
- return; //position isn't an item already in the list.
+ {
+ std::cout << __FUNCTION__ << ": item not found" << std::endl;
+ return;
+ }
//std::vector::insert() adds before rather than after:
// jhs: We want to add after rather than before - at least for dnd
@@ -130,6 +133,13 @@
m_list_items.insert(iter, item);
}
+void LayoutGroup::remove_item (const sharedptr<LayoutItem>& item)
+{
+ sharedptr<LayoutItem> unconst = sharedptr<LayoutItem>::cast_const(item);
+ type_list_items::iterator iter = std::find(m_list_items.begin(), m_list_items.end(), unconst);
+ m_list_items.erase(iter);
+}
+
LayoutGroup::type_list_items LayoutGroup::get_items()
{
return m_list_items;
Modified: trunk/glom/libglom/data_structure/layout/layoutgroup.h
==============================================================================
--- trunk/glom/libglom/data_structure/layout/layoutgroup.h (original)
+++ trunk/glom/libglom/data_structure/layout/layoutgroup.h Mon Feb 18 17:53:02 2008
@@ -52,6 +52,11 @@
* @param position The item after which the item should be added.
*/
void add_item(const sharedptr<LayoutItem>& item, const sharedptr<const LayoutItem>& position);
+
+ /** Remove a layout item from the group
+ * @param item The item to remove.
+ */
+ void remove_item (const sharedptr<LayoutItem>& item);
/** Remove any instance of the field (from the current table) from the layout.
*/
Modified: trunk/glom/libglom/document/document_glom.cc
==============================================================================
--- trunk/glom/libglom/document/document_glom.cc (original)
+++ trunk/glom/libglom/document/document_glom.cc Mon Feb 18 17:53:02 2008
@@ -1347,78 +1347,11 @@
type_list_layout_groups result;
- //Add one if necessary:
- sharedptr<LayoutGroup> pTopLevel;
- sharedptr<LayoutGroup> pOverview;
- sharedptr<LayoutGroup> pDetails;
- if(!pTopLevel)
- {
- sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::create();
- group->set_name("main");
- group->m_columns_count = 1;
- result.push_back(group);
- pTopLevel = group;
-
- if(layout_name == "details") //The Details default layut is a bit more complicated.
- {
- sharedptr<LayoutGroup> overview = sharedptr<LayoutGroup>::create();;
- overview->set_name("overview");
- overview->set_title_original("Overview"); //Don't translate this, but TODO: add standard translations.
- overview->m_columns_count = 2;
- pTopLevel->add_item(overview);
- pOverview = overview;
-
- sharedptr<LayoutGroup> details = sharedptr<LayoutGroup>::create();
- details->set_name("details");
- details->set_title_original("Details"); //Don't translate this, but TODO: add standard translations.
- details->m_columns_count = 2;
- pTopLevel->add_item(details);
- pDetails = details;
- }
- }
-
- //If, for some reason, we didn't create the-subgroups, add everything to the top level group:
- if(!pOverview)
- pOverview = pTopLevel;
-
- if(!pDetails)
- pDetails = pTopLevel;
-
-
- //Discover new fields, and add them:
- type_vecFields all_fields = get_table_fields(parent_table_name);
- for(type_vecFields::const_iterator iter = all_fields.begin(); iter != all_fields.end(); ++iter)
- {
- const Glib::ustring field_name = (*iter)->get_name();
- if(!field_name.empty())
- {
- //See whether it's already in the result:
- //TODO_Performance: There is a lot of iterating and comparison here:
- bool found = false; //TODO: This is horrible.
- for(type_list_layout_groups::const_iterator iterFind = result.begin(); iterFind != result.end(); ++iterFind)
- {
- if(*iterFind && (*iterFind)->has_field(field_name))
- {
- found = true;
- break;
- }
- }
-
- if(!found)
- {
- sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
- layout_item->set_full_field_details(*iter);
- //layout_item.set_table_name(child_table_name); //TODO: Allow viewing of fields through relationships.
-
- //std::cout << " debug: add_item(): " << layout_item.get_name() << std::endl;
- if(layout_item->get_full_field_details()->get_primary_key())
- pOverview->add_item(layout_item);
- else
- pDetails->add_item(layout_item);
- }
- }
- }
-
+ sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::create();
+ group->set_name("main");
+ group->m_columns_count = 1;
+ result.push_back(group);
+
return result;
}
Modified: trunk/glom/mode_data/box_data_details.cc
==============================================================================
--- trunk/glom/mode_data/box_data_details.cc (original)
+++ trunk/glom/mode_data/box_data_details.cc Mon Feb 18 17:53:02 2008
@@ -45,7 +45,8 @@
m_Button_Nav_Next(Gtk::Stock::GO_FORWARD),
m_Button_Nav_Last(Gtk::Stock::GOTO_LAST),
m_bDoNotRefreshRelated(false),
- m_ignore_signals(true)
+ m_ignore_signals(true),
+ m_design_mode(false)
{
m_layout_name = "details";
@@ -215,7 +216,9 @@
m_FlowTable.add_layout_group(*iter);
}
}
-
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ m_FlowTable.set_design_mode(m_design_mode);
+#endif
}
bool Box_Data_Details::fill_from_database()
@@ -556,16 +559,16 @@
void Box_Data_Details::on_flowtable_layout_changed()
{
//Get new layout:
- //Document_Glom::type_list_layout_groups layout_groups;
- //m_FlowTable.get_layout_groups(layout_groups);
+#if 0
+ Document_Glom::type_list_layout_groups layout_groups;
+ m_FlowTable.get_layout_groups(layout_groups);
//Store it in the document:
Document_Glom* document = get_document();
- document->set_modified();
- //if(document)
- // document->set_data_layout_groups(m_layout_name, m_table_name, layout_groups);
-
+ if(document)
+ document->set_data_layout_groups(m_layout_name, m_table_name, layout_groups);
//Build the view again from the new layout:
+#endif
create_layout();
//And fill it with data:
@@ -816,7 +819,8 @@
void Box_Data_Details::on_userlevel_changed(AppState::userlevels user_level)
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
- m_FlowTable.set_design_mode( user_level == AppState::USERLEVEL_DEVELOPER );
+ m_design_mode = ( user_level == AppState::USERLEVEL_DEVELOPER );
+ m_FlowTable.set_design_mode(m_design_mode);
#endif
}
Modified: trunk/glom/mode_data/box_data_details.h
==============================================================================
--- trunk/glom/mode_data/box_data_details.h (original)
+++ trunk/glom/mode_data/box_data_details.h Mon Feb 18 17:53:02 2008
@@ -141,6 +141,10 @@
type_signal_record_deleted m_signal_record_deleted;
type_signal_requested_related_details m_signal_requested_related_details;
+
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ bool m_design_mode; // Cache here because we need it when the layout is redrawn
+#endif
};
} //namespace Glom
Modified: trunk/glom/mode_data/dialog_layout_details.cc
==============================================================================
--- trunk/glom/mode_data/dialog_layout_details.cc (original)
+++ trunk/glom/mode_data/dialog_layout_details.cc Mon Feb 18 17:53:02 2008
@@ -303,23 +303,16 @@
Document_Glom::type_list_layout_groups list_groups = document->get_data_layout_groups_plus_new_fields(layout, m_table_name);
document->fill_layout_field_details(m_table_name, list_groups); //Update with full field information.
- //If no information is stored in the document, then start with something:
+ //If no information is stored in the document, add a default group
if(list_groups.empty())
{
sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::create();
group->set_name("main");
- group->m_columns_count = 2;
+ group->m_columns_count = 1;
- for(type_vecLayoutFields::const_iterator iter = table_fields.begin(); iter != table_fields.end(); ++iter)
- {
- sharedptr<LayoutItem_Field> item = *iter;
-
- group->add_item(item);
- }
-
- list_groups[1] = group;
- }
+ list_groups.push_back(group);
+ }
//Show the field layout
//typedef std::list< Glib::ustring > type_listStrings;
Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc (original)
+++ trunk/glom/mode_data/flowtablewithfields.cc Mon Feb 18 17:53:02 2008
@@ -229,7 +229,6 @@
flow_table->signal_field_open_details_requested().connect( sigc::mem_fun(*this, &FlowTableWithFields::on_flowtable_entry_open_details_requested) );
flow_table->signal_related_record_changed().connect( sigc::mem_fun(*this, &FlowTableWithFields::on_flowtable_related_record_changed) );
flow_table->signal_requested_related_details().connect( sigc::mem_fun(*this, &FlowTableWithFields::on_flowtable_requested_related_details) );
-
flow_table->signal_script_button_clicked().connect( sigc::mem_fun(*this, &FlowTableWithFields::on_script_button_clicked) );
}
}
@@ -618,6 +617,20 @@
}
}
+void FlowTableWithFields::get_layout_groups(Document_Glom::type_list_layout_groups& groups)
+{
+ sharedptr<LayoutGroup> group(get_layout_group());
+ if (group)
+ {
+ groups.push_back (group);
+ }
+}
+
+sharedptr<LayoutGroup> FlowTableWithFields::get_layout_group()
+{
+ return sharedptr<LayoutGroup>::cast_dynamic(get_layout_item());
+}
+
void FlowTableWithFields::remove_field(const Glib::ustring& id)
{
@@ -1132,9 +1145,6 @@
else
cur_widget = m_list_layoutwidgets.end();
- add_layout_item_at_position(layout_item_field, cur_widget);
-
-
//Get the layout group that the "above" widget's layout item is in:
sharedptr<LayoutGroup> layout_group = sharedptr<LayoutGroup>::cast_dynamic(get_layout_item());
if(!layout_group)
@@ -1142,8 +1152,8 @@
std::cerr << "FlowTableWithFields::on_datawidget_layout_item_added(): layout_group is null." << std::endl;
return;
}
-
- if(above)
+
+ if (above && above->get_layout_item())
layout_group->add_item(layout_item_field, above->get_layout_item());
else
layout_group->add_item(layout_item_field);
@@ -1159,14 +1169,36 @@
cur_widget = std::find(m_list_layoutwidgets.begin(), m_list_layoutwidgets.end(), above);
else
cur_widget = m_list_layoutwidgets.end();
-
- // TODO: Get a title using a dialog and set a mimimum size because
- // the layoutgroup does not have any items
+
sharedptr<LayoutGroup> group(new LayoutGroup());
- group->set_title("test");
- add_layout_group_at_position(group, cur_widget);
- signal_layout_item_added().emit(TYPE_GROUP);
- signal_layout_changed().emit();
+ group->set_title(_("New Group"));
+ group->set_name (_("Group"));
+
+
+ //Get the layout group that the "above" widget's layout item is in
+ sharedptr<LayoutGroup> layout_group = get_layout_group();
+ if(!layout_group)
+ {
+ std::cerr << "FlowTableWithFields::on_dnd_layout_group_added(): layout_group is null." << std::endl;
+ return;
+ }
+
+ std::cout << "Group: " << layout_group->get_title() << std::endl;
+
+ //add_layout_group_at_position (group, cur_widget);
+ if(above && above->get_layout_item())
+ {
+ std::cout << "Adding group above item" << std::endl;
+ layout_group->add_item(group, above->get_layout_item());
+ }
+ else
+ {
+ std::cout << "Adding group at the end" << std::endl;
+ layout_group->add_item(group);
+ }
+
+ //Tell the parent to tell the document to save the layout
+ signal_layout_changed().emit();
}
void FlowTableWithFields::on_dnd_add_layout_item_button(LayoutWidgetBase* above)
@@ -1179,23 +1211,21 @@
//Add a widget for this layout item, after the "above" item:
type_list_layoutwidgets::iterator cur_widget;
- if(above)
+ if (above && above->get_layout_item())
cur_widget = std::find (m_list_layoutwidgets.begin(), m_list_layoutwidgets.end(), above);
else
cur_widget = m_list_layoutwidgets.end();
- add_layout_item_at_position(layout_item_button, cur_widget);
-
-
//Get the layout group that the "above" widget's layout item is in:
sharedptr<LayoutGroup> layout_group = sharedptr<LayoutGroup>::cast_dynamic(get_layout_item());
if(!layout_group)
{
- std::cerr << "FlowTableWithFields::on_datawidget_layout_item_added(): layout_group is null." << std::endl;
return;
}
- if(above)
+ add_layout_item_at_position(layout_item_button, cur_widget);
+
+ if (above && above->get_layout_item())
layout_group->add_item(layout_item_button, above->get_layout_item());
else
layout_group->add_item(layout_item_button);
@@ -1213,14 +1243,11 @@
//Add a widget for this layout item, after the "above" item:
type_list_layoutwidgets::iterator cur_widget;
- if(above)
+ if (above && above->get_layout_item())
cur_widget = std::find (m_list_layoutwidgets.begin(), m_list_layoutwidgets.end(), above);
else
cur_widget = m_list_layoutwidgets.end();
- add_layout_item_at_position(textobject, cur_widget);
-
-
//Get the layout group that the "above" widget's layout item is in:
sharedptr<LayoutGroup> layout_group = sharedptr<LayoutGroup>::cast_dynamic(get_layout_item());
if(!layout_group)
@@ -1228,8 +1255,10 @@
std::cerr << "FlowTableWithFields::on_datawidget_layout_item_added(): layout_group is null." << std::endl;
return;
}
+
+ add_layout_item_at_position(textobject, cur_widget);
- if(above)
+ if (above && above->get_layout_item())
layout_group->add_item(textobject, above->get_layout_item());
else
layout_group->add_item(textobject);
@@ -1252,17 +1281,49 @@
if(dynamic_cast<Glom::PlaceholderGlom*>(*cur_widget))
return;
- remove (*m_placeholder);
+ on_dnd_remove_placeholder();
}
-
sharedptr<LayoutItem_Placeholder> placeholder_field(new LayoutItem_Placeholder);
add_layout_item_at_position (placeholder_field, cur_widget);
+
+ //Get the layout group that the "above" widget's layout item is in
+ sharedptr<LayoutGroup> layout_group = get_layout_group();
+ if(!layout_group)
+ {
+ std::cerr << "FlowTableWithFields::on_dnd_add_placeholder: layout_group is null." << std::endl;
+ return;
+ }
+
+ std::cout << "Group: " << layout_group->get_title() << std::endl;
+
+ if(above)
+ {
+ layout_group->add_item(placeholder_field, above->get_layout_item());
+ }
+ else
+ layout_group->add_item(placeholder_field);
}
void FlowTableWithFields::on_dnd_remove_placeholder()
{
if(m_placeholder)
{
+ //Get the layout group that the "above" widget's layout item is in
+ sharedptr<LayoutGroup> layout_group = get_layout_group();
+ if(layout_group)
+ {
+ LayoutGroup::type_list_items items = layout_group->get_items();
+ for (LayoutGroup::type_list_items::iterator item = items.begin();
+ item != items.end(); item++)
+ {
+ sharedptr<LayoutItem_Placeholder> placeholder =
+ sharedptr<LayoutItem_Placeholder>::cast_dynamic(*item);
+ if (placeholder)
+ {
+ layout_group->remove_item (*item);
+ }
+ }
+ }
remove(*m_placeholder);
}
Modified: trunk/glom/mode_data/flowtablewithfields.h
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.h (original)
+++ trunk/glom/mode_data/flowtablewithfields.h Mon Feb 18 17:53:02 2008
@@ -91,8 +91,8 @@
* for instance, if the user chose a new field for a DataWidget,
* or a new relationship for a portal.
*/
- //void get_layout_groups(Document_Glom::type_list_layout_groups& groups);
- //sharedptr<LayoutGroup> get_layout_group();
+ void get_layout_groups(Document_Glom::type_list_layout_groups& groups);
+ sharedptr<LayoutGroup> get_layout_group();
/** For instance,
* void on_flowtable_field_edited(const sharedptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
@@ -123,7 +123,7 @@
*/
typedef sigc::signal<void, const sharedptr<LayoutItem_Button>&> type_signal_script_button_clicked;
type_signal_script_button_clicked signal_script_button_clicked();
-
+
protected:
virtual type_list_widgets get_field(const sharedptr<const LayoutItem_Field>& field);
@@ -138,7 +138,6 @@
void on_entry_open_details_requested(const Gnome::Gda::Value& value, sharedptr<const LayoutItem_Field> field);
void on_flowtable_entry_edited(const sharedptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
void on_flowtable_entry_open_details_requested(const sharedptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
-
void on_portal_record_changed(const Glib::ustring& relationship_name);
void on_flowtable_related_record_changed(const Glib::ustring& relationship_name);
void on_flowtable_requested_related_details(const Glib::ustring& table_name, Gnome::Gda::Value primary_key_value);
@@ -224,7 +223,6 @@
//type_signal_related_record_added m_signal_related_record_added;
type_signal_related_record_changed m_signal_related_record_changed;
type_signal_requested_related_details m_signal_requested_related_details;
-
type_signal_script_button_clicked m_signal_script_button_clicked;
};
Modified: trunk/glom/utility_widgets/dragbar.cc
==============================================================================
--- trunk/glom/utility_widgets/dragbar.cc (original)
+++ trunk/glom/utility_widgets/dragbar.cc Mon Feb 18 17:53:02 2008
@@ -24,6 +24,8 @@
#include <glibmm/i18n.h>
#include "config.h"
+#include "layoutwidgetbase.h"
+
namespace Glom
{
@@ -31,23 +33,27 @@
{
Gtk::Image* image_item =
Gtk::manage (new Gtk::Image(GLOM_ICON_DIR "/glom-field.png"));
- Gtk::Image* image_group =
- Gtk::manage (new Gtk::Image(GLOM_ICON_DIR "/glom-group.png"));
Gtk::Image* image_button =
Gtk::manage (new Gtk::Image(GLOM_ICON_DIR "/glom-button.png"));
Gtk::Image* image_text =
Gtk::manage (new Gtk::Image(GLOM_ICON_DIR "/glom-text.png"));
- DragButton* drag_item = Gtk::manage(new DragButton(*image_item, "LayoutField"));
- DragButton* drag_group = Gtk::manage(new DragButton(*image_group, "LayoutGroup"));
- DragButton* drag_button = Gtk::manage(new DragButton(*image_button, "LayoutButton"));
- DragButton* drag_text = Gtk::manage(new DragButton(*image_text, "LayoutText"));
+ Gtk::Image* image_group =
+ Gtk::manage (new Gtk::Image(GLOM_ICON_DIR "/glom-group.png"));
+ Gtk::Image* image_notebook =
+ Gtk::manage (new Gtk::Image(GLOM_ICON_DIR "/glom-notebook.png"));
- // FIXME: This does not work currently
- drag_group->set_sensitive (false);
+ DragButton* drag_group = Gtk::manage(new DragButton(*image_group, LayoutWidgetBase::TYPE_GROUP));
+ DragButton* drag_notebook = Gtk::manage(new DragButton(*image_notebook, LayoutWidgetBase::TYPE_NOTEBOOK));
+
+ DragButton* drag_item = Gtk::manage(new DragButton(*image_item, LayoutWidgetBase::TYPE_FIELD));
+ DragButton* drag_button = Gtk::manage(new DragButton(*image_button, LayoutWidgetBase::TYPE_BUTTON));
+ DragButton* drag_text = Gtk::manage(new DragButton(*image_text, LayoutWidgetBase::TYPE_TEXT));
+
+ add_button (*drag_group);
+ add_button (*drag_notebook);
add_button (*drag_item);
- add_button (*drag_group);
add_button (*drag_button);
add_button (*drag_text);
Modified: trunk/glom/utility_widgets/dragbutton.cc
==============================================================================
--- trunk/glom/utility_widgets/dragbutton.cc (original)
+++ trunk/glom/utility_widgets/dragbutton.cc Mon Feb 18 17:53:02 2008
@@ -23,10 +23,10 @@
namespace Glom
{
-DragButton::DragButton(Gtk::Image& image, const Glib::ustring& id)
+DragButton::DragButton(Gtk::Image& image, LayoutWidgetBase::enumType type)
{
set_image(image);
- m_id = id;
+ m_type = type;
std::list<Gtk::TargetEntry> targetentries;
targetentries.push_back(Gtk::TargetEntry(get_target()));
drag_source_set(targetentries, Gdk::MODIFIER_MASK,
@@ -41,7 +41,7 @@
void DragButton::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
Gtk::SelectionData& selection_data, guint, guint)
{
- selection_data.set(get_target(), m_id);
+ selection_data.set(8, (guint8*)(&m_type), 4);
}
void DragButton::on_drag_begin(const Glib::RefPtr<Gdk::DragContext>& drag_context)
Modified: trunk/glom/utility_widgets/dragbutton.h
==============================================================================
--- trunk/glom/utility_widgets/dragbutton.h (original)
+++ trunk/glom/utility_widgets/dragbutton.h Mon Feb 18 17:53:02 2008
@@ -22,6 +22,8 @@
#include <gtkmm/image.h>
#include <string>
+#include "layoutwidgetbase.h"
+
#ifndef DRAGBUTTON_H
#define DRAGBUTTON_H
@@ -31,7 +33,7 @@
class DragButton : public Gtk::Button
{
public:
- DragButton(Gtk::Image& image, const Glib::ustring& id);
+ DragButton(Gtk::Image& image, LayoutWidgetBase::enumType type);
~DragButton();
@@ -42,7 +44,7 @@
Gtk::SelectionData& selection_data, guint, guint);
private:
- Glib::ustring m_id;
+ LayoutWidgetBase::enumType m_type;
};
}
Modified: trunk/glom/utility_widgets/flowtable.cc
==============================================================================
--- trunk/glom/utility_widgets/flowtable.cc (original)
+++ trunk/glom/utility_widgets/flowtable.cc Mon Feb 18 17:53:02 2008
@@ -654,6 +654,11 @@
void FlowTable::on_size_request(Gtk::Requisition* requisition)
{
+ // Set a minimum size so people are able to drag items into the
+ // table
+ const int MIN_HEIGHT = (m_design_mode ? 50 : 0);
+ const int MIN_WIDTH = (m_design_mode ? 100 : 0);
+
//Initialize the output parameter:
*requisition = Gtk::Requisition();
@@ -662,8 +667,8 @@
int total_width = 0;
const int column_height = get_minimum_column_height(0, m_columns_count, total_width); //This calls itself recursively.
- requisition->height = column_height;
- requisition->width = total_width;
+ requisition->height = (column_height > MIN_HEIGHT ? column_height : MIN_HEIGHT);
+ requisition->width = (total_width > MIN_WIDTH ? total_width : MIN_WIDTH);
}
//Give it whatever height/width it wants, at this location:
@@ -1143,27 +1148,38 @@
void FlowTable::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& drag_context, int drag_x, int drag_y, const Gtk::SelectionData& selection_data, guint, guint time)
{
- const Glib::ustring type = selection_data.get_data_as_string();
+ std::cout << __FUNCTION__ << std::endl;
+ LayoutWidgetBase::enumType type = static_cast<LayoutWidgetBase::enumType>(*selection_data.get_data());
LayoutWidgetBase* above = dnd_find_datawidget ();
- if(type == "LayoutField")
+ switch (type)
+ {
+ case LayoutWidgetBase::TYPE_FIELD:
on_dnd_add_layout_item_field(above);
- else if (type == "LayoutGroup")
- on_dnd_add_layout_group(above);
- else if (type == "LayoutButton")
+ break;
+ case LayoutWidgetBase::TYPE_BUTTON:
on_dnd_add_layout_item_button(above);
- else if (type == "LayoutText")
+ break;
+ case LayoutWidgetBase::TYPE_TEXT:
on_dnd_add_layout_item_text(above);
- else
+ break;
+ case LayoutWidgetBase::TYPE_GROUP:
+ on_dnd_add_layout_group(above);
+ break;
+ case LayoutWidgetBase::TYPE_NOTEBOOK:
+ on_dnd_add_layout_notebook(above);
+ break;
+ default:
std::cerr << "Unknown drop type: " << type << std::endl;
-
+ }
change_dnd_status(false);
}
void FlowTable::on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& drag_context, guint time)
{
+ std::cout << __FUNCTION__ << std::endl;
on_dnd_remove_placeholder();
- realize();
change_dnd_status(false);
+ realize();
}
// Calculate the nearest FlowTableItem below the current drag position
@@ -1219,18 +1235,27 @@
{
Gtk::Alignment* alignment = dynamic_cast <Gtk::Alignment*>(m_current_dnd_item->m_first);
if (alignment)
+ {
above = dynamic_cast<PlaceholderGlom*>(alignment->get_child());
+ if (above)
+ std::cout << "Above placeholder" << std::endl;
+ }
}
if(!above && m_current_dnd_item->m_first)
above = dynamic_cast<LayoutWidgetBase*>(m_current_dnd_item->m_first);
-
if(!above && m_current_dnd_item->m_second)
{
above = dynamic_cast<LayoutWidgetBase*>(m_current_dnd_item->m_second);
//std::cout << g_type_name (G_OBJECT_TYPE (m_current_dnd_item->m_second->gobj())) << std::endl;
}
+ std::cout << "cur_widget: ";
+ std::cout << g_type_name (G_OBJECT_TYPE(m_current_dnd_item->m_first->gobj())) << std::endl;
+ Gtk::Alignment* al = dynamic_cast<Gtk::Alignment*> (m_current_dnd_item->m_first);
+ if (al)
+ {
+ std::cout << g_type_name (G_OBJECT_TYPE(al->get_child()->gobj())) << std::endl;
+ }
}
-
return above;
}
Modified: trunk/glom/utility_widgets/flowtable.h
==============================================================================
--- trunk/glom/utility_widgets/flowtable.h (original)
+++ trunk/glom/utility_widgets/flowtable.h Mon Feb 18 17:53:02 2008
@@ -108,6 +108,7 @@
virtual void on_dnd_add_layout_group(LayoutWidgetBase* above) = 0;
virtual void on_dnd_add_layout_item_button (LayoutWidgetBase* above) = 0;
virtual void on_dnd_add_layout_item_text (LayoutWidgetBase* above) = 0;
+ virtual void on_dnd_add_layout_notebook (LayoutWidgetBase* above) {};
#endif // !GLOM_ENABLE_CLIENT_ONLY
Modified: trunk/icons/16x16/Makefile.am
==============================================================================
--- trunk/icons/16x16/Makefile.am (original)
+++ trunk/icons/16x16/Makefile.am Mon Feb 18 17:53:02 2008
@@ -6,6 +6,7 @@
glom-group.png \
glom-button.png \
glom-text.png \
- glom-image.png
+ glom-image.png \
+ glom-notebook.png
EXTRA_DIST = $(icon_DATA) $(pixmaps_DATA) glom.svg
Added: trunk/icons/16x16/glom-notebook.png
==============================================================================
Binary file. No diff available.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]