Reviewers: ,


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

Affected files:
  M tryton/gui/window/view_form/view/form_gtk/many2many.py
  M tryton/gui/window/view_form/view/form_gtk/many2one.py
  M tryton/gui/window/view_form/view/form_gtk/one2many.py


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

--- a/tryton/gui/window/view_form/view/form_gtk/many2many.py
+++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py
@@ -34,22 +34,14 @@
         tooltips = common.Tooltips()

         self.wid_text = gtk.Entry()
+        self.wid_text.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY,
+            'tryton-list-add')
         self.wid_text.set_property('width_chars', 13)
         self.wid_text.connect('activate', self._sig_activate)
+        self.wid_text.connect('icon-release', self._sig_add)
+ self.wid_text.set_icon_tooltip_text(gtk.ENTRY_ICON_SECONDARY, _('Add'))
         hbox.pack_start(self.wid_text, expand=True, fill=True)

-        self.but_add = gtk.Button()
-        tooltips.set_tip(self.but_add, _('Add'))
-        self.but_add.connect('clicked', self._sig_add)
-        img_add = gtk.Image()
-        img_add.set_from_stock('tryton-list-add',
-            gtk.ICON_SIZE_SMALL_TOOLBAR)
-        img_add.set_alignment(0.5, 0.5)
-        self.but_add.add(img_add)
-        self.but_add.set_relief(gtk.RELIEF_NONE)
-        hbox.pack_start(self.but_add, expand=False, fill=False)
-
-
         self.but_remove = gtk.Button()
         tooltips.set_tip(self.but_remove, _('Remove'))
         self.but_remove.connect('clicked', self._sig_remove)
@@ -170,7 +162,7 @@
         self.wid_text.set_editable(not value)
         self.wid_text.set_sensitive(not value)
         self.but_remove.set_sensitive(not value)
-        self.but_add.set_sensitive(not value)
+ self.wid_text.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, not value)

     def _sig_label(self, screen, signal_data):
         if signal_data[0] >= 1:

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

--- a/tryton/gui/window/view_form/view/form_gtk/many2one.py
+++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py
@@ -40,15 +40,11 @@
         self.wid_text.connect_after('focus-out-event', self.sig_activate)
         self.focus_out = True
         self.widget.pack_start(self.wid_text, expand=True, fill=True)
-
-        self.but_open = gtk.Button()
-        img_find = gtk.Image()
-        img_find.set_from_stock('tryton-find', gtk.ICON_SIZE_SMALL_TOOLBAR)
-        self.but_open.set_image(img_find)
-        self.but_open.set_relief(gtk.RELIEF_NONE)
-        self.but_open.connect('clicked', self.sig_edit)
-        self.but_open.set_alignment(0.5, 0.5)
-        self.widget.pack_start(self.but_open, expand=False, fill=False)
+        self.wid_text.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY,
+            'tryton-find')
+        self.wid_text.connect('icon-release', self.sig_edit)
+        self.wid_text.set_icon_tooltip_text(gtk.ENTRY_ICON_SECONDARY,
+            _('Open a record'))

         self.but_new = gtk.Button()
         img_new = gtk.Image()
@@ -63,7 +59,6 @@

         self.tooltips = common.Tooltips()
         self.tooltips.set_tip(self.but_new, _('Create a new record'))
-        self.tooltips.set_tip(self.but_open, _('Open a record'))
         self.tooltips.enable()

         self._readonly = False
@@ -158,7 +153,7 @@
             self.focus_out = True
         WinForm(screen, callback, new=True)

-    def sig_edit(self, widget):
+    def sig_edit(self, *args):
         self.changed = False
         value = self.field.get(self.record)
         self.focus_out = False
@@ -252,16 +247,21 @@
             self.wid_text.set_text('')
             self.changed = True
             return False
-        img = self.but_open.get_image()
-        current_stock = img.get_stock()[0]
+ current_stock = self.wid_text.get_icon_name(gtk.ENTRY_ICON_SECONDARY)
         res = field.get_client(record)
         self.wid_text.set_text((res and str(res)) or '')
+        update_icon = True
         if res and current_stock != 'tryton-open':
-            img.set_from_stock('tryton-open', gtk.ICON_SIZE_SMALL_TOOLBAR)
-            self.tooltips.set_tip(self.but_open, _('Open a record'))
+            stock_name, tooltip_text = 'tryton-open', _('Open a record')
         elif not res and current_stock != 'tryton-find':
-            img.set_from_stock('tryton-find', gtk.ICON_SIZE_SMALL_TOOLBAR)
-            self.tooltips.set_tip(self.but_open, _('Search a record'))
+            stock_name, tooltip_text = 'tryton-find', _('Search a record')
+        else:
+            update_icon = False
+        if update_icon:
+            self.wid_text.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY,
+                stock_name)
+            self.wid_text.set_icon_tooltip_text(gtk.ENTRY_ICON_SECONDARY,
+                tooltip_text)
         self.changed = True

     def _populate_popup(self, widget, menu):

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

--- a/tryton/gui/window/view_form/view/form_gtk/one2many.py
+++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py
@@ -42,15 +42,10 @@
             self.wid_text.connect('activate', self._sig_activate)
             hbox.pack_start(self.wid_text, expand=True, fill=True)

-            self.but_add = gtk.Button()
-            tooltips.set_tip(self.but_add, _('Add'))
-            self.but_add.connect('clicked', self._sig_add)
-            img_add = gtk.Image()
- img_add.set_from_stock('tryton-list-add', gtk.ICON_SIZE_SMALL_TOOLBAR)
-            img_add.set_alignment(0.5, 0.5)
-            self.but_add.add(img_add)
-            self.but_add.set_relief(gtk.RELIEF_NONE)
-            hbox.pack_start(self.but_add, expand=False, fill=False)
+            self.wid_text.connect('icon-release', self._sig_add)
+            self.wid_text.set_icon_tooltip_text(gtk.ENTRY_ICON_SECONDARY,
+                _('Add'))
+            self.wid_text.connect('icon-release', self._sig_add)

             self.but_remove = gtk.Button()
             tooltips.set_tip(self.but_remove, _('Remove'))
@@ -217,7 +212,8 @@
         self.but_undel.set_sensitive(not value)
         if self.attrs.get('add_remove'):
             self.wid_text.set_sensitive(not value)
-            self.but_add.set_sensitive(not value)
+            self.wid_text.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY,
+                not value)
             self.but_remove.set_sensitive(not value)

     def _sig_new(self, widget):



--
[email protected] mailing list

Reply via email to