Check-in [7b1ee3b5a6]
Overview
Comment: | Added pixbuf() creation method (from base64 stringified PNG to gdk.Pixbuf) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7b1ee3b5a6ae3071e56f1aa139bcf09d |
User & Date: | mario on 2015-03-31 16:17:19 |
Other Links: | manifest | tags |
Context
2015-03-31
| ||
16:19 | Use `ui_xml` instead of local filename. (Read via pkgutil.get_data, so should work independently of installation path.) Add logo/banner from `logo.py` → `logo.png`. check-in: 9057171155 user: mario tags: trunk | |
16:17 | Added pixbuf() creation method (from base64 stringified PNG to gdk.Pixbuf) check-in: 7b1ee3b5a6 user: mario tags: trunk | |
16:15 | Removed gtk2.xml, only gtk3.xml packaged and modified at runtime. (It's just the minimum version= that needs adaption meanwhile.) check-in: dc0351d754 user: mario tags: trunk | |
Changes
Modified uikit.py from [b71d7199bb] to [a2be3b7a05].
|
| < < < < < < | > > | < | | | | > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # encoding: UTF-8 # api: python # type: functions # title: uikit helper functions # description: simplify usage of some gtk widgets # version: 1.8 # author: mario # license: public domain # # Wrappers around gtk methods. The TreeView method .columns() allows # to fill a treeview. It adds columns and data rows with a mapping # dictionary (which specifies many options and data positions). # # The .tree() method is a trimmed-down variant of that, creates a # single column, but has threaded entries. # # With the methodes .app_state() and .app_restore() named gtk widgets # can be queried for attributes. The methods return a saveable dict, # which contain current layout options for a few Widget types. Saving # and restoring must be handled elsewhere. # debug from config import __print__, dbg, plugin_meta # system import os.path import copy import sys import base64 import inspect from compat2and3 import unicode, xrange, PY3 import pkgutil # gtk version (2=gtk2, 3=gtk3, 7=tk;) ver = 2 # if running on Python3 or with commandline flag if PY3 or "--gtk3" in sys.argv: ver = 3 # load gtk modules if ver==3: from gi import pygtkcompat as pygtk pygtk.enable() pygtk.enable_gtk(version='3.0') from gi.repository import Gtk as gtk from gi.repository import GObject as gobject from gi.repository import GdkPixbuf empty_pixbuf = GdkPixbuf.Pixbuf.new_from_data(b"\0\0\0\0", GdkPixbuf.Colorspace.RGB, True, 8, 1, 1, 4, None, None) __print__(dbg.STAT, gtk) __print__(dbg.STAT, gobject) else: import pygtk import gtk import gobject GdkPixbuf = gtk.gdk empty_pixbuf = GdkPixbuf.Pixbuf(gtk.gdk.COLORSPACE_RGB,True,8,16,16) empty_pixbuf.fill(0xFFFFFFFF) # prepare gtkbuilder data ui_xml = pkgutil.get_data("config", "gtk3.xml") if ver == 2: ui_xml = ui_xml.replace('version="3.0"', 'version="2.16"') # simplified gtk constructors --------------------------------------------- class uikit: |
︙ | ︙ | |||
437 438 439 440 441 442 443 444 445 446 447 448 449 450 | @staticmethod def msg(text, style=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CLOSE): m = gtk.MessageDialog(None, 0, style, buttons, message_format=text) m.show() m.connect("response", lambda *w: m.destroy()) # Text-only dropdown list. # # Necessary because gtk.ComboBoxText binding is absent in debian packages # https://bugzilla.gnome.org/show_bug.cgi?id=660659 # # This one implements a convenience method `.set_default()` to define the active | > > > > > > > > > > > > > > > > > > | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | @staticmethod def msg(text, style=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CLOSE): m = gtk.MessageDialog(None, 0, style, buttons, message_format=text) m.show() m.connect("response", lambda *w: m.destroy()) # Pixbug loader (from inline string, as in `logo.png`) @staticmethod def pixbuf(buf, fmt="png"): p = GdkPixbuf.PixbufLoader(fmt) try: # inline encoding buf = base64.b64decode(buf) except: None #print "PNG: %s" % len(buf) p.write(buf, len(buf)) #print "FMT: %s" % p.get_format() pix = p.get_pixbuf() p.close() #print "PIX: %s" % pix return pix # Text-only dropdown list. # # Necessary because gtk.ComboBoxText binding is absent in debian packages # https://bugzilla.gnome.org/show_bug.cgi?id=660659 # # This one implements a convenience method `.set_default()` to define the active |
︙ | ︙ | |||
575 576 577 578 579 580 581 | class AboutStreamtuner2(AuxiliaryWindow): def __init__(self, parent): a = gtk.AboutDialog() a.set_name(parent.meta["id"]) a.set_version(parent.meta["version"]) a.set_license(parent.meta["license"]) a.set_authors(parent.meta["author"].split(",")) | < | 593 594 595 596 597 598 599 600 601 602 603 | class AboutStreamtuner2(AuxiliaryWindow): def __init__(self, parent): a = gtk.AboutDialog() a.set_name(parent.meta["id"]) a.set_version(parent.meta["version"]) a.set_license(parent.meta["license"]) a.set_authors(parent.meta["author"].split(",")) a.set_website(parent.meta["url"]) a.connect("response", lambda a, ok: ( a.hide(), a.destroy() ) ) a.show() |