US Tray Menu 2: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(New page: {{Nav US Tray Menu 2}} '''''US Tray Menu 2''''' == Introduction == Previous tutorial concluded with a new UniTray other than UTF-8 support it offered no ne...)
 
(Punctuation and grammatical changes; some clarification.)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Nav US Tray Menu 2}}
{{Nav US Tray Menu 2}}
'''''US Tray Menu 2'''''
 
== Introduction ==
== Introduction ==
[[US Tray Menu: Introduction | Previous tutorial]] concluded with a new UniTray other than UTF-8 support it offered no new features. It mimics the original menu hence menu items are static and control files are command line based. Running menu on a dark background a noticeable ghosting effect is produced.  
[[US Tray Menu: Introduction | The previous tutorial]] concluded with a new UniTray. Other than UTF-8 support, it offered no new features. It mimics the original menu, so menu items are static and the control files are command line based. When running the menu on a dark background, a noticeable ghosting effect is produced.  


This tutorial covers adding new features making our menu user-friendlier. It also addresses that undesirable ghosting effect.
This tutorial covers adding new features and making our menu more user-friendly. It also addresses that undesirable ghosting effect.


Due to a lack of interest for a plugin there is an interesting final twist!   
Due to a lack of interest for a plugin, there is an interesting final twist!   
 
'''''[[#top | Top]]'''''


== User feedback ==
== User feedback ==
To start and stop either both or individual servers currently our menu uses individual buttons. This applies to running as a standard program or as a service. Other than looking pretty icon to the left of each button provide no real information.
To start and stop either of the individual servers or both, currently our menu uses individual buttons. This applies to running as a standard program or as a service. Other than looking pretty, the icon to the left of each button provides no additional information.


There is no real reason why an icon should not indicate current server status (green running and red not running). Also whey use two buttons when a single toggle button will do. Unlike a third party menu we have no constraints this allows us to change anything we like.
There is no real reason why an icon should not indicate current server status (e.g., green running and red not running). Also, why use two buttons when a single toggle button will doUnlike with a third party menu program, we have no constraints. This allows us to change anything we like.


'''''[[#top | Top]]'''''
=== Configuration file ===
=== Configuration file ===
Text displayed on each server button (menu item) toggles between start and stop hence we need to supply these two pieces of text. Since they are user translatable (different language) they cannot be hard coded hence are part of the configuration file. In addition our script needs to known what functionality a button is performing. Assigning a command to each button and letting the script decide its current state (in real time) accommodates the above.
The text displayed on each server button (menu item) toggles between start and stop, hence we need to supply these two pieces of text. Since they are user translatable (different language) they cannot be hard coded, so they are part of the configuration file. In addition our script needs to known what functionality a button is performing. Assigning a command to each button and letting the script decide its current state (in real time) accommodates the above.


Similarly there are menu items (buttons) that become active only when servers are running. Assigning a command to these buttons allow alternative text to be displayed, these again are defined in the configuration file.     
Similarly there are menu items (buttons) that become active only when the servers are running. Assigning commands to these buttons allows for alternative text to be displayed. These again are defined in the configuration file.     
 
'''''[[#top | Top]]'''''


=== Status Icon ===
=== Status Icon ===
The left icon of each button toggles showing current server status (red stopped green running). This can be difficult to achieve however a feature inherent in our menu makes this very easy. Clicking any button automatically minimises our menu. On restoring; whole menu is redrawn using data from the master array. This is used to great effect; before redrawing update master array with current server status (real time) and appropriate button text.
The left icon of each button toggles showing the current server status (red stopped, green running). This can be difficult to achieve, however a feature inherent in our menu makes this very easy. Clicking any button automatically minimises our menu. On restoring, the whole menu is redrawn using data from the master array. This is used to great effect; before redrawing, we update master array with current server status (real time) and appropriate button text.


This technique can be applied to any menu item.   
This technique can be applied to any menu item.   


'''''[[#top | Top]]'''''


=== Commands ===
=== Commands ===
Line 40: Line 34:
icon[]      = "7"                                      ; icon id number
icon[]      = "7"                                      ; icon id number
</pre>
</pre>
Each menu item consists of five lines. Depending on the action (command) selected a line can have alternative functionality. Expanding this concept is key to adding our new features.
Each menu item consists of five lines. Depending on the action (command) selected, a line can have alternative functionality. Expanding this concept is key to adding our new features.


Actions run and runh are executed, as is however sub and separator are intercepted and manipulated according to their functionality. Applying the later to our new features gives the following generic command:
Actions run and runh are executed as is, however sub and separator are intercepted and manipulated according to their functionality. Applying the latter to our new features gives the following generic command:
<pre>
<pre>
item[]      = "Optional text"  ; display menu item (Text 1 or Text2
item[]      = "Optional text"  ; display menu item (Text 1 or Text2
Line 59: Line 53:
icon[]      = ""                                      ; Empty string
icon[]      = ""                                      ; Empty string
</pre>  
</pre>  
'''''Note'':''' A side effect some array names no longer perform what’s implied to avoid confusion these should be changed.  
'''''Note'':''' A side effect is that some array names no longer perform what’s implied. To avoid confusion these should be changed.  
    
    
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
Line 71: Line 65:
men5[] = "Optional Id"    ; Optional icon id number
men5[] = "Optional Id"    ; Optional icon id number
</pre>
</pre>
Advantage, we can apply new functionality as we wish so long as it’s explained to an end user in the final release.
Another advantage is that we can apply new functionality as we wish so long as it’s explained to an end user in the final release.


'''''Note'':''' men1[] Is a special case it is set to whichever text (Text1 or Text2) is the longest. This text is used for calculating width of main or sub-menu. Duplication applies only to commands xxxx.
'''''Note'':''' men1[] is a special case. It is set to whichever text (Text1 or Text2) is the longest. This text is used for calculating the width of main or sub-menu. Duplication applies only to commands xxxx.
 
'''''[[#top | Top]]'''''


=== Define commands ===
=== Define commands ===
To serve as a reference its worth defining commands we intend to use.
To serve as a reference here, it's worth defining commands we intend to use.
{|
{|
|-  
|-  
Line 107: Line 99:
|cmd_php_info ||- Display PHP information in default browser
|cmd_php_info ||- Display PHP information in default browser
|}  
|}  
'''''Note'':''' Above list reflects current menu options depending on final requirements this may change.
'''''Note'':''' The above list reflects current menu options. This may change depending on final requirements.


'''''[[#top | Top]]'''''


== Summary ==
== Summary ==
The above introduced the concept of dynamic menu items and hinted at how these can be implemented.
This introduces the concept of dynamic menu items and hints at how these can be implemented.
 
The menu structure now includes additional predefined commands and a generic naming convention.  
Menu structure now includes additional predefined commands and a generic naming convention.  


Next page takes one of these commands and details [[US Tray Menu 2: Implementation | '''how to integrate''']] it into our tray menu.
Next page takes one of these commands and details [[US Tray Menu 2: Implementation | '''how to integrate''']] it into our tray menu.
Line 122: Line 112:
----
----


[[Category: To be published]]
[[Category: Tutorials]]
[[Category: Tutorials]]
[[Category: How To]]
[[Category: How To]]
[[Category: Uniform Server 5.0-Nano]]
[[Category: Uniform Server 5.0-Nano]]

Latest revision as of 17:39, 30 June 2010

 

UniServer 5-Nano
US Tray Menu 2.
UniServer 6-Carbo

Introduction

The previous tutorial concluded with a new UniTray. Other than UTF-8 support, it offered no new features. It mimics the original menu, so menu items are static and the control files are command line based. When running the menu on a dark background, a noticeable ghosting effect is produced.

This tutorial covers adding new features and making our menu more user-friendly. It also addresses that undesirable ghosting effect.

Due to a lack of interest for a plugin, there is an interesting final twist!

User feedback

To start and stop either of the individual servers or both, currently our menu uses individual buttons. This applies to running as a standard program or as a service. Other than looking pretty, the icon to the left of each button provides no additional information.

There is no real reason why an icon should not indicate current server status (e.g., green running and red not running). Also, why use two buttons when a single toggle button will do? Unlike with a third party menu program, we have no constraints. This allows us to change anything we like.

Configuration file

The text displayed on each server button (menu item) toggles between start and stop, hence we need to supply these two pieces of text. Since they are user translatable (different language) they cannot be hard coded, so they are part of the configuration file. In addition our script needs to known what functionality a button is performing. Assigning a command to each button and letting the script decide its current state (in real time) accommodates the above.

Similarly there are menu items (buttons) that become active only when the servers are running. Assigning commands to these buttons allows for alternative text to be displayed. These again are defined in the configuration file.

Status Icon

The left icon of each button toggles showing the current server status (red stopped, green running). This can be difficult to achieve, however a feature inherent in our menu makes this very easy. Clicking any button automatically minimises our menu. On restoring, the whole menu is redrawn using data from the master array. This is used to great effect; before redrawing, we update master array with current server status (real time) and appropriate button text.

This technique can be applied to any menu item.


Commands

Our current architecture caters for the above additional commands. A menu item has the following format:

item[]      = "Start UniServer (Apache MySQL Program)"  ; display menu item
action[]    = "runh"                                    ; run, runh , sub, separator 
file[]      = "php.exe"                                 ; file name or sub-name
parameter[] = "-n ../main/start_servers.php 7"          ; parameters to pass
icon[]      = "7"                                       ; icon id number

Each menu item consists of five lines. Depending on the action (command) selected, a line can have alternative functionality. Expanding this concept is key to adding our new features.

Actions run and runh are executed as is, however sub and separator are intercepted and manipulated according to their functionality. Applying the latter to our new features gives the following generic command:

item[]      = "Optional text"  ; display menu item (Text 1 or Text2
action[]    = "xxxx"           ; run, runh , sub, separator (xxxx new command) 
file[]      = "Text 1"         ; Item inactive text
parameter[] = "Text 2"         ; Item active text
icon[]      = "Optional Id"    ; Optional icon id number

Converting the above gives:

 
item[]      = ""  ; Empty string
action[]    = "cmd_servers_pall"   ; run, runh , sub, separator (xxxx new command) 
 
file[]      = "Start UniServer (Apache MySQL Program)" ; Item inactive text 
parameter[] = "Stop  UniServer (Apache MySQLProgram)"  ; Item active text 
icon[]      = ""                                       ; Empty string

Note: A side effect is that some array names no longer perform what’s implied. To avoid confusion these should be changed.

Top

Generic menu naming

Using generic names removes any implied functionality.

men1[] = "Long text"      ; display menu item (Text 1 or Text2)
men2[] = "xxxx"           ; run, runh, sub, separator (xxxx new command) 
men3[] = "Text 1"         ; Item inactive text
men4[] = "Text 2"         ; Item active text
men5[] = "Optional Id"    ; Optional icon id number

Another advantage is that we can apply new functionality as we wish so long as it’s explained to an end user in the final release.

Note: men1[] is a special case. It is set to whichever text (Text1 or Text2) is the longest. This text is used for calculating the width of main or sub-menu. Duplication applies only to commands xxxx.

Define commands

To serve as a reference here, it's worth defining commands we intend to use.

cmd_servers_pall – Run both servers as a program
cmd_server_papache – Run Apache server as a program
cmd_server_pmysql – Run MySQL server as a program
cmd_servers_sall – Run both servers as a service
cmd_server_sapache – Run Apache server as a service
cmd_server_smysql – Run MySQL server as a service
cmd_apanel – Run Apanel
cmd_phpmyadmin – Run PHP MySQL Admin
cmd_www_root – Display root www in default browser
cmd_ssl_root – Display root ssl in default browser
cmd_server_information - Display Apache server info in default browser
cmd_server_status - Display Apache server ststus in default browser
cmd_php_info - Display PHP information in default browser

Note: The above list reflects current menu options. This may change depending on final requirements.


Summary

This introduces the concept of dynamic menu items and hints at how these can be implemented. The menu structure now includes additional predefined commands and a generic naming convention.

Next page takes one of these commands and details how to integrate it into our tray menu.

Top