[glom/maemo5] Maemo: Hide group titles by default.



commit 6b7aa06fa009d593edb228a1c01512f523df146d
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Oct 5 17:09:47 2009 +0200

    Maemo: Hide group titles by default.
    
    * glom/libglom/data_structure/translatable_item.[h|cc]:
    Added clear_title_in_all_locales().
    * glom/libglom/document/document.cc:
    maemo_restrict_layouts_to_single_column_group(): Also clear the group titles
    to make the default maemo layout more compact.

 ChangeLog                                        |   10 ++++++++++
 glom/libglom/data_structure/translatable_item.cc |   16 +++++++++++++++-
 glom/libglom/data_structure/translatable_item.h  |    4 ++++
 glom/libglom/document/document.cc                |    7 +++++--
 4 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9a4a47a..199c5f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-05  Murray Cumming  <murrayc murrayc com>
+
+	Maemo: Hide group titles by default.
+	
+	* glom/libglom/data_structure/translatable_item.[h|cc]:
+	Added clear_title_in_all_locales().
+	* glom/libglom/document/document.cc:
+	maemo_restrict_layouts_to_single_column_group(): Also clear the group titles 
+	to make the default maemo layout more compact.
+	
 2009-10-05  Murray Cumming  <murrayc murrayc-desktop>
 
 	Export: Correct problems in the binary data for images: Escape newlines.
diff --git a/glom/libglom/data_structure/translatable_item.cc b/glom/libglom/data_structure/translatable_item.cc
index 1e5e9c6..780b5eb 100644
--- a/glom/libglom/data_structure/translatable_item.cc
+++ b/glom/libglom/data_structure/translatable_item.cc
@@ -134,7 +134,10 @@ Glib::ustring TranslatableItem::get_title() const
         //This would be quite unusual.
         type_map_locale_to_translations::const_iterator iter = m_map_translations.begin();
         if(iter != m_map_translations.end())
+        {
+          //std::cout << "debug: TranslatableItem::get_title() falling back to the first translation: locale=" << iter->first << std::endl;
           return iter->second;
+        }
       }
       else
       {
@@ -186,11 +189,22 @@ void TranslatableItem::set_title_original(const Glib::ustring& title)
   m_title = title;
 }
 
+void TranslatableItem::clear_title_in_all_locales()
+{
+  m_title.clear();
+  
+  for(type_map_locale_to_translations::iterator iter = m_map_translations.begin(); iter != m_map_translations.end(); ++iter)
+  {
+    Glib::ustring& translation = iter->second;
+    translation.clear();
+  }
+}
+
 Glib::ustring TranslatableItem::get_current_locale()
 {
   if(m_current_locale.empty())
   {
-    char* cLocale = setlocale(LC_ALL, NULL); //Passing NULL means query, instead of set.
+    const char* cLocale = setlocale(LC_ALL, NULL); //Passing NULL means query, instead of set.
     if(cLocale)
     {
       //std::cout << "TranslatableItem::get_current_locale(): locale=" << cLocale << std::endl;
diff --git a/glom/libglom/data_structure/translatable_item.h b/glom/libglom/data_structure/translatable_item.h
index 550ca2c..775844c 100644
--- a/glom/libglom/data_structure/translatable_item.h
+++ b/glom/libglom/data_structure/translatable_item.h
@@ -78,8 +78,12 @@ public:
    */
   void set_title_original(const Glib::ustring& title);
 
+  //TODO: Rename to set_title_translation()?
   void set_translation(const Glib::ustring& locale, const Glib::ustring& translation);
   Glib::ustring get_translation(const Glib::ustring& locale) const;
+  
+  /// Clear the original title and any translations of the title.
+  void clear_title_in_all_locales();
 
   typedef std::map<Glib::ustring, Glib::ustring> type_map_locale_to_translations;
 
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 8be87b9..afe108e 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -4125,7 +4125,10 @@ void Document::maemo_restrict_layouts_to_single_column_group(const sharedptr<Lay
   //Change it to a single column group:
   if(layout_group->get_columns_count() > 1)  
     layout_group->set_columns_count(1);
-     
+   
+  //Remove the title, as it uses too much space on a Maemo screen:
+  layout_group->clear_title_in_all_locales();
+ 
   //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)
   {
@@ -4134,7 +4137,7 @@ void Document::maemo_restrict_layouts_to_single_column_group(const sharedptr<Lay
     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()



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