Skip to content
Advertisement

Is there a javascript function to add a generic text box to Gnome extension applets?

I am creating an indicator applet for Ubuntu in the form of a Gnome extension. I’m using javascript (which I don’t have very much experience with).

The goal is to have an icon in the panel which when clicked simply pops up a small window (connected to the panel like a menu) with a text box that allows the user to input text (todo list, random thoughts etc). Clicking the icon again removes the window and so on. The text would need to be retained in between sessions.

My problem (apart from finding very few resources in constructing Gnome applets) is that I can’t figure out what the function for creating a text box would be.

I have tried looking at the various St.Widgets available but cannot find an appropriate one.

Using the below code I can generate the icon, place it in the panel and create a pop up menu on click (along with some test notifications to try out functions). However I cannot create a text input box.

JavaScript

Any help in identifying the best function/widget/code to use for a text box would be really appreciated, or even some direction to decent documentation that could help answer my questions. Thanks!

Advertisement

Answer

Kind of old but since the documentation is so scarce it’s still worth answering.

You can use an St.Label like this:

JavaScript

Note that if you are planning to have both the icon and text you will need to wrap them in a BoxLayout, I learned that the hard way.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement