Example #1
0
	def loadDesktopEntry( self, desktopItem ):
		try:
			self.appName = desktopItem.getName()
			self.appGenericName = desktopItem.getGenericName()
			self.appComment = desktopItem.getComment()
			self.appExec = desktopItem.getExec()
			self.appIconName = desktopItem.getIcon()
			self.appCategories = desktopItem.getCategories()
			self.appGnomeDocPath = desktopItem.get( "X-GNOME-DocPath" ) or ""
			self.useTerminal = desktopItem.getTerminal()

			if not self.appGnomeDocPath:
				self.appKdeDocPath	= desktopItem.getDocPath() or ""

			self.appName		= self.appName.strip()
			self.appGenericName	= self.appGenericName.strip()
			self.appComment		= self.appComment.strip()
			
			basename = os.path.basename( self.desktopFile )
			self.startupFilePath = os.path.join( os.path.expanduser("~"), ".config", "autostart", basename )
			if self.startupMonitorId:
				filemonitor.removeMonitor( self.startupMonitorId  )
			self.startupMonitorId = filemonitor.addMonitor( self.startupFilePath, self.startupFileChanged )
			#self.inStartup = os.path.exists( self.startupFilePath )

		except Exception, e:
			print e
			self.appName		= ""
			self.appGenericName	= ""
			self.appComment		= ""
			self.appExec		= ""
			self.appIconName		= ""
			self.appCategories	= ""
			self.appDocPath		= ""
			self.startupMonitorId 	= 0
Example #2
0
    def __init__(self, desktopFile, iconSize):

        if isinstance(desktopFile, xdg.Menu.MenuEntry):
            desktopItem = desktopFile.DesktopEntry
            desktopFile = desktopItem.filename
            self.appDirs = desktop.desktopFile.AppDirs
        elif isinstance(desktopFile, xdg.Menu.DesktopEntry):
            desktopItem = desktopFile
            desktopFile = desktopItem.filename
            self.appDirs = [os.path.dirname(desktopItem.filename)]
        else:
            desktopItem = xdg.DesktopEntry.DesktopEntry(desktopFile)
            self.appDirs = [os.path.dirname(desktopFile)]

        self.desktopFile = desktopFile
        self.startupMonitorId = 0

        self.loadDesktopEntry(desktopItem)

        self.desktopEntryMonitors = []

        base = os.path.basename(self.desktopFile)
        for dir in self.appDirs:
            self.desktopEntryMonitors.append(
                filemonitor.addMonitor(os.path.join(dir, base),
                                       self.desktopEntryFileChangedCallback))

        easyButton.__init__(self, self.appIconName, iconSize)
        self.setupLabels()

        # Drag and Drop
        self.connectSelf("drag-data-get", self.dragDataGet)

        array = TargetEntry * 2
        targets = array(("text/plain", 0, 100), ("text/uri-list", 0, 101))
        gtk.gtk_drag_source_set.argtypes = [
            c_void_p, c_ushort, c_void_p, c_int, c_ushort
        ]
        gtk.gtk_drag_source_set(hash(self), Gdk.ModifierType.BUTTON1_MASK,
                                targets, 2, Gdk.DragAction.COPY)

        icon = self.getIcon(Gtk.IconSize.DND)
        if icon:
            iconName, s = icon.get_icon_name()
            c = c_char_p(
                iconName.decode('utf-8', 'ignore').encode('ascii', 'ignore'))
            gtk.gtk_drag_source_set_icon_name.argtypes = [c_void_p, c_char_p]
            gtk.gtk_drag_source_set_icon_name(hash(self), c)

        self.connectSelf("focus-in-event", self.onFocusIn)
        self.connectSelf("focus-out-event", self.onFocusOut)
        self.connectSelf("clicked", self.execute)
Example #3
0
    def __init__( self, desktopFile, iconSize):

        if isinstance( desktopFile, xdg.Menu.MenuEntry ):
            desktopItem = desktopFile.DesktopEntry
            desktopFile = desktopItem.filename
            self.appDirs = desktop.desktopFile.AppDirs
        elif isinstance( desktopFile, xdg.Menu.DesktopEntry ):
            desktopItem = desktopFile
            desktopFile = desktopItem.filename
            self.appDirs = [ os.path.dirname( desktopItem.filename ) ]
        else:
            desktopItem = xdg.DesktopEntry.DesktopEntry( desktopFile )
            self.appDirs = [ os.path.dirname( desktopFile ) ]

        self.desktopFile = desktopFile
        self.startupMonitorId = 0

        self.loadDesktopEntry( desktopItem )

        self.desktopEntryMonitors = []

        base = os.path.basename( self.desktopFile )
        for dir in self.appDirs:
            self.desktopEntryMonitors.append( filemonitor.addMonitor( os.path.join(dir, base) , self.desktopEntryFileChangedCallback ) ))

        easyButton.__init__( self, self.appIconName, iconSize )
        self.setupLabels()

        # Drag and Drop
        self.connectSelf( "drag-data-get", self.dragDataGet )
        array = TargetEntry * 2
        targets = array(( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ))
        gtk.gtk_drag_source_set(hash(self), Gdk.ModifierType.BUTTON1_MASK, targets, 2, Gdk.DragAction.COPY)

        icon = self.getIcon( Gtk.IconSize.DND )
        if icon:
            if icon.get_storage_type() == Gtk.ImageType.PIXBUF:
                pb = icon.get_pixbuf()
                gtk.gtk_drag_source_set_icon_pixbuf( hash(self), hash(pb) )
                del icon
            else:
                if self.iconName:
                    c = c_char_p(self.iconName)
                    gtk.gtk_drag_source_set_icon_name( hash(self), c)

        self.connectSelf( "focus-in-event", self.onFocusIn )
        self.connectSelf( "focus-out-event", self.onFocusOut )
        self.connectSelf( "enter-notify-event", self.onEnterNotify )
        self.connectSelf( "clicked", self.execute )
Example #4
0
    def __init__(self, desktopFile, iconSize, height=38):

        if isinstance(desktopFile, xdg.Menu.MenuEntry):
            desktopItem = desktopFile.DesktopEntry
            desktopFile = desktopItem.filename
            self.appDirs = desktop.desktopFile.AppDirs
        elif isinstance(desktopFile, xdg.Menu.DesktopEntry):
            desktopItem = desktopFile
            desktopFile = desktopItem.filename
            self.appDirs = [os.path.dirname(desktopItem.filename)]
        else:
            desktopItem = xdg.DesktopEntry.DesktopEntry(desktopFile)
            self.appDirs = [os.path.dirname(desktopFile)]

        self.desktopFile = desktopFile
        self.startupMonitorId = 0

        self.loadDesktopEntry(desktopItem)

        self.desktopEntryMonitors = []

        base = os.path.basename(self.desktopFile)
        for dir in self.appDirs:
            self.desktopEntryMonitors.append(
                filemonitor.addMonitor(os.path.join(dir, base),
                                       self.desktopEntryFileChangedCallback))

        easyButton.__init__(self, self.appIconName, iconSize, None, 200,
                            height)
        self.setupLabels()

        # Drag and Drop
        self.connectSelf("drag-data-get", self.dragDataGet)

        targets = (Gtk.TargetEntry.new("text/plain", 0, 100),
                   Gtk.TargetEntry.new("text/uri-list", 0, 101))
        self.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, targets,
                             Gdk.DragAction.COPY)

        icon = self.getIcon(Gtk.IconSize.DND)
        if icon:
            iconName, s = icon.get_icon_name()
            self.drag_source_set_icon_name(iconName)

        self.connectSelf("focus-in-event", self.onFocusIn)
        self.connectSelf("focus-out-event", self.onFocusOut)
        self.connectSelf("clicked", self.execute)
Example #5
0
    def __init__( self, desktopFile, iconSize):

        if isinstance( desktopFile, xdg.Menu.MenuEntry ):
            desktopItem = desktopFile.DesktopEntry
            desktopFile = desktopItem.filename
            self.appDirs = desktop.desktopFile.AppDirs
        elif isinstance( desktopFile, xdg.Menu.DesktopEntry ):
            desktopItem = desktopFile
            desktopFile = desktopItem.filename
            self.appDirs = [ os.path.dirname( desktopItem.filename ) ]
        else:
            desktopItem = xdg.DesktopEntry.DesktopEntry( desktopFile )
            self.appDirs = [ os.path.dirname( desktopFile ) ]

        self.desktopFile = desktopFile
        self.startupMonitorId = 0

        self.loadDesktopEntry( desktopItem )

        self.desktopEntryMonitors = []

        base = os.path.basename( self.desktopFile )
        for dir in self.appDirs:
            self.desktopEntryMonitors.append( filemonitor.addMonitor( os.path.join(dir, base) , self.desktopEntryFileChangedCallback ) )

        easyButton.__init__( self, self.appIconName, iconSize )
        self.setupLabels()

        # Drag and Drop
        self.connectSelf( "drag-data-get", self.dragDataGet )

        array = TargetEntry * 2
        targets = array(( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ))
        gtk.gtk_drag_source_set.argtypes = [c_void_p, c_ushort, c_void_p, c_int, c_ushort]
        gtk.gtk_drag_source_set(hash(self), Gdk.ModifierType.BUTTON1_MASK, targets, 2, Gdk.DragAction.COPY)

        icon = self.getIcon( Gtk.IconSize.DND )
        if icon:
            iconName, s = icon.get_icon_name()
            c = c_char_p(iconName.decode('utf-8', 'ignore').encode('ascii', 'ignore'))
            gtk.gtk_drag_source_set_icon_name.argtypes = [c_void_p, c_char_p]
            gtk.gtk_drag_source_set_icon_name( hash(self), c)

        self.connectSelf( "focus-in-event", self.onFocusIn )
        self.connectSelf( "focus-out-event", self.onFocusOut )
        self.connectSelf( "clicked", self.execute )
Example #6
0
    def __init__(self, desktopFile, iconSize):

        if isinstance(desktopFile, xdg.Menu.MenuEntry):
            desktopItem = desktopFile.DesktopEntry
            desktopFile = desktopItem.filename
            self.appDirs = desktop.desktopFile.AppDirs
        elif isinstance(desktopFile, xdg.Menu.DesktopEntry):
            desktopItem = desktopFile
            desktopFile = desktopItem.filename
            self.appDirs = [os.path.dirname(desktopItem.filename)]
        else:
            desktopItem = xdg.DesktopEntry.DesktopEntry(desktopFile)
            self.appDirs = [os.path.dirname(desktopFile)]

        self.desktopFile = desktopFile
        self.startupMonitorId = 0

        self.loadDesktopEntry(desktopItem)

        self.desktopEntryMonitors = []

        base = os.path.basename(self.desktopFile)
        for dir in self.appDirs:
            self.desktopEntryMonitors.append(
                filemonitor.addMonitor(os.path.join(dir, base),
                                       self.onDesktopEntryFileChanged))

        easyButton.__init__(self, self.appIconName, iconSize)
        self.setupLabels()

        # Drag and Drop
        self.connectSelf("drag_data_get", self.dragDataGet)
        self.drag_source_set(gtk.gdk.BUTTON1_MASK, [("text/plain", 0, 100),
                                                    ("text/uri-list", 0, 101)],
                             gtk.gdk.ACTION_COPY)

        icon = self.getIcon(gtk.ICON_SIZE_DND)
        if icon:
            self.drag_source_set_icon_pixbuf(icon)
            del icon

        self.connectSelf("focus-in-event", self.onFocusIn)
        self.connectSelf("focus-out-event", self.onFocusOut)
        self.connectSelf("enter-notify-event", self.onEnterNotify)
        self.connectSelf("clicked", self.execute)
Example #7
0
    def loadDesktopEntry(self, desktopItem):
        try:
            self.appName = self.strip_accents(desktopItem.getName())
            self.appGenericName = self.strip_accents(
                desktopItem.getGenericName())
            self.appComment = self.strip_accents(desktopItem.getComment())
            self.appExec = self.strip_accents(desktopItem.getExec())
            self.appIconName = desktopItem.getIcon()
            self.appCategories = desktopItem.getCategories()
            self.appUkuiDocPath = desktopItem.get("X-MATE-DocPath") or ""
            self.useTerminal = desktopItem.getTerminal()
            self.appPath = desktopItem.getPath()
            self.appNoDisplay = desktopItem.getNoDisplay()
            self.appType = desktopItem.getType()

            if not self.appUkuiDocPath:
                self.appKdeDocPath = desktopItem.getDocPath() or ""
            if not self.appIconName:
                self.appIconName = 'system-run'

            self.appName = self.appName.strip()
            self.appGenericName = self.appGenericName.strip()
            self.appComment = self.appComment.strip()

            configPath = os.environ.get(
                "XDG_CONFIG_HOME", os.path.join(os.environ["HOME"], ".config"))
            basename = os.path.basename(self.desktopFile)
            self.startupFilePath = os.path.join(configPath, "autostart",
                                                basename)
            if self.startupMonitorId:
                filemonitor.removeMonitor(self.startupMonitorId)
            if os.path.exists(self.startupFilePath):
                self.startupMonitorId = filemonitor.addMonitor(
                    self.startupFilePath, self.startupFileChanged)

        except Exception, e:
            print e
            self.appName = ""
            self.appGenericName = ""
            self.appComment = ""
            self.appExec = ""
            self.appIconName = ""
            self.appCategories = ""
            self.appDocPath = ""
            self.startupMonitorId = 0
Example #8
0
    def __init__( self, desktopFile, iconSize):

        if isinstance( desktopFile, xdg.Menu.MenuEntry ):
            desktopItem = desktopFile.DesktopEntry
            desktopFile = desktopItem.filename
            self.appDirs = desktop.desktopFile.AppDirs
        elif isinstance( desktopFile, xdg.Menu.DesktopEntry ):
            desktopItem = desktopFile
            desktopFile = desktopItem.filename
            self.appDirs = [ os.path.dirname( desktopItem.filename ) ]
        else:
            desktopItem = xdg.DesktopEntry.DesktopEntry( desktopFile )
            self.appDirs = [ os.path.dirname( desktopFile ) ]

        self.desktopFile = desktopFile
        self.startupMonitorId = 0

        self.loadDesktopEntry( desktopItem )

        self.desktopEntryMonitors = []

        base = os.path.basename( self.desktopFile )
        for dir in self.appDirs:
            self.desktopEntryMonitors.append( filemonitor.addMonitor( os.path.join(dir, base) , self.desktopEntryFileChangedCallback ) )

        easyButton.__init__( self, self.appIconName, iconSize )
        self.setupLabels()

        # Drag and Drop
        self.connectSelf( "drag-data-get", self.dragDataGet )

        targets = ( Gtk.TargetEntry.new( "text/plain", 0, 100 ), Gtk.TargetEntry.new( "text/uri-list", 0, 101 ) )
        self.drag_source_set( Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY )

        icon = self.getIcon( Gtk.IconSize.DND )
        if icon:
            iconName, s = icon.get_icon_name()
            self.drag_source_set_icon_name( iconName )

        self.connectSelf( "focus-in-event", self.onFocusIn )
        self.connectSelf( "focus-out-event", self.onFocusOut )
        self.connectSelf( "clicked", self.execute )
Example #9
0
	def __init__( self, desktopFile, iconSize ):

		if isinstance( desktopFile, xdg.Menu.MenuEntry ):
			desktopItem = desktopFile.DesktopEntry
			desktopFile = desktopItem.filename
			self.appDirs = desktop.desktopFile.AppDirs
		elif isinstance( desktopFile, xdg.Menu.DesktopEntry ):
			desktopItem = desktopFile
			desktopFile = desktopItem.filename
			self.appDirs = [ os.path.dirname( desktopItem.filename ) ]
		else:
			desktopItem = xdg.DesktopEntry.DesktopEntry( desktopFile )
			self.appDirs = [ os.path.dirname( desktopFile ) ]

		self.desktopFile = desktopFile
		self.startupMonitorId = 0
		
		self.loadDesktopEntry( desktopItem )
		
		self.desktopEntryMonitors = []

		base = os.path.basename( self.desktopFile )
		for dir in self.appDirs:
			self.desktopEntryMonitors.append( filemonitor.addMonitor( os.path.join(dir, base) , self.onDesktopEntryFileChanged ) )
		
		easyButton.__init__( self, self.appIconName, iconSize )
		self.setupLabels()

		# Drag and Drop
		self.connectSelf( "drag_data_get", self.dragDataGet )
		self.drag_source_set( gtk.gdk.BUTTON1_MASK  , [ ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) ], gtk.gdk.ACTION_COPY )

		icon = self.getIcon( gtk.ICON_SIZE_DND )
		if icon:
			self.drag_source_set_icon_pixbuf( icon )
			del icon

		self.connectSelf( "focus-in-event", self.onFocusIn )
		self.connectSelf( "focus-out-event", self.onFocusOut )
		self.connectSelf( "enter-notify-event", self.onEnterNotify )
		self.connectSelf( "clicked", self.execute )
Example #10
0
    def loadDesktopEntry(self, desktopItem):
        try:
            self.appName = self.strip_accents(desktopItem.getName())
            self.appGenericName = self.strip_accents(
                desktopItem.getGenericName())
            self.appComment = self.strip_accents(desktopItem.getComment())
            self.appExec = self.strip_accents(desktopItem.getExec().replace(
                '\\\\', '\\'))
            self.appIconName = desktopItem.getIcon()
            self.appCategories = desktopItem.getCategories()
            self.appMateDocPath = desktopItem.get("X-MATE-DocPath") or ""
            self.useTerminal = desktopItem.getTerminal()
            self.appPath = desktopItem.getPath()

            if not self.appMateDocPath:
                self.appKdeDocPath = desktopItem.getDocPath() or ""

            self.appName = self.appName.strip()
            self.appGenericName = self.appGenericName.strip()
            self.appComment = self.appComment.strip()

            basename = os.path.basename(self.desktopFile)
            self.startupFilePath = os.path.join(os.path.expanduser("~"),
                                                ".config", "autostart",
                                                basename)
            if self.startupMonitorId:
                filemonitor.removeMonitor(self.startupMonitorId)
            if os.path.exists(self.startupFilePath):
                self.startupMonitorId = filemonitor.addMonitor(
                    self.startupFilePath, self.startupFileChanged)

        except Exception, e:
            print e
            self.appName = ""
            self.appGenericName = ""
            self.appComment = ""
            self.appExec = ""
            self.appIconName = ""
            self.appCategories = ""
            self.appDocPath = ""
            self.startupMonitorId = 0