KDE-Apps.org Applications for the KDE-Desktop 
 GTK-Apps.org Applications using the GTK Toolkit 
 GnomeFiles.org Applications for GNOME 
 MeeGo-Central.org Applications for MeeGo 
 CLI-Apps.org Command Line Applications 
 Qt-Apps.org Free Qt Applications 
 Qt-Prop.org Proprietary Qt Applications 
 Maemo-Apps.org Applications for the Maemo Plattform 
 Java-Apps.org Free Java Applications 
 eyeOS-Apps.org Free eyeOS Applications 
 Wine-Apps.org Wine Applications 
 Server-Apps.org Server Applications 
 apps.ownCloud.com ownCloud Applications 
 KDE-Look.org Artwork for the KDE-Desktop 
 GNOME-Look.org Artwork for the GNOME-Desktop 
 Xfce-Look.org Artwork for the Xfce-Desktop 
 Box-Look.org Artwork for your Windowmanager 
 E17-Stuff.org Artwork for Enlightenment 
 Beryl-Themes.org Artwork for the Beryl Windowmanager 
 Compiz-Themes.org Artwork for the Compiz Windowmanager 
 EDE-Look.org Themes for your EDE Desktop 
 Debian-Art.org Stuff for Debian 
 Gentoo-Art.org Artwork for Gentoo Linux 
 SUSE-Art.org Artwork for openSUSE 
 Ubuntu-Art.org Artwork for Ubuntu 
 Kubuntu-Art.org Artwork for Kubuntu 
 LinuxMint-Art.org Artwork for Linux Mint 
 Arch-Stuff.org Art And Stuff for Arch Linux 
 Frugalware-Art.org Themes for Frugalware 
 Fedora-Art.org Artwork for Fedora Linux 
 Mandriva-Art.org Artwork for Mandriva Linux 
 KDE-Files.org Files for KDE Applications 
 OpenTemplate.org Documents for OpenOffice.org
 GIMPStuff.org Files for GIMP
 InkscapeStuff.org Files for Inkscape
 ScribusStuff.org Files for Scribus
 BlenderStuff.org Textures and Objects for Blender
 VLC-Addons.org Themes and Extensions for VLC
 KDE-Help.org Support for your KDE Desktop 
 GNOME-Help.org Support for your GNOME Desktop 
 Xfce-Help.org Support for your Xfce Desktop 
openDesktop.orgopenDesktop.org:   Applications   Artwork   Linux Distributions   Documents    Linux42.org    OpenSkillz.com   

- Knowledge base . 
Go back to the overview page to see other entries
Back to overview

click to vote up

Trigger my app when another one is activated

ownCloud - Feb 21 2014

I’ve written a small app that adds configuration options to owncloud included text editor (font size, search parameters, hidden characters...)

The way I've done it works, but it cannot be the right way to do it. To launch my app whenever the TextEditor is displayed, I overwrite the registered file actions that launch the text editor in apps/files_texteditor/editor.js.

Here is the piece of my code that manages the launch of my app.
In app.php:
OCP\Util::addscript('myapp', 'MyApp');

In MyApp.js:
if (typeof FileActions !== 'undefined')
FileActions.register('text', 'Edit', OC.PERMISSION_READ, '', function(filename){
showFileEditor($('#dir').val(), filename); // Down to here, it is the existing code in files_texteditor plug-in
textConfigurator.Init(); }); // This is my own piece of code
// [...Same with other file types...]

As you can see, it involves much maintenance (the function has to be checked on every Owncloud update, to match with changes in files_texteditor/editor.js) and more importantly it does not allow another app to do the same, which cannot be good.

My question is: what is the best way to load an app that depends on another app being loaded?
Should I implement a JavaScript polling that checks every so often that the other app is loaded? But if every app does the same, would there not be a risk on useless processor usage, apps being active even when not needed?

As a side note, is there a way to include my Javascripts only if the user is within the Files app where it may be needed, so as not to overload the generated .js file?

Thanks a lot for your input,

Xavier Takvorian

Answer:1) You can check if the other app is enabled and if so enable your "code"

if (\OCP\App::isEnabled('dependency')) { // checks whether or not an app is enabled
\OCP\Util::addscript('myapp', 'MyApp');

2) access $_SERVER['SCRIPT_URI'] and if it is the files app then add your code; this way it is only added when you are within the app

Edit answer

Back to overview

Add comment

Do you have a question?
Post your question here

How do you like Plasma 5?
 The best KDE Desktop ever.
 Definitely a nice improvement.
 Not decided yet. Haven't tried it yet.
 I do not like some of the changes.
 KDE is taking the wrong way.
 I am still sticking with KDE 3.5.
 I have no opinion, but wanted to vote anyway.

 Who we are
More about us
Frequently Asked Questions
Updates on identi.ca
Updates on Twitter
Content RSS   
Events RSS   

Add App
Public API
About KDE-Apps.org
Legal Notice
Spreadshirt Shop
CafePress Shop
Sponsor us
Report Abuse

Copyright 2003-2016 KDE-Apps.org Team  
All rights reserved. KDE-Apps.org is not liable for any content or goods on this site.
All contributors are responsible for the lawfulness of their uploads.
KDE and K Desktop Environment are trademarks of KDE e.V.