You are not logged in.

#201 2018-11-27 03:34:38

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,721
Website

Re: jgmenu

I've been using jgmenu's "ob" mode for some time as a replacement for the openbox menu, and this upgrade makes it perfect. Thank you!


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#202 2018-12-07 19:07:40

o9000
tint2 developer
From: Network Neighborhood
Registered: 2015-10-24
Posts: 399
Website

Re: jgmenu

jgmenu keeps getting better! Congratulations!

Offline

#203 2018-12-07 21:07:51

malm
jgmenu developer
Registered: 2016-10-13
Posts: 480
Website

Re: jgmenu

@o9000 great to hear from you!

Online

#204 2018-12-08 02:49:37

DeepDayze
Member
From: In Linux Land
Registered: 2017-05-28
Posts: 731

Re: jgmenu

Tint2 is great so need to try jgmenu too smile


Real Men Use Linux

Offline

#205 2018-12-08 14:52:37

wagmic
Member
From: Casablanca
Registered: 2015-09-30
Posts: 73

Re: jgmenu

Merci


La liberté, personne ne peut l’expliquer mais tout le monde peut la comprendre.Cecilia Meireles
Tout ce qui n'est pas donné ou partagé est perdu (proverbe tsigane)

Offline

#206 2019-01-05 10:33:06

malm
jgmenu developer
Registered: 2016-10-13
Posts: 480
Website

Re: jgmenu

jgmenu v1.6 has been released and is in the backports.

Updates since v1.5 include

  • Resolve '\n' characters in item names (to give new line characters). As a result, when using the lx module, a '\n' can be included in csv_name_format in jgmenurc to span several lines (see scrot below). For example:

    csv_name_format = %n\n<span size="x-small">%g</span>
  • Amend CSV API to include 'working directory' and 'metadata'

  • Improvements to lx module
     

    • Allow commas in 'name' and 'command' fields

    • Add working_dir to output, taking the value from the .desktop files' 'Path=' field

  • Improvements to openbox module
     

    • Support icons with pipe-menu entries (useful with obmenu-generator)

    • Use /etc/xdg/openbox/menu.xml as fallback if no file is specified and $HOME/.config/openbox/menu.xml does not exist.

    • Add experimental i18n support.

  • Fix pmenu markup bug

  • Escape markup characters in "<empty>" string to show correctly

  • Set menu width correctly taking into account pango markup

The improvements relating to the 'lx' module are only available for those using Buster (or Arch, etc), because of a libmenu-cache version dependency.

I have built a modest internationalisation (i18n) implementation which can be used by the 'openbox' module. It's inspired by gettext, but ignores everything in po-files except the msgid and msgstr data. It does not support plural forms or strings spanning multiple lines.

Current we read an environment variable (JGMENU_I18N) to specify translation file/directory. I will add a config file option for this in due course. If the environment variable JGMENU_I18N is set to a directory, the value of $LANG will be used to find the right file.

It is not yet documented, but you can test it by taking the followint steps (replacing sv with whatever is appropriate for you):

(a) Run `jgmenu_run ob | jgmenu_run i18n --init >sv`
(b) Translate entries in file 'sv'
(c) Run 'JGMENU_I18N=sv jgmenu' (with csv_cmd=ob in jgmenurc)

See 'jgmenu_run i18n --help' for more details

Johan

2018-12-28-113148_1024x600_scrot.th.png

2018-12-17-192521_1024x600_scrot.th.png

My translation file (work in progress - not quite complete)

# Translation file for BunsenLabs Helium openbox menu

# Main Menu

msgid "Run Program"
msgstr "Kör program"

msgid "Terminal"
msgstr "Terminal"

msgid "Web Browser"
msgstr "Webbläsare"

msgid "File Manager"
msgstr "Filhanterare"

msgid "Text Editor"
msgstr "Textredigerare"

msgid "Media Player"
msgstr "Mediaspelare"

msgid "Accessories"
msgstr "Tillbehör"

msgid "Graphics"
msgstr "Grafik"

msgid "Multimedia"
msgstr "Multimedia"

msgid "Network"
msgstr "Nätverk"

msgid "Office"
msgstr "Kontor"

msgid "Places"
msgstr "Platser"

msgid "Recent Files"
msgstr "Nyligen använda filer"

msgid "Preferences"
msgstr "Inställningar"

msgid "System"
msgstr "System"

msgid "Help & Resources"
msgstr "Hjälp och resurser"

msgid "Display Keybinds"
msgstr "Visa tangentbindningar"

msgid "Lock Screen"
msgstr "Lås skärmen"

msgid "Exit"
msgstr "Avsluta"

# Accessories Menu

msgid "Catfish File Search"
msgstr "Catfish fil sökning"

msgid "Archive Manager"
msgstr "Arkiveringshanterare"

msgid "Task Manager (htop)"
msgstr "Program hanterare (htop)"

msgid "System Information (hardinfo)"
msgstr "System information (hardinfo)"

# Graphics Menu (pipe-menu)

msgid "Mirage Image Viewer"
msgstr "Mirage bild visare"

msgid "Screenshots"
msgstr "Skärmdumpar"

msgid "Xfce4 Screenshooter"
msgstr "Xfce4 skärmdump"

msgid "scrot Screenshooter"
msgstr "scrot skärmdump"

msgid "Install"
msgstr "Installera"

# Multimedia Menu (pipe-menu)

msgid "Vlc Media Player"
msgstr "Vlc mediaspelare"

msgid "utilities"
msgstr "verktyg"

# Network Menu

msgid "WWW Browsers"
msgstr "WWW utforskare"

msgid "Select Default Browser"
msgstr "Välj standard utforskare"

msgid "Filezilla FTP Client"
msgstr "Filezilla FTP klient"

msgid "Transmission BitTorrent Client"
msgstr "Transmission BitTorrent klient"

msgid "HexChat IRC Client"
msgstr "HexChat IRC klient"

msgid "Remote Filesystems"
msgstr "Avseläget filsystem"

msgid "Remote Desktop"
msgstr "Avseläget skrivbord"

msgid "SSH"
msgstr "SSH"

# Office Menu

msgid "LibreOffice"
msgstr "Libreoffice"

msgid "Gnumeric Spreadsheet"
msgstr "Gnumeric kalkylark"

msgid "Calculator"
msgstr "Miniräknare"

msgid "Evince PDF Viewer"
msgstr "Evince PDF visare"

# Places Menu

msgid "Browse here..."
msgstr "Bläddra här..."

# Recent Files Menu

msgid "Clear recent files"
msgstr "Rensa nyligen använda filer"

# Preferences Menu

msgid "Openbox"
msgstr "Openbox"

msgid "Compositor"
msgstr "Kompositör"

msgid "Conky"
msgstr "Conky"

msgid "Tint2"
msgstr "Tint2"

msgid "Appearance"
msgstr "Utseende"

msgid "Font configuration"
msgstr "Font konfigurering"

msgid "BLOB Themes Manager"
msgstr "BLOB tema hanterare"

msgid "Wallpaper"
msgstr "Bakgrund"

msgid "Notifications"
msgstr "Underrättelse"

msgid "Power Management"
msgstr "Strömhanterare"

msgid "dmenu"
msgstr "dmenu"

msgid "gmrun"
msgstr "gmrun"

msgid "Display"
msgstr "Skärm"

msgid "Edit menu.xml"
msgstr "Redigera menu.xml"

msgid "Edit rc.xml"
msgstr "Redigera rc.xml"

msgid "Edit autostart"
msgstr "Redigera autostart"

msgid "Menu Editor"
msgstr "Meny redigerare"

msgid "WM Preferences"
msgstr "WM preferencer"

msgid "How to Edit Menu"
msgstr "Hur man redigerarer menyn"

msgid "Reconfigure"
msgstr "Omkonfigurera"

msgid "Restart"
msgstr "Starta om"

msgid "Edit Start-up Script"
msgstr "Redigera uppstarts script"

msgid "man page"
msgstr "Manual sidor"

msgid "Edit Config File"
msgstr "Redigera config fil"

msgid "ARandR Screen Layout Editor"
msgstr "ARandR skärm layout redigerare"

msgid "man xrandr"
msgstr "xrandr manual"

msgid "System"
msgstr "System"

msgid "Printers"
msgstr "Skrivare"

msgid "Synaptic Package Manager"
msgstr "Synaptic paket hanterare"

msgid "Login Settings"
msgstr "Inloggnings inställningar"

msgid "GParted"
msgstr "GParted"

msgid "Edit Debian Alternatives"
msgstr "Redigera Debian alternativ"

msgid "About Bunsen Alternatives"
msgstr "Om Bunsen alternativ"

msgid "Bunsen Help Files"
msgstr "Bunsen hjälp filer"

msgid "Openbox 3"
msgstr "Openbox 3"

msgid "Log out"
msgstr "Logga ut"

msgid "Suspend"
msgstr "Vänteläge"

msgid "Reboot"
msgstr "Start om"

msgid "Power off"
msgstr "Stäng av"

Online

#207 2019-02-24 15:44:12

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 1,089

Re: jgmenu

jgmenu v 2.1 - greeneye theme:

Screenshot_2019-02-24_10-40-07.md.png

the arrow keys only work on the right half of the menu to select an application to run. I have to use the mouse on the left hand side to select the category. Is that by design?


You must unlearn what you have learned.
    -- yoda

Offline

#208 2019-02-24 17:45:25

Sector11
The Tpyo Knig Mod
From: 77345 ¡#
Registered: 2015-08-20
Posts: 5,528

Re: jgmenu

Q PackRat

Sorry not jgmenu related.

PLEASE a link to that wallpaper!


BunsenLabs Forum Rules ---== I'm a Conky 1.9'er ==---
System:    Host: d67 Kernel: 4.9.0-9-amd64 x86_64 (64 bit gcc: 6.3.0)
Desktop: Openbox 3.6.1 Distro: Debian GNU/Linux 9 (stretch)

Offline

#209 2019-02-24 17:54:18

damo
....moderator....
Registered: 2015-08-20
Posts: 5,057

Re: jgmenu

Sector11 wrote:

Q PackRat

Sorry not jgmenu related.

PLEASE a link to that wallpaper!

TIP: use a reverse image search wink
https://tineye.com/search/718a08394ca5c … 5fcefaef7/


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#210 2019-02-24 18:07:25

Sector11
The Tpyo Knig Mod
From: 77345 ¡#
Registered: 2015-08-20
Posts: 5,528

Re: jgmenu

DOH!  I knew that ... been soooooo long I forgot I had/knew it.

Thanks damo


BunsenLabs Forum Rules ---== I'm a Conky 1.9'er ==---
System:    Host: d67 Kernel: 4.9.0-9-amd64 x86_64 (64 bit gcc: 6.3.0)
Desktop: Openbox 3.6.1 Distro: Debian GNU/Linux 9 (stretch)

Offline

#211 2019-02-24 20:37:45

malm
jgmenu developer
Registered: 2016-10-13
Posts: 480
Website

Re: jgmenu

@PackRat, great to see a scrot so quickly smile

In greeneye, the categories on the left are widgets. I haven't yet implemented keyboard control of widgets, but it's next on the list:

Roadmap

I was thinking to using <tab> to jump between "normal" menu items (i.e. applications) and widgets. I'm open to any ideas though.

I never posted anything for v2.0, so for those who are interested, please see the release notes:

v2.0
v2.1

Thanks @2ion for packaging so quickly.

I was going to post something on ArchLabs, but Arch is stuck on v1.6 (argh...) Arch used to be so quick. Will e-mail foxboron to see if I can help with anything. Guess he is just busy.

Online

#212 2019-02-24 21:58:37

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 1,089

Re: jgmenu

malm wrote:

@PackRat, great to see a scrot so quickly smile

I was thinking to using <tab> to jump between "normal" menu items (i.e. applications) and widgets. I'm open to any ideas though.

Using tab would be good.


You must unlearn what you have learned.
    -- yoda

Offline

#213 2019-02-25 06:21:51

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,721
Website

Re: jgmenu

^or else left-right arrows to switch between categories and applications lists?


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#214 2019-02-26 18:57:30

malm
jgmenu developer
Registered: 2016-10-13
Posts: 480
Website

Re: jgmenu

^ I’ll have a play.
Left/right would be good, but will have to co-exit with openening submenus and revering to partent (which is the current function of those keys).

Want sideway movement between columns (non-widget) to take priority too.

And widgets could be above/below/left/right of applications column - so all in all it needs some thought.

Online

#215 2019-02-28 02:00:03

miyo
Member
Registered: 2018-12-21
Posts: 12

Re: jgmenu

Hi everyone!

This jgmenu is a work of art! Many thanks for the time put into developing it!

I've installed jgmenu via the .deb file available in the jgmenu page of the Bunsenlabs repository on Devuan ascii (stretch) and Devuan beowulf (buster).

On the Ascii partition, after clicking on the jgmenu launcher, my cursor stays busy for about 10 seconds...maybe 15 seconds. The menu works perfectly though. It doesn't do that on the beowulf partition.

I removed it on Ascii, and added the Bunsenlabs repository to install it that way...I'm still getting the same busy cursor.

Any ideas as to why or something that I can do to possibly fix it?

Thank you!

Offline

#216 2019-02-28 05:45:02

miyo
Member
Registered: 2018-12-21
Posts: 12

Re: jgmenu

miyo wrote:

Hi everyone!

This jgmenu is a work of art! Many thanks for the time put into developing it!

I've installed jgmenu via the .deb file available in the jgmenu page of the Bunsenlabs repository on Devuan ascii (stretch) and Devuan beowulf (buster).

On the Ascii partition, after clicking on the jgmenu launcher, my cursor stays busy for about 10 seconds...maybe 15 seconds. The menu works perfectly though. It doesn't do that on the beowulf partition.

I removed it on Ascii, and added the Bunsenlabs repository to install it that way...I'm still getting the same busy cursor.

Any ideas as to why or something that I can do to possibly fix it?

Thank you!

I've come up with a solution that solves it well enough for me. I made an executor for it. Works great and no busy cursor. smile

Offline

#217 2019-02-28 06:17:38

malm
jgmenu developer
Registered: 2016-10-13
Posts: 480
Website

Re: jgmenu

@miyo thanks for writing.

I’m glad that you found a solution, but am still keen to address the issue.

How was jgmenu launched when you got the busy cursor? Were you using the jgmenu.desktop launcher in tint2?

We have
“StartupNotify=false” in the desktop file, so it should not happen (startupnotify gives the spinning cursor).

I seem to remember that this used to happen in old versions of tint2. Which version are you using?

Last edited by malm (2019-02-28 06:18:59)

Online

#218 2019-02-28 07:57:08

miyo
Member
Registered: 2018-12-21
Posts: 12

Re: jgmenu

malm wrote:

@miyo thanks for writing.

I’m glad that you found a solution, but am still keen to address the issue.

How was jgmenu launched when you got the busy cursor? Were you using the jgmenu.desktop launcher in tint2?

We have
“StartupNotify=false” in the desktop file, so it should not happen (startupnotify gives the spinning cursor).

I seem to remember that this used to happen in old versions of tint2. Which version are you using?

Hi malm! Wow...you've done something really spectacular with jgmenu! Thank you!

Oy! I don't think I'll be much help now...but I'll try to answer what I can. After posting my last reply, I was feeling a little frisky and upgraded tint2 on my Devuan ascii installation by temporarily changing the sources.list to beowulf and upgrading only tint2. tongue

Yes, I got the busy cursor from launching the jgmenu.desktop in tint2. I had noticed that startupnotify was false, so that's why I was wondering what else it could possibly be.

I think it must have been the tint2 version. Since I have already upgraded tint2, I had to look on Devuan's packages website to get the version in ascii...it's version 0.12.12-3.

The version in Devuan beowulf (and what I'm now using on ascii) is 16.16.1-1

Now that I've upgraded tint2, it's no longer giving me the busy cursor if I use the jgmenu.desktop launcher.

Thanks again!

Offline

#219 2019-02-28 17:12:46

malm
jgmenu developer
Registered: 2016-10-13
Posts: 480
Website

Re: jgmenu

Sounds like it’s sorted. Thanks.

Online

#220 2019-04-04 16:47:19

misko_2083
Member
Registered: 2016-05-24
Posts: 218

Re: jgmenu

@malm We can have some binary decorations in jgmenu. smile

printf "First,ls\n ͩ ̵̦͓̬̺ͪ͊ z ̖͖̟ͫ͊͢͝ ȩ̵̬̜̬̜̫̠̂̇ z͋͋̎ ̺̗͖̰̣̩ͭ̈́͞ͅ a͗̉͂͂ ̡̯̥̞̬ͪ̿̆̕ s̿̆̄̌ ͫ͏̟̥̹̦ m͇̺̖̫͎͕̈͝ a ͔̹͉ͮ͆͢ l̴̪̐͊̉͐͢͞ . ̝̤ͨ̔̄̋̃͒̈́̀o̎ ͨ̾̆̅ ͬ͒͒̈  ҉̖̬͙̟̪̮̝ͅͅ ͬ͒͒̈ z͋͋̎ ̺̗͖̰̣̩ͭ̈́͞ͅ(づ,ls\n" | jgmenu --simple

https://i.imgur.com/1yz7MW0.gif

Last edited by misko_2083 (2019-04-04 16:48:03)

Offline

#221 2019-05-20 20:48:45

malm
jgmenu developer
Registered: 2016-10-13
Posts: 480
Website

Re: jgmenu

^ @misko_2083 - Sorry, I had missed that post. Not sure what you've done there, but looks cool.

Just to say that jgmenu v3.0 has been released and is in the backports.

v3.0 release notes
v2.2 release notes

Here are a couple of things worth trying (works on Helium/stretch):

jgmenu init --theme=bunsenlabs_lithium

It's worth installing some xdg menu files if you want to see system applications ordered by directory:

sudo apt-get install lxmenu-data

Then launch the menu with `jgmenu_run`

I welcome any feedback on the proposed lithium menu. The theme (colours, etc) itself is just a copy from that of helium and on the surface it looks the same. However:

  • It's not the built-in openbox menu, it's jgmenu (i.e. not just different content - a different application altogether)

  • We have a search box at the top. Just type to search.

  • Halfway down we have 'Applications'. This shows your installed applications (those with .desktop files). It will automatically update when new apps are installed.

  • Although it's configured to start at the pointer (just as the built-in openbox menu), it will snap to the panel / edge if launched with a tint2 button

  • It's easy to build translation files for this menu (see previous post in this thread)

I recommend trying some different themes too - it'll give you a feel for the app.

jgmenu init --theme=greeneye
jgmenu init --theme=archlabs_1803

Last edited by malm (2019-05-20 20:51:00)

Online

#222 2019-07-02 13:04:54

misko_2083
Member
Registered: 2016-05-24
Posts: 218

Re: jgmenu

malm wrote:

[*]Although it's configured to start at the pointer (just as the built-in openbox menu), it will snap to the panel / edge if launched with a tint2 button[/*]

For other panels applet has to be written.
A little mate panel applet for the old virtual machine.
This is Ubuntu Mate 17.10 with gtk3 panel with jgmenu v3.0.
https://www.youtube.com/watch?v=ZNg3Avf … e=youtu.be
Theme "greeneye" looks good.
I have a little trouble positioning bottom/left/right panel positions.
That's mostly because of my "awesome" python skills. smile
The top panel applet is well positioned, though.

Last edited by misko_2083 (2019-07-02 13:06:10)

Offline

#223 2019-07-02 16:58:43

malm
jgmenu developer
Registered: 2016-10-13
Posts: 480
Website

Re: jgmenu

@misko wow. Would you mind letting us in on the inner secrets of you did that?

Online

#224 2019-07-02 19:34:51

misko_2083
Member
Registered: 2016-05-24
Posts: 218

Re: jgmenu

^Needs some files.
Next file adds the applet to the add dialog.
/usr/share/mate-panel/applets/org.mate.panel.JgMenuApplet.mate-panel-applet

[Applet Factory]
Id=JgMenuAppletFactory
Location=/home/milos/applet/mate-jgmenu.py
Name=JGmenu Applet Factory
Description=A JGmenu Applet Factory
 
[JgMenuApplet]
Name=JGMENU
Description=A JGMENU Launcher
Icon=mate
MateComponentId=OAFIID:MATE_JgMenuApplet;

Next the service file, this will launch the script.
/usr/share/dbus-1/services/org.mate.panel.applet.JgMenuAppletFactory.service

[D-BUS Service]
Name=org.mate.panel.applet.JgMenuAppletFactory
Exec=/usr/lib/mate-jgmenu-applet/mate-jgmenu.py

Script, needs to be executive.
/usr/lib/mate-jgmenu-applet/mate-jgmenu.py

#!/usr/bin/env python3

import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
gi.require_version('MatePanelApplet', '4.0')
from gi.repository import Gtk, Gdk
from gi.repository import MatePanelApplet
from gi.repository.GdkPixbuf import Pixbuf
import os
import sys
import shlex
import subprocess
import re
import setproctitle

# Rename the process
setproctitle.setproctitle('mate-jgmenu')

HOME=os.environ['HOME']
CONFIG_PATH=HOME + '/.config/jgmenu/jgmenurc'


class JgMenu(MatePanelApplet.Applet):
    def __init__(self, applet):
        self.applet_fill(applet)


    def execute(self, command):
        """function to exec"""
        subprocess.Popen(shlex.split(command), 
                         stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

    def applet_fill(self, applet):

         # you can use this path with gio/gsettings
        settings_path = applet.get_preferences_path()

        applet.set_border_width(0)
        self.button = Gtk.Button(border_width=0)
        try:
           pixbuf = Gtk.IconTheme.get_default().load_icon("distributor-logo", applet.get_size(), 0)
           button_icon = Gtk.Image.new_from_pixbuf(pixbuf)
        except:
           button_icon = Gtk.Label("jgmenu")
        self.button.add(button_icon)
        # Disable label to show icon
        self.button.set_label("JG menu")
        self.button.connect("clicked", self.on_toggle, self.button, applet)
        self.applet = applet
        self.applet.add(self.button)
        toplevel = self.button.get_toplevel()

        self.applet.show_all()


    def replace(self, file, pattern, subst):
        file_handle = open(file, 'r')
        file_string = file_handle.read()
        file_handle.close()
        file_string = (re.sub(pattern, subst, file_string))
        file_handle = open(file, 'w')
        file_handle.write(file_string)
        file_handle.close()

    def parse_config(self, filename):
        COMMENT_CHAR = '#'
        OPTION_CHAR =  '='
        options = {}
        f = open(filename)
        for line in f:
            if COMMENT_CHAR in line:
                line, comment = line.split(COMMENT_CHAR, 1)
            if OPTION_CHAR in line:
                option, value = line.split(OPTION_CHAR, 1)
                option = option.strip()
                value = value.strip()
                options[option] = value
        f.close()
        return options

    def on_toggle(self, button, applet, data=None):
        rect = button.get_allocation()
        main_window = self.button.get_toplevel()
        [val, win_x, win_y] = main_window.get_window().get_origin()
        orientation = self.applet.get_orient()
        # This needs fixing
        if orientation == 0:
           # BOTTOM
           cal_x = win_x 
           cal_y = win_y
        elif orientation == 1:
           # TOP
           cal_x = win_x + rect.x
           cal_y = win_y + rect.y + rect.height
           print(cal_y)
        elif orientation == 2:
           # RIGHT
           cal_x = win_x
           cal_y = win_y
        elif orientation == 3:
           # LEFT
           cal_x = win_x + rect.x
           cal_y = win_y + rect.y
        else:
           cal_x = win_x
           cal_y = win_y
        options = self.parse_config(CONFIG_PATH)
        [x, y] = self.apply_screen_coord_correction(cal_x, cal_y, options, button)
        #set coordinates
        pattern_x = re.compile("menu_margin_x\s+\=\s+(\d+)")
        self.replace(CONFIG_PATH,pattern_x,'menu_margin_x = ' + str(x))
        pattern_y = re.compile("menu_margin_y\s+\=\s+(\d+)")
        self.replace(CONFIG_PATH,pattern_y,'menu_margin_y = ' + str(y))
        self.execute('jgmenu')

    def apply_screen_coord_correction(self, x, y, options, relative_widget):
        corrected_y = y
        corrected_x = x

        screen_w = Gdk.Screen.width()
        screen_h = Gdk.Screen.height()
        delta_x = screen_w - (x + int(options["menu_width"]))
        delta_y = screen_h - (y + int(options["menu_height_max"]))
        corrected_y = delta_y
        print(delta_x,delta_y)
        if delta_x < 0:
            corrected_x += delta_x
        if corrected_x < 0:
            corrected_x = 0
        if delta_y < 0:
            corrected_y = y - int(options["menu_height_max"]) - relative_widget.get_allocation().height
        if corrected_y < 0:
            corrected_y = 0
        print(corrected_x,corrected_y)
        return [corrected_x, corrected_y]


def applet_factory(applet, iid, data):
    if iid != "JgMenuApplet":
       return False
    JgMenu(applet)
    return True

if __name__ == "__main__":
    MatePanelApplet.Applet.factory_main("JgMenuAppletFactory", True,
                                    MatePanelApplet.Applet.__gtype__,
                                    applet_factory, None)

And /home/malm/.config/jgmenu/jgmenurc

csv_cmd             = jgmenu_run apps
stay_alive          = 0
sub_hover_action    = 0
tint2_look          = 0
menu_width          = 450
menu_height_min     = 510
menu_height_max     = 510
menu_padding_top    = 40
menu_padding_right  = 2
menu_padding_bottom = 1
menu_padding_left   = 151
menu_border         = 1
item_height         = 30
item_radius         = 2
item_border         = 1
color_menu_bg       = #212121 100
color_menu_border   = #eeeeee 20
#color_norm_fg       = #eeeeee 100
#color_sel_bg        = #ffffff 20
#color_sel_fg        = #eeeeee 100
#color_sel_border    = #eeeeee 8
color_scroll_ind    = #000000 0
csv_name_format     = %n\n<span size="x-small">%g</span>
csv_no_dirs         = 1
menu_margin_x = 677
menu_margin_y = 543

Script parses and menu_margin_x and menu_margin_y in jgmenurc conf file.
It gets the button position and size and based on that it changes menu_margin_x and menu_margin_y before launching Jgmenu.

It has some bugs, positions the jgmenu correctly only for the top panel.
If you can fixit, that would be awesome.

Applet can be added without the exec path in the dbus service file and then the script can be started in the terminal. Then it will appear in the panel. That's useful for development purposes, debbuging etc.

Last edited by misko_2083 (2019-07-03 06:39:42)

Offline

#225 2019-07-04 18:18:10

misko_2083
Member
Registered: 2016-05-24
Posts: 218

Re: jgmenu

Ok double posting now.
This is how much I did with the xfce panel applet
I have a button that runs jgmenu.
It only needs to position jgmenu correctly in all the possible panel positions.
That's the hard part for me. I barely know c.
Only a little python and some bash. smile

Here we go with the seven easy steps:
1. Install dependancies
apt update && apt install libgtk-3-dev libxfce4util-dev xfce4-dev-tools libxfce4ui-1-dev xfce4-panel-dev libxfconf-0-dev pkg-config

build-essential and gcc are required of course

create some dir and put two files inside:

jgmenu-applet.h

/*
* Copyright © 2019
*
* Distributed under terms of the GPL2 license.
*/

#ifndef SRC_HEADERS_JGMENU_H_
#define SRC_HEADERS_JGMENU_H_

G_BEGIN_DECLS

#define DEFAULT_ICON_NAME "jgmenu"
#define DEFAULT_TOOLTIP_MESSAGE "Applications Menu"
#define DEFAULT_RUN_COMMAND "jgmenu_run"

typedef struct _JgmenuPlugin {
    XfcePanelPlugin *plugin;

    GtkWidget       *button;
    GtkWidget       *icon;

    gchar           *icon_name;
}
JgmenuPlugin;


G_END_DECLS


#endif /* SRC_HEADERS_JGMENU_H_ */

jgmenu-applet.c

/*
* Copyright © 2019
*
* Distributed under terms of the GPL2 license.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif


#include <gtk/gtk.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#include "jgmenu-applet.h"


#ifdef LIBXFCE4PANEL_CHECK_VERSION
#if LIBXFCE4PANEL_CHECK_VERSION(4, 12, 1)
#define HAS_PANEL_412
#endif
#endif


static void button_clicked(GtkWidget *button, JgmenuPlugin *jgmenu)
{
    /*
    * --------- TODO: ---------
    * Before starting jgmenu here need to:
    * - get button widget's aboslute position
    * gint wx, wy;
    * gdk_window_get_origin(gtk_widget_get_window(jgmenu->button), &wx, &wy);
    * - get button size (allocation->width and allocation->widthheight)
    * - get panel's screen position https://wiki.xfce.org/dev/howto/panel_plugins
    *
    * -------- Option I -------
    * - parse the /.config/jgmenu/jgmenurc config file and get menu height
    * + Menu width would also be useful for the panel(s) on the right;
    * - calculate where the jgmenu is supposed to be
    * - write corected menu_margin_x and menu_margin_x to the config file
    *
    * -------- Option II -------
    * - Implement new conf files to write the button positions/sizes and
    * the panel orientation.
    * Jgmenu would check those files before determing where to position
    *
    * -------- Option III ------
    * - For heaven's sake! Recalibrate and set some Tint2 env variables that
    * jgmenu checks for and let jgmenu do the heavy lifting and position itself
    *
    * ----------- End ---------
    * Useful links:
    *    https://git.xfce.org/panel-plugins/xfce4-sample-plugin/
    *    https://ecc-comp.blogspot.com/2015/02/a-simple-tutorial-for-xfce-panel-plugin.html?m=1
    *
    * For now simply run jgmenu_run
    */
    GError *error = NULL;
    g_spawn_command_line_async(DEFAULT_RUN_COMMAND, &error);
    if (error != NULL) {
        g_warning("unable to launch: %s", error->message);
    }
}


static JgmenuPlugin *
jgmenu_init(XfcePanelPlugin *plugin)
{
    JgmenuPlugin *jgmenu = g_slice_new0(JgmenuPlugin);
    jgmenu->plugin = plugin;
    jgmenu->icon_name = g_strdup(DEFAULT_ICON_NAME);
    jgmenu->button = xfce_panel_create_button();
    gtk_widget_show(jgmenu->button);
    g_signal_connect(G_OBJECT(jgmenu->button),
                     "clicked", G_CALLBACK(button_clicked), plugin);
    gtk_widget_set_tooltip_text(GTK_WIDGET(jgmenu->button),
                                DEFAULT_TOOLTIP_MESSAGE);
    jgmenu->icon = xfce_panel_image_new_from_source(jgmenu->icon_name);
    gtk_widget_show(jgmenu->icon);
    gtk_container_add(GTK_CONTAINER(jgmenu->button), jgmenu->icon);
    return jgmenu;
}



static void jgmenu_free(XfcePanelPlugin *plugin, JgmenuPlugin *jgmenu)
{
    gtk_widget_destroy(jgmenu->button);
    gtk_widget_destroy(jgmenu->icon);
    g_slice_free(JgmenuPlugin, jgmenu);
}



static gboolean jgmenu_size_changed(XfcePanelPlugin *plugin,
                                    gint size, JgmenuPlugin *jgmenu)
{
#ifdef HAS_PANEL_412
    size /= xfce_panel_plugin_get_nrows(plugin);
#endif
    gtk_widget_set_size_request(GTK_WIDGET(jgmenu->button), size, size);
    return TRUE;
}



static void jgmenu_construct(XfcePanelPlugin *plugin)
{
    JgmenuPlugin *jgmenu;
    jgmenu = jgmenu_init(plugin);
    gtk_container_add(GTK_CONTAINER(plugin), jgmenu->button);
    xfce_panel_plugin_add_action_widget(plugin, jgmenu->button);
    g_signal_connect(G_OBJECT(plugin),
                     "free-data", G_CALLBACK(jgmenu_free), jgmenu);
    g_signal_connect(G_OBJECT(plugin),
                     "size-changed", G_CALLBACK(jgmenu_size_changed), jgmenu);
}

XFCE_PANEL_PLUGIN_REGISTER(jgmenu_construct);

cd to that dir and compile

gcc -s -Wall -shared -o libjgmenu.so -fPIC jgmenu-applet.c `pkg-config --cflags --libs libxfce4panel-1.0 gtk+-3.0`

32bit OS
copy libjgmenu.so to /usr/lib/i386-linux-gnu/xfce4/panel/plugins/libjgmenu.so

64bit OS
copy libjgmenu.so to /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libjgmenu.so

5. set permissions
chmod 755 libjgmenu.so

6. Create a desktop file in /usr/share/xfce4/panel/plugins/jgmenu-applet.desktop

jgmenu-applet.desktop

[Xfce Panel]
Type=X-XFCE-PanelPlugin
Encoding=UTF-8
Name=JGMENU
Comment=Start Applications
Icon=jgmenu
X-XFCE-Module=jgmenu
X-XFCE-Internal=true
X-XFCE-Unique=false

7. After creating that desktop file, panel applet can be added via right-click -> panel->add new items<- and search for jgmenu.

Offline

Board footer

Powered by FluxBB