223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
for entry in entries:
if isinstance(entry, (str,unicode)):
main = ls.append(None, [str(entry), icon])
else:
for sub_title in entry:
ls.append(main, [str(sub_title), icon])
# just one column
tvcolumn = gtk.TreeViewColumn(title);
widget.append_column(tvcolumn)
# inner display: icon & string
pix = gtk.CellRendererPixbuf()
txt = gtk.CellRendererText()
# position
tvcolumn.pack_start(pix, expand=False)
tvcolumn.pack_end(txt, expand=True)
# select array content source in treestore
tvcolumn.add_attribute(pix, "stock_id", 1)
tvcolumn.add_attribute(txt, "text", 0)
# finalize
widget.set_model(ls)
tvcolumn.set_sort_column_id(0)
widget.set_search_column(0)
#tvcolumn.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
#tvcolumn.set_fixed_width(125])
#widget.expand_all()
#widget.expand_row("3", False)
#print(widget.row_expanded("3"))
return ls
#-- save window size and widget properties
#
# needs a list of widgetnames
# e.g. pickle.dump(uikit.app_state(...), open(os.environ["HOME"]+"/.config/app_winstate", "w"))
|
>
>
>
>
>
>
>
>
>
>
>
>
>
<
<
<
<
<
<
<
<
<
<
<
<
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
for entry in entries:
if isinstance(entry, (str,unicode)):
main = ls.append(None, [str(entry), icon])
else:
for sub_title in entry:
ls.append(main, [str(sub_title), icon])
# finalize
widget.set_model(ls)
widget.set_search_column(0)
#tvcolumn.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
#tvcolumn.set_fixed_width(125])
#widget.expand_all()
#widget.expand_row("3", False)
#print(widget.row_expanded("3"))
return ls
@staticmethod
def tree_column(widget, title="Category"):
# just one column
tvcolumn = gtk.TreeViewColumn(title);
widget.append_column(tvcolumn)
# inner display: icon & string
pix = gtk.CellRendererPixbuf()
txt = gtk.CellRendererText()
# position
tvcolumn.pack_start(pix, expand=False)
tvcolumn.pack_end(txt, expand=True)
# select array content source in treestore
tvcolumn.add_attribute(pix, "stock_id", 1)
tvcolumn.add_attribute(txt, "text", 0)
tvcolumn.set_sort_column_id(0)
#-- save window size and widget properties
#
# needs a list of widgetnames
# e.g. pickle.dump(uikit.app_state(...), open(os.environ["HOME"]+"/.config/app_winstate", "w"))
|
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
|
def save_file_filterchange(c):
fn, ext = c.get_filename(), c.get_filter().get_name()
if fn and ext:
fn = os.path.basename(fn)
c.set_current_name(re.sub(r"\.(m3u|pls|xspf|jspf|asx|json|smil|wpl)$", ext.strip("*"), fn))
# pass updates from another thread, ensures that it is called just once
@staticmethod
def do(callback, *args, **kwargs):
gobject.idle_add(lambda: callback(*args, **kwargs) and False)
# adds background color to widget,
# eventually wraps it into a gtk.Window, if it needs a container
@staticmethod
def bg(w, color="", where=["bg"]):
""" this method should be called after widget creation, and before .add()ing it to container """
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
|
>
>
>
|
|
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
def save_file_filterchange(c):
fn, ext = c.get_filename(), c.get_filter().get_name()
if fn and ext:
fn = os.path.basename(fn)
c.set_current_name(re.sub(r"\.(m3u|pls|xspf|jspf|asx|json|smil|wpl)$", ext.strip("*"), fn))
# Spool gtk update calls from non-main threads (optional immediate=1 flag to run task next, not last)
@staticmethod
def do(callback, *args, **kwargs):
pos = kwargs.get("immediate", -1)
if pos and pos >= 0:
del kwargs["immediate"]
pos = 0
if uikit.idle_run:
log.UIKIT_DORUN(str(callback))
callback(*args, **kwargs)
else:
log.UIKIT_SPOOL(str(callback))
uikit.idle_tasks.insert(pos, [lambda: callback(*args, **kwargs), str(callback)])
gobject.idle_add(uikit.idle_do)
# Collect tasks to perform in gtk.main loop
idle_tasks = []
idle_run = False
# Execute UI updating tasks in order
@staticmethod
def idle_do():
uikit.idle_run = True
if uikit.idle_tasks:
task, callback = uikit.idle_tasks.pop(0)
log.UIKIT_EXEC(callback)
task()
uikit.idle_run = False
return len(uikit.idle_tasks) > 0
# adds background color to widget,
# eventually wraps it into a gtk.Window, if it needs a container
@staticmethod
def bg(w, color="", where=["bg"]):
""" this method should be called after widget creation, and before .add()ing it to container """
|