Saturday, September 19, 2015

Online Python Learning Resources

Friday, September 4, 2015

MATE Is Creating A Challenge With Porting GnoMenu

Well as the saying goes anything worth doing will not come without challenges. Case in point is bringing back the abilities of GnoMenu, which was originally made to work with Gnome 2 to MATE which is a continuation of the afore mentioned Gnome 2. Now oddly enough the challenge is caused by the deprecation of the one thing that caused the GnoMenu the most issues, Bonobo.

Bonobo was a component model for creating reusable software components and compound documents in GNOME 2. Bonobo was deprecated in both MATE and GNOME 3 (officially deprecated in GNOME 2.4) and MATE for the sake of backwards compatibility implemented their version of Bonobo which was a short lived stop gap to allow panel apps in MATE to continue functioning while the MATE developers to move the new D-BUS implementation via GSettings/DBUS. To understand how much this changes things you need to understand that syntax is vital in programming. The switch from Bonobo to DBUS changes not only the command and calls but the syntax as well. As an example here is piece of code used in that needs to redone to use Gsettings/DBUS:

import gtk
import pygtk
import commands
import sys
import gobject
import mateapplet
from gi.repository import MatePanelApplet as mateapplet
import os

if not os.path.exists(os.path.expanduser("~") + '/.mnwmenu') or not os.path.isdir(os.path.expanduser("~") + '/.mnwmenu'):
os.system('mkdir ~/.mnwmenu')

import gconf

Now here is an example of code that performs this same base function with the new syntax:

import gi
gi.require_version("Gtk", "2.0")

from gi.repository import Gtk
from gi.repository import MatePanelApplet

def applet_fill(applet):

    # you can use this path with gio/gsettings
    settings_path = applet.get_preferences_path()

    label = Gtk.Label("My MATE applet in Python")

def applet_factory(applet, iid, data):
    if iid != "TestApplet":
       return False


    return True

MatePanelApplet.Applet.factory_main("TestAppletFactory", True,
                                    applet_factory, None)

Though this is not a pure function to function or process to process example it shows how the syntax has changed. Not all syntax changes can be attributed to the change from Bonobo to D-BUS either as Python also has had some changes to its base syntax as well.

I'm just learning Python and haven't written a program in years in any computer language. Beyond shell scripting and some HTML CSS stuff I really haven't kept up with it. Even with shell scripts like to help convert the Python code, because of the changes in the syntax structure, that are required, I quickly realized I am going to have rewrite nearly all of the modules from GnoMenu from scratch to comply with syntax structure and ensure that the proper commands and functions are used. I contacted Helder Fraga and unfortunately he no longer has any notes on GnoMenu, which means (drum roll please) I'm going to have to reverse engineer the GnoMenu code (which means creating lots of flow charts) so I can recreate the app.

You can bet you A$$ there will be follow ups to this Post.