Commit 438137d9 authored by Murray Cumming's avatar Murray Cumming
Browse files

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.
parent 015d5c58
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
......
......@@ -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
......
......@@ -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:
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment