Esempio n. 1
0
 def addrow(self, data):
     iter = self.model.append()
     for i in range(len(data[0])):
         self.model.set_value(iter, i, data[0][i])
     O = gobject.GObject()
     O.set_data('', data)
     self.model.set_value(iter, i + 1, O)
Esempio n. 2
0
 def createStoreModelFromNode(self, node, parent=None):
     iter=self.append(parent)
     gobj=gobject.GObject()
     gobj.set_data(DOMTreeModel.NODE_KEY, node)
     self.set_value(iter, DOMModel.COLUMN_NAME, node.nodeName)
     self.set_value(iter, DOMModel.COLUMN_VALUE, node.nodeValue)
     self.set_value(iter, DOMModel.COLUMN_EDITABLE, False)
     self.set_value(iter, DOMModel.COLUMN_NODE, gobj)
     for child in node.childNodes:
         self.createStoreModelFromNode(child, iter)
Esempio n. 3
0
 def addrow(self, data, expand=None):
     iter = self.model.append(self.root[-1])
     self.last = iter
     for i in range(len(data[0])):
         self.model.set_value(iter, i, data[0][i])
     O = gobject.GObject()
     if expand: O.set_data('', (data, expand))
     else: O.set_data('', (data, 0))
     self.model.set_value(iter, i + 1, O)
     if expand:
         self._sub()
         self.addrow(data)
         self._unsub()
Esempio n. 4
0
    def createStoreModelFromNode(self, node):
        iter=self.append()
        ComLog.getLogger(__logStrLevel__).debug("Node: %s, %s" % (node, node.attributes))
        gobj=gobject.GObject()
        gobj.set_data(DOMTreeModel.NODE_KEY, node)
        self.set_value(iter, DOMModel.COLUMN_NAME, node.nodeName)
        self.set_value(iter, DOMModel.COLUMN_VALUE, node.nodeValue)
        self.set_value(iter, DOMModel.COLUMN_EDITABLE, True)
        self.set_value(iter, DOMModel.COLUMN_NODE, gobj)

        if node.attributes and len(node.attributes) > 0:
            for child in node.attributes:
                self.createStoreModelFromNode(child)
Esempio n. 5
0
 def __init__(self,
              name="---",
              icon='gtk-discard',
              widgets=None,
              pages=None):
     self.name = name
     self.icon = icon
     self.gobject = gobject.GObject()
     self.gobject.loading = False
     self.gobject.number_of_settings = 0
     self.widget = gtk.VBox()
     self.widget.show()
     self.widgets = None
     self._widgets = widgets
     self._pages = pages
Esempio n. 6
0
 def __init__(self,
              settings={},
              number_of_settings=1,
              hidden_on_load=False):
     self.title = None
     self.gobject = gobject.GObject()
     if gobject.signal_lookup('settings-changed', self.gobject) == 0:
         gobject.signal_new(
             "settings-changed", gobject.GObject, gobject.SIGNAL_ACTION,
             gobject.TYPE_NONE,
             (str, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT))
     if gobject.signal_lookup('loading-settings', self.gobject) == 0:
         gobject.signal_new("loading-settings", gobject.GObject,
                            gobject.SIGNAL_ACTION, gobject.TYPE_NONE,
                            (int, ))
     if gobject.signal_lookup('settings-changed', self.gobject) == 0:
         gobject.signal_new(
             "settings-changed", gobject.GObject, gobject.SIGNAL_ACTION,
             gobject.TYPE_NONE,
             (str, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT))
     if gobject.signal_lookup('settings-loaded', self.gobject) == 0:
         gobject.signal_new("settings-loaded", gobject.GObject,
                            gobject.SIGNAL_ACTION, gobject.TYPE_NONE,
                            (str, gobject.TYPE_PYOBJECT))
     self.gobject.loading = True
     self.gobject._loaded = False
     self._gui_initialized = False
     self.gobject.number_of_settings = number_of_settings
     if 'hidden_on_load' not in dir(self):
         self.hidden_on_load = hidden_on_load
     self.threading = async .ThreadedClass()
     self.settings = settings
     gtk.VBox.__init__(self)
     self.set_spacing(0)
     if '_build_interface' in dir(self):
         self._build_interface_real = self._build_interface
         self._build_interface = self._build_interface_wrapper
     else:
         self._gui_initialized = True
Esempio n. 7
0
 def add_element(self, item, model, piter, name, iter=None):
     self.status("Menu Add Element... " + name + " pressed menuitem %s, model %s, piter %s, iter %s" % (item, model, piter, iter))
     if iter:
         value = model.get_value(iter, DOMModel.COLUMN_NODE)
         ref_node=value.get_data(DOMModel.NODE_KEY)
         ref_node=ref_node.nextSibling
         citer=model.convert_iter_to_child_iter(iter)
     else:
         citer=None
         ref_node=None
     value=model.get_value(piter, DOMModel.COLUMN_NODE)
     parent_node=value.get_data(DOMModel.NODE_KEY)
     ComLog.getLogger(__logStrLevel__).debug("parentnode: %s" % parent_node)
     node=self.__basemodell.document.createElement(name)
     parent_node.insertBefore(node, ref_node)
     cpiter=model.convert_iter_to_child_iter(piter)
     iter_newnode=model.get_model().insert_after(cpiter, citer)
     gobj=gobject.GObject()
     gobj.set_data(DOMTreeModel.NODE_KEY, node)
     model.get_model().set_value(iter_newnode, DOMModel.COLUMN_NAME, node.nodeName)
     model.get_model().set_value(iter_newnode, DOMModel.COLUMN_VALUE, node.nodeValue)
     model.get_model().set_value(iter_newnode, DOMModel.COLUMN_EDITABLE, False)
     model.get_model().set_value(iter_newnode, DOMModel.COLUMN_NODE, gobj)
Esempio n. 8
0
    def on_delete_released( self, w, d=None):
        (model, iter) = self.ui.selection.get_selected()
        if not iter:
            gnutr.Dialog( 'warn', 'You must select a recipe or food to delete.',
                self.parent)
            return
        
        date = self.ui.date.entry.get_text()

        data = model.get_value( iter, 4)
        if data:
            if isinstance( data, gnutr.Ingredient):
                self.delete_from_plan_temp_db( date, food=data) 
            elif isinstance( data, gnutr.Recipe):
                self.delete_from_plan_temp_db( date, recipe=data) 
            else:
                return
            model.set_value( iter, 1, '')
            model.set_value( iter, 2, '')
            model.set_value( iter, 3, '')
            model.set_value( iter, 4, gobject.GObject())
        else:
            return
Esempio n. 9
0
 def testNewInstanceHasTwoRefs(self):
     obj = gobject.GObject()
     self.assertEquals(sys.getrefcount(obj), 2)
Esempio n. 10
0
    def testRegularObject(self):
        obj = gobject.GObject()
        self.assertEquals(obj.__grefcount__, 1)

        obj = gobject.new(gobject.GObject)
        self.assertEquals(obj.__grefcount__, 1)
Esempio n. 11
0
 def testGObjectModule(self):
     obj = gobject.GObject()
     self.assertEquals(obj.__module__, 'gobject._gobject')
Esempio n. 12
0
 def add_to_ui(self, app):
     wrapper = gobject.GObject()
     wrapper.slot = copy.deepcopy(self)
     app.slot_list.append((self.id, self.type, wrapper))
Esempio n. 13
0
 def testGoodArguments(self):
     tasklet.WaitForSignal(gobject.GObject(), 'notify')
Esempio n. 14
0
 def testBadArguments(self):
     self.assertRaises(TypeError, tasklet.WaitForSignal, '', '')
     self.assertRaises(ValueError, tasklet.WaitForSignal, gobject.GObject(),
                       'foo')