-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
desktop.c: purge strncpy() and replace with custom pstrcpy() #20
Conversation
I think I'm going to have another go. Will force push soon, took a completely different approach from anything suggested. |
I stole Edit to add: I placed a comment before the function linking to qemu and of course giving credit |
I'm going to add another test using 'zh_HK.utf8' - |
My rationale for not using the heap is that continuosly allocating and freeing memory might slow things down enough to be a pain - especially if we use the generator to provide a pipe-menu (which I haven't tried yet but will soon). If @johanmalm you disagree with my choice I have no problem! You have years of experience and I'm a novice :) edit for completeness: t/t1002.t#!/bin/sh
test_description='parse .desktop files to generate openbox menu'
. ./sharness.sh
test_menu() {
export XDG_DATA_HOME=${PWD}
export XDG_DATA_DIRS="bad-location"
export LABWC_MENU_GENERATOR_DEBUG_FIRST_DIR_ONLY=1
export LANG="$2"
cat ../t1002/"$1" >expect
cp -a ../t1000/applications .
../../labwc-menu-generator >actual
test_cmp expect actual
}
test_expect_success 'parse .desktop files with LANG=zh_HK.utf8' '
test_menu "menu-zh.xml" "zh_HK.utf8"
'
test_done t/t1002/menu-zh.xml<?xml version="1.0" encoding="UTF-8"?>
<openbox_menu>
<menu id="root-menu" label="root-menu">
<menu id="Internet" label="互聯網">
<item label="Avahi SSH Server Browser" icon="network-wired">
<action name="Execute"><command>/usr/bin/bssh</command></action>
</item>
<item label="Avahi VNC Server Browser" icon="network-wired">
<action name="Execute"><command>/usr/bin/bvnc</command></action>
</item>
<item label="Chromium" icon="chromium">
<action name="Execute"><command>/usr/bin/chromium</command></action>
</item>
<item label="Firefox" icon="firefox">
<action name="Execute"><command>/usr/lib/firefox/firefox</command></action>
</item>
<item label="HexChat" icon="io.github.Hexchat">
<action name="Execute"><command>hexchat --existing</command></action>
</item>
<item label="NetSurf Web Browser" icon="netsurf.png">
<action name="Execute"><command>netsurf</command></action>
</item>
<item label="qBittorrent" icon="qbittorrent">
<action name="Execute"><command>qbittorrent</command></action>
</item>
<item label="Vivaldi" icon="vivaldi">
<action name="Execute"><command>/usr/bin/vivaldi-stable</command></action>
</item>
</menu> <!-- Internet -->
<menu id="Multimedia" label="多媒體">
<item label="Audacious" icon="audacious">
<action name="Execute"><command>audacious</command></action>
</item>
<item label="mpv Media Player" icon="mpv">
<action name="Execute"><command>mpv --player-operation-mode=pseudo-gui --</command></action>
</item>
<item label="Qt V4L2 test Utility" icon="qv4l2">
<action name="Execute"><command>qv4l2</command></action>
</item>
<item label="Qt V4L2 video capture utility" icon="qvidcap">
<action name="Execute"><command>qvidcap</command></action>
</item>
<item label="VLC media player" icon="vlc">
<action name="Execute"><command>/usr/bin/vlc --started-from-file</command></action>
</item>
</menu> <!-- Multimedia -->
<menu id="System" label="系統">
<item label="Alacritty" icon="Alacritty">
<action name="Execute"><command>alacritty</command></action>
</item>
<item label="Avahi Zeroconf Browser" icon="network-wired">
<action name="Execute"><command>/usr/bin/avahi-discover</command></action>
</item>
<item label="File Manager PCManFM" icon="system-file-manager">
<action name="Execute"><command>pcmanfm</command></action>
</item>
<item label="Foot" icon="foot">
<action name="Execute"><command>foot</command></action>
</item>
<item label="Foot Client" icon="foot">
<action name="Execute"><command>footclient</command></action>
</item>
<item label="Foot Server" icon="foot">
<action name="Execute"><command>foot --server</command></action>
</item>
<item label="OpenJDK Java 11 Console" icon="java11-openjdk">
<action name="Execute"><command>/usr/lib/jvm/java-11-openjdk/bin/jconsole</command></action>
</item>
<item label="OpenJDK Java 11 Shell" icon="java11-openjdk">
<action name="Execute"><command>/usr/lib/jvm/java-11-openjdk/bin/jshell</command></action>
</item>
<item label="QTerminal" icon="utilities-terminal">
<action name="Execute"><command>qterminal</command></action>
</item>
<item label="QTerminal drop down" icon="utilities-terminal">
<action name="Execute"><command>qterminal --drop</command></action>
</item>
<item label="Sakura" icon="terminal-tango">
<action name="Execute"><command>sakura</command></action>
</item>
<item label="Tint2" icon="tint2">
<action name="Execute"><command>tint2</command></action>
</item>
<item label="urxvt" icon="utilities-terminal">
<action name="Execute"><command>urxvt</command></action>
</item>
<item label="urxvt (client)" icon="utilities-terminal">
<action name="Execute"><command>urxvtc</command></action>
</item>
<item label="urxvt (tabbed)" icon="utilities-terminal">
<action name="Execute"><command>urxvt-tabbed</command></action>
</item>
<item label="UXTerm" icon="xterm-color_48x48">
<action name="Execute"><command>uxterm</command></action>
</item>
<item label="XTerm" icon="xterm-color_48x48">
<action name="Execute"><command>xterm</command></action>
</item>
</menu> <!-- System -->
<menu id="Graphics" label="美工繪圖">
<item label="Flameshot" icon="org.flameshot.Flameshot">
<action name="Execute"><command>/usr/bin/flameshot</command></action>
</item>
<item label="GNU 圖片處理程式" icon="gimp">
<action name="Execute"><command>gimp-2.10</command></action>
</item>
<item label="Image Viewer" icon="gpicview">
<action name="Execute"><command>gpicview</command></action>
</item>
<item label="Inkscape" icon="org.inkscape.Inkscape">
<action name="Execute"><command>inkscape</command></action>
</item>
<item label="MATE Color Selection" icon="gtk-select-color">
<action name="Execute"><command>mate-color-select</command></action>
</item>
<item label="mtPaint" icon="mtpaint">
<action name="Execute"><command>mtpaint</command></action>
</item>
<item label="文件檢視器" icon="org.gnome.Evince">
<action name="Execute"><command>evince</command></action>
</item>
</menu> <!-- Graphics -->
<menu id="Settings" label="設定">
<item label="Desktop Preferences" icon="user-desktop">
<action name="Execute"><command>pcmanfm --desktop-pref</command></action>
</item>
<item label="nitrogen" icon="nitrogen">
<action name="Execute"><command>nitrogen</command></action>
</item>
<item label="Preferred Applications" icon="preferences-desktop">
<action name="Execute"><command>libfm-pref-apps</command></action>
</item>
<item label="Text Editor Settings" icon="org.xfce.mousepad">
<action name="Execute"><command>mousepad --preferences</command></action>
</item>
<item label="Tint2 Settings" icon="tint2conf">
<action name="Execute"><command>tint2conf</command></action>
</item>
<item label="wdisplays" icon="network.cycles.wdisplays">
<action name="Execute"><command>wdisplays</command></action>
</item>
</menu> <!-- Settings -->
<menu id="Office" label="辦公">
<item label="Gnumeric" icon="gnumeric">
<action name="Execute"><command>gnumeric</command></action>
</item>
<item label="文件檢視器" icon="org.gnome.Evince">
<action name="Execute"><command>evince</command></action>
</item>
</menu> <!-- Office -->
<menu id="Development" label="開發">
<item label="CMake" icon="CMakeSetup">
<action name="Execute"><command>cmake-gui</command></action>
</item>
<item label="Geany" icon="geany">
<action name="Execute"><command>geany</command></action>
</item>
<item label="GTK Demo" icon="org.gtk.Demo4">
<action name="Execute"><command>gtk4-demo</command></action>
</item>
<item label="Icon Browser" icon="org.gtk.IconBrowser4">
<action name="Execute"><command>gtk4-icon-browser</command></action>
</item>
<item label="IntelliJ IDEA Community Edition" icon="idea">
<action name="Execute"><command>/usr/bin/idea</command></action>
</item>
<item label="Print Editor" icon="org.gtk.PrintEditor4">
<action name="Execute"><command>gtk4-print-editor</command></action>
</item>
<item label="Widget Factory" icon="org.gtk.WidgetFactory4">
<action name="Execute"><command>gtk4-widget-factory</command></action>
</item>
</menu> <!-- Development -->
<menu id="Accessories" label="附屬應用">
<item label="File Manager PCManFM" icon="system-file-manager">
<action name="Execute"><command>pcmanfm</command></action>
</item>
<item label="Image Viewer" icon="gpicview">
<action name="Execute"><command>gpicview</command></action>
</item>
<item label="Leafpad" icon="leafpad">
<action name="Execute"><command>leafpad</command></action>
</item>
<item label="Mousepad" icon="org.xfce.mousepad">
<action name="Execute"><command>mousepad</command></action>
</item>
<item label="nitrogen" icon="nitrogen">
<action name="Execute"><command>nitrogen</command></action>
</item>
<item label="picom" icon="picom">
<action name="Execute"><command>picom</command></action>
</item>
<item label="Sakura" icon="terminal-tango">
<action name="Execute"><command>sakura</command></action>
</item>
<item label="Vim" icon="gvim">
<action name="Execute"><command>vim</command></action>
</item>
<item label="檔案" icon="org.gnome.Nautilus">
<action name="Execute"><command>nautilus --new-window</command></action>
</item>
</menu> <!-- Accessories -->
</menu> <!-- root-menu -->
</openbox_menu> |
Demo: scriptlab-gen-menu#!/bin/sh
# script to generate labwc menu with pipe-menus
# prints to stdout so redirect to menu.xml
# header
printf "%s\n\n%s\n" '<?xml version="1.0" encoding="UTF-8"?>' '<openbox_menu>'
printf " %s\n" '<menu id="root-menu" label="root-menu">'
printf " %s\n" '<item label="Web browser"><action name="Execute" command="vivaldi" /></item>'
printf " %s\n" '<item label="Terminal"><action name="Execute" command="alacritty" /></item>'
printf " %s\n" '<item label="File Manager"><action name="Execute" command="thunar" /></item>'
printf " %s\n" '<menu id="Windows" label="Windows" execute="app-list-cut.sh" /> <!-- pipemenu -->'
printf " %s\n" '<menu id="Applications" label="Applications" execute="labwc-menu-generator -p" /> <!-- pipemenu -->'
printf " %s\n" '<separator />'
printf " %s\n" '<menu id="Exit" label="Exit">'
printf " %s\n" '<item label="Reconfigure"><action name="Reconfigure" /></item>'
printf " %s\n" '<item label="Logout"><action name="Execute" command="wlogout" /></item>'
printf " %s\n" '</menu> <!-- exit-menu -->'
printf " %s\n" '</menu> <!-- root-menu -->'
printf "%s\n" '</openbox_menu>'
main menu<?xml version="1.0" encoding="UTF-8"?>
<openbox_menu>
<menu id="root-menu" label="root-menu">
<item label="Web browser"><action name="Execute" command="vivaldi" /></item>
<item label="Terminal"><action name="Execute" command="alacritty" /></item>
<item label="File Manager"><action name="Execute" command="thunar" /></item>
<menu id="Windows" label="Windows" execute="app-list-cut.sh" /> <!-- pipemenu -->
<menu id="Applications" label="Applications" execute="labwc-menu-generator -p" /> <!-- pipemenu -->
<separator />
<menu id="Exit" label="Exit">
<item label="Reconfigure"><action name="Reconfigure" /></item>
<item label="Logout"><action name="Execute" command="wlogout" /></item>
</menu> <!-- exit-menu -->
</menu> <!-- root-menu -->
</openbox_menu> The 'Windows' pipe-menu is @davidphilipbarr 's. |
Sorry. Got distracted for a couple of days. |
All good. No rush 😃 |
Thanks. This only happens once, so heap-allocating would be fine if we were worried about truncating... but given the situation, I'm not bothered. And it's nice to have a touch of "Fabrice Bellard". |
Thanks |
fixes #19