Convert to GtkBuilder from Libglade

Bug #799738 reported by Mike M
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Decibel Audio Player
Fix Released
Low
Anonym25712

Bug Description

since libglade is long deprecated, and totally gone in gtk3 converting to gtkbuilder makes sense,
im not an expert coder but i tried everything i could think of and everything seems to still be fine, i couldnt figure out how to make a patch, so i did it as follows,

1, open all .glade files in glade 3.8
Edit -> Preferences and Select GtkBuilder then save, (gtk-builder-convert from the commandline seems to fail)

2, run this command in the src directory
find . -name "*.py" -print | xargs sed -i 's/get_widget/get_object/g'

3, change tools/init.py and gui/window.py as follows

tools/init.py

def loadGladeFile(file, root=None):
    """ Load the given Glade file and return the tree of widgets """
    builder = gtk.Builder()
    if root is None:
 builder.add_from_file(os.path.join(consts.dirRes, file))
 return builder
    else:
 builder.add_from_file(os.path.join(consts.dirRes, file))
 widget = builder.get_object(root)
 return widget, builder

gui/window.py

def __init__(self, resFile, container, modName, title, defaultWidth, defaultHeight):
        """ Constructor """
        gtk.Window.__init__(self)

        self.wTree, self.wBuilder = tools.loadGladeFile(resFile, container)
        self.visible = False
        self.modName = modName
        self.set_title(title)

        self.wBuilder.get_object(container).reparent(self)

        if tools.prefs.get(modName, 'win-is-maximized', False):
            self.maximize()

        self.resize(tools.prefs.get(modName, 'win-width', defaultWidth),
            tools.prefs.get(modName, 'win-height', defaultHeight))

        self.set_position(gtk.WIN_POS_CENTER)

        self.connect('delete-event', self.onDelete)
        self.connect('size-allocate', self.onResize)
        self.connect('window-state-event', self.onState)

def getWidget(self, name):
        """ Return the widget with the given name """
        return self.wBuilder.get_object(name)

4, in decibel-audio-player.py comment out the two gtk.glade localization lines

decibel-audio-player.py
#gtk.glade.textdomain(consts.appNameShort)
#gtk.glade.bindtextdomain(consts.appNameShort, consts.dirLocale)

5, uninstall python-glade2 and watch decibel still run fine

Revision history for this message
Anonym25712 (anonym25712) wrote :

Fixed on trunk.

Changed in decibel-audio-player:
assignee: nobody → François Ingelrest (athropos)
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
Anonym25712 (anonym25712) wrote :

See v1.08

Changed in decibel-audio-player:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.