Merge lp:~openerp-dev/openobject-client/trunk-page_tooltips-rga into lp:openobject-client

Proposed by Ravi Gadhia (OpenERP)
Status: Merged
Merged at revision: 1874
Proposed branch: lp:~openerp-dev/openobject-client/trunk-page_tooltips-rga
Merge into: lp:openobject-client
Diff against target: 177 lines (+52/-8)
4 files modified
bin/modules/gui/main.py (+5/-0)
bin/modules/gui/window/__init__.py (+0/-1)
bin/modules/gui/window/form.py (+30/-7)
bin/widget/screen/screen.py (+17/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client/trunk-page_tooltips-rga
Reviewer Review Type Date Requested Status
tfr (Openerp) Needs Fixing
Naresh(OpenERP) Approve
Review via email: mp+53422@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve
Revision history for this message
tfr (Openerp) (tfr) wrote :

Is it possible to add in the title of the tab the begining of the object's name :

Like instead of only "lead", having "lead: title" (keep ony the 6 first letter of the object name)

review: Needs Fixing
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello tfr

The merge proposal serves you what is needed. It does show the "OBJECT's:TITLE" the title will be added only when you open some record. If you are in a list view so there will be only the "OBJECT's NAME" . Try to open multiple tabs with the same object.

correct me if I am missing something !

Thanks

Revision history for this message
tfr (Openerp) (tfr) wrote :

The tooltip is correct but I'm talking about the Title of the tab, it's another feature.
Going on the tab to see the tooltip still annoying, but if we can see the beginning of title directly on the tab, that's perfect

> Hello tfr
>
> The merge proposal serves you what is needed. It does show the
> "OBJECT's:TITLE" the title will be added only when you open some record. If
> you are in a list view so there will be only the "OBJECT's NAME" . Try to open
> multiple tabs with the same object.
>
> correct me if I am missing something !
>
> Thanks

1837. By Ravi Gadhia (OpenERP)

Merge with trunk clinet

1838. By Ravi Gadhia (OpenERP)

[IMP]Form view: page title display action name + name field's first 6 character

Revision history for this message
Ravi Gadhia (OpenERP) (rga-openerp) wrote :

> Is it possible to add in the title of the tab the begining of the object's
> name :
>
> Like instead of only "lead", having "lead: title" (keep ony the 6 first letter
> of the object name)

Hello tfr
    I implement page title as you said. now page title display action_name:name[:6] e.g (Leads:The Ga)

Revision history for this message
xrg (xrg) wrote :

On Thursday 31 March 2011, you wrote:
> > Is it possible to add in the title of the tab the begining of the
> > object's name :
> >
> > Like instead of only "lead", having "lead: title" (keep ony the 6 first
> > letter of the object name)
>
> Hello tfr
> I implement page title as you said. now page title display
> action_name:name[:6] e.g (Leads:The Ga)

Hmmm....

What happens when the name is in utf-8?

I'm afraid you can only safely use the [:6] operator on _unicode_ strings, not
byte strings of utf-8!

--
Say NO to spam and viruses. Stop using Microsoft Windows!

1839. By Ravi Gadhia (OpenERP)

[REF] Convert string to unicode before slicing

Revision history for this message
Ravi Gadhia (OpenERP) (rga-openerp) wrote :

> On Thursday 31 March 2011, you wrote:
> > > Is it possible to add in the title of the tab the begining of the
> > > object's name :
> > >
> > > Like instead of only "lead", having "lead: title" (keep ony the 6 first
> > > letter of the object name)
> >
> > Hello tfr
> > I implement page title as you said. now page title display
> > action_name:name[:6] e.g (Leads:The Ga)
>
> Hmmm....
>
> What happens when the name is in utf-8?
>
> I'm afraid you can only safely use the [:6] operator on _unicode_ strings, not
> byte strings of utf-8!
>
>
>
> --
> Say NO to spam and viruses. Stop using Microsoft Windows!

Hello xrg,
      Thank you for pointing out the issue. it has been improved by last revision(1839) <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/modules/gui/main.py'
2--- bin/modules/gui/main.py 2011-01-27 06:31:03 +0000
3+++ bin/modules/gui/main.py 2011-04-01 09:48:50 +0000
4@@ -1206,6 +1206,7 @@
5 return True
6 return False
7 return True
8+
9
10 def win_add(self, win, datas):
11 """
12@@ -1226,6 +1227,10 @@
13 closebtn.unset_flags(gtk.CAN_FOCUS)
14
15 box_label = gtk.Label(win.name)
16+ box_label.set_tooltip_text(win.name)
17+ win.page_label = box_label
18+
19+
20 event_box = gtk.EventBox()
21 event_box.add(box_label)
22 event_box.set_visible_window(False)
23
24=== modified file 'bin/modules/gui/window/__init__.py'
25--- bin/modules/gui/window/__init__.py 2010-12-21 05:18:43 +0000
26+++ bin/modules/gui/window/__init__.py 2011-04-01 09:48:50 +0000
27@@ -40,7 +40,6 @@
28 if context is None:
29 context = {}
30 context.update(rpc.session.context)
31-
32 if view_type=='form':
33 mode = (mode or 'form,tree').split(',')
34 win = form.form(model, res_id, domain, view_type=mode,
35
36=== modified file 'bin/modules/gui/window/form.py'
37--- bin/modules/gui/window/form.py 2011-03-28 09:11:21 +0000
38+++ bin/modules/gui/window/form.py 2011-04-01 09:48:50 +0000
39@@ -67,6 +67,7 @@
40 self.fields = fields
41 self.domain = domain
42 self.context = context
43+ self.page_label = None
44 self.screen = Screen(self.model, view_type=view_type,
45 context=self.context, view_ids=view_ids, domain=domain,help=help,
46 hastoolbar=options.options['form.toolbar'], hassubmenu=options.options['form.submenu'],
47@@ -136,7 +137,22 @@
48
49 if auto_refresh and int(auto_refresh):
50 gobject.timeout_add(int(auto_refresh) * 1000, self.sig_reload)
51-
52+
53+ def set_tooltips(fn):
54+ def _decorate(self, *args, **kws):
55+ result = fn(self, *args, **kws)
56+ if self.screen.current_view.view_type == 'form':
57+ tips= unicode(self.screen.current_model and self.screen.current_model.value.get('name') or self.name)
58+ tooltips = tips == self.name and self.name or self.name + ': ' + tips[:64]
59+ lable = tips == self.name and self.name or self.name + ': ' + tips[:6]
60+ self.page_label.set_text(lable)
61+ self.page_label.set_tooltip_text(tooltips)
62+ else:
63+ self.page_label.set_text(self.name)
64+ self.page_label.set_tooltip_text(self.name)
65+ return result
66+ return _decorate
67+
68 def sig_switch_diagram(self, widget=None):
69 return self.sig_switch(widget, 'diagram')
70
71@@ -229,7 +245,7 @@
72 else:
73 self.message_state(_('No record selected ! You can only attach to existing record.'), color='red')
74 return True
75-
76+
77 def sig_switch(self, widget=None, mode=None):
78 if not self.modified_save():
79 return
80@@ -262,7 +278,8 @@
81 message+=val+': '+str(line[key] or '/')+'\n'
82 common.message(message)
83 return True
84-
85+
86+ @set_tooltips
87 def sig_remove(self, widget=None):
88 if not self.id_get():
89 msg = _('Record is not saved ! \n Do you want to clear current record ?')
90@@ -286,7 +303,7 @@
91 screen_fields = copy.deepcopy(self.screen.fields)
92 win = win_import.win_import(self.model, screen_fields, fields, parent=self.window,local_context= self.screen.context)
93 res = win.go()
94-
95+
96 def sig_save_as(self, widget=None):
97 fields = []
98 while(self.screen.view_to_load):
99@@ -294,7 +311,7 @@
100 screen_fields = copy.deepcopy(self.screen.fields)
101 win = win_export.win_export(self.model, self.screen.ids_get(), screen_fields, fields, parent=self.window, context=self.context)
102 res = win.go()
103-
104+
105 def sig_new(self, widget=None, autosave=True):
106 if autosave:
107 if not self.modified_save():
108@@ -303,6 +320,9 @@
109 return
110 self.screen.new()
111 self.message_state('')
112+ self.page_label and self.page_label.set_text(self.name)
113+ self.page_label and self.page_label.set_tooltip_text(self.name)
114+
115
116 def sig_copy(self, *args):
117 if not self.modified_save():
118@@ -319,7 +339,8 @@
119
120 def _form_save(self, auto_continue=True):
121 pass
122-
123+
124+ @set_tooltips
125 def sig_save(self, widget=None, sig_new=True, auto_continue=True):
126 res = self.screen.save_current()
127 warning = False
128@@ -337,12 +358,14 @@
129 common.warning(warning,_('Warning !'), parent=self.screen.current_view.window)
130 return bool(id)
131
132+ @set_tooltips
133 def sig_previous(self, widget=None):
134 if not self.modified_save():
135 return
136 self.screen.display_prev()
137 self.message_state('')
138-
139+
140+ @set_tooltips
141 def sig_next(self, widget=None):
142 if not self.modified_save():
143 return
144
145=== modified file 'bin/widget/screen/screen.py'
146--- bin/widget/screen/screen.py 2011-02-11 06:59:40 +0000
147+++ bin/widget/screen/screen.py 2011-04-01 09:48:50 +0000
148@@ -478,6 +478,21 @@
149 del self.win_search
150 del self.win_search_callback
151 del self.window
152+
153+ def set_tooltips(self):
154+ terp_main = service.LocalService('gui.main')
155+ page_id= terp_main.notebook.get_current_page()
156+ form_obj = terp_main.pages[page_id]
157+ action_name = form_obj.name or ''
158+ if self.current_view.view_type == 'form':
159+ tips = unicode(self.current_model and self.current_model.value.get('name') or action_name)
160+ tooltips = tips == action_name and action_name or action_name + ': ' + tips[:64]
161+ label = tips == action_name and action_name or action_name + ': ' + tips[:6]
162+ else:
163+ tooltips = action_name
164+ label = action_name
165+ form_obj.page_label.set_text(label)
166+ form_obj.page_label.set_tooltip_text(tooltips)
167
168 # mode: False = next view, value = open this view
169 def switch_view(self, screen=None, mode=False):
170@@ -526,6 +541,8 @@
171 self.current_view.set_cursor()
172
173 main = service.LocalService('gui.main')
174+ if mode:
175+ self.set_tooltips()
176 if main:
177 main.sb_set()
178