# Path: vocto/composite_commands.py
# class CompositeCommand:
# 
#     def __init__(self, composite, A, B):
#         self.composite = composite
#         self.A = A
#         self.B = B
# 
#     def from_str(command):
#         A = None
#         B = None
#         # match case: c(A,B)
#         r = re.match(
#             r'^\s*([|+-]?\w[-_\w]*)\s*\(\s*([-_\w*]+)\s*,\s*([-_\w*]+)\)\s*$', command)
#         if r:
#             A = r.group(2)
#             B = r.group(3)
#         else:
#             # match case: c(A)
#             r = re.match(r'^\s*([|+-]?\w[-_\w]*)\s*\(\s*([-_\w*]+)\s*\)\s*$', command)
#             if r:
#                 A = r.group(2)
#             else:
#                 # match case: c
#                 r = re.match(r'^\s*([|+-]?\w[-_\w]*)\s*$', command)
#                 assert r
#         composite = r.group(1)
#         if composite == '*':
#             composite = None
#         if A == '*':
#             A = None
#         if B == '*':
#             B = None
#         return CompositeCommand(composite,A,B)
# 
#     def modify(self, mod, reverse=False):
#         # get command as string and process all replactions
#         command = original = str(self)
#         for r in mod.split(','):
#             what, _with = r.split('->')
#             if reverse:
#                 what, _with = _with, what
#             command = command.replace(what.strip(), _with.strip())
#         modified = original != command
#         # re-convert string to command and take the elements
#         command = CompositeCommand.from_str(command)
#         self.composite = command.composite
#         self.A = command.A
#         self.B = command.B
#         return modified
# 
#     def unmodify(self, mod):
#         return self.modify(mod, True)
# 
#     def __str__(self):
#         return "%s(%s,%s)" % (self.composite if self.composite else "*",
#                                self.A if self.A else "*",
#                                self.B if self.B else "*")
# 
#     def __eq__(self, other):
#         return ((self.composite == other.composite or not(self.composite and other.composite))
#                 and (self.A == other.A or not(self.A and other.A))
#                 and (self.B == other.B or not(self.B and other.B)))


import os
import logging
import copy
import lib.connection as Connection
from gi.repository import Gtk
from lib.config import Config
from vocto.composite_commands import CompositeCommand
from lib.toolbar.buttons import Buttons
from lib.uibuilder import UiBuilder
                    if id in self.sourcesB and self.sourcesB[id]['button'].get_active():
                        self.sourceB = None
                        self.sourcesB[self.sourceA]['button'].set_active(True)
                    self.sourceA = id
                    self.log.info(
                        "Selected '%s' for preview source A", self.sourceA)
                elif self.sourcesB[id]['button'] == btn:
                    if self.sourcesA[id]['button'].get_active():
                        self.sourceA = None
                        self.sourcesA[self.sourceB]['button'].set_active(True)
                    self.sourceB = id
                    self.log.info(
                        "Selected '%s' for preview source B", self.sourceB)
                self.test()
            elif id in self.composites:
                self.composite = id
                self.enable_sourcesB()
                self.enable_modifiers()
                self.log.info(
                    "Selected '%s' for preview target composite", self.composite)
                self.test()
        if id in self.mods:
            self.modstates[id] = btn.get_active()
            self.log.info("Turned preview modifier '%s' %s", id,
                          'on' if self.modstates[id] else 'off')
            self.test()
        self.enable_sources();
        self.log.debug("current command is '%s", self.command())

    def enable_modifiers(self):

# Path: vocto/composite_commands.py
# class CompositeCommand:
# 
#     def __init__(self, composite, A, B):
#         self.composite = composite
#         self.A = A
#         self.B = B
# 
#     def from_str(command):
#         A = None
#         B = None
#         # match case: c(A,B)
#         r = re.match(
#             r'^\s*([|+-]?\w[-_\w]*)\s*\(\s*([-_\w*]+)\s*,\s*([-_\w*]+)\)\s*$', command)
#         if r:
#             A = r.group(2)
#             B = r.group(3)
#         else:
#             # match case: c(A)
#             r = re.match(r'^\s*([|+-]?\w[-_\w]*)\s*\(\s*([-_\w*]+)\s*\)\s*$', command)
#             if r:
#                 A = r.group(2)
#             else:
#                 # match case: c
#                 r = re.match(r'^\s*([|+-]?\w[-_\w]*)\s*$', command)
#                 assert r
#         composite = r.group(1)
#         if composite == '*':
#             composite = None
#         if A == '*':
#             A = None
#         if B == '*':
#             B = None
#         return CompositeCommand(composite,A,B)
# 
#     def modify(self, mod, reverse=False):
#         # get command as string and process all replactions
#         command = original = str(self)
#         for r in mod.split(','):
#             what, _with = r.split('->')
#             if reverse:
#                 what, _with = _with, what
#             command = command.replace(what.strip(), _with.strip())
#         modified = original != command
#         # re-convert string to command and take the elements
#         command = CompositeCommand.from_str(command)
#         self.composite = command.composite
#         self.A = command.A
#         self.B = command.B
#         return modified
# 
#     def unmodify(self, mod):
#         return self.modify(mod, True)
# 
#     def __str__(self):
#         return "%s(%s,%s)" % (self.composite if self.composite else "*",
#                                self.A if self.A else "*",
#                                self.B if self.B else "*")
# 
#     def __eq__(self, other):
#         return ((self.composite == other.composite or not(self.composite and other.composite))
#                 and (self.A == other.A or not(self.A and other.A))
#                 and (self.B == other.B or not(self.B and other.B)))


# Path: voctogui/lib/toolbar/preview.py
import os
import logging
import copy
import lib.connection as Connection
from gi.repository import Gtk
from lib.config import Config
from vocto.composite_commands import CompositeCommand
from lib.toolbar.buttons import Buttons
from lib.uibuilder import UiBuilder

                    if id in self.sourcesB and self.sourcesB[id]['button'].get_active():
                        self.sourceB = None
                        self.sourcesB[self.sourceA]['button'].set_active(True)
                    self.sourceA = id
                    self.log.info(
                        "Selected '%s' for preview source A", self.sourceA)
                elif self.sourcesB[id]['button'] == btn:
                    if self.sourcesA[id]['button'].get_active():
                        self.sourceA = None
                        self.sourcesA[self.sourceB]['button'].set_active(True)
                    self.sourceB = id
                    self.log.info(
                        "Selected '%s' for preview source B", self.sourceB)
                self.test()
            elif id in self.composites:
                self.composite = id
                self.enable_sourcesB()
                self.enable_modifiers()
                self.log.info(
                    "Selected '%s' for preview target composite", self.composite)
                self.test()
        if id in self.mods:
            self.modstates[id] = btn.get_active()
            self.log.info("Turned preview modifier '%s' %s", id,
                          'on' if self.modstates[id] else 'off')
            self.test()
        self.enable_sources();
        self.log.debug("current command is '%s", self.command())

    def enable_modifiers(self):

        command = CompositeCommand(self.composite, self.sourceA, self.sourceB)