Example #1
0
 def loadPosition (window):
     width, height = window.get_size_request()
     
     if conf.hasKey(key+"_width") and conf.hasKey(key+"_height"):
         width = conf.getStrict(key+"_width")
         height = conf.getStrict(key+"_height")
         window.resize(width, height)
     
     elif defaultSize:
         width, height = defaultSize
         window.resize(width, height)
     
     if conf.hasKey(key+"_x") and conf.hasKey(key+"_y"):
         window.move(conf.getStrict(key+"_x"),
                     conf.getStrict(key+"_y"))
     
     elif defaultPosition in (POSITION_CENTER, POSITION_GOLDEN):
         monitor_x, monitor_y, monitor_width, monitor_height = getMonitorBounds()
         x = int(monitor_width/2-width/2) + monitor_x
         if defaultPosition == POSITION_CENTER:
             y = int(monitor_height/2-height/2) + monitor_y
         else:
             # Place the window on the upper golden ratio line
             y = int(monitor_height/2.618-height/2) + monitor_y
         window.move(x, y)
Example #2
0
 def setFromConf ():
     try:
         v = conf.getStrict(key)
     except TypeError:
         log.warning("uistuff.keep.setFromConf: Key '%s' from conf had the wrong type '%s', ignored" % \
                  (key, type(conf.getStrict(key))))
         if first_value != None:
             conf.set(key, first_value)
         else: conf.set(key, get_value())
     else:
         set_value(v)
Example #3
0
def loadDialogWidget(widget,
                     widget_name,
                     config_number,
                     get_value_=None,
                     set_value_=None,
                     first_value=None):
    key = widget_name + "-" + str(config_number)

    if widget is None:
        raise AttributeError("key '%s' isn't in widgets" % widget_name)

    for class_, methods_ in METHODS:
        if isinstance(widget, class_):
            getter, setter, signal = methods_
            break
    else:
        if set_value_ is None:
            raise AttributeError("I don't have any knowledge of type: '%s'" %
                                 widget)

    if get_value_:
        def get_value():
            return get_value_(widget)
    else:
        get_value = getattr(widget, getter)

    if set_value_:
        def set_value(v):
            return set_value_(widget, v)
    else:
        set_value = getattr(widget, setter)

    if conf.hasKey(key):
        try:
            v = conf.getStrict(key)
        except TypeError:
            log.warning("uistuff.loadDialogWidget: Key '%s' from conf had the wrong type '%s', ignored" %
                        (key, type(conf.getStrict(key))))
            if first_value is not None:
                conf.set(key, first_value)
            else:
                conf.set(key, get_value())
        else:
            set_value(v)
    elif first_value is not None:
        conf.set(key, first_value)
        set_value(conf.getStrict(key))
    else:
        log.warning("Didn't load widget \"%s\": no conf value and no first_value arg" % widget_name)
Example #4
0
 def loadPosition (window):
     #log.debug("keepWindowSize.loadPosition: %s" % window.title)
     width, height = window.get_size_request()
     
     if conf.hasKey(key+"_width") and conf.hasKey(key+"_height"):
         width = conf.getStrict(key+"_width")
         height = conf.getStrict(key+"_height")
         log.debug("Resizing window to width=%s height=%s" % (width, height))
         window.resize(width, height)
     
     elif defaultSize:
         width, height = defaultSize
         log.debug("Resizing window to width=%s height=%s" % (width, height))
         window.resize(width, height)
     
     if conf.hasKey(key+"_x") and conf.hasKey(key+"_y"):
         log.debug("Moving window to x=%s y=%s" % (conf.getStrict(key+"_x"),
                                                   conf.getStrict(key+"_y")))
         window.move(conf.getStrict(key+"_x"),
                     conf.getStrict(key+"_y"))
     
     elif defaultPosition in (POSITION_CENTER, POSITION_GOLDEN):
         monitor_x, monitor_y, monitor_width, monitor_height = getMonitorBounds()
         x = int(monitor_width/2-width/2) + monitor_x
         if defaultPosition == POSITION_CENTER:
             y = int(monitor_height/2-height/2) + monitor_y
         else:
             # Place the window on the upper golden ratio line
             y = int(monitor_height/2.618-height/2) + monitor_y
         log.debug("Moving window to x=%s y=%s" % (x, y))
         window.move(x, y)
Example #5
0
def saveDialogWidget (widget, widget_name, config_number, get_value_=None):
    key = widget_name + "-" + str(config_number)
    
    if widget == None:
        raise AttributeError("key '%s' isn't in widgets" % widget_name)
    
    for class_, methods_ in METHODS:
        if isinstance(widget, class_):
            getter, setter, signal = methods_
            break
    else:
        if get_value_ == None:
            raise AttributeError("I don't have any knowledge of type: '%s'" % widget)
    
    if get_value_:
        get_value = lambda: get_value_(widget)
    else:
        get_value = getattr(widget, getter)

    if not conf.hasKey(key) or conf.getStrict(key) != get_value():
        conf.set(key, get_value())
Example #6
0
 def callback(*args):
     if not conf.hasKey(key) or conf.getStrict(key) != get_value():
         conf.set(key, get_value())
Example #7
0
 def callback(*args):
     if not conf.hasKey(key) or conf.getStrict(key) != get_value():
         conf.set(key, get_value())