Меnu:


In the previous article one hand menu we have shown how the navigation menu is constructed based on a file, the goal of this post is getting emacs helping us to modify the configuration file graphically.

Improve the way of changing the configuration file for the menu using emacs as a graphical editor

Let's talk about the configuration file content, with the snippet below:

1|Bt Others|
2|Bluetooth|
3|switch|sh ~/bt-switch.sh

On the file the pipe character is used as attribute separator. Now we are going to explain each attribute on every line:

See the menu below.

See more menu pics on the previous article one hand menu.

Explaining what is needed for using emacs as a graphical editor

Software requirements:

Cogre is used for manipulating a connected graph. and We would like to show the "one hand menu" navigation options as a tree view or items hierarchy view.

Giving examples about some required goals with the graphical editor

What about deleting the "Bt Others" button and showing directly on the first frame {"Bluetooth", "Others Conn", "Cell Net"}.

Another case would be the "take Screenshot" button present in all the frames above the "Back" button.

¿Have something been done?

Yes. We have coded a lisp function for converting from the configuration file to lisp data. The function3 output is showed below.

(cogre-base-graph "~/dev/elisp/shell_data" :file "shell_data.cgr" :name "~/dev/elisp/shell_data" :elements
                  (list
                   (cogre-node "Bt Others" :object-name "Bt Others" :position
                               [1 1])
                   (cogre-node "Bluetooth" :object-name "Bluetooth" :position
                               [13 5])
                   (cogre-link "Name" :object-name "Name" :start "Bt Others" :end "Bluetooth")
                   (cogre-node "switch" :object-name "switch" :position
                               [25 9])
                   (cogre-link "Name" :object-name "Name" :start "Bluetooth" :end "switch")
                   (cogre-node "connect to NAP1" :object-name "connect to NAP1" :position
                               [25 13])
                   (cogre-link "Name" :object-name "Name" :start "Bluetooth" :end "connect to NAP1")
                   (cogre-node "connect to headset1" :object-name "connect to headset1" :position
                               [25 17])
                   (cogre-link "Name" :object-name "Name" :start "Bluetooth" :end "connect to headset1")
                   (cogre-node "Others Conn Cell Net" :object-name "Others Conn Cell Net" :position
                               [13 21])
                   (cogre-link "Name" :object-name "Name" :start "Bt Others" :end "Others Conn Cell Net")
                   (cogre-node "Connections" :object-name "Connections" :position
                               [25 25])
                   (cogre-link "Name" :object-name "Name" :start "Others Conn Cell Net" :end "Connections")
                   (cogre-node "connect data plan" :object-name "connect data plan" :position
                               [37 29])
                   (cogre-link "Name" :object-name "Name" :start "Connections" :end "connect data plan")
                   (cogre-node "connect home network" :object-name "connect home network" :position
                               [37 33])
                   (cogre-link "Name" :object-name "Name" :start "Connections" :end "connect home network")
                   (cogre-node "Cell Connections" :object-name "Cell Connections" :position
                               [25 37])
                   (cogre-link "Name" :object-name "Name" :start "Others Conn Cell Net" :end "Cell Connections")
                   (cogre-node "disconn from cell net" :object-name "disconn from cell net" :position
                               [37 41])
                   (cogre-link "Name" :object-name "Name" :start "Cell Connections" :end "disconn from cell net")
                   (cogre-node "conn 2 cell net" :object-name "conn 2 cell net" :position
                               [37 45])
                   (cogre-link "Name" :object-name "Name" :start "Cell Connections" :end "conn 2 cell net")
                   (cogre-node "Network Setup" :object-name "Network Setup" :position
                               [25 49])
                   (cogre-link "Name" :object-name "Name" :start "Others Conn Cell Net" :end "Network Setup")
                   (cogre-node "myusbnet" :object-name "myusbnet" :position
                               [37 53])
                   (cogre-link "Name" :object-name "Name" :start "Network Setup" :end "myusbnet")
                   (cogre-node "take Screenshot" :object-name "take Screenshot" :position
                               [25 57])
                   (cogre-link "Name" :object-name "Name" :start "Others Conn Cell Net" :end "take Screenshot")))

Below is the connected graph rendered by cogre which is showed within an emacs buffer. In this case we are using emacs as a graphic editor. Even it is not completely automated yet.

Those items below need to be coded

Some steps are necessary for getting using emacs as a graphical editor. The lines that have the same level below a parent are rendered on the same frame within the menu.

  1. Being able of modifying every button label. Cogre do this by default on every node.
  2. Change the number of buttons on an specific frame. Adding or removing children on a parent node.
  3. Reorder siblings buttons.
  4. the "button action" or "action to run", should stays as it was before loading the connected graph using cogre. Even if the label or order have been modified by the user.

How to get things done:

Conclusion

Once the requirements have been explained, it is only necessary to start coding in order to be able to change the menu and its options graphically in a more automated way.

Footnotes:

1. Also known as a window if you are not an emacs user.

Last change: 12.06.2018 09:56

blog comments powered by Disqus