GithubHelp home page GithubHelp logo

Support sub-menus about labwc HOT 32 CLOSED

01micko avatar 01micko commented on May 26, 2024
Support sub-menus

from labwc.

Comments (32)

johanmalm avatar johanmalm commented on May 26, 2024 1

I like "bringing out the lab". Very puppy-like.

I've had a quick go. Still not working very well though 😄

20211101_21h01m34s_grim

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024 1

First attempt pushed. It'd doesn't supported nested (inline) definitions yet.

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024 1

Excellent.
Video looks great.
Just an idea - maybe we ought to create a labwc organization (github.com/labwc) and move the whole repo there.
Then we could add separate repos for

  • labwc-gnome-menus (yours)
  • labwc-gnome-menus-3.0 (just had a quick play and reckon it would be fairly quick to do - with gio, etc)
  • labwc-lxmenu (I have the structure for this in jgmenu/contrib)
  • labwc-garcon (for xfce users)

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

Great question. My quick thoughts are outlined below.

In the interest of keeping labwc small and maintainable, I prefer the feature
set of the built-in menu to be pretty small. Having developed jgmenu I know
how easy it is to over-do it 😄

In my opinion, the most sensible way forward is to have a very limited built-in
menu and to use layer-shell clients for more feature rich menus. I'm not aware
of any openbox/JWM style wayland clients.

So where do we draw the line? Here is a proposal:

Built-in menu

  • Read openbox style menu.xml [already done]
  • Separators
  • Submenus

Layer-shell client

  • Icons
  • Pipe-menus
  • Search
  • Auto-refresh when new apps installed
  • Read xdg menu spec
  • Read read menu.xml as well as .desktop + .directory files

For a layer-shell client I think it would be best to avoid GTK/Qt.

from labwc.

01micko avatar 01micko commented on May 26, 2024

A layer-shell client would be a lot of work. I am familiar with xlib code and wrote a few xlib programs and a library ( pmclock - a configurable desktop analogue clock, pmdesktop - a simple library that finds a wm's desktop window ID and cairo-msg - displays a splash message on screen ). I'm not a trained programmer either, though I did learn some basic java in a network engineering diploma but that was mostly windows 7 and server based, though I completed the course mostly running Fedora!

I probably don't have time until Christmas to dive into wlroots and layer-shell, and I don't know if I have the inclination.

Another idea though, if I could develop a cli menu generator similar to the one above that just displays the categories and once clicked a category that menu opens up and the category menu closes, generated by an option to the cli program like this: -g, --generate-categories : generate individual menus for each category

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

Nice apps. You're code looks very neat 😄
I'll have a got at implementing submenus (but not icons). That way we can show xdg-menus.
Probably won't have time to look until next week though.

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

I'm working on this now.

TODO:

  1. Parsing sub-menus in menu.xml
  2. Render sub-menus and handle cursor movements and button presses
  3. Handle some basic keys such as arrows and escape
  4. Fit within output geometry
  5. Support hover-delay (i.e. delay before showing sub-menu when hovering over sub-menu item)
  6. Support nested menus
  7. Support <separator>

from labwc.

01micko avatar 01micko commented on May 26, 2024

Thanks for looking at this. IMHO this will allow labwc to be more user friendly and and a good step to bringing it out of the 'lab'.

from labwc.

01micko avatar 01micko commented on May 26, 2024

I like "bringing out the lab". Very puppy-like.

Was early morning when I posted and that thought hadn't occurred to me. It gives me a good idea for a wallpaper at least when I can get a labwc based puppy ready for testing. 😄

from labwc.

01micko avatar 01micko commented on May 26, 2024

In Puppy, JWM uses dynamic menus. I certainly don't expect labwc to support this so I've raised an issue on gtkdialog to support gtk-layer-shell.

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

In Puppy, JWM uses dynamic menus. I certainly don't expect labwc to support this so I've raised an issue on gtkdialog to support gtk-layer-shell.

What is a dynamic menu? It is like a pipe-menu in openbox?

from labwc.

01micko avatar 01micko commented on May 26, 2024

What is a dynamic menu? It is like a pipe-menu in openbox?

Yes, similar

from labwc.

01micko avatar 01micko commented on May 26, 2024

First attempt pushed. It'd doesn't supported nested (inline) definitions yet.

Working great for me with very minor issue (gap - see screencap)

<openbox_menu>
<menu id="submenu0" label="Net">
  <item label="Browser">
    <action name="Execute"><command>$BROWSER</command></action>
  </item>
  <item label="Torrent">
    <action name="Execute"><command>transmission-gtk</command></action>
  </item>
</menu>
<menu id="submenu1" label="Doc">
  <item label="Word Processor">
    <action name="Execute"><command>abiword</command></action>
  </item>
  <item label="Spread Sheet">
    <action name="Execute"><command>gnumeric</command></action>
  </item>
  <item label="Text Editor">
    <action name="Execute"><command>geany</command></action>
  </item>
  <item label="PDF Viewer">
    <action name="Execute"><command>evince</command></action>
  </item>
</menu>
<menu id="submenu2" label="Graphic">
  <item label="Image Viewer">
    <action name="Execute"><command>imgview</command></action>
  </item>
  <item label="Image Editor">
    <action name="Execute"><command>mtpaint</command></action>
  </item>
</menu>
<menu id="submenu3" label="Utility">
  <item label="Terminal">
    <action name="Execute"><command>lxterminal</command></action>
  </item>
  <item label="Processes">
    <action name="Execute"><command>lxtask</command></action>
  </item>
</menu>

<menu id="root-menu" label="">
  <menu id="submenu0" />
  <menu id="submenu1" />
  <menu id="submenu2" />
  <menu id="submenu3" />
  <item label="____________">
  </item>
  <item label="Exit">
    <action name="Exit"></action>
  </item>
  <item label="Reconfigure">
    <action name="Reconfigure"></action>
  </item>
</menu>
</openbox_menu>

labwc-sub

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

That’s good.

Regarding the gap, sorry I just hard-coded a value of 10 with a TODO note.
I will implement theme option menu.overlap.x

http://openbox.org/wiki/Help:Themes#menu.overlap.x

from labwc.

01micko avatar 01micko commented on May 26, 2024

I re-coded the menu generator and use a template script to build the menu. Works great!

See screen recording:

recording.mp4

from labwc.

01micko avatar 01micko commented on May 26, 2024

The code for labwc-xdgmenu

/**
 * labwc-xdgmenu
 * 
 * This command line application generates an OpenBox menu XML segment based on
 * an Xdg menu structure. Adapted for labwc <https://github.com/johanmalm/labwc>
 * 
 * Usage: labwc-xdgmenu <Xdg menu file>
 * 
 * Copyright (C) Nathan Fisher <[email protected]>
 * Copyright (C) 2008 Siegfried-A. Gevatter <[email protected]>
 * Copyright (C) 2011 Kévin Joly <[email protected]>
 * Copyright (C) 2016 James Budiono <[email protected]>
 * Copyright (C) 2021 Michael Amadio <[email protected]>
 * Originally based upon code by Raul Suarez <[email protected]>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Dependencies:
 *   gnome-menus
 *   glib
 */

#include <string.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <gnome-menus/gmenu-tree.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

/*=============================================================================
 * Declarations
 */
static void show_help();
static void process_directory(GMenuTreeDirectory *directory);
static void process_entry(GMenuTreeEntry *entry);

/*=============================================================================
 * Main Function
 */
int main (int argc, char **argv)
{
    if ((argc < 2)
      || (strcmp (argv[1], "-h") == 0)
      || (strcmp (argv[1], "-help") == 0)
      || (strcmp (argv[1], "--help") == 0))
  {
    show_help();
    return (1);
  }
    
    GMenuTree *menuTree = gmenu_tree_lookup (argv[1],  GMENU_TREE_FLAGS_NONE );
    
    GMenuTreeDirectory *rootDirectory = gmenu_tree_get_root_directory(menuTree);
        
    process_directory(rootDirectory);
    
    gmenu_tree_item_unref (rootDirectory);   

    return 0;
}

/*=============================================================================
 * Shows usage parameters
 */
void show_help()
{
    g_printf ("Creates a labwc menu from an Xdg menu structure.\n");
    g_printf ("\n");
    g_printf ("Usage:\n");
    g_printf ("  labwc-xdgmenu <Xdg menu file>\n");
    g_printf ("\n");
    g_printf ("For example:\n");
    g_printf ("  labwc-xdgmenu \"/etc/xdg/menus/applications.menu\"\n\n");
}

/*=============================================================================
 * This function processes a directory entry and all it's child nodes
 */
void process_directory(GMenuTreeDirectory *directory)
{
   g_printf(
		  "<menu id=\"xdg-menu-%s\" label=\"%s\">\n",
		  gmenu_tree_directory_get_name(directory),
		  gmenu_tree_directory_get_name(directory));

    GMenuTreeItemType entryType;
    GSList *entryList = gmenu_tree_directory_get_contents (directory);
    GSList *l;
    
     for (l = entryList; l; l = l->next)
    {
        GMenuTreeItem *item = l->data;
        
        entryType = gmenu_tree_item_get_type (GMENU_TREE_ITEM(item));
        
        switch (entryType)
        {
            case GMENU_TREE_ITEM_DIRECTORY:
                break;
            case GMENU_TREE_ITEM_ENTRY:
                process_entry(GMENU_TREE_ENTRY(item));
                break;
        }
        
        gmenu_tree_item_unref (item);
    }
    
    g_printf("</menu>\n");
    g_slist_free (entryList);
}

/*=============================================================================
 * This function adds an application entry
 */
void process_entry(GMenuTreeEntry *entry)
{
    char *name = g_strdup (gmenu_tree_entry_get_name(entry));
    char *exec = g_strdup (gmenu_tree_entry_get_exec(entry));
    int i;
    
    for (i = 0; i < strlen(exec) - 1; i++) {
        if (exec[i] == '%')
        {
            switch (exec[i+1]) {
                case 'f': case 'F':
                case 'u': case 'U':
                case 'd': case 'D':
                case 'n': case 'N':
                case 'i': case 'c': case 'k': case 'v': case 'm':
                    exec[i] = ' ';
                    exec[i+1] = ' ';
                    i++;
                    break;
            }
        }
    }

    g_printf("  <item label=\"%s\">\n", g_strjoinv("&amp;", g_strsplit(name,"&",0))),
    g_printf("    <action name=\"Execute\"><command>%s</command></action>\n", exec),
    g_printf("  </item>\n");
    
    g_free(name);
    g_free(exec);
}

/*=============================================================================
 */

It puts each category iterated over on STDOUT . I might event start a github repo for this.

from labwc.

01micko avatar 01micko commented on May 26, 2024

A separate labwc organization sounds like a good idea. It could -

  • attract more interest
  • have it's own github.io website
  • have useful forks of related projects

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

Yeah. I’ve just created the org.

from labwc.

01micko avatar 01micko commented on May 26, 2024

Yeah. I’ve just created the org.

A simple logo

labwc


labwc.svg

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 120 160">
  <!--labwc logo
  (c) Michael Amadio, [email protected], Labrador, QLD, Australia
  LICENSE: CC BY-SA 4.0-->
  <path d="m 80,29.5 a 0.5 0.5 0 0 1 -0.5,0.5 l -30,0 -30,-20  c -5,-3.5 -7,-2 -7,4   l 0,60  
            c 0,6 1,7.5 7,4 l 30,-20 30,0
            a 0.5 0.5 0 0 1 0.5,0.5 l 5,0 a 5.5 5.5 0 0 0 -5.5,-5.5 
            l -62,0 0,-38 30,20 32,0 a 5.5 5.5 0 0 0 5.5,-5.5 z" style="fill:#000000"/>
  <path d="m 77.5 80 -5,0 0,60  a 12.5,12.5 0 0 0 25,0 l 0,-60 -5,0 0,40 -15,0 z" style="fill:#000000"/>
  <path d="m 85,58 a 10 10 0 0 1 -3,7 a 5 5 1 1 0 6,0 a 10 10 0 0 1 -3,-7" style="fill:#000000;stroke-linejoin:round"  />
</svg>

.. and font from icomoon

20211107_10h30m38s_grim
Maybe more contrast needed in my config.

A better one.. and a fullscreen
20211108_10h18m29s_grim

20211108_10h19m50s_grim

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

Any copyright on it. Did you make it?

from labwc.

01micko avatar 01micko commented on May 26, 2024

Any copyright on it. Did you make it?

Yes I did. I'll add a comment in the xml... later.

icomoon allows you to add your own svg files to the font. More on that later.

from labwc.

01micko avatar 01micko commented on May 26, 2024

I updated comment, yes, I live in Labrador 🤣

EDIT: forgot to save, now updated.

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

@01micko
Nested menus work now :) And I've added support for menu.overlap.{x,y} which solves the gap issue.

from labwc.

01micko avatar 01micko commented on May 26, 2024

@01micko Nested menus work now :) And I've added support for menu.overlap.{x,y} which solves the gap issue.

Excellent, thanks 😄 . Just built and running now from 3541616

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

@01micko
I've written a little hack for libgnome-menu-3.0 and gio.
https://github.com/labwc/labwc-menu-gnome3

from labwc.

dimkr avatar dimkr commented on May 26, 2024

@01micko I've written a little hack for libgnome-menu-3.0 and gio. https://github.com/labwc/labwc-menu-gnome3

Puppy's menu generator with JWM this patch (https://github.com/puppylinux-woof-CE/woof-CE/blob/testing/woof-code/rootfs-petbuilds/xdg-puppy-jwm/2089.patch), which:

  1. Adds tooltips
  2. Removes %F and friends -
$ grep ^Exec /usr/share/applications/geany.desktop 
Exec=geany %F
  1. Runs applications with Terminal=true inside a terminal emulator, and wraps the command-line with sh -c (puppylinux-woof-CE/woof-CE#2542, puppylinux-woof-CE/woof-CE#2561)

@johanmalm I'll open a PR to https://github.com/labwc/labwc-menu-gnome3, with 2 and 3, sometime soon.

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

I'm working on this now.

TODO:

1. [x]  Parsing sub-menus in menu.xml

2. [x]  Render sub-menus and handle cursor movements and button presses

3. [ ]  Handle some basic keys such as arrows and escape

4. [ ]  Fit within output geometry

5. [ ]  Support hover-delay (i.e. delay before showing sub-menu when hovering over sub-menu item)

6. [x]  Support nested menus

7. [ ]  Support `<separator>`

I've added support for <separator> to the TODO list (sorry --edited--). Still lots to do with menus 😄
Just playing around with themes

recording.mp4

from labwc.

01micko avatar 01micko commented on May 26, 2024

Looking good.

I want to see if I can add icon font support to the menu generator 😆
20211114_08h42m02s_grim

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

I like the look of that. Keeps it simple and avoids all the color clashes that comes with PNG/SVG icons.

Talking of icons - for the longer term most advanced layer-shell menu (with pipemenus, icons, etc, I think this library will be great https://gitlab.freedesktop.org/ddevault/fdicons

from labwc.

Arnaudv6 avatar Arnaudv6 commented on May 26, 2024

does implementation allow to fix drawn out-of screen menus?
(in master when right-clicking the desktop near screen right-edge, menu will draw off-screen)

from labwc.

Arnaudv6 avatar Arnaudv6 commented on May 26, 2024

sorry, please ignore, had not seen your 4th point

from labwc.

johanmalm avatar johanmalm commented on May 26, 2024

Will close this now as sub-menus have been implemented.
Will track other menu enhancements here https://github.com/labwc/labwc-acceptance-criteria/blob/main/TODO.md
Have written a separator implementation, just need to refactoring some output.c code before committing.

from labwc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.