~ubuntu-branches/ubuntu/trusty/screenlets/trusty

« back to all changes in this revision

Viewing changes to src/lib/backend.py

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2011-07-02 11:06:42 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110702110642-d0oqdiy8sye8cli2
Tags: 0.1.4-0ubuntu1
* New upstream release.
* debian/patches:
 - 90-disable-resize-grip.patch : Drop, merged upstream.
 - 91_use_webkit.patch: Drop, merged upstream.
* debian/rules:
 - Only fix the permission on 1 file.
* debian/copyright:
 - Update copyright holders.

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
                                                #print "LOAD: "+line[:-1]
199
199
                                                parts = line[:-1].split('=', 1)
200
200
                                                if len(parts) > 1:
201
 
                                                        # undocumented feature to resize screenlet dynamically on first launch
 
201
                                                        # undocumented features to resize screenlet dynamically on first launch
 
202
                                                        # width, height must precede rel_x and rel_y with "_"
202
203
                                                        # by boamaod for Estobuntu
 
204
                                                        if parts[0] == 'x':
 
205
                                                                if parts[1].startswith("*"): # if * is added, take distance from the opposite side
 
206
                                                                        parts[1] = parts[1].strip("*")
 
207
                                                                        add_width = 0
 
208
                                                                        if parts[1].startswith("_"): # if _ is added, take it to be right corner
 
209
                                                                                add_width = int(float(self.__instances[id]["width"])*float(self.__instances[id]["scale"]))
 
210
                                                                                print "ADD W", add_width
 
211
                                                                        parts[1] = str(gtk.gdk.screen_width() - int(parts[1].strip("_")) - add_width)
 
212
                                                                        print ">>>X", parts[1]
 
213
                                                        if parts[0] == 'y':
 
214
                                                                if parts[1].startswith("*"): # if * is added, take distance from the opposite side
 
215
                                                                        parts[1] = parts[1].strip("*")
 
216
                                                                        add_height = 0
 
217
                                                                        if parts[1].startswith("_"): # if _ is added, take it to be bottom corner
 
218
                                                                                add_height = int(float(self.__instances[id]["height"])*float(self.__instances[id]["scale"]))
 
219
                                                                                print "ADD H", add_height
 
220
                                                                        parts[1] = str(gtk.gdk.screen_height() - int(parts[1].strip("_")) - add_height)
 
221
                                                                        print ">>>Y", parts[1]
203
222
                                                        if parts[0] == 'rel_x':
204
223
                                                                parts[0] = 'x'
205
 
                                                                parts[1] = str(int(gtk.gdk.screen_width()*float(parts[1])))
 
224
                                                                add_width = 0
 
225
                                                                if parts[1].startswith("_"): # if _ is added, take it to be right corner
 
226
                                                                        add_width = int(float(self.__instances[id]["width"])*float(self.__instances[id]["scale"]))
 
227
                                                                        print "ADD W", add_width
 
228
                                                                parts[1] = str(int(gtk.gdk.screen_width()*float(parts[1].strip("_"))) - add_width)
 
229
                                                                print ">>>X", parts[1]
206
230
                                                        if parts[0] == 'rel_y':
207
231
                                                                parts[0] = 'y'
208
 
                                                                parts[1] = str(int(gtk.gdk.screen_height()*float(parts[1])))
 
232
                                                                add_height = 0
 
233
                                                                if parts[1].startswith("_"): # if _ is added, take it to be bottom corner
 
234
                                                                        add_height = int(float(self.__instances[id]["height"])*float(self.__instances[id]["scale"]))
 
235
                                                                        print "ADD H", add_height
 
236
                                                                parts[1] = str(int(gtk.gdk.screen_height()*float(parts[1].strip("_"))) - add_height)
 
237
                                                                print ">>>Y", parts[1]
209
238
                                                        if parts[0] == 'rel_scale':
210
239
                                                                parts[0] = 'scale'
211
 
                                                                parts[1] = str(gtk.gdk.screen_height()/float(parts[1]))
 
240
                                                                scale = float(self.__instances[id]["scale"])
 
241
                                                                initial_scale = scale + float(gtk.gdk.screen_height()*gtk.gdk.screen_width())/float(parts[1])
 
242
                                                                if initial_scale < 1.5:
 
243
                                                                        initial_scale = 1.5
 
244
                                                                if initial_scale > 3:
 
245
                                                                        initial_scale = 3
 
246
                                                                parts[1] = str(initial_scale)
 
247
#                                                               parts[1] = str(gtk.gdk.screen_height()/float(parts[1]))
 
248
                                                                print ">>>SCALE", parts[1]
 
249
                                                        if parts[0] == 'rel_font_name':
 
250
                                                                parts[0] = 'font_name'
 
251
                                                                print "|||", parts[1]
 
252
                                                                font_parts = parts[1].split(" ")
 
253
                                                                parts[1]=""
 
254
                                                                for fp in font_parts:
 
255
                                                                        if len(fp.strip("0123456789.")) == 0:
 
256
                                                                                parts[1]+= str( round(float(fp)*float(self.__instances[id]["scale"]), 1) ) + " "
 
257
                                                                        else:
 
258
                                                                                parts[1]+= fp + " "
 
259
                                                                parts[1] = parts[1].strip(" ")
 
260
                                                                print ">>>FONT_NAME", parts[1]
 
261
                                                        # End of dynamic resize section
212
262
                                                        print "%s='%s'" % (parts[0], parts[1])
213
263
                                                        self.__instances[id][parts[0]] = parts[1]
214
264
                                        f.close()