[glom] List View: Correct the default column widths.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] List View: Correct the default column widths.
- Date: Mon, 17 Oct 2011 11:56:54 +0000 (UTC)
commit 438137d97d8854e30808e959408a0ef46450d3ba
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Oct 17 13:56:38 2011 +0200
List View: Correct the default column widths.
* glom/utils_ui.[h|cc]: get_suitable_field_width_for_widget(): Added a
for_treeview parameter and adjust the width accordingly.
* glom/mode_data/db_adddel/db_adddel.cc: treeview_append_colum():
Replace the overly-generic division-by-3 hack with the new parameter, and
add some hard-coded extra space.
ChangeLog | 10 ++++++++++
glom/mode_data/db_adddel/db_adddel.cc | 4 ++--
glom/utils_ui.cc | 16 +++++++++++-----
glom/utils_ui.h | 2 +-
4 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1d56c5d..3d487d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2011-10-17 Murray Cumming <murrayc murrayc com>
+ List View: Correct the default column widths.
+
+ * glom/utils_ui.[h|cc]: get_suitable_field_width_for_widget(): Added a
+ for_treeview parameter and adjust the width accordingly.
+ * glom/mode_data/db_adddel/db_adddel.cc: treeview_append_colum():
+ Replace the overly-generic division-by-3 hack with the new parameter, and
+ add some hard-coded extra space.
+
+2011-10-17 Murray Cumming <murrayc murrayc com>
+
Details: Avoid an outdent after group titles
* glom/mode_data/flowtablewithfields.cc: add_layout_group(): Work around
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index ae5c10c..b7d4886 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -1714,8 +1714,8 @@ guint DbAddDel::treeview_append_column(const Glib::ustring& title, Gtk::CellRend
//TODO: Choose a width based on the first 100 values.
if(layout_item_field)
{
- column_width = Utils::get_suitable_field_width_for_widget(*this, layout_item_field, true /* or_title */);
- column_width = column_width / 3;
+ column_width = Utils::get_suitable_field_width_for_widget(*this, layout_item_field, true /* or_title */, true /* for treeview */);
+ column_width = column_width + 8; //Some extra for the GtkTreeView's padding.
//std::cout << "DEBUG: column_width=" << column_width << std::endl;
}
else
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index 38d5dfe..d1d4408 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -298,7 +298,7 @@ static int get_width_for_text(Gtk::Widget& widget, const Glib::ustring& text)
return result;
}
-int Utils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const sharedptr<const LayoutItem_Field>& field_layout, bool or_title)
+int Utils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const sharedptr<const LayoutItem_Field>& field_layout, bool or_title, bool for_treeview)
{
int result = 150; //Suitable default.
@@ -309,7 +309,7 @@ int Utils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const shared
{
case(Field::TYPE_DATE):
{
- Glib::Date date(31, Glib::Date::Month(12), 2000);
+ const Glib::Date date(31, Glib::Date::Month(12), 2000);
example_text = Conversions::get_text_for_gda_value(field_type, Gnome::Gda::Value(date));
break;
}
@@ -324,14 +324,21 @@ int Utils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const shared
}
case(Field::TYPE_NUMERIC):
{
- example_text = "EUR 9999999999";
+ if(for_treeview)
+ example_text = "EUR 999.99";
+ else
+ example_text = "EUR 9999999999";
+
break;
}
case(Field::TYPE_TEXT):
case(Field::TYPE_IMAGE): //Give images the same width as text fields, so they will often line up.
{
- //if(!field_layout->get_text_format_multiline()) //Use the full width for multi-line text.
+ if(for_treeview)
+ example_text = "AAAAAAAAAAAA";
+ else
example_text = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+
break;
}
default:
@@ -340,7 +347,6 @@ int Utils::get_suitable_field_width_for_widget(Gtk::Widget& widget, const shared
}
}
-
if(!example_text.empty())
{
//Get the width required for this string in the current font:
diff --git a/glom/utils_ui.h b/glom/utils_ui.h
index 71c8beb..550074c 100644
--- a/glom/utils_ui.h
+++ b/glom/utils_ui.h
@@ -84,7 +84,7 @@ Glib::RefPtr<Gdk::Pixbuf> get_pixbuf_for_gda_value(const Gnome::Gda::Value& valu
* @or_title If true, check the width of the item's title too, returning the larger of the two values.
* @result The width in pixels.
*/
-int get_suitable_field_width_for_widget(Gtk::Widget& widget, const sharedptr<const LayoutItem_Field>& field_layout, bool or_title = false);
+int get_suitable_field_width_for_widget(Gtk::Widget& widget, const sharedptr<const LayoutItem_Field>& field_layout, bool or_title = false, bool for_treeview = false);
/// Add the @a extension if no extension is there already:
std::string get_filepath_with_extension(const std::string& filepath, const std::string& extension);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]