From: Pat Thoyts Date: Sun, 24 Jan 2010 01:05:56 +0000 (+0000) Subject: Added icon and XDG desktop file for use installing onto X desktops X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=4807d916d01a3e2cb188a15840323f789f9e3953;p=tkcon Added icon and XDG desktop file for use installing onto X desktops --- diff --git a/ChangeLog b/ChangeLog index cd69beb..8a35add 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-01-24 Pat Thoyts + + * icons/*: Added an SVG icon and .desktop file suitable + * tkcon-console.desktop: for use installing tkcon into the desktop + * install-desktop-menu.sh: menus on a unix desktop. Also an install + * tkcon.tcl: script to show how it is done. And for + use with 8.6 on X11 - if we can locate the icon, use it as the + tkcon iconphoto so it shows up associated with the running app. + 2010-01-23 Pat Thoyts * tkcon.tcl: Make use of the extended window manager hints from diff --git a/icons/tkcon-small.svg b/icons/tkcon-small.svg new file mode 100644 index 0000000..8d6287b --- /dev/null +++ b/icons/tkcon-small.svg @@ -0,0 +1,534 @@ + + + + + tkcon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + tkcon + 23 Jan 2010 + + + Pat Thoyts + + + Tcl feather icon blended with the console icon fron the tango theme icon package. + + + Pat Thoyts, The Tango Project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/tkcon-small48.png b/icons/tkcon-small48.png new file mode 100644 index 0000000..8797a76 Binary files /dev/null and b/icons/tkcon-small48.png differ diff --git a/install-desktop-menu.sh b/install-desktop-menu.sh new file mode 100755 index 0000000..1e4c4eb --- /dev/null +++ b/install-desktop-menu.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# To install a tkcon entry into a FreeDesktop.org compatible menu system such +# as used by GNOME, KDE or most modern X11 desktop environments the tkcon.desktop +# and icons/* files are installed. This should be done using the xdg-desktop-menu +# utility and xdg-icon-resource utility from the xdg-utils package. See +# http://portland.freedesktop.org/xdg-utils-1.0/ for further details. +# + +PROG_XDG_DESKTOP_MENU=`which xdg-desktop-menu` +PROG_XDG_ICON_RESOURCE=`which xdg-icon-resource` + +ICONFILE=icons/tkcon-small48.png + +if [ -x $PROG_XDG_DESKTOP_MENU -a -x PROG_XDG_ICON_RESOURCE ] +then + $PROG_XDG_DESKTOP_MENU install tkcon-console.desktop + $PROG_XDG_ICON_RESOURCE install --size 48 $ICONFILE tkcon-icon +else + [ -d $HOME/.local/share/applications ] || mkdirhier $HOME/.local/share/applications + [ -d $HOME/.local/share/icons ] || mkdirhier $HOME/.local/share/icons + install tkcon-console.desktop $HOME/.local/share/applications/tkcon-console.desktop + install $ICONFILE $HOME/.local/share/icons/tkcon-icon.png +fi + + diff --git a/tkcon-console.desktop b/tkcon-console.desktop new file mode 100644 index 0000000..0be3094 --- /dev/null +++ b/tkcon-console.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=tkcon +GenericName=Tk console +Comment=Tk console +Exec=tkcon +Icon=tkcon-icon +Terminal=false +Type=Application +Categories=Development;Utility; diff --git a/tkcon.tcl b/tkcon.tcl index 11ffc73..725007b 100755 --- a/tkcon.tcl +++ b/tkcon.tcl @@ -683,6 +683,16 @@ proc ::tkcon::InitUI {title} { grid remove $sbar } + # If we can locate the XDG icon file then make use of it. + if {[package vsatisfies [package provide Tk] 8.6]} { + if {[tk windowingsystem] eq "x11"} { + if {[set icon [locate_xdg_icon tkcon-icon.png]] ne ""} { + image create photo tkcon_icon -file $icon + wm iconphoto $root tkcon_icon + } + } + } + if {!$PRIV(WWW)} { wm title $root "tkcon $PRIV(version) $title" if {$PRIV(showOnStartup)} { wm deiconify $root } @@ -693,6 +703,29 @@ proc ::tkcon::InitUI {title} { } } +# Hunt around the XDG defined directories for the icon. +# Note: hicolor is the standard theme used by xdg-icon-resource. +proc ::tkcon::locate_xdg_icon {name} { + global env + set dirs [list /usr/local/share /usr/share] + if {[info exists env(XDG_DATA_DIRS)]} { + set dirs [split $env(XDG_DATA_DIRS) :] + } + if {[file isdirectory ~/.local/share]} { + set dirs [linsert $dirs 0 ~/.local/share] + } + foreach dir $dirs { + foreach path [list icons icons/hicolor/48x48/apps] { + set path [file join $dir $path $name] + puts "$path [file exists $path]" + if {[file exists $path]} { + return $path + } + } + } + return "" +} + proc ::tkcon::InitTab {w} { variable OPT variable PRIV @@ -6321,7 +6354,7 @@ proc ::send::Pop {varname {nth 0}} { return $r } ## -## end 'send' pacakge +## end 'send' package ## special case 'tk appname' in Tcl plugin if {$::tkcon::PRIV(WWW)} {