Reviewers: ,


Please review this at http://codereview.tryton.org/40007/

Affected files:
  M tryton/common/date_widget.py
  M tryton/gui/window/view_form/view/form_gtk/binary.py
  M tryton/gui/window/view_form/view/form_gtk/char.py
  M tryton/gui/window/view_form/view/form_gtk/float.py
  M tryton/gui/window/view_form/view/form_gtk/integer.py
  M tryton/gui/window/view_form/view/form_gtk/reference.py
  M tryton/gui/window/view_form/view/form_gtk/selection.py


Index: tryton/common/date_widget.py
===================================================================

--- a/tryton/common/date_widget.py
+++ b/tryton/common/date_widget.py
@@ -276,7 +276,7 @@
         self.widget.select_region(0, 0)
         self.widget_cmd = CmdEntry()
         self.widget_cmd.hide()
-        self.pack_start(self.widget, expand=True, fill=True)
+        self.pack_start(self.widget, expand=False, fill=False)
         self.pack_start(self.widget_cmd, expand=False, fill=True)

     def _date_cb(self, event):

Index: tryton/gui/window/view_form/view/form_gtk/binary.py
===================================================================

--- a/tryton/gui/window/view_form/view/form_gtk/binary.py
+++ b/tryton/gui/window/view_form/view/form_gtk/binary.py
@@ -31,7 +31,7 @@

         self.widget = gtk.HBox(spacing=0)
         self.wid_size = gtk.Entry()
-        self.wid_size.set_width_chars(11)
+        self.wid_size.set_width_chars(10)
         self.wid_size.props.sensitive = False
         if self.filename and attrs.get('filename_visible'):
             self.wid_text = gtk.Entry()

Index: tryton/gui/window/view_form/view/form_gtk/char.py
===================================================================

--- a/tryton/gui/window/view_form/view/form_gtk/char.py
+++ b/tryton/gui/window/view_form/view/form_gtk/char.py
@@ -30,12 +30,12 @@
             focus_entry = self.entry.get_child()
         else:
             self.entry = gtk.Entry()
-            self.entry.set_property('activates_default', True)
-            self.entry.set_max_length(int(attrs.get('size', 0)))
-            self.entry.set_width_chars(5)
-            self.entry.connect('activate', self.sig_activate)
             focus_entry = self.entry

+        focus_entry.set_property('activates_default', True)
+        focus_entry.set_width_chars(10)
+        focus_entry.set_max_length(int(attrs.get('size', 0)))
+        focus_entry.connect('activate', self.sig_activate)
focus_entry.connect('focus-in-event', lambda x, y: self._focus_in()) focus_entry.connect('focus-out-event', lambda x, y: self._focus_out())
         self.widget.pack_start(self.entry)

Index: tryton/gui/window/view_form/view/form_gtk/float.py
===================================================================

--- a/tryton/gui/window/view_form/view/form_gtk/float.py
+++ b/tryton/gui/window/view_form/view/form_gtk/float.py
@@ -12,6 +12,7 @@
         super(Float, self).__init__(field_name, model_name, window,
                 attrs=attrs)
         self.digits = (16, 2)
+        self.entry.set_width_chars(sum(self.digits))
         self.entry.connect('key-press-event', self.key_press_event)

     def set_value(self, record, field):
@@ -31,6 +32,7 @@
             digits = record.expr_eval(self.digits)
         else:
             digits = self.digits
+        self.entry.set_width_chars(sum(digits))
         self.entry.set_text(locale.format('%.' + str(digits[1]) + 'f',
             field.get(record) or 0.0, True))


Index: tryton/gui/window/view_form/view/form_gtk/integer.py
===================================================================

--- a/tryton/gui/window/view_form/view/form_gtk/integer.py
+++ b/tryton/gui/window/view_form/view/form_gtk/integer.py
@@ -10,6 +10,11 @@
     def __init__(self, field_name, model_name, window, attrs=None):
         super(Integer, self).__init__(field_name, model_name, window,
                 attrs=attrs)
+        self.entry.set_width_chars(8)
+        _, _, padding, pack_type = self.widget.query_child_packing(
+            self.entry)
+        self.widget.set_child_packing(self.entry, False, False,
+            padding, pack_type)
         self.entry.set_max_length(0)
         self.entry.set_alignment(1.0)
         self.entry.connect('insert_text', self.sig_insert_text)

Index: tryton/gui/window/view_form/view/form_gtk/reference.py
===================================================================

--- a/tryton/gui/window/view_form/view/form_gtk/reference.py
+++ b/tryton/gui/window/view_form/view/form_gtk/reference.py
@@ -3,6 +3,7 @@
 import gtk
 import gobject
 import gettext
+import math
 from interface import WidgetInterface
 from tryton.gui.window.win_search import WinSearch
 from tryton.gui.window.win_form import WinForm
@@ -29,7 +30,6 @@
         child.connect('changed',
                 self.sig_changed_combo)
         child.connect('key_press_event', self.sig_key_pressed)
- self.widget_combo.set_size_request(int(attrs.get('widget_size', -1)), -1)
         self.widget.pack_start(self.widget_combo, expand=False, fill=True)

         self.widget.pack_start(gtk.Label('-'), expand=False, fill=False)
@@ -85,6 +85,14 @@
                 common.process_exception(exception, self.window)
                 selection = []
         selection.sort(lambda x, y: cmp(x[1], y[1]))
+        if selection:
+            width = int(math.sqrt(
+                sum(len(y)**2 for x, y in selection)
+                / len(selection)))
+            width = max(width, 10)
+        else:
+            width = 10
+        child.set_width_chars(width)
         self.set_popdown(selection)

         self.last_key = (None, 0)

Index: tryton/gui/window/view_form/view/form_gtk/selection.py
===================================================================

--- a/tryton/gui/window/view_form/view/form_gtk/selection.py
+++ b/tryton/gui/window/view_form/view/form_gtk/selection.py
@@ -2,6 +2,7 @@
 #this repository contains the full copyright notices and license terms.
 import gtk
 import gobject
+import math
 from interface import WidgetInterface
 import tryton.rpc as rpc
 import tryton.common as common
@@ -20,15 +21,14 @@
         child = self.entry.get_child()
         child.set_property('activates_default', True)
         child.set_max_length(int(attrs.get('size', 0)))
-        child.set_width_chars(5)
+        child.set_width_chars(10)

         child.connect('changed', self.sig_changed)
         self.changed = True
         child.connect('key_press_event', self.sig_key_press)
         child.connect('activate', self.sig_activate)
         child.connect_after('focus-out-event', self.sig_activate)
-        self.entry.set_size_request(int(attrs.get('widget_size', -1)), -1)
-        self.widget.pack_start(self.entry, expand=True, fill=True)
+        self.widget.pack_start(self.entry, expand=False, fill=False)
         self.widget.set_focus_chain([child])

         self._selection = {}
@@ -98,6 +98,14 @@
             completion.set_inline_selection(True)
         completion.set_model(model)
         self.entry.get_child().set_completion(completion)
+        if self._selection:
+            width = int(math.sqrt(
+                sum(len(x)**2 for x in self._selection)
+                / len(self._selection)))
+            width = max(width, 10)
+        else:
+            width = 10
+        self.entry.get_child().set_width_chars(width)
         completion.set_text_column(0)
         return lst




--
[email protected] mailing list

Reply via email to