[glom/maemo5] Maemo: Avoid multi-column details layouts.



commit b45df3db52fa584d9a3866e20a01960eb9549e84
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Oct 2 17:21:23 2009 +0200

    Maemo: Avoid multi-column details layouts.
    
    * glom/libglom/document/document.[h|cc]:
    Added maemo_restrict_layouts_to_single_column_group().
    * glom/application.cc: on_document_load(): On maemo, call it to make the
    layout more suitable by default, if no custom maemo layout is defined.

 ChangeLog                         |    9 ++++++
 glom/application.cc               |    8 ++++-
 glom/libglom/document/document.cc |   56 +++++++++++++++++++++++++++++++++++++
 glom/libglom/document/document.h  |   11 ++++++-
 4 files changed, 82 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 70f3086..7f7680b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2009-10-02  Murray Cumming  <murrayc murrayc com>
 
+	Maemo: Avoid multi-column details layouts.
+	 
+	* glom/libglom/document/document.[h|cc]:
+	Added maemo_restrict_layouts_to_single_column_group().
+	* glom/application.cc: on_document_load(): On maemo, call it to make the 
+	layout more suitable by default, if no custom maemo layout is defined. 
+
+2009-10-02  Murray Cumming  <murrayc murrayc com>
+
 	Maemo: Fix the build.
 	
 	* glom/frame_glom.cc:
diff --git a/glom/application.cc b/glom/application.cc
index 970bfe2..0d108bc 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -943,7 +943,13 @@ bool App_Glom::on_document_load()
 
   if(!pDocument->get_is_new() && !check_document_hosting_mode_is_supported(pDocument))
     return false;
- 
+    
+  #ifdef GLOM_ENABLE_MAEMO
+  //On Maemo, make regular (not specifically maemo) layouts single-column,
+  //so they are more appropriate by default:
+  pDocument->maemo_restrict_layouts_to_single_column();
+  #endif //GLOM_ENABLE_MAEMO
+  
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   //Connect signals:
   pDocument->signal_userlevel_changed().connect( sigc::mem_fun(*this, &App_Glom::on_userlevel_changed) );
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 95f698a..2a8a24b 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -4103,6 +4103,62 @@ bool Document::load(int& failure_code)
   return GlomBakery::Document_XML::load(failure_code);
 }
 
+void Document::maemo_restrict_layouts_to_single_column_group(const sharedptr<LayoutGroup>& layout_group)
+{
+  if(!layout_group)
+    return;
+    
+  std::cout << "debug: group columns=" << layout_group->get_columns_count() << std::endl;
+
+  //Change it to a single column group:
+  if(layout_group->get_columns_count() > 1)
+  {     
+    layout_group->set_columns_count(1);
+    std::cout << "  debug: changed group columns=" << layout_group->get_columns_count() << std::endl;
+  }
+     
+  //Do the same with any child groups:
+  for(LayoutGroup::type_list_items::iterator iter = layout_group->m_list_items.begin(); iter != layout_group->m_list_items.end(); ++iter)
+  {
+    sharedptr<LayoutItem> layout_item = *iter;
+
+    sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::cast_dynamic(layout_item);
+    if(group)
+      maemo_restrict_layouts_to_single_column_group(group);
+  } 
+}
+
+void Document::maemo_restrict_layouts_to_single_column()
+{
+  //Look at every table:
+  for(type_tables::iterator iter = m_tables.begin(); iter != m_tables.end(); ++iter)
+  {
+    DocumentTableInfo& info = iter->second;
+    //std::cout << "debug: table: " << info.m_info->m_name << std::endl;
+      
+    //Look at every layout:
+    for(DocumentTableInfo::type_layouts::iterator iterLayouts = info.m_layouts.begin();
+      iterLayouts != info.m_layouts.end(); ++iterLayouts)
+    {
+      LayoutInfo& layout_info = *iterLayouts;
+      std::cout << "debug: layout: " << layout_info.m_layout_name << std::endl;
+      
+      //Allow specifically-designed maemo layouts to have multiple columns,
+      //but resize the others.
+      if(true)//layout_info.m_layout_platform != "maemo")
+      {
+        //Look at every group, recursively:
+        for(type_list_layout_groups::iterator iterGroups = layout_info.m_layout_groups.begin(); 
+          iterGroups != layout_info.m_layout_groups.end(); ++iterGroups)
+        {
+          sharedptr<LayoutGroup> group = *iterGroups;
+          maemo_restrict_layouts_to_single_column_group(group);
+        }
+      }
+    }
+  }      
+}
+
 
 } //namespace Glom
 
diff --git a/glom/libglom/document/document.h b/glom/libglom/document/document.h
index c77028f..b9b8758 100644
--- a/glom/libglom/document/document.h
+++ b/glom/libglom/document/document.h
@@ -402,7 +402,13 @@ public:
    */
   void set_active_layout_platform(const Glib::ustring& layout_platform = Glib::ustring());
 
-
+  /** Change any non-maemo layouts so their groups never have multiple columns, 
+   * because this could never be displayed on the Maemo screen.
+   * This allows layouts to be shown fairly sanely on Maemo even if no custom 
+   * maemo layout was defined.
+   * This does not save the change to disk.
+   */
+  void maemo_restrict_layouts_to_single_column();
 
 #ifndef SWIG //Hide this API from swig.
   Glib::ustring build_and_get_contents() const;
@@ -483,6 +489,9 @@ private:
   Glib::ustring get_child_text_node(const xmlpp::Element* node, const Glib::ustring& child_node_name) const;
   void set_child_text_node(xmlpp::Element* node, const Glib::ustring& child_node_name, const Glib::ustring& text);
 
+  ///A recursive helper function.
+  static void maemo_restrict_layouts_to_single_column_group(const sharedptr<LayoutGroup>& layout_group);
+  
   AppState m_app_state;
   type_signal_userlevel_changed m_signal_userlevel_changed;
 



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