rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
solr_select += '&sort=title'
solr_select += '&sort=title+asc'
def works_by_author(akey, sort='editions', offset=0, limit=1000): q='author_key:' + akey solr_select = solr_select_url + "?version=2.2&q.op=AND&q=%s&fq=&start=%d&rows=%d&fl=key,author_name,author_key,title,edition_count,ia,cover_edition_key,has_fulltext,first_publish_year&qt=standard&wt=json" % (q, offset, limit) facet...
i = web.inputs()
i = web.input()
def read_subject(path_info): m = re_subject_types.match(path_info) if m: subject_type = subject_types[m.group(1)] key = str_to_key(m.group(2)).lower().replace('_', ' ') full_key = '/subjects/%s/%s' % (m.group(1), key) q = '%s_key:"%s"' % (subject_type, url_quote(key)) else: subject_type = 'subject' key = str_to_key(pat...
if len(pub) == 4 and pub.is_digit():
if len(pub) == 4 and pub.isdigit():
def read_subject(path_info): m = re_subject_types.match(path_info) if m: subject_type = subject_types[m.group(1)] key = str_to_key(m.group(2)).lower().replace('_', ' ') full_key = '/subjects/%s/%s' % (m.group(1), key) q = '%s_key:"%s"' % (subject_type, url_quote(key)) else: subject_type = 'subject' key = str_to_key(pat...
class account_login(delegate.page): path = "/account/login" def GET(self): referer = web.ctx.env.get('HTTP_REFERER', '/') i = web.input(redirect=referer) f = forms.Login() f['redirect'].value = i.redirect return render.login(f) def POST(self): i = web.input(remember=False, redirect='/') def error(name): f = forms.Lo...
def GET(self): user = web.ctx.site.get_user() return render.account(user)
q = params.get('q', None)
q = params.get('q')
def advanced_to_simple(params): q_list = [] q = params.get('q', None) if q and q != '*:*': q_list.append(params['q']) for k in 'title', 'author': if k in params: q_list.append("%s:(%s)" % (k, params[k])) return ' '.join(q_list)
cover_edition_key = w.get('cover_edition_key', None),
cover_edition_key = w.get('cover_edition_key'),
def work_object(w): ia = w.get('ia', []) obj = dict( authors = [web.storage(key='/authors/' + k, name=n) for k, n in zip(w['author_key'], w['author_name'])], edition_count = w['edition_count'], key = '/works/' + w['key'], title = w['title'], public_scan = w.get('public_scan_b', bool(ia)), lending_edition = w.get('lendi...
if w.get(f, None):
if w.get(f):
def work_object(w): ia = w.get('ia', []) obj = dict( authors = [web.storage(key='/authors/' + k, name=n) for k, n in zip(w['author_key'], w['author_name'])], edition_count = w['edition_count'], key = '/works/' + w['key'], title = w['title'], public_scan = w.get('public_scan_b', bool(ia)), lending_edition = w.get('lendi...
if i.get('ftokens', None) and ',' not in i.ftokens:
if i.get('ftokens') and ',' not in i.ftokens:
def GET(self): global ftoken_db i = web.input(author_key=[], language=[], first_publish_year=[], publisher_facet=[], subject_facet=[], person_facet=[], place_facet=[], time_facet=[]) if i.get('ftokens', None) and ',' not in i.ftokens: token = i.ftokens if ftoken_db is None: ftoken_db = dbm.open('/olsystem/ftokens', 'r'...
if ftoken_db.get(token, None):
if ftoken_db.get(token):
def GET(self): global ftoken_db i = web.input(author_key=[], language=[], first_publish_year=[], publisher_facet=[], subject_facet=[], person_facet=[], place_facet=[], time_facet=[]) if i.get('ftokens', None) and ',' not in i.ftokens: token = i.ftokens if ftoken_db is None: ftoken_db = dbm.open('/olsystem/ftokens', 'r'...
if 'doc' in row:
if row.get('doc'):
def _get_seed_summary(self): rawseeds = self._get_rawseeds() db = self._get_seeds_db() zeros = {"editions": 0, "works": 0, "ebooks": 0, "last_update": ""} d = dict((seed, web.storage(zeros)) for seed in rawseeds) for row in self._couchdb_view(db, "_all_docs", keys=rawseeds, include_docs=True): if 'doc' in row: if 'e...
e_first_pub = doc.find("int[@name='first_publish_year']")
e_first_pub = doc.find("arr[@name='first_publish_year']")
def get_doc(doc): e_ia = doc.find("arr[@name='ia']") first_pub = None e_first_pub = doc.find("int[@name='first_publish_year']") if e_first_pub is not None and len(e_first_pub) == 1: first_pub = e_first_pub[0].text ak = [e.text for e in doc.find("arr[@name='author_key']")] an = [e.text for e in doc.find("arr[@name='aut...
def update_work(self, work): key = work['key'] work2 = self.works_db.get(key, {}) works2.update(work) self.works_db[key] = work2 seeds = _get_seeds(work2) for e in work2.get("editions", []): self.update_edition_in_editions_db(e, seeds) for seed in seeds: self.update_seeds_db(seed) def update_edition(self, editi...
def process_changeset(self, changeset): logging.info("processing changeset %s", changeset["id"]) works = {} editions = {} seeds = {} ctx = UpdaterContext() for work in self._get_works(changeset): work = self.works_db.update_work(ctx, work) for edition in self._get_editions(changeset): self.works_db.update_edition(c...
def _get_seeds(self, work): return [k for k, v in SeedView().map(work)] def _find_old_work(self, edition_key): """Returns the key of the work that has this edition by querying the works_db. """ pass
def _get_editions(self, changeset): return [doc for doc in changeset.get("docs", []) if doc['key'].startswith("/books/")]
try: work = self.db[work_key] except KeyError:
work = self.db.get(work_key) if work is None:
def update_edition(self, ctx, edition): """Adds/updates the given edition in the database and returns the work from the database. """ logging.info("updating edition %s", edition['key']) old_work_key = self._get_old_work_key(edition) try: work_key = edition.get("works", [])[0]['key'] except IndexError: work_key = None
revs = dict((row.key, row.value["rev"]) for row in db.view("_all_docs", keys=keys))
revs = dict((row.key, row.value["rev"]) for row in db.view("_all_docs", keys=keys) if "value" in row)
def couchdb_bulk_save(db, docs): """Saves/updates the given docs into the given couchdb database using bulk save. """ keys = [doc["_id"] for doc in docs if "_id" in doc] revs = dict((row.key, row.value["rev"]) for row in db.view("_all_docs", keys=keys)) for doc in docs: id = doc.get('_id') if id in revs: doc['_rev'] =...
config = formats.load_yaml(configfile)
config = formats.load_yaml(open(configfile).read())
def main(configfile): """Creates an updater using the config files and calls it with changesets read from stdin. Expects one changeset per line in JSON format. """ config = formats.load_yaml(configfile) updater = Updater(config) def changesets(): for line in sys.stdin: yield simplejson.loads(line.strip()) for c in c...
for c in changesets:
for c in changesets():
def changesets(): for line in sys.stdin: yield simplejson.loads(line.strip())
def test_loginAndLogout(self):
def test_loginAndLogoutSSO(self):
def test_loginAndLogout(self): browser = self.browser browser.open(self.portal.absolute_url()) browser.getLink('Log in').click() # The test browser does not support iframes form = browser.getForm(name='login_form') form.submit() # We are now inside the iframe self.failUnless(browser.url.startswith(self.login_portal.abs...
state['entropy'] /= num
state['entropy'] /= state['num']
def evaluate(node, words): with self.get_context(node) as context: for word in words: symbol = self.dictionary.index(word) context.update(symbol) if word in keys: prob = 0.0 count = 0 state['num'] += 1 for j in xrange(self.order): node = context.get(j) if node is not None: child = node.get_child(symbol, add=False) if c...
return self.cfg.config_vars[key][1]
return self.cfg.config_vars[key].get_default()
def __getitem__(self, key): """Get an item from the transaction or the underlaying config.""" if key in self._converted_values: return self._converted_values[key] elif key in self._remove: return self.cfg.config_vars[key][1] return self.cfg[key]
raise ValidationError(_('You have to select the user that ' 'gets the posts assigned.'))
raise ValidationError(_('You have to select a user to reassign ' 'the posts to.'))
def context_validate(self, data): if data['action'] == 'reassign' and not data['reassign_to']: # XXX: Bad wording raise ValidationError(_('You have to select the user that ' 'gets the posts assigned.'))
Model = declarative_base(name='Model', cls=ModelBase, mapper=session.mapper)
Model = declarative_base(name='Model', cls=ModelBase, mapper=mapper)
def first(self, raise_if_missing=False): """Return the first result of this `Query` or None if the result doesn't contain any rows. If `raise_if_missing` is set to `True` a `NotFound` exception is raised if no row is found. """ rv = orm.Query.first(self) if rv is None and raise_if_missing: raise NotFound() return rv
db.mapper = session.mapper
db.mapper = mapper
def first(self, raise_if_missing=False): """Return the first result of this `Query` or None if the result doesn't contain any rows. If `raise_if_missing` is set to `True` a `NotFound` exception is raised if no row is found. """ rv = orm.Query.first(self) if rv is None and raise_if_missing: raise NotFound() return rv
etree = writer.etree
def __init__(self, writer): self.app = writer.app etree = writer.etree self.writer = writer
participant.setup()
participant.before_dump()
def dump_node(node): return etree.tostring(node, encoding='utf-8')
>>> root = parse_zeml("1 <b>2</b> 3")
>>> root = parse_zeml("1 <b>2</b> 3", 'system')
def walk(self): yield self for child in _iter_all(self.children): yield child
filename = modname[10:] + '.txt'
filename = modname[5:] + '.txt'
def suite(modnames=[], return_covermods=False): """Generate the test suite. The first argument is a list of modules to be tested. If it is empty (which it is by default), all sub-modules of the zine package are tested. If the second argument is True, this function returns two objects: a TestSuite instance and a list o...
impl = sqlalchemy.Binary
impl = sqlalchemy.LargeBinary
def cursor_execute(self, execute, cursor, statement, parameters, context, executemany): start = _timer() try: return execute(cursor, statement, parameters, context) finally: from zine.application import get_request from zine.utils.debug import find_calling_context request = get_request() if request is not None: request...
for name in 'delete', 'save', 'flush', 'execute', 'begin', 'mapper', \ 'commit', 'rollback', 'clear', 'refresh', 'expire', \ 'query_property':
for name in ('delete', 'flush', 'execute', 'begin', 'mapper', 'commit', 'rollback', 'refresh', 'expire', 'query_property'):
def register_init(self, *args, **kwargs): old_init(self, *args, **kwargs) session.add(self)
return render_account_response('admin/help.html', 'system.help',
return render_account_response('account/help.html', 'system.help',
def help(req, page=''): """Show help page.""" from zine.docs import load_page, get_resource rv = load_page(req.app, page) if rv is None: resource = get_resource(req.app, page) if resource is None: return render_account_response('admin/help.html', 'system.help', not_found=True) return resource parts, is_index = rv end...
self.begin_node(node, 'h2', CLASS='section-subtitle')
self.begin_node(node, tag, CLASS='section-subtitle')
def visit_subtitle(self, node): close_two = False if isinstance(node.parent, nodes.sidebar): self.begin_node(node, 'p', CLASS='sidebar-subtitle') elif isinstance(node.parent, nodes.document): self.begin_node(node, 'h2', CLASS='subtitle') elif isinstance(node.parent, nodes.section): tag = 'h%s' % (self.section_level + s...
u'turn it off again once you finish your changes.'))
u'turn it off again once you finish your changes. You ' u'can do that under System -&gt; Maintenance'))
def render_admin_response(template_name, _active_menu_item=None, **values): """Works pretty much like the normal `render_response` function but it emits some events to collect navigation items and injects that into the template context. This also gets the flashes messages from the user session and injects them into the...
u'turn it off again once you finish your ' u'changes.') % url_for('admin/maintenance'))
u'turn it off again once you finish your changes.'))
def render_admin_response(template_name, _active_menu_item=None, **values): """Works pretty much like the normal `render_response` function but it emits some events to collect navigation items and injects that into the template context. This also gets the flashes messages from the user session and injects them into the...
source, _, _ = hg.parseurl(ui.expandpath("default"), None)
source = hg.parseurl(ui.expandpath("default"), None)[0]
def getremote(ui, repo, opts): # save $http_proxy; creating the HTTP repo object will # delete it in an attempt to "help" proxy = os.environ.get('http_proxy') source, _, _ = hg.parseurl(ui.expandpath("default"), None) other = hg.repository(cmdutil.remoteui(repo, opts), source) if proxy is not None: os.environ['http_pro...
def __call__(self, *args, **kw):
def __call__(self, im_self=None, *args, **kw):
def __call__(self, *args, **kw): if self.im_self is None: im_self, args = args[0], args[1:] else: im_self = aq_base(self.im_self) if IAcquirer.providedBy(im_self): im_self = im_self.__of__(im_self.context) return self.im_func(im_self, *args, **kw)
im_self, args = args[0], args[1:]
im_self = im_self
def __call__(self, *args, **kw): if self.im_self is None: im_self, args = args[0], args[1:] else: im_self = aq_base(self.im_self) if IAcquirer.providedBy(im_self): im_self = im_self.__of__(im_self.context) return self.im_func(im_self, *args, **kw)
template = ImplicitAcquisitionWrapper(template, self)
template = ImplicitAcquisitionWrapper(template, aq_parent(self))
def call_template(self, *args, **kw): template = getattr(self, '_template', _marker) if template is _marker: self._template = template = BaseTemplateFile(self.filename) if IAcquirer.providedBy(template): template = template.__of__(self) else: template = ImplicitAcquisitionWrapper(template, self) return template(self,...
GCONF_CLIENT.set_string(GCONF_DIR+'/'+setting_name, sod[value])
GCONF_CLIENT.set_string(GCONF_DIR+'/select_one_window', sod[value])
def cb_changed(self, combobox): # Read the value of the combo box and write to gconf # Groupbutton settings for name, cb in self.gb_combos.items(): if cb == combobox: setting_name = self.gb_labels_and_settings[name] value = combobox.get_active_text() if value == None: return for (action, translation) in self.gb_actions...
GCONF_CLIENT.set_string(GCONF_DIR+'/'+setting_name, smd[value])
GCONF_CLIENT.set_string(GCONF_DIR+'/select_multiple_windows', smd[value])
def cb_changed(self, combobox): # Read the value of the combo box and write to gconf # Groupbutton settings for name, cb in self.gb_combos.items(): if cb == combobox: setting_name = self.gb_labels_and_settings[name] value = combobox.get_active_text() if value == None: return for (action, translation) in self.gb_actions...
hbox.pack_start(self.label, False)
hbox.pack_start(self.label, True, True)
def __init__(self,window,groupbutton): self.groupbutton = groupbutton self.dockbar = groupbutton.dockbar self.screen = self.groupbutton.screen self.name = window.get_name() self.window = window self.locked = False self.is_active_window = False self.needs_attention = False self.opacified = False self.button_pressed = Fa...
else: self.preview = False
self.label.set_ellipsize(pango.ELLIPSIZE_END) else:
def __init__(self,window,groupbutton): self.groupbutton = groupbutton self.dockbar = groupbutton.dockbar self.screen = self.groupbutton.screen self.name = window.get_name() self.window = window self.locked = False self.is_active_window = False self.needs_attention = False self.opacified = False self.button_pressed = Fa...
width, height = pixmap.get_size() pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height) pixbuf.get_from_drawable(pixmap, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, width, height) w = width h = height
depth = pixmap.get_depth() if depth <= 24: cmap = screen.get_rgb_colormap() else: cmap = screen.get_rgba_colormap() w, h = pixmap.get_size() pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, w, h) pixbuf.get_from_drawable(pixmap, cmap, 0, 0, 0, 0, w, h)
def get_screenshot_xcomposite(self, screen, window, size=200): ''' Get the window pixmap of window from the X compositor extension, return it as a gdk.pixbuf. ''' display = screen.get_display() xdisplay = libgdk.gdk_x11_display_get_xdisplay(hash(display))
h = int(h * size/width)
h = int(h * size/w)
def get_screenshot_xcomposite(self, screen, window, size=200): ''' Get the window pixmap of window from the X compositor extension, return it as a gdk.pixbuf. ''' display = screen.get_display() xdisplay = libgdk.gdk_x11_display_get_xdisplay(hash(display))
w = int(w * size/height)
def get_screenshot_xcomposite(self, screen, window, size=200): ''' Get the window pixmap of window from the X compositor extension, return it as a gdk.pixbuf. ''' display = screen.get_display() xdisplay = libgdk.gdk_x11_display_get_xdisplay(hash(display))
if len(name) > 40:
if len(name) > 40 and not self.preview:
def on_window_name_changed(self, window): name = u""+window.get_name() # TODO: fix a better way to shorten names. if len(name) > 40: name = name[0:37]+"..." self.name = name self.label.set_label(name)
gdkw = gtk.gdk.window_foreign_new(window.get_xid()) wm_class_property = gdkw.property_get(ATOM_WM_CLASS)[2].split('\0') res_class = u"" + wm_class_property[1].lower() res_name = u"" + wm_class_property[0].lower()
try: gdkw = gtk.gdk.window_foreign_new(window.get_xid()) wm_class_property = gdkw.property_get(ATOM_WM_CLASS)[2].split('\0') res_class = u"" + wm_class_property[1].lower() res_name = u"" + wm_class_property[0].lower() except: res_class = window.get_class_group().get_res_class().lower() res_name = window.get_class_grou...
def on_window_opened(self,screen,window): if window.is_skip_tasklist() \ or not (window.get_window_type() in [wnck.WINDOW_NORMAL, wnck.WINDOW_DIALOG]): return
self.button.connect("close-clicked", self.action_close_window)
self.button.connect("close-clicked", self.on_close_clicked)
def __init__(self, window): gobject.GObject.__init__(self) self.globals = Globals() self.globals.connect('show-only-current-monitor-changed', self.on_show_only_current_monitor_changed) self.screen = wnck.screen_get_default() self.name = window.get_name() self.window = window self.needs_attention = False self.opacified ...
if type & self.DRAG_DROPP: surface = self.double_surface(surface, self.dockbar.orient)
def surface_update(self, type = 0): # Checks if the requested pixbuf is already drawn and returns it if it is. # Othervice the surface is drawn, saved and returned. self.win_nr = type & 15 if self.win_nr > self.max_win_nr: type = (type - self.win_nr) | self.max_win_nr self.win_nr = self.max_win_nr self.temp = {} if typ...
def double_surface(self, surface, direction = 'h'):
def dd_highlight(self, surface, direction = 'h'):
def double_surface(self, surface, direction = 'h'): w = surface.get_width() h = surface.get_height() # Make a background almost twice as wide or high # as the surface depending on panel orientation. if direction == 'v': h = h * 2 - 2 else: w = w * 2 - 2 bg = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) ctx = cairo.Con...
h = h * 2 - 2 else: w = w * 2 - 2
h = h + 4 else: w = w + 4
def double_surface(self, surface, direction = 'h'): w = surface.get_width() h = surface.get_height() # Make a background almost twice as wide or high # as the surface depending on panel orientation. if direction == 'v': h = h * 2 - 2 else: w = w * 2 - 2 bg = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) ctx = cairo.Con...
ctx.move_to(2, h / 2 + 2) ctx.line_to(w - 2, h / 2 + 2) ctx.line_to(w / 2, 0.65 * h + 2) ctx.close_path() else: ctx.move_to(w / 2 + 2, 2) ctx.line_to(w / 2 + 2, h - 2) ctx.line_to(0.65 * w, h / 2) ctx.close_path() ctx.set_source_rgb(0, 0, 0) ctx.fill()
ctx.move_to(1, h - 1.5) ctx.line_to(w - 1, h - 1.5) ctx.set_source_rgba(1, 1, 1, 0.2) ctx.set_line_width(2) ctx.stroke() ctx.move_to(2, h - 1.5) ctx.line_to(w - 2, h - 1.5) ctx.set_source_rgba(0, 0, 0, 0.7) ctx.set_line_width(1) ctx.stroke() else: ctx.move_to(w - 1.5, 1) ctx.line_to(w - 1.5, h - 1) ctx.set_source_rgba(...
def double_surface(self, surface, direction = 'h'): w = surface.get_width() h = surface.get_height() # Make a background almost twice as wide or high # as the surface depending on panel orientation. if direction == 'v': h = h * 2 - 2 else: w = w * 2 - 2 bg = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) ctx = cairo.Con...
if self.dockbar.orient == 'v':
if self.dockbar.orient == 'h':
def command_get_pixmap(self, surface, name, size=0): if surface == None: if self.dockbar.orient == 'v': width = int(self.size * ar) height = self.size else: width = self.size height = int(self.size * ar) else: width = surface.get_width() height = surface.get_height() if self.dockbar.theme.has_surface(name): surface = s...
self.dnd_show_popup = gobject.timeout_add(settings['popup_delay'], self.show_list)
if not 'text/groupbutton_name' in drag_context.targets: if len(self.windows) == 1: self.dnd_select_window = gobject.timeout_add(600, self.windows.values()[0].action_select_window) elif len(self.windows) > 1: self.dnd_show_popup = gobject.timeout_add(settings['popup_delay'], self.show_list)
def on_button_drag_motion(self, widget, drag_context, x, y, t): if not self.button_drag_entered: self.button_drag_entered = True self.dnd_show_popup = gobject.timeout_add(settings['popup_delay'], self.show_list) for target in ('text/uri-list', 'text/groupbutton_name'): if target in drag_context.targets and \ not self.i...
if target in drag_context.targets and \ not self.is_current_drag_source:
if target in drag_context.targets \ and not self.is_current_drag_source:
def on_button_drag_motion(self, widget, drag_context, x, y, t): if not self.button_drag_entered: self.button_drag_entered = True self.dnd_show_popup = gobject.timeout_add(settings['popup_delay'], self.show_list) for target in ('text/uri-list', 'text/groupbutton_name'): if target in drag_context.targets and \ not self.i...
gobject.source_remove(self.dnd_show_popup)
if self.dnd_show_popup != None: gobject.source_remove(self.dnd_show_popup) self.dnd_show_popup = None if self.dnd_select_window != None: gobject.source_remove(self.dnd_select_window) self.dnd_select_window = None
def on_button_drag_leave(self, widget, drag_context, t): self.dnd_highlight = False self.button_drag_entered = False self.update_state() self.hide_list_request() gobject.source_remove(self.dnd_show_popup) if self.is_current_drag_source: # If drag leave signal is given because of a drop, # a small delay is needed since ...
if self.dockbar.orient == "v" and allocation.width>10 \
if self.dockbar.orient == "v" \ and allocation.width>10 and allocation.width < 220 \
def on_sizealloc(self,applet,allocation): # Sends the new size to icon_factory so that a new icon in the right # size can be found. The icon is then updated. if self.button_old_alloc != self.button.get_allocation(): if self.dockbar.orient == "v" and allocation.width>10 \ and allocation.width != self.button_old_alloc.wi...
elif allocation.height>10 \
elif self.dockbar.orient == "h" \ and allocation.height>10 and allocation.height<220\
def on_sizealloc(self,applet,allocation): # Sends the new size to icon_factory so that a new icon in the right # size can be found. The icon is then updated. if self.button_old_alloc != self.button.get_allocation(): if self.dockbar.orient == "v" and allocation.width>10 \ and allocation.width != self.button_old_alloc.wi...
result_type=datamodel.ResultType.MostRecentSubjects,
result_type=None,
def _get(name=None, result_type=datamodel.ResultType.MostRecentSubjects, days=14, number_of_results=5, mimetypes=[]): time_range = datamodel.TimeRange.from_seconds_ago(days * 3600 * 24) event_template = datamodel.Event() if name: event_template.set_actor('application://%s'%name) for mimetype in mimetypes: event_templ...
group.emit('set-icongeo-grp')
group.on_set_icongeo_grp()
def on_desktop_changed(self, screen=None, workspace=None): if not self.globals.settings['show_only_current_desktop']: return for group in self.groups.get_groups(): group.update_state() group.emit('set-icongeo-grp') group.nextlist = None
if not self.globals.settings['show_only_current_desktop'] \ or (self.window.get_workspace() is None \ or self.screen.get_active_workspace() == \ self.window.get_workspace()) \ and self.window.is_in_viewport( self.screen.get_active_workspace()): t = gtk.get_current_event_time()
aws = self.screen.get_active_workspace() wws = win.get_workspace() if not self.globals.settings['show_only_current_desktop'] or \ (wws is None or aws == wws) and win.is_in_viewport(aws): t = int(time()) if wws is not None and aws != wws: win.get_workspace().activate(t) if not win.is_in_viewport(aws): wx,wy,ww,wh = self...
def gkey_select_next_group(self, previous=False): active_found = False gl = self.groups.values() # Repeat list twice so we can get # back to the first group after the last gl = gl + gl if previous: gl.reverse() for gr in gl: if gr.list_hide_timeout is not None: # Hide the popup if it's opened # by keyboard shortcut. gr...
for win, wb in self.windows.items(): if wb.is_on_current_desktop(): previews.append(5) previews.append(win.get_xid()) alloc = wb.preview_image.get_allocation() (xo, yo, w, h) = wb.get_preview_alloc(ps) previews.append(alloc.x+xo) previews.append(alloc.y+yo) previews.append(w) previews.append(h)
for win in self.get_windows(): wb = self.windows[win] previews.append(5) previews.append(win.get_xid()) alloc = wb.preview_image.get_allocation() (xo, yo, w, h) = wb.get_preview_alloc(ps) previews.append(alloc.x+xo) previews.append(alloc.y+yo) previews.append(w) previews.append(h)
def show_list(self): # Move popup to it's right spot and show it. offset = 3
if self.globals.orient == 'h' and b_m_x>=0 and b_m_x<=(b_r.width-1):
if self.globals.orient == 'h' and b_m_x>=-8 and b_m_x<=(b_r.width+7):
def hide_list_request(self): if self.popup.window == None: return # Checks if mouse cursor really isn't hovering the button # or the popup window anymore and hide the popup window # if so. p_m_x,p_m_y = self.popup.get_pointer() p_w,p_h = self.popup.get_size() b_m_x,b_m_y = self.button.get_pointer() b_r = self.button.ge...
elif self.globals.orient == 'v' and b_m_y>=0 and b_m_y<=(b_r.height-1):
elif self.globals.orient == 'v' and b_m_y>=-8 and b_m_y<=(b_r.height+7):
def hide_list_request(self): if self.popup.window == None: return # Checks if mouse cursor really isn't hovering the button # or the popup window anymore and hide the popup window # if so. p_m_x,p_m_y = self.popup.get_pointer() p_w,p_h = self.popup.get_size() b_m_x,b_m_y = self.button.get_pointer() b_r = self.button.ge...
self.size = 0
self.size = 15
def __init__(self, class_group=None, launcher=None, app=None, identifier=None): self.theme = Theme() self.globals = Globals() self.globals.connect('color-changed', self.reset_surfaces) self.app = app self.launcher = launcher self.identifier = identifier if self.launcher and self.launcher.app: self.app = self.launcher.a...
if ("groupbutton" in name) \ and ("click" in name or "scroll" in name) \ and value in group_button_actions_d:
if ("groupbutton" in name) and \ ("click" in name or "scroll" in name) and \ (value in group_button_actions_d):
def __init__(self): if not 'settings' in self.__dict__: # First run. gobject.GObject.__init__(self)
self.setup()
self.set_shape_mask()
def expose(self, widget, event): self.setup() w,h = self.window.get_size() self.ctx = self.window.window.cairo_create() # set a clip region for the expose event, XShape stuff self.ctx.save() if self.window.is_composited(): self.ctx.set_source_rgba(1, 1, 1,0) else: self.ctx.set_source_rgb(1, 1, 1) self.ctx.set_operator(...
def setup(self):
def set_shape_mask(self):
def setup(self): # Set window shape from alpha mask of background image w,h = self.window.get_size() if w==0: w = 800 if h==0: h = 600 pixmap = gtk.gdk.Pixmap (None, w, h, 1) ctx = pixmap.cairo_create() ctx.save() ctx.set_source_rgba(1, 1, 1,0) ctx.set_operator (cairo.OPERATOR_SOURCE) ctx.paint() ctx.restore() self.dra...
ctx.save()
def setup(self): # Set window shape from alpha mask of background image w,h = self.window.get_size() if w==0: w = 800 if h==0: h = 600 pixmap = gtk.gdk.Pixmap (None, w, h, 1) ctx = pixmap.cairo_create() ctx.save() ctx.set_source_rgba(1, 1, 1,0) ctx.set_operator (cairo.OPERATOR_SOURCE) ctx.paint() ctx.restore() self.dra...
ctx.restore() self.draw_frame(ctx, w, h) if self.window.is_composited(): self.window.window.shape_combine_mask(None, 0, 0) ctx.rectangle(0,0,w,h) ctx.fill() self.window.input_shape_combine_mask(pixmap,0,0) else: self.window.shape_combine_mask(pixmap, 0, 0) del pixmap def draw_frame(self, ctx, w, h): ctx.save()
def setup(self): # Set window shape from alpha mask of background image w,h = self.window.get_size() if w==0: w = 800 if h==0: h = 600 pixmap = gtk.gdk.Pixmap (None, w, h, 1) ctx = pixmap.cairo_create() ctx.save() ctx.set_source_rgba(1, 1, 1,0) ctx.set_operator (cairo.OPERATOR_SOURCE) ctx.paint() ctx.restore() self.dra...
bg = 0.2 color = colors['color1'] red = float(int(color[1:3], 16))/255 green = float(int(color[3:5], 16))/255 blue = float(int(color[5:7], 16))/255 alpha= float(colors['color1_alpha']) / 255
def draw_frame(self, ctx, w, h): ctx.save() r = 6 bg = 0.2 color = colors['color1'] red = float(int(color[1:3], 16))/255 green = float(int(color[3:5], 16))/255 blue = float(int(color[5:7], 16))/255
ctx.restore() ctx.clip()
def draw_frame(self, ctx, w, h): ctx.save() r = 6 bg = 0.2 color = colors['color1'] red = float(int(color[1:3], 16))/255 green = float(int(color[3:5], 16))/255 blue = float(int(color[5:7], 16))/255
cmd = u""+app.get_commandline()
try: cmd = u""+app.get_commandline() except AttributeError: cmd = u""
def reload(self, event=None, data=None): # Remove all old groupbuttons from container. for child in self.container.get_children(): self.container.remove(child) if self.windows: # Removes windows and non-launcher group buttons for win in self.screen.get_windows(): self.on_window_closed(None, win) if self.groups != None:...
file = uri
def launch(self, uri=None): os.chdir(os.path.expanduser('~')) command = self.getExec() # Replace arguments if "%i" in command: icon = self.getIcon() if icon: command = command.replace("%i","--icon %s"%icon) else: command = command.replace("%i", "") command = command.replace("%c", self.getName()) command = command.repla...
{_("Close"): self.action_close_all_windows, _("Close") + _(" all windows"): self.action_close_all_windows,
{_("_Close"): self.action_close_all_windows, _("_Close") + _(" all windows"): self.action_close_all_windows,
def on_menuitem_activated(self, arg, name): if name in self.zg_files: self.launch_item(None, None, self.zg_files[name]) return {_("Close"): self.action_close_all_windows, _("Close") + _(" all windows"): self.action_close_all_windows, _("Ma_ximize"): self.action_maximize_all_windows, _("Ma_ximize") + _(" all windows"): ...
self.about.set_copyright("Copyright (c) 2008-2009 Aleksey Shaferov and Matias S\xc3\xa4rs)")
self.about.set_copyright("Copyright (c) 2008-2009 Aleksey Shaferov and Matias S\xc3\xa4rs")
def __init__ (self): if AboutDialog.__instance == None: AboutDialog.__instance = self else: AboutDialog.__instance.about.present() return self.about = gtk.AboutDialog() self.about.set_name("DockBarX Applet") self.about.set_version(VERSION) self.about.set_copyright("Copyright (c) 2008-2009 Aleksey Shaferov and Matias S\...
self.applet.show_all()
def __init__(self,applet): gobject.GObject.__init__(self) global settings print "Dockbarx init" self.applet = applet # self.dragging is used to tell functions wheter # a drag-and-drop is going on self.dragging = False self.right_menu_showing = False self.opacified = False self.opacity_values = None self.opacity_matches...
gobject.idle_add(self.idle_init)
def __init__(self,applet): gobject.GObject.__init__(self) print "Dockbarx init" self.applet = applet
self.idle_init() def idle_init(self): later_imports() self.dragging = False self.right_menu_showing = False self.opacified = False self.opacity_values = None self.opacity_matches = None self.groups = None self.windows = None self.theme = None wnck.set_client_type(wnck.CLIENT_TYPE_PAGER) self.screen = wnck.screen...
def __init__(self,applet): gobject.GObject.__init__(self) print "Dockbarx init" self.applet = applet
self.name = self.windows.keys()[0].get_class_group.get_name()
self.name = self.windows.keys()[0].get_class_group().get_name()
def update_name(self): if self.desktop_entry: self.name = self.desktop_entry.getName() elif self.windows: # Uses first half of the name, # like "Amarok" from "Amarok - [SONGNAME]" # A program that uses a name like "[DOCUMENT] - [APPNAME]" would be # totally screwed up. So far no such program has been reported. self.nam...
self.windows.keys[0].get_class_group.get_res_class() + \
self.windows.keys[0].get_class_group().get_res_class() + \
def opacify(self): # Makes all windows but the one connected to this windowbutton # transparent if self.globals.opacity_values is None: try: self.globals.opacity_values = \ compiz_call('obs/screen0/opacity_values','get') except: try: self.globals.opacity_values = \ compiz_call('core/screen0/opacity_values','get') excep...
print len(wins)
def action_compiz_scale_windows(self, widget, event): wins = self.get_unminimized_windows() if not wins: return print len(wins) if len(wins) == 1: self.windows[wins[0]].action_select_window(widget, event) return if self.globals.settings['show_only_current_desktop']: path = 'scale/allscreens/initiate_key' else: path = '...
'iclass=%s'%wins[0].get_class_group.get_res_class())
'iclass=%s'%wins[0].get_class_group().get_res_class())
def action_compiz_scale_windows(self, widget, event): wins = self.get_unminimized_windows() if not wins: return print len(wins) if len(wins) == 1: self.windows[wins[0]].action_select_window(widget, event) return if self.globals.settings['show_only_current_desktop']: path = 'scale/allscreens/initiate_key' else: path = '...
'iclass=%s'%wins[0].get_class_group.get_res_class())
'iclass=%s'%wins[0].get_class_group().get_res_class())
def action_compiz_shift_windows(self, widget, event): wins = self.get_unminimized_windows() if not wins: return if len(wins) == 1: self.windows[wins[0]].action_select_window(widget, event) return
theme_name = theme_name.translate(None, '!?*()/
try: theme_name = theme_name.translate(None, '!?*()/ except: pass
def update(self): """Set widgets according to settings."""
theme_name = theme_name.translate(None, '!?*()/
try: theme_name = theme_name.translate(None, '!?*()/ except: pass
def color_set(self, button, c): # Read the value from color (and aplha) and write # it as 8-bit/channel hex string for gconf. # (Alpha is written like int (0-255).) color_string = colors[c] color = button.get_color() cs = color.to_string() # cs has 16-bit per color, we want 8. new_color = cs[0:3] + cs[5:7] + cs[9:11] t...
theme_name = theme_name.translate(None, '!?*()/
try: theme_name = theme_name.translate(None, '!?*()/ except: pass
def color_reset(self, button, c): # Reset gconf color setting to default. if self.theme_colors.has_key(c): color_string = self.theme_colors[c] else: color_string = DEFAULT_COLORS[c] theme_name = self.dockbar.theme.get_name().replace(' ', '_').encode() theme_name = theme_name.translate(None, '!?*()/#"@') color_dir = GCO...
theme_name = theme_name.translate(None, '!?*()/
try: theme_name = theme_name.translate(None, '!?*()/ except: pass
def reload(self, event=None, data=None): if self.groups != None: for group in self.groups.get_groups(): group.hide_list() del self.groups del self.windows self.groups = GroupList() self.windows = {} self.apps_by_id = {} #--- Generate Gio apps self.apps_by_id = {} self.apps_by_exec={} self.apps_by_name = {} self.apps_by...
theme_name = theme_name.translate(None, '!?*()/
try: theme_name = theme_name.translate(None, '!?*()/ except: pass
def on_gconf_changed(self, client, par2, entry, par4): if entry.get_value() == None: return pref_update = False changed_settings = [] entry_get = { str: entry.get_value().get_string, bool: entry.get_value().get_bool, int: entry.get_value().get_int } key = entry.get_key().split('/')[-1] if key in settings: value = setti...
dekstop_entry = None
desktop_entry = None
def on_window_opened(self,screen,window): if window.is_skip_tasklist() \ or not (window.get_window_type() in [wnck.WINDOW_NORMAL, wnck.WINDOW_DIALOG]): return
if (pos==0) and (lname[len(rc)] == ' '): id = self.launchers_by_longname[lname] print "Opened window matched with launcher on long name:", rc break elif (pos+len(rc) == len(lname)) and (lname[pos-1] == ' '): id = self.launchers_by_longname[lname] print "Opened window matched with launcher on long name:", rc break elif ...
if rc == lname \ or (pos==0 and lname[len(rc)] == ' ') \ or (pos+len(rc) == len(lname) and lname[pos-1] == ' ') \ or (lname[pos-1] == ' ' and lname[pos+len(rc)] == ' '):
def on_window_opened(self,screen,window): if window.is_skip_tasklist() \ or not (window.get_window_type() in [wnck.WINDOW_NORMAL, wnck.WINDOW_DIALOG]): return
if (pos==0) and (lname[len(rc)] == ' '): app_id = self.apps_by_longname[lname] print "Opened window matched with gio app on longname:", rc break elif (pos+len(rc) == len(lname)) and (lname[pos-1] == ' '): app_id = self.apps_by_longname[lname] print "Opened window matched with gio app on longname:", rc break elif (lname...
if rc == lname \ or (pos==0 and lname[len(rc)] == ' ') \ or (pos+len(rc) == len(lname) and lname[pos-1] == ' ') \ or (lname[pos-1] == ' ' and lname[pos+len(rc)] == ' '):
def find_gio_app(self, res_class): app = None app_id = None rc = u""+res_class.lower() if rc != "": # WM_CLASS res_class exists. if rc in self.apps_by_id: app_id = rc print "Opened window matched with gio app on id:", rc elif rc in self.apps_by_name: app_id = self.apps_by_name[rc] print "Opened window matched with gio ...
self.button.set_preview_aspect(self.window.get_geometry()[2], self.window.get_geometry()[3], self.globals.settings['preview_size'])
def __init__(self, window): gobject.GObject.__init__(self) self.globals = Globals() self.opacify_obj = Opacify() self.globals.connect('show-only-current-monitor-changed', self.on_show_only_current_monitor_changed) self.screen = wnck.screen_get_default() self.name = window.get_name() self.window = window self.needs_atte...
if self.class_group:
if self.identifier: icon_name = self.identifier.lower() elif self.class_group:
def find_icon_pixbuf(self, size): # Returns the icon pixbuf for the program. Uses the following metods:
if icon_name == "wine" and settings['separate_wine_apps']:
if icon_name.startswith("wine__"):
def find_icon_pixbuf(self, size): # Returns the icon pixbuf for the program. Uses the following metods:
return self.class_group.get_icon().copy
return self.class_group.get_icon().copy()
def find_icon_pixbuf(self, size): # Returns the icon pixbuf for the program. Uses the following metods:
self.popup_label.set_tooltip_text("Resource class name: "+self.identifier)
self.popup_label.set_tooltip_text("Identifier: "+self.identifier)
def __init__(self,dockbar,class_group=None, identifier=None, launcher=None, index=None, app=None): gobject.GObject.__init__(self)
self.popup_label.set_tooltip_text("Resource class name: "+self.identifier)
self.popup_label.set_tooltip_text("Identifier: "+self.identifier)
def identifier_changed(self, identifier): self.identifier = identifier self.launcher.set_identifier(identifier) self.popup_label.set_tooltip_text("Resource class name: "+self.identifier)
edit_identifier_item = gtk.MenuItem('Edit Resource Name')
edit_identifier_item = gtk.MenuItem('Edit Identifier')
def action_show_menu(self, widget, event): try: action_maximize = wnck.WINDOW_ACTION_MAXIMIZE except: action_maximize = 1 << 14 self.hide_list() #Creates a popup menu menu = gtk.Menu() menu.connect('selection-done', self.menu_closed) if self.app and not self.launcher: #Add launcher item add_launcher_item = gtk.MenuItem...
def class_name_dialog(self, identifier=None):
def identifier_dialog(self, identifier=None):
def class_name_dialog(self, identifier=None): # Input dialog for inputting the res_class_name. dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, None) dialog.set_title('Resource Class') dialog.set_markup('<b>Enter the resource class name he...
dialog.set_title('Resource Class') dialog.set_markup('<b>Enter the resource class name here</b>')
dialog.set_title('Identifier') dialog.set_markup('<b>Enter the identifier here</b>')
def class_name_dialog(self, identifier=None): # Input dialog for inputting the res_class_name. dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, None) dialog.set_title('Resource Class') dialog.set_markup('<b>Enter the resource class name he...